/* ============================================================
   FunPayLiteBot Wiki — modern docs UI
   Light/dark via [data-theme] on <html>.
   ============================================================ */

:root {
    --topbar-h: 60px;
    --sidebar-w: 288px;
    --toc-w: 256px;
    --content-max: 780px;
    --radius: 10px;
    --radius-sm: 7px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

/* ---- Light theme (default) ---- */
[data-theme='light'] {
    --bg: #ffffff;
    --bg-elev: #ffffff;
    --bg-subtle: #f6f8fb;
    --bg-hover: #eef2f9;
    --bg-active: #e8effe;
    --text: #1b2333;
    --text-strong: #0d1424;
    --text-muted: #5b6675;
    --text-faint: #8a94a3;
    --border: #e6e9f0;
    --border-strong: #d3d8e2;
    --primary: #2f6bff;
    --primary-hover: #1f57e6;
    --primary-soft: #eaf0ff;
    --code-bg: #f1f4f9;
    --code-border: #e6e9f0;
    --code-text: #2a3446;
    --shadow: 0 6px 24px rgba(20, 30, 55, 0.10), 0 2px 6px rgba(20, 30, 55, 0.06);
    --note-bg: #eef5ff;
    --note-border: #2f6bff;
    --warn-bg: #fff6e9;
    --warn-border: #f0a020;
    color-scheme: light;
}

/* ---- Dark theme ---- */
[data-theme='dark'] {
    --bg: #0d1017;
    --bg-elev: #12161f;
    --bg-subtle: #12161f;
    --bg-hover: #1a2130;
    --bg-active: #1c2740;
    --text: #d6dbe6;
    --text-strong: #f2f4f9;
    --text-muted: #97a1b2;
    --text-faint: #6b7688;
    --border: #222a37;
    --border-strong: #2d3747;
    --primary: #5b8dff;
    --primary-hover: #6f9cff;
    --primary-soft: #16233d;
    --code-bg: #161b25;
    --code-border: #232c3b;
    --code-text: #cdd6e5;
    --shadow: 0 10px 34px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.35);
    --note-bg: #12203a;
    --note-border: #5b8dff;
    --warn-bg: #2a2010;
    --warn-border: #d99a2b;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    height: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-strong);
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-logo {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2f6bff, #6f9cff);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.topbar-search { margin-left: auto; }
.search-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 12px;
    min-width: 220px;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.search-trigger span { flex: 1; text-align: left; }
.search-trigger kbd, .search-input-row kbd {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 6px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    color: var(--text-faint);
    background: var(--bg);
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-link {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}
.topbar-link:hover { color: var(--text-strong); background: var(--bg-hover); text-decoration: none; }
.icon-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-strong); }
.menu-toggle { display: none; }

/* Theme icons: show the one for the mode you'd switch TO. */
.ic-moon { display: none; }
.ic-sun { display: block; }
[data-theme='dark'] .ic-sun { display: none; }
[data-theme='dark'] .ic-moon { display: block; }

/* ============================================================
   Layout
   ============================================================ */
.layout {
    max-width: 1440px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
    align-items: start;
}

/* ---- Sidebar ---- */
.sidebar {
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    padding: 22px 14px 40px 20px;
    border-right: 1px solid var(--border);
    overscroll-behavior: contain;
}
.nav-home {
    display: block;
    padding: 7px 12px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
}
.nav-home:hover { background: var(--bg-hover); text-decoration: none; }
.nav-home.active { color: var(--primary); background: var(--primary-soft); }
.nav-section { margin-top: 4px; }
.nav-section-title {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.1px;
    color: var(--text-strong);
    text-align: left;
    border-radius: var(--radius-sm);
    transition: background 0.12s;
}
.nav-section-title:hover { background: var(--bg-hover); }
.nav-section-name { flex: 1; min-width: 0; }
.nav-ic { font-size: 16px; line-height: 1; }
.nav-chevron { flex-shrink: 0; color: var(--text-faint); transition: transform 0.2s ease; }
.nav-section.open > .nav-section-title .nav-chevron { transform: rotate(90deg); }
/* Collapse/expand without knowing the content height (grid 0fr -> 1fr). */
.nav-section-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.24s ease;
}
.nav-section.open > .nav-section-body { grid-template-rows: 1fr; }
.nav-section-inner { overflow: hidden; min-height: 0; }
/* Applied by app.js only while the initial open/closed state is set, so
   restored categories don't visibly animate open on every page load. */
