/* ==========================================================================
   Tokens. Light is the base; dark follows the system unless the visitor picks a theme.
   ========================================================================== */
:root {
    --font-ui: "IBM Plex Sans", system-ui, sans-serif;
    --font-code: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --font-prose: "Literata", Georgia, serif;

    --bg: #f3f2ee;
    --chrome: #e9e7e1;
    --chrome-2: #dfddd6;
    --editor: #fbfaf7;
    --line: #d4d1c8;
    --line-soft: #e4e1d9;
    --text: #22252a;
    --text-2: #4d525b;
    --muted: #7c8089;
    --accent: #2f62e0;
    --accent-soft: #dfe7fb;
    --accent-ink: #fff;
    --ok: #2f8a4a;
    --warn: #b86a00;
    --err: #c2352b;
    --select: #d8e2f8;

    --syn-keyword: #0b33b3;
    --syn-type: #00727a;
    --syn-member: #87108f;
    --syn-string: #0b7a1e;
    --syn-number: #1750eb;
    --syn-comment: #8a8c90;
    --hint-bg: #ebe9e3;
    --hint-text: #8a8c90;

    --shadow: 0 18px 50px -18px rgb(30 30 40 / 0.35);
    --radius: 8px;
    --sidebar-w: 268px;
    --panel-h: 28vh;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #17181b;
        --chrome: #1e1f23;
        --chrome-2: #26282d;
        --editor: #1b1c1f;
        --line: #33353b;
        --line-soft: #2a2c31;
        --text: #d6d8dd;
        --text-2: #a9adb6;
        --muted: #7a7f89;
        --accent: #5c8dff;
        --accent-soft: #233154;
        --accent-ink: #0d1220;
        --ok: #5fbf7a;
        --warn: #e0a24a;
        --err: #f0766b;
        --select: #2a3a5e;

        --syn-keyword: #d6955f;
        --syn-type: #6fc2c9;
        --syn-member: #c98fcf;
        --syn-string: #7fbf7f;
        --syn-number: #5fb4d9;
        --syn-comment: #6f747d;
        --hint-bg: #2a2c31;
        --hint-text: #80858e;

        --shadow: 0 18px 50px -12px rgb(0 0 0 / 0.6);
    }
}

:root[data-theme="dark"] {
    --bg: #17181b;
    --chrome: #1e1f23;
    --chrome-2: #26282d;
    --editor: #1b1c1f;
    --line: #33353b;
    --line-soft: #2a2c31;
    --text: #d6d8dd;
    --text-2: #a9adb6;
    --muted: #7a7f89;
    --accent: #5c8dff;
    --accent-soft: #233154;
    --accent-ink: #0d1220;
    --ok: #5fbf7a;
    --warn: #e0a24a;
    --err: #f0766b;
    --select: #2a3a5e;

    --syn-keyword: #d6955f;
    --syn-type: #6fc2c9;
    --syn-member: #c98fcf;
    --syn-string: #7fbf7f;
    --syn-number: #5fb4d9;
    --syn-comment: #6f747d;
    --hint-bg: #2a2c31;
    --hint-text: #80858e;

    --shadow: 0 18px 50px -12px rgb(0 0 0 / 0.6);
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
code, kbd, pre { font-family: var(--font-code); }
::selection { background: var(--select); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

kbd {
    display: inline-block;
    min-width: 1.6em;
    padding: 0 0.35em;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--editor);
    font-size: 0.78em;
    line-height: 1.5;
    text-align: center;
    color: var(--text-2);
}

svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }

.muted { color: var(--muted); }
.ok { color: var(--ok); }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; padding: 8px 12px; background: var(--accent); color: var(--accent-ink); border-radius: 6px; }
.skip:focus { left: 8px; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
}
.icon-btn:hover { background: var(--chrome-2); color: var(--text); }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--editor);
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   IDE shell
   ========================================================================== */
