:root {
        --bg: #ffffff;
        --bg-alt: #f6f7f9;
        --border: #d8dbe0;
        --fg: #202122;
        --muted: #6a6f76;
        --link: #2a5db0;
        --link-new: #b32424;
        --accent: #36c;
        --shadow: 0 1px 3px rgba(0, 0, 0, .08);
        --serif: Georgia, "Times New Roman", serif;
        --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    }

    @media (prefers-color-scheme: dark) {
        :root {
            --bg: #16181d;
            --bg-alt: #1e2128;
            --border: #333842;
            --fg: #e6e6e6;
            --muted: #9aa0a8;
            --link: #7aa7ff;
            --link-new: #ff7b72;
            --accent: #7aa7ff;
            --shadow: 0 1px 3px rgba(0, 0, 0, .5);
        }
    }

    * { box-sizing: border-box; }

    html, body {
        margin: 0;
        padding: 0;
        background: var(--bg);
        color: var(--fg);
        font-family: var(--sans);
    }

    /* ----------------------------------------------------------- address bar */

    .addressbar {
        position: sticky;
        top: 0;
        z-index: 40;
        display: flex;
        gap: .5rem;
        align-items: center;
        padding: .5rem .75rem;
        background: var(--bg-alt);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
    }

    .addressbar button {
        font: inherit;
        padding: .35rem .6rem;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--bg);
        color: var(--fg);
        cursor: pointer;
    }

    .addressbar button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
    .addressbar button:disabled { opacity: .5; cursor: progress; }

    .nav-buttons { display: flex; gap: .25rem; }

    .path-form {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 0;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 999px;
        padding: .15rem .15rem .15rem .8rem;
        min-width: 12rem;
    }

    .path-root { color: var(--muted); font-family: var(--mono); font-size: .85rem; }

    .path-form input {
        flex: 1;
        border: 0;
        outline: 0;
        background: transparent;
        color: var(--fg);
        font-family: var(--mono);
        font-size: .9rem;
        padding: .35rem .4rem;
    }

    .path-form .go { border-radius: 999px; }
     /* -------------------------------------------------------------- search box */
     .search-wrap { position: relative; display: flex; }
     .search-form {
         display: flex;
         align-items: center;
         background: var(--bg);
         border: 1px solid var(--border);
         border-radius: 999px;
         padding: .15rem .15rem .15rem .7rem;
     }
     .search-form input {
         border: 0;
         outline: 0;
         background: transparent;
         color: var(--fg);
         font-family: var(--sans);
         font-size: .85rem;
         width: 11rem;
         padding: .3rem .2rem;
     }
     .search-form .go { border-radius: 999px; }
     .search-results {
         position: absolute;
         top: calc(100% + .4rem);
         right: 0;
         width: min(32rem, 85vw);
         max-height: 60vh;
         overflow: auto;
         background: var(--bg);
         border: 1px solid var(--border);
         border-radius: 8px;
         box-shadow: var(--shadow);
         z-index: 60;
         font-family: var(--sans);
         font-size: .85rem;
     }
     .search-results ul { list-style: none; margin: 0; padding: .3rem; }
     .search-results li { padding: .35rem .5rem; border-radius: 6px; }
     .search-results li:hover { background: var(--bg-alt); }
     .search-results li p { margin: .15rem 0 0; color: var(--muted); font-size: .78rem; }
     .search-results a { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
     .search-results code { font-family: var(--mono); font-size: .72rem; color: var(--muted); }
     .search-results .empty { color: var(--muted); }
     .search-results .ask {
         border-top: 1px solid var(--border);
         margin-top: .3rem;
         padding-top: .55rem;
     }
     /* ----------------------------------------------------------- setup overlay */
     .overlay {
         position: fixed;
         inset: 0;
         z-index: 100;
         display: flex;
         align-items: center;
         justify-content: center;
         padding: 1rem;
         background: rgba(0, 0, 0, .55);
     }
     .overlay[hidden] { display: none; }
     .setup {
         width: min(40rem, 100%);
         background: var(--bg);
         border: 1px solid var(--border);
         border-radius: 10px;
         box-shadow: var(--shadow);
         padding: 1.25rem 1.4rem 1.1rem;
         font-family: var(--sans);
     }
     .setup h2 { font-family: var(--serif); font-weight: 400; margin: 0 0 .3rem; }
     .setup .hint { color: var(--muted); font-size: .8rem; margin: .2rem 0 .7rem; }
     .setup code { font-family: var(--mono); font-size: .78rem; }
     .setup textarea {
         width: 100%;
         font-family: var(--mono);
         font-size: .85rem;
         line-height: 1.5;
         padding: .6rem;
         border: 1px solid var(--border);
         border-radius: 6px;
         background: var(--bg-alt);
         color: var(--fg);
         resize: vertical;
     }
     .setup .examples { display: flex; flex-wrap: wrap; gap: .35rem; margin: .55rem 0 0; }
     .setup .examples button,
     .setup-actions button {
         font: inherit;
         font-size: .8rem;
         padding: .3rem .65rem;
         border: 1px solid var(--border);
         border-radius: 999px;
         background: var(--bg);
         color: var(--fg);
         cursor: pointer;
     }
     .setup .examples button:hover,
     .setup-actions button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
     .setup button:disabled { opacity: .5; cursor: progress; }
     .setup-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .9rem; }
     .setup-actions #setup-go { border-color: var(--accent); color: var(--accent); font-weight: 600; }


    .actions { display: flex; gap: .35rem; }

    /* ---------------------------------------------------------------- panels */

    .panel {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
        align-items: center;
        padding: .75rem 1rem;
        background: var(--bg-alt);
        border-bottom: 1px solid var(--border);
    }

    .panel label { font-size: .85rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; }
    .panel select { font: inherit; padding: .25rem; background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 4px; }
    .panel .hint { flex-basis: 100%; margin: 0; font-size: .75rem; color: var(--muted); }

    .status {
        display: flex;
        align-items: center;
        gap: .6rem;
        padding: .45rem 1rem;
        font-size: .85rem;
        background: #fff8e1;
        color: #6b5300;
        border-bottom: 1px solid var(--border);
    }

    @media (prefers-color-scheme: dark) {
        .status { background: #2b2712; color: #f0d78c; }
    }

    .spinner {
        width: 12px;
        height: 12px;
        border: 2px solid currentColor;
        border-right-color: transparent;
        border-radius: 50%;
        animation: spin .8s linear infinite;
        flex: none;
    }

    @keyframes spin { to { transform: rotate(360deg); } }

    /* ---------------------------------------------------------------- layout */

    .layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 18rem;
        gap: 2rem;
        max-width: 1280px;
        margin: 0 auto;
        padding: 1.5rem 1.25rem 5rem;
    }

    @media (max-width: 900px) {
        .layout { grid-template-columns: 1fr; }
        .sidebar { order: -1; }
    }

    .content { min-width: 0; font-family: var(--serif); font-size: 1.02rem; line-height: 1.65; }

    .breadcrumbs { font-family: var(--sans); font-size: .78rem; color: var(--muted); margin-bottom: .25rem; }
    .breadcrumbs a { color: var(--muted); }

    .article-header h1 {
        font-family: var(--serif);
        font-weight: 400;
        font-size: 2.1rem;
        margin: 0 0 .25rem;
        padding-bottom: .3rem;
        border-bottom: 1px solid var(--border);
    }

    .article-header .summary { color: var(--muted); font-style: italic; margin: .4rem 0; }
    .tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 0; }
    .tags span {
        font-family: var(--sans);
        font-size: .72rem;
        padding: .1rem .5rem;
        border: 1px solid var(--border);
        border-radius: 999px;
        color: var(--muted);
    }

    .article-body h2 {
        font-weight: 400;
        font-size: 1.5rem;
        margin: 1.8rem 0 .5rem;
        padding-bottom: .2rem;
        border-bottom: 1px solid var(--border);
    }

    .article-body h3 { font-weight: 600; font-size: 1.15rem; margin: 1.3rem 0 .4rem; }
    .article-body p { margin: .7rem 0; }
    .article-body img { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 1rem auto; }
    .article-body blockquote {
        margin: 1rem 0;
        padding: .3rem 1rem;
        border-left: 4px solid var(--border);
        color: var(--muted);
    }

    .article-body table { border-collapse: collapse; margin: 1rem 0; width: 100%; font-family: var(--sans); font-size: .9rem; }
    .article-body th, .article-body td { border: 1px solid var(--border); padding: .4rem .6rem; text-align: left; }
    .article-body th { background: var(--bg-alt); }
    .article-body pre { overflow: auto; border-radius: 6px; }
    .article-body code { font-family: var(--mono); font-size: .88em; }
    .article-body :not(pre) > code { background: var(--bg-alt); padding: .1em .35em; border-radius: 4px; }
    .article-body .mermaid { display: flex; justify-content: center; margin: 1.2rem 0; }
    .article-body hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

    a { color: var(--link); text-decoration: none; }
    a:hover { text-decoration: underline; }
    a.new { color: var(--link-new); }
    a.new::after { content: "＋"; font-size: .7em; vertical-align: super; opacity: .7; }
    a.external::after { content: "↗"; font-size: .75em; margin-left: .15em; opacity: .7; }
    a.current { font-weight: 700; }

    /* --------------------------------------------------------------- sidebar */

    .sidebar { font-family: var(--sans); font-size: .85rem; }
    .sidebar section { margin-bottom: 1.5rem; }
    .sidebar h3 {
        font-size: .75rem;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: var(--muted);
        margin: 0 0 .5rem;
        padding-bottom: .25rem;
        border-bottom: 1px solid var(--border);
    }

    .badge { float: right; font-weight: 400; opacity: .8; }

    .linklist { list-style: none; margin: 0; padding: 0; max-height: 16rem; overflow: auto; }
    .linklist li { padding: .12rem 0; }
     .linklist a.pathlink {
         font-family: var(--mono);
         font-size: .78rem;
         line-height: 1.35;
         word-break: break-word;
     }
    .linklist .empty, .toc .empty { color: var(--muted); }
    .toc { display: flex; flex-direction: column; gap: .15rem; }
    .toc a.sub { padding-left: .9rem; font-size: .8rem; color: var(--muted); }

    /* ----------------------------------------------------------- placeholder */

    .placeholder { font-family: var(--sans); color: var(--muted); }
    .placeholder h1 { font-family: var(--serif); font-weight: 400; color: var(--fg); }
    .placeholder .path { font-family: var(--mono); font-size: .8rem; }
    .ghost { margin-top: 1.5rem; display: flex; flex-direction: column; gap: .7rem; }
    .ghost span {
        display: block;
        height: .8rem;
        border-radius: 4px;
        background: linear-gradient(90deg, var(--bg-alt), var(--border), var(--bg-alt));
        background-size: 200% 100%;
        animation: shimmer 1.4s ease-in-out infinite;
    }

    .ghost span:nth-child(2) { width: 92%; }
    .ghost span:nth-child(3) { width: 78%; }
    .ghost span:nth-child(4) { width: 85%; }

    @keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

    body.busy .content { opacity: .75; }