*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w: 280px;
    --header-h: 56px;
    --brand: #4f46e5;
    --brand-dark: #3730a3;
    --brand-light: #e0e7ff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #4f46e5;
    --sidebar-hover: #1e293b;
    --sidebar-group: #64748b;
    --content-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --code-bg: #0f172a;
    --code-inline-bg: #f1f5f9;
    --tip-bg: #eff6ff;
    --tip-border: #3b82f6;
    --warn-bg: #fffbeb;
    --warn-border: #f59e0b;
    --danger-bg: #fef2f2;
    --danger-border: #ef4444;
}

html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--text); background: var(--content-bg); line-height: 1.6; }

/* ── HEADER ── */
.site-header {
    position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
    background: var(--sidebar-bg); border-bottom: 1px solid #1e293b;
    display: flex; align-items: center; padding: 0 20px;
    z-index: 100; gap: 16px;
}
.header-logo {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: #fff; font-weight: 700; font-size: 1.1rem;
    flex-shrink: 0;
}
.header-logo .logo-badge {
    background: var(--brand); color: #fff;
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 900; letter-spacing: -0.5px;
}
.header-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.header-nav a {
    color: var(--sidebar-text); text-decoration: none; font-size: 13px;
    padding: 6px 12px; border-radius: 6px; transition: all 0.15s;
}
.header-nav a:hover { color: #fff; background: var(--sidebar-hover); }
.header-version {
    background: var(--brand); color: #fff; font-size: 11px; font-weight: 700;
    padding: 3px 10px; border-radius: 20px; letter-spacing: 0.04em;
}
.mobile-menu-btn {
    display: none; background: none; border: none; color: #fff;
    cursor: pointer; padding: 8px; border-radius: 6px; margin-right: 4px;
}

/* ── LAYOUT ── */
.layout { display: flex; padding-top: var(--header-h); min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--sidebar-bg); position: fixed;
    top: var(--header-h); bottom: 0; left: 0;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: #334155 transparent;
    padding: 16px 0 40px;
    transition: transform 0.25s ease;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.sidebar-search {
    padding: 0 16px 16px;
}
.sidebar-search input {
    width: 100%; background: #1e293b; border: 1px solid #334155;
    border-radius: 8px; padding: 8px 12px 8px 36px; color: #fff;
    font-size: 13px; outline: none; font-family: inherit;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-size: 16px; background-position: 10px center;
    transition: border-color 0.15s;
}
.sidebar-search input:focus { border-color: var(--brand); }
.sidebar-search input::placeholder { color: #475569; }

.sidebar-group { margin-bottom: 4px; }
.sidebar-group-label {
    color: var(--sidebar-group); font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    padding: 12px 20px 4px; display: block;
}
.sidebar-link {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 20px; color: var(--sidebar-text); text-decoration: none;
    font-size: 13.5px; border-radius: 0; transition: all 0.12s;
    border-left: 3px solid transparent; cursor: pointer;
    background: none; border-right: none; border-top: none; border-bottom: none;
    width: 100%; text-align: left; font-family: inherit;
}
.sidebar-link:hover { color: #fff; background: var(--sidebar-hover); }
.sidebar-link.active { color: #fff; background: rgba(79,70,229,0.2); border-left-color: var(--brand); }
.sidebar-link .icon { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.6; }
.sidebar-link.active .icon { opacity: 1; }
.sidebar-sub { padding-left: 16px; }
.sidebar-sub .sidebar-link { font-size: 13px; padding: 5px 20px 5px 16px; }

/* ── MAIN CONTENT ── */
.main { margin-left: var(--sidebar-w); flex: 1; max-width: 100%; }
.content-wrap { max-width: 860px; padding: 48px 48px 80px; }

/* breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 24px; }
.breadcrumb span { display: flex; align-items: center; gap: 6px; }
.breadcrumb svg { width: 12px; height: 12px; }

/* section */
.doc-section { display: none; }
.doc-section.active { display: block; }

/* typography */
.content-wrap h1 { font-size: 2rem; font-weight: 800; color: var(--text); margin-bottom: 12px; line-height: 1.2; }
.content-wrap h2 { font-size: 1.35rem; font-weight: 700; color: var(--text); margin: 40px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.content-wrap h3 { font-size: 1.1rem; font-weight: 600; color: var(--text); margin: 28px 0 10px; }
.content-wrap h4 { font-size: 0.95rem; font-weight: 600; color: var(--text); margin: 20px 0 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.content-wrap p { color: #334155; margin-bottom: 16px; line-height: 1.75; }
.content-wrap ul, .content-wrap ol { margin: 0 0 16px 20px; color: #334155; }
.content-wrap li { margin-bottom: 6px; line-height: 1.7; }
.content-wrap a { color: var(--brand); text-decoration: none; }
.content-wrap a:hover { text-decoration: underline; }
.content-wrap strong { color: var(--text); }
.content-wrap hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

/* lead text */
.lead { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 32px; line-height: 1.7; }

/* code */
code { background: var(--code-inline-bg); color: #be185d; padding: 2px 6px; border-radius: 4px; font-size: 0.875em; font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace; }
pre { background: var(--code-bg); border-radius: 10px; padding: 20px 24px; margin: 16px 0 24px; overflow-x: auto; }
pre code { background: none; color: #e2e8f0; padding: 0; font-size: 0.85rem; line-height: 1.7; }
.code-block { position: relative; margin: 16px 0 24px; }
.code-block .lang-badge {
    position: absolute; top: 10px; right: 12px;
    font-size: 10px; color: #475569; text-transform: uppercase; letter-spacing: 0.08em;
    font-family: monospace;
}

/* callouts */
.callout { border-radius: 8px; padding: 16px 20px; margin: 20px 0; border-left: 4px solid; display: flex; gap: 12px; }
.callout.tip { background: var(--tip-bg); border-color: var(--tip-border); }
.callout.warning { background: var(--warn-bg); border-color: var(--warn-border); }
.callout.danger { background: var(--danger-bg); border-color: var(--danger-border); }
.callout-icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; }
.callout.tip .callout-icon { color: var(--tip-border); }
.callout.warning .callout-icon { color: var(--warn-border); }
.callout.danger .callout-icon { color: var(--danger-border); }
.callout-body p { margin: 0; font-size: 14px; line-height: 1.6; }
.callout-body strong { display: block; margin-bottom: 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }

/* cards grid */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 24px 0; }
.card {
    border: 1px solid var(--border); border-radius: 10px; padding: 20px;
    text-decoration: none; color: inherit; transition: all 0.15s;
    cursor: pointer; background: #fff;
}
.card:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.card-icon { font-size: 24px; margin-bottom: 10px; }
.card h3 { font-size: 14px; font-weight: 700; margin: 0 0 6px; color: var(--text); }
.card p { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.5; }

/* table */
.content-wrap table { width: 100%; border-collapse: collapse; margin: 16px 0 24px; font-size: 14px; }
.content-wrap th { background: #f8fafc; padding: 10px 16px; text-align: left; font-weight: 600; border-bottom: 2px solid var(--border); color: var(--text); }
.content-wrap td { padding: 10px 16px; border-bottom: 1px solid var(--border); color: #334155; }
.content-wrap tr:last-child td { border-bottom: none; }

/* badge */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* steps */
.steps { counter-reset: step; margin: 24px 0; }
.step { display: flex; gap: 16px; margin-bottom: 24px; }
.step-num {
    counter-increment: step; content: counter(step);
    width: 32px; height: 32px; border-radius: 50%; background: var(--brand);
    color: #fff; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.step-body { flex: 1; }
.step-body h4 { margin-top: 4px; }

/* file tree */
pre.file-tree { background: #f8fafc; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; font-size: 13px; line-height: 1.8; margin: 16px 0 24px; overflow-x: auto; }
.file-tree .dir { color: var(--brand); font-weight: 600; }
.file-tree .file { color: #334155; }
.file-tree .comment { color: #94a3b8; }

/* page nav */
.page-nav { display: flex; gap: 16px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border); }
.page-nav-btn {
    flex: 1; border: 1px solid var(--border); border-radius: 10px;
    padding: 16px 20px; text-decoration: none; color: var(--text);
    transition: all 0.15s; display: block;
}
.page-nav-btn:hover { border-color: var(--brand); background: var(--brand-light); }
.page-nav-btn.next { text-align: right; }
.page-nav-btn .nav-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; display: block; margin-bottom: 4px; }
.page-nav-btn .nav-title { font-weight: 600; font-size: 14px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); z-index: 90; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .content-wrap { padding: 32px 24px 60px; }
    .mobile-menu-btn { display: flex; align-items: center; }
    .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 89; }
    .sidebar-overlay.open { display: block; }
}
@media (max-width: 600px) {
    .content-wrap { padding: 24px 16px 60px; }
    .content-wrap h1 { font-size: 1.6rem; }
    .cards-grid { grid-template-columns: 1fr; }
}

/* syntax highlight tokens */
.tok-kw { color: #c792ea; }
.tok-str { color: #c3e88d; }
.tok-fn { color: #82aaff; }
.tok-num { color: #f78c6c; }
.tok-cmt { color: #546e7a; font-style: italic; }
.tok-cls { color: #ffcb6b; }
.tok-var { color: #eeffff; }
.tok-op { color: #89ddff; }
.tok-tag { color: #f07178; }
.tok-attr { color: #ffcb6b; }
.tok-val { color: #c3e88d; }