.ide {
    display: grid;
    height: 100vh;
    height: 100dvh;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
        "title  title"
        "side   editor"
        "side   panel"
        "status status";
}

.titlebar {
    grid-area: title;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
    padding: 0 10px 0 12px;
    background: var(--chrome);
    border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; }
.brand__logo {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--accent), var(--syn-member));
    color: #fff;
    font: 800 10px/1 var(--font-code);
    letter-spacing: 0.02em;
}
.brand__branch { padding: 1px 8px; border-radius: 5px; background: var(--chrome-2); color: var(--text-2); font: 12px var(--font-code); }

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(380px, 40vw);
    margin: 0 auto;
    padding: 4px 6px 4px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--editor);
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}
.search span { flex: 1; text-align: left; }
.search:hover { border-color: var(--accent); }

.titlebar__links { display: flex; align-items: center; gap: 6px; }

/* Sidebar */
.sidebar {
    grid-area: side;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
    padding: 6px 0 20px;
    background: var(--chrome);
    border-right: 1px solid var(--line);
    font-size: 13.5px;
}

.tool + .tool { margin-top: 14px; }
.tool__title {
    margin: 6px 0 4px;
    padding: 0 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.tree { margin: 0; padding: 0; list-style: none; }
.tree .tree { padding-left: 14px; }

.node {
    position: relative;
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    min-height: 26px;
    padding: 2px 10px 2px 14px;
    border: 0;
    background: none;
    color: var(--text);
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.node:hover { background: var(--chrome-2); }
.node.is-active, .node--folder a.is-active { background: var(--select); color: var(--text); }
summary.node { list-style: none; }
summary.node::-webkit-details-marker { display: none; }
summary.node a { color: inherit; text-decoration: none; }
summary.node .count { margin-left: auto; }

/* Chevron for folders */
summary.node::before {
    content: "";
    width: 6px;
    height: 6px;
    margin: 0 3px 0 -2px;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform 0.15s;
}
details[open] > summary.node::before { transform: rotate(45deg); }

/* File type badges: small colored glyphs instead of icon images. */
.node--file::before, [data-lang].area__file::before, .tab::before, .files__name::before, .palette__item::before {
    content: "";
    flex: none;
    width: 15px;
    height: 15px;
    border-radius: 3px;
    background: var(--muted);
    font: 800 7.5px/15px var(--font-code);
    color: #fff;
    text-align: center;
}
.badged[data-lang="cs"]::before, .badged [data-lang="cs"]::before { content: "C#"; background: #8a5cd1; }
.badged[data-lang="swift"]::before, .badged [data-lang="swift"]::before { content: "SW"; background: #f06a3b; }
.badged[data-lang="json"]::before, .badged [data-lang="json"]::before { content: "{}"; background: #c09000; }
.badged[data-lang="md"]::before, .badged [data-lang="md"]::before { content: "MD"; background: #3a7bd5; }
.badged[data-lang="db"]::before, .badged [data-lang="db"]::before { content: "DB"; background: #2c9a6b; }
.badged[data-lang="folder"]::before, .badged [data-lang="folder"]::before { content: ""; background: var(--warn); border-radius: 2px 5px 3px 3px; }

.node--table::before, .node--view::before, .node--diagram::before, .node--db::after {
    content: "";
    flex: none;
    width: 13px;
    height: 11px;
    border: 1.5px solid var(--ok);
    border-radius: 2px;
    background: linear-gradient(var(--ok), var(--ok)) 0 3px / 100% 1.5px no-repeat;
}
.node--view::before { border-style: dashed; background: none; }
.node--diagram::before { border-radius: 50%; width: 11px; border-color: var(--accent); background: none; }
.node--db::after { display: none; }
.node .count, .badge {
    margin-left: auto;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--chrome-2);
    color: var(--muted);
    font: 11px/18px var(--font-code);
}
.badge { margin-left: 6px; }

/* Editor */
.editor {
    grid-area: editor;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--editor);
}

.tabbar {
    position: relative;
    display: flex;
    flex: none;
    background: var(--chrome);
    border-bottom: 1px solid var(--line);
}

.tabs {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
/* Fade the edge that has hidden tabs behind it, like Rider and VS Code. */
.tabs.fade-left { mask-image: linear-gradient(to right, transparent, #000 40px); }
.tabs.fade-right { mask-image: linear-gradient(to left, transparent, #000 40px); }
.tabs.fade-left.fade-right { mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); }

.tabs__more { position: relative; flex: none; display: flex; border-left: 1px solid var(--line); }
.tabs__more-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
}
.tabs__more-btn:hover, .tabs__more-btn[aria-expanded="true"] { background: var(--chrome-2); color: var(--text); }
.tabs__more-btn .count { font: 11px var(--font-code); }
.tabs__more-btn svg { width: 14px; height: 14px; }

.tabs__menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 6px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: min(340px, calc(100vw - 32px));
    max-height: min(440px, 60vh);
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--editor);
    box-shadow: var(--shadow);
}
.tabs__menu[hidden] { display: none; }
.tabs__menu-list { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.tabs__menu-title { margin: 2px 8px 6px; color: var(--muted); font: 600 11px var(--font-code); letter-spacing: 0.06em; text-transform: uppercase; }
.tabs__menu-item { display: flex; align-items: center; gap: 4px; border-radius: 6px; }
.tabs__menu-item:hover, .tabs__menu-item:focus-within { background: var(--chrome-2); }
.tabs__menu-item.is-active { background: var(--select); }
.tabs__menu-item a {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 7px 8px;
    color: var(--text);
    font-size: 13.5px;
    text-decoration: none;
}
.tabs__menu-item a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs__menu-item a::before {
    content: "";
    flex: none;
    width: 15px;
    height: 15px;
    border-radius: 3px;
    background: var(--muted);
    font: 800 7.5px/15px var(--font-code);
    color: #fff;
    text-align: center;
}
.tabs__menu-item .tab__close { margin-right: 4px; }
.tabs__menu-actions { display: flex; gap: 6px; margin-top: 6px; padding: 6px 4px 2px; border-top: 1px solid var(--line-soft); }
.tabs__menu-actions button {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: none;
    color: var(--text-2);
    font-size: 12.5px;
    cursor: pointer;
}
.tabs__menu-actions button:hover { border-color: var(--accent); color: var(--accent); }
.tabs::-webkit-scrollbar { display: none; }

.tab {
    position: relative;
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 8px 0 12px;
    border-right: 1px solid var(--line);
    color: var(--text-2);
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}
.tab a { display: flex; align-items: center; align-self: stretch; color: inherit; text-decoration: none; }
.tab:hover { background: var(--chrome-2); }
.tab.is-active { background: var(--editor); color: var(--text); }
.tab.is-active::after { content: ""; position: absolute; inset: auto 0 -1px; height: 2px; background: var(--accent); }
.tab__close {
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.tab__close:hover { background: var(--line); color: var(--text); }

.editor__scroll { flex: 1; overflow: auto; min-height: 0; outline: none; }
.editor__scroll.is-loading { opacity: 0.55; transition: opacity 0.2s 0.1s; }

.crumbs {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: color-mix(in srgb, var(--editor) 92%, transparent);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line-soft);
    color: var(--muted);
    font: 12px var(--font-code);
}
.crumbs__sep { opacity: 0.6; }
.action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 3px 10px;
    border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent);
    border-radius: 6px;
    background: color-mix(in srgb, var(--ok) 10%, transparent);
    color: var(--ok);
    font: 600 12px var(--font-code);
    cursor: pointer;
}
.action:hover { background: color-mix(in srgb, var(--ok) 18%, transparent); }
.action svg { width: 12px; height: 12px; }

/* ==========================================================================
   Code view
   ========================================================================== */
.source { padding: 14px 0 40px; }

.code {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: line;
    font: 13.5px/1.75 var(--font-code);
    font-variant-ligatures: contextual;
}
.code li {
    --gutter: 58px;
    position: relative;
    min-height: 1.75em;
    padding: 0 20px 0 var(--gutter);
    counter-increment: line;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.code li::before {
    content: counter(line);
    position: absolute;
    left: 0;
    width: calc(var(--gutter) - 20px);
    color: var(--muted);
    opacity: 0.6;
    text-align: right;
    user-select: none;
}
.code li:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.code li:hover::before { opacity: 1; color: var(--text-2); }

.k { color: var(--syn-keyword); }
.t { color: var(--syn-type); }
.m { color: var(--syn-member); }
.s { color: var(--syn-string); text-decoration: none; }
a.s:hover { text-decoration: underline; }
.n { color: var(--syn-number); }
.c { color: var(--syn-comment); font-style: italic; }
.hint {
    display: inline;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--hint-bg);
    color: var(--hint-text);
    font-size: 0.86em;
    font-style: normal;
}

/* ==========================================================================
   Markdown preview (README + blog)
   ========================================================================== */
.preview { max-width: 760px; margin: 0 auto; padding: 36px 32px 72px; }

.build { margin: 0 0 30px; color: var(--muted); font: 12.5px var(--font-code); }

.readme__name {
    margin: 0;
    font: 800 clamp(2.4rem, 6vw, 4.4rem)/1 var(--font-code);
    letter-spacing: -0.04em;
}
.caret {
    display: inline-block;
    width: 0.09em;
    height: 0.85em;
    margin-left: 0.08em;
    background: var(--accent);
    vertical-align: -0.06em;
    animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.readme__title { margin: 14px 0 0; font: 600 1.15rem var(--font-code); color: var(--syn-member); }
.readme__lead { margin: 20px 0 0; font: 1.2rem/1.6 var(--font-prose); color: var(--text-2); max-width: 62ch; }
.readme__meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 18px 0 0; font-size: 14px; color: var(--text-2); }
.status-dot::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }

.callout {
    margin: 30px 0 8px;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    background: var(--chrome);
    color: var(--text-2);
}
.callout strong { color: var(--text); }

.preview h2 {
    margin: 44px 0 14px;
    font: 600 0.8rem var(--font-code);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.preview h2::before { content: "## "; color: var(--accent); }

.areas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.area {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--editor);
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s;
}
.area:hover { border-color: var(--accent); transform: translateY(-2px); }
.area__name { font: 800 1.35rem var(--font-code); letter-spacing: -0.02em; }
.area__file { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font: 12px var(--font-code); }
.area ul { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13.5px; }
.area li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 0; }
.meter { width: 54px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) calc(var(--v) * 20%), var(--line-soft) 0); }

.post-list { margin: 0; padding: 0; list-style: none; }
.post-list a {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 2px 18px;
    padding: 14px 0;
    border-top: 1px solid var(--line-soft);
    color: var(--text);
    text-decoration: none;
}
.post-list time { grid-row: span 2; color: var(--muted); font: 12.5px/1.9 var(--font-code); }
.post-list__title { font-weight: 600; }
.post-list a:hover .post-list__title { color: var(--accent); }
.post-list__summary { color: var(--text-2); font-size: 14px; }

/* Blog post */
.post { position: relative; }
.viewswitch {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 1;
    display: flex;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--chrome);
}
.viewswitch button {
    padding: 2px 10px;
    border: 0;
    border-radius: 5px;
    background: none;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
}
.viewswitch [aria-pressed="true"] { background: var(--editor); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.post .source { padding-top: 56px; }

.post__head { margin-bottom: 34px; }
.post__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; color: var(--muted); font: 12.5px var(--font-code); }
.post__head h1 { margin: 14px 0 0; font: 600 clamp(1.9rem, 4.5vw, 2.6rem)/1.15 var(--font-prose); letter-spacing: -0.01em; }
.post__lead { margin: 14px 0 0; color: var(--text-2); font-size: 1.1rem; }