.nav-no-anim .nav-section-body,
.nav-no-anim .nav-chevron { transition: none; }
.nav-folder { margin: 4px 0 10px; }
.nav-folder-title {
    display: block;
    padding: 6px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-faint);
}
.nav-folder-ic { margin-right: 5px; font-size: 12px; letter-spacing: 0; }
.nav-folder ul { list-style: none; margin: 0; padding: 0; }
.nav-folder li { margin: 1px 0; }
.nav-folder a {
    display: block;
    padding: 6px 12px 6px 14px;
    border-left: 2px solid transparent;
    margin-left: 6px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.45;
    transition: color 0.12s, background 0.12s;
}
.nav-folder a:hover { color: var(--text-strong); background: var(--bg-hover); text-decoration: none; }
.nav-folder a.active {
    color: var(--primary);
    background: var(--primary-soft);
    border-left-color: var(--primary);
    font-weight: 600;
}

/* ---- Content ---- */
.content {
    min-width: 0;
    padding: 36px 48px 80px;
}
.content.content-wide { max-width: none; }
.article { max-width: var(--content-max); }

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .sep { color: var(--text-faint); }

.article h1 {
    font-size: 34px;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0 0 12px;
    color: var(--text-strong);
    font-weight: 700;
}
.lead {
    font-size: 18px;
    line-height: 1.55;
    color: var(--text-muted);
    margin: 0 0 8px;
}

/* ---- Prose ---- */
.prose { font-size: 16px; }
.prose h2 {
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-strong);
    margin: 40px 0 14px;
    padding-top: 8px;
    scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.prose h3 {
    font-size: 18.5px;
    font-weight: 650;
    color: var(--text-strong);
    margin: 28px 0 10px;
    scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.prose h2 + p, .prose h3 + p { margin-top: 0; }
.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 24px; }
.prose li { margin: 6px 0; }
.prose li > ul, .prose li > ol { margin: 6px 0; }
.prose strong { color: var(--text-strong); font-weight: 650; }
.prose a { font-weight: 500; border-bottom: 1px solid color-mix(in srgb, var(--primary) 35%, transparent); text-decoration: none; }
.prose a:hover { border-bottom-color: var(--primary); }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

.heading-anchor {
    float: left;
    margin-left: -22px;
    padding-right: 8px;
    color: var(--text-faint);
    opacity: 0;
    font-weight: 400;
    border: none !important;
    transition: opacity 0.12s;
}
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--primary); text-decoration: none; }

/* inline + block code */
.prose code {
    font-family: var(--font-mono);
    font-size: 0.86em;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 5px;
    padding: 0.12em 0.4em;
    color: var(--code-text);
}
.prose pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    overflow-x: auto;
    margin: 0 0 18px;
}
.prose pre code { background: none; border: none; padding: 0; font-size: 13.5px; line-height: 1.6; }

/* blockquotes as callouts */
.prose blockquote {
    margin: 0 0 18px;
    padding: 12px 16px;
    background: var(--note-bg);
    border-left: 3px solid var(--note-border);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text);
}
.prose blockquote p:last-child { margin-bottom: 0; }

/* tables */
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 18px;
    font-size: 14.5px;
    display: block;
    overflow-x: auto;
}
.prose th, .prose td { padding: 9px 14px; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--bg-subtle); font-weight: 650; color: var(--text-strong); }
.prose tr:nth-child(even) td { background: var(--bg-subtle); }

/* ---- Prev / next ---- */
.prevnext {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.pn {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-strong);
    transition: border-color 0.15s, background 0.15s;
}
.pn:hover { border-color: var(--primary); background: var(--bg-subtle); text-decoration: none; }
.pn-next { text-align: right; align-items: flex-end; }
.pn-dir { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.pn-title { font-weight: 600; font-size: 15px; }

/* ---- TOC ---- */
.toc-col { min-width: 0; }
.toc {
    position: sticky;
    top: var(--topbar-h);
    max-height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    padding: 36px 20px 40px 8px;
}
.toc-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 12px;
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a {
    display: block;
    padding: 5px 0 5px 14px;
    margin-left: -1px;
    border-left: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.4;
}
.toc li a:hover { color: var(--text-strong); text-decoration: none; }
.toc li.toc-l3 a { padding-left: 26px; font-size: 12.5px; }
.toc li a.active { color: var(--primary); border-left-color: var(--primary); font-weight: 600; }

/* ============================================================
   Home page
   ============================================================ */
.home { max-width: 1080px; margin: 0 auto; }
.home-hero { padding: 24px 0 36px; border-bottom: 1px solid var(--border); margin-bottom: 36px; }
.home-hero h1 {
    font-size: 40px;
    line-height: 1.12;
    letter-spacing: -0.025em;
    margin: 0 0 12px;
    color: var(--text-strong);
    font-weight: 800;
}
.home-hero p { font-size: 18px; color: var(--text-muted); max-width: 620px; margin: 0 0 22px; }
.home-search {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.home-search:hover { border-color: var(--primary); color: var(--text-strong); }
.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
}
.home-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elev);
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.home-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.home-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; color: var(--text-strong); }
.home-card-head:hover { text-decoration: none; }
.home-card-head:hover h2 { color: var(--primary); }
.home-card-ic { font-size: 22px; }
.home-card h2 { font-size: 19px; margin: 0; color: var(--text-strong); font-weight: 700; transition: color 0.12s; }
.home-card > p { font-size: 14.5px; color: var(--text-muted); margin: 0 0 14px; }
.home-card-list { list-style: none; margin: 0; padding: 0; }
.home-card-list li { margin: 5px 0; }
.home-card-list a { font-size: 14px; color: var(--text-muted); }
.home-card-list a:hover { color: var(--primary); }
.home-card-count {
    margin-top: 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-faint);
}

/* ============================================================
   Search modal
   ============================================================ */
.search-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 90px 16px 16px;
    background: rgba(10, 14, 22, 0.55);
    backdrop-filter: blur(2px);
}
.search-modal[hidden] { display: none; }
.search-box {
    width: 100%;
    max-width: 600px;
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.search-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}
.search-input-row input {
    flex: 1;
    border: none;
    outline: none;
    background: none;
    font-family: inherit;
    font-size: 16px;
    color: var(--text);
}
.search-close {
    border: 1px solid var(--border-strong);
    background: var(--bg-subtle);
    color: var(--text-faint);
    border-radius: 5px;
    font-size: 11px;
    padding: 3px 7px;
    cursor: pointer;
}
.search-results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.search-empty { padding: 28px 16px; text-align: center; color: var(--text-faint); font-size: 14px; }
.search-hit {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
}
.search-hit:hover, .search-hit.active { background: var(--bg-hover); text-decoration: none; }
.search-hit-cat { font-size: 11.5px; color: var(--primary); font-weight: 600; margin-bottom: 2px; }
.search-hit-title { font-size: 15px; font-weight: 600; color: var(--text-strong); }
.search-hit-desc { font-size: 13px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hit mark { background: color-mix(in srgb, var(--primary) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ============================================================
   404 + buttons
   ============================================================ */
.notfound { max-width: 560px; margin: 60px auto; text-align: center; }
.notfound h1 { font-size: 72px; margin: 0; color: var(--primary); }
.notfound p { color: var(--text-muted); font-size: 17px; margin: 8px 0 24px; }
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }

/* ---- Off-canvas sidebar backdrop ---- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    z-index: 29;
    background: rgba(10, 14, 22, 0.5);
}
.sidebar-backdrop.show { display: block; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
    .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
    .toc-col { display: none; }
}
@media (max-width: 900px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .menu-toggle { display: grid; }
    .sidebar {
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        z-index: 30;
        width: var(--sidebar-w);
        max-width: 84vw;
        background: var(--bg-elev);
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow);
    }
    .sidebar.open { transform: translateX(0); }
    .content { padding: 26px 22px 64px; }
    .search-trigger { min-width: 0; width: 36px; padding: 0; justify-content: center; }
    .search-trigger span, .search-trigger kbd { display: none; }
    .topbar-link { display: none; }
}
@media (max-width: 560px) {
    .article h1 { font-size: 27px; }
    .home-hero h1 { font-size: 30px; }
    .prevnext { grid-template-columns: 1fr; }
    .brand-name { display: none; }
}