.prose { font: 1.075rem/1.75 var(--font-prose); }
.prose > :not(header) { max-width: 68ch; }
.prose h2 { margin-top: 2.2em; font: 600 1.35rem/1.3 var(--font-prose); letter-spacing: 0; text-transform: none; color: var(--text); }
.prose h2::before { content: none; }
.prose h3 { margin-top: 1.8em; font: 600 1.1rem var(--font-ui); }
.prose blockquote { margin: 1.4em 0; padding: 2px 18px; border-left: 3px solid var(--warn); color: var(--text-2); font-style: italic; }
.prose :not(pre) > code { padding: 0.1em 0.35em; border-radius: 4px; background: var(--chrome); font-size: 0.86em; }
.prose pre {
    max-width: none;
    margin: 1.5em 0;
    padding: 16px 18px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--chrome);
    font-size: 13.5px;
    line-height: 1.65;
}
.prose pre code { background: none; padding: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.35em; }
.prose img { max-width: 100%; border-radius: var(--radius); }
.prose table { border-collapse: collapse; font: 14px var(--font-ui); }
.prose th, .prose td { padding: 6px 12px; border: 1px solid var(--line); }

/* highlight.js tokens mapped onto the editor palette */
.hljs-keyword, .hljs-built_in, .hljs-literal { color: var(--syn-keyword); }
.hljs-title, .hljs-type, .hljs-title.class_ { color: var(--syn-type); }
.hljs-string, .hljs-regexp { color: var(--syn-string); }
.hljs-number { color: var(--syn-number); }
.hljs-comment, .hljs-meta { color: var(--syn-comment); font-style: italic; }
.hljs-attr, .hljs-property, .hljs-variable, .hljs-params { color: var(--syn-member); }

.post__nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 760px; margin: 0 auto; padding: 0 32px 60px; }
.post__nav a {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}
.post__nav a:hover { border-color: var(--accent); }
.post__nav .next { grid-column: 2; text-align: right; }
.post__nav .muted { font: 12px var(--font-code); }

/* Blog folder */
.folder { max-width: 980px; padding: 28px 28px 60px; }
.folder__head h1 { margin: 0 0 14px; font: 800 1.8rem var(--font-code); letter-spacing: -0.02em; }
.folder__head .muted { font-weight: 400; font-size: 1rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.tag {
    padding: 1px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text-2);
    font: 12px/1.7 var(--font-code);
    text-decoration: none;
}
.tag:hover, .tag.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.categories { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.category {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    font: 500 13.5px var(--font-ui);
    text-decoration: none;
}
.category .count { color: var(--muted); font: 11px var(--font-code); }
.category:hover { border-color: var(--accent); }
.category.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.files { width: 100%; border-collapse: collapse; font-size: 14px; }
.files__group th {
    padding: 22px 10px 8px;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font: 600 13px var(--font-code);
    text-align: left;
    text-transform: capitalize;
}
.files__group .muted { font-weight: 400; text-transform: none; }
.files__category {
    display: inline-block;
    margin-top: 6px;
    padding: 0 7px;
    border-radius: 4px;
    background: var(--chrome);
    color: var(--text-2);
    font: 11.5px/1.7 var(--font-code);
    text-decoration: none;
}
.files__category:hover { color: var(--accent); }
.files th {
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font: 600 11px var(--font-code);
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
}
.files td { padding: 14px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; color: var(--text-2); font: 12.5px/1.6 var(--font-code); }
.files tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.files__name { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font: 600 13.5px var(--font-code); text-decoration: none; }
.files__name:hover { color: var(--accent); }
.files__title { display: block; margin-top: 6px; color: var(--text); font: 600 15px var(--font-ui); }
.files__summary { display: block; margin-top: 2px; color: var(--text-2); font: 14px/1.5 var(--font-ui); }
.num { text-align: right; white-space: nowrap; }

/* ==========================================================================
   Schema diagram
   ========================================================================== */
.diagram-page { padding: 28px 28px 60px; }
.diagram-page__head h1 { margin: 0; font: 800 1.8rem var(--font-code); letter-spacing: -0.02em; }
.diagram-page__head p { max-width: 70ch; margin: 8px 0 28px; }

.diagram {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
        "deneyim    deneyim_yetenek  yetenekler"
        "projeler   proje_yetenek    yetenekler"
        "profil     egitim           yazilar"
        "proje_detay deneyim_detay   .";
    gap: 34px 70px;
    align-items: start;
    max-width: 1060px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background:
        radial-gradient(circle, var(--line) 1px, transparent 1.2px) 0 0 / 18px 18px,
        var(--editor);
}
.diagram__lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.diagram__lines path { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: 0.75; }
.diagram__lines circle { fill: var(--editor); stroke: var(--accent); stroke-width: 1.5; }
.diagram__lines .is-hot { opacity: 1; stroke-width: 2.5; }

.entity {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--editor);
    box-shadow: 0 1px 0 var(--line-soft), 0 8px 24px -16px rgb(0 0 0 / 0.4);
    font: 12.5px/1.5 var(--font-code);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
}
.entity:hover, .entity.is-hot { border-color: var(--accent); transform: translateY(-1px); }
.entity--view { border-style: dashed; }
.entity__head { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; background: var(--chrome); border-bottom: 1px solid var(--line); }
.entity__name { font-weight: 800; }
.entity__kind { color: var(--muted); font-size: 11px; }
.entity__cols { display: block; padding: 4px 0; }
.entity__col { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 6px; padding: 1px 10px; }
.entity__col .key { color: var(--warn); font-size: 10px; font-weight: 800; line-height: 18px; }
.entity__col[data-fk] .key { color: var(--accent); }
.entity__col .col { overflow: hidden; text-overflow: ellipsis; }
.entity__col .type { color: var(--muted); font-size: 11px; }

/* ==========================================================================
   Bottom panel: SQL console
   ========================================================================== */
.panel {
    grid-area: panel;
    position: relative;
    display: flex;
    flex-direction: column;
    height: var(--panel-h);
    min-height: 0;
    background: var(--chrome);
    border-top: 1px solid var(--line);
}
.panel.is-collapsed { height: auto; }
.panel.is-collapsed .console, .panel.is-collapsed .panel__resize { display: none; }
.panel.is-collapsed .chevron { transform: rotate(180deg); }

.panel__resize { position: absolute; inset: -4px 0 auto; height: 8px; cursor: row-resize; z-index: 3; }
.panel__resize:hover, .panel__resize.is-dragging { background: linear-gradient(transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px); }

.panel__bar { display: flex; align-items: center; gap: 12px; height: 34px; flex: none; padding: 0 8px 0 4px; }
.panel__tab {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 100%;
    padding: 0 10px;
    border: 0;
    border-bottom: 2px solid var(--accent);
    background: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.panel__meta { margin-left: auto; color: var(--muted); font: 12px var(--font-code); }

.console { display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--editor); border-top: 1px solid var(--line); font: 13px/1.6 var(--font-code); }
.console__out { flex: 1; overflow: auto; padding: 10px 16px 6px; }
.line { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.line--muted { color: var(--muted); }
.line--err { color: var(--err); }
.line--echo { margin-top: 10px; color: var(--text); }
.line--echo::before { content: "tekinali=# "; color: var(--accent); font-weight: 600; }
.line code { color: var(--accent); }

.result { width: max-content; max-width: 100%; margin: 6px 0 4px; overflow-x: auto; }
.result table { border-collapse: collapse; font-size: 12.5px; }
.result th { padding: 3px 12px; border-bottom: 1px solid var(--line); color: var(--syn-type); font-weight: 600; text-align: left; white-space: nowrap; }
.result td { max-width: 46ch; padding: 3px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.result td.null { color: var(--muted); font-style: italic; }
.result td.number { color: var(--syn-number); text-align: right; }
.result tr:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.result__foot { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.console__presets { display: flex; gap: 6px; padding: 6px 12px; overflow-x: auto; border-top: 1px solid var(--line-soft); scrollbar-width: thin; }
.chip {
    flex: none;
    padding: 2px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--chrome);
    color: var(--text-2);
    font: 12px/1.7 var(--font-code);
    cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.console__in { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px 10px 16px; border-top: 1px solid var(--line-soft); }
.prompt { padding-top: 5px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.console__in textarea {
    flex: 1;
    min-height: 32px;
    max-height: 140px;
    padding: 5px 0;
    border: 0;
    outline: none;
    background: none;
    color: var(--text);
    font: inherit;
    resize: none;
}
.console__in textarea::placeholder { color: var(--muted); opacity: 0.7; }
.run {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: var(--accent-ink);
    font: 600 12px var(--font-ui);
    cursor: pointer;
}
.run:hover { filter: brightness(1.08); }
.run svg { width: 11px; height: 11px; }
.run[disabled] { opacity: 0.6; cursor: progress; }

/* Status bar */
.statusbar {
    grid-area: status;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 24px;
    padding: 0 8px;
    background: var(--chrome);
    border-top: 1px solid var(--line);
    color: var(--muted);
    font: 11.5px var(--font-code);
    white-space: nowrap;
}
.statusbar__item { padding: 0 8px; color: inherit; text-decoration: none; }
a.statusbar__item:hover { color: var(--text); }
.statusbar__spacer { flex: 1; }

/* ==========================================================================
   Search everywhere palette
   ========================================================================== */
.palette {
    width: min(600px, calc(100vw - 32px));
    margin: 12vh auto auto;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--editor);
    color: var(--text);
    box-shadow: var(--shadow);
}
.palette::backdrop { background: rgb(10 12 18 / 0.35); backdrop-filter: blur(2px); }
.palette__box { margin: 0; }
.palette__input {
    width: 100%;
    padding: 14px 18px;
    border: 0;
    border-bottom: 1px solid var(--line);
    outline: none;
    background: none;
    color: var(--text);
    font: 15px var(--font-ui);
}
.palette__list { max-height: 50vh; margin: 0; padding: 6px; overflow-y: auto; list-style: none; }
.palette__item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.palette__item[aria-selected="true"] { background: var(--select); }
.palette__item .muted { margin-left: auto; font: 11.5px var(--font-code); }
.palette__item[data-lang="cmd"]::before { content: "›"; background: var(--text-2); font-size: 11px; }
.palette__empty { padding: 14px; color: var(--muted); font-size: 14px; }
.palette__hint { display: flex; gap: 6px; align-items: center; margin: 0; padding: 8px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

/* Error page */
.error-page { max-width: 760px; padding: 40px 32px; }
.error-page__code { margin: 0; font: 800 clamp(4rem, 14vw, 8rem)/1 var(--font-code); letter-spacing: -0.05em; color: var(--line); }
.error-page__trace { padding: 16px 18px; overflow-x: auto; border-radius: var(--radius); background: var(--chrome); font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.err { color: var(--err); }
.error-page__trace .hint { margin-left: 4px; }

/* ==========================================================================
   Plain CV (/cv): built for reading and printing.
   ========================================================================== */
.plain { background: var(--editor); }
.cv { max-width: 780px; margin: 0 auto; padding: 28px 24px 80px; }
.cv__tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; font-size: 14px; }
.cv__head h1 { margin: 0; font: 600 2.6rem/1.1 var(--font-prose); letter-spacing: -0.01em; }
.cv__title { margin: 6px 0 0; color: var(--syn-member); font: 600 1rem var(--font-code); }
.cv__contact { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 14px 0 0; color: var(--text-2); font-size: 14px; }
.cv__summary { margin: 18px 0 0; font: 1.05rem/1.7 var(--font-prose); color: var(--text-2); }
.cv section { margin-top: 36px; }
.cv h2 { margin: 0 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--muted); font: 600 0.78rem var(--font-code); letter-spacing: 0.1em; text-transform: uppercase; }
.cv__item { padding: 12px 0; break-inside: avoid; }
.cv__row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.cv h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.cv h3 a { color: inherit; }
.cv h3 .muted { font-weight: 400; }
.cv__date { flex: none; color: var(--muted); font: 12.5px var(--font-code); }
.cv__item p { margin: 4px 0 0; color: var(--text-2); }
.cv__tech { color: var(--muted) !important; font: 12px var(--font-code); }
.cv__skills { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px 16px; margin: 12px 0 0; }
.cv__skills dt { font-weight: 600; }
.cv__skills dd { margin: 0; color: var(--text-2); }

@media print {
    :root { --editor: #fff; --text: #000; --text-2: #222; --muted: #555; --line: #bbb; --syn-member: #333; }
    .cv__tools { display: none; }
    .cv { padding: 0; max-width: none; }
    body { font-size: 11pt; }
    a { color: inherit; text-decoration: none; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
.mobile-only { display: none !important; }

@media (max-width: 1100px) {
    .diagram {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-areas:
            "deneyim         yetenekler"
            "deneyim_yetenek yetenekler"
            "proje_yetenek   projeler"
            "profil          egitim"
            "yazilar         proje_detay"
            "deneyim_detay   .";
        gap: 30px 50px;
    }
}

@media (max-width: 820px) {
    :root { --panel-h: 42vh; }
    .mobile-only { display: inline-grid !important; }
    .desktop-only { display: none !important; }

    .ide { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "editor" "panel" "status"; }

    .sidebar {
        position: fixed;
        top: 44px;
        bottom: 0;
        left: 0;
        z-index: 20;
        width: min(300px, 85vw);
        transform: translateX(-102%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
    }
    .ide.sidebar-open .sidebar { transform: none; }
    .scrim { position: fixed; inset: 44px 0 0; z-index: 19; display: block !important; background: rgb(0 0 0 / 0.35); }
    .scrim[hidden] { display: none !important; }

    .titlebar { gap: 8px; padding: 0 8px; }
    .brand__branch, .search span, .search kbd { display: none; }
    .search { width: auto; margin: 0 0 0 auto; padding: 6px 8px; }

    .preview { padding: 24px 16px 56px; }
    .areas { grid-template-columns: minmax(0, 1fr); }
    .post-list a { grid-template-columns: minmax(0, 1fr); }
    .post-list time { grid-row: auto; }
    .post__nav { grid-template-columns: minmax(0, 1fr); padding: 0 16px 48px; }
    .post__nav .next { grid-column: 1; }
    .folder, .diagram-page { padding: 20px 16px 48px; }
    .code { font-size: 12.5px; }
    .code li { --gutter: 42px; padding-right: 12px; }
    .crumbs { padding: 6px 16px; }
    .action { margin-left: 0; }
    .panel__meta { display: none; }
    .console__out { padding: 8px 12px; }
    .console__in { padding-left: 12px; }
    .prompt { display: none; }
    .run span { display: none; }
    .error-page { padding: 32px 16px; }
    .cv__row { flex-direction: column; gap: 2px; }
    .cv__skills { grid-template-columns: minmax(0, 1fr); }
    .cv__skills dd { margin-bottom: 8px; }
}

@media (max-width: 620px) {
    .diagram { grid-template-columns: minmax(0, 1fr); grid-template-areas: none; gap: 14px; padding: 14px; }
    .diagram .entity { grid-area: auto !important; }
    .diagram__lines { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
