/* ───── TOKENS ───── */
:root {
  --sidebar-w: 270px;
  --toc-w: 220px;
  --hdr-h: 56px;
  --bg:          #ffffff;
  --bg-2:        #f8f7f5;
  --bg-3:        #f1efe9;
  --sidebar-bg:  #16161a;
  --sidebar-txt: #c9c8d3;
  --sidebar-muted: #6e6d7a;
  --sidebar-active-bg: #2b2b33;
  --sidebar-active: #ffffff;
  --sidebar-accent: #7c6fff;
  --txt:         #1a1a24;
  --txt-2:       #4a4a60;
  --txt-3:       #8a8aa8;
  --accent:      #6654f0;
  --accent-lite: #ede9ff;
  --accent-2:    #f0a500;
  --border:      #e4e3ec;
  --code-bg:     #1e1e2e;
  --code-txt:    #cdd6f4;
  --note-bg:     #ede9ff;
  --note-border: #6654f0;
  --warn-bg:     #fff8e6;
  --warn-border: #f0a500;
  --tip-bg:      #e6f9f1;
  --tip-border:  #1aaa6e;
  --danger-bg:   #fdecea;
  --danger-border:#e53935;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --trans:       .2s ease;
}
[data-theme="dark"] {
  --bg:          #13131a;
  --bg-2:        #1c1c26;
  --bg-3:        #222230;
  --txt:         #e8e8f4;
  --txt-2:       #a0a0c0;
  --txt-3:       #5a5a7a;
  --accent:      #9183ff;
  --accent-lite: #2a2450;
  --accent-2:    #ffbb33;
  --border:      #2c2c40;
  --note-bg:     #1f1d40;
  --note-border: #7c6fff;
  --warn-bg:     #2a2008;
  --warn-border: #f0a500;
  --tip-bg:      #0d2a1e;
  --tip-border:  #1aaa6e;
  --danger-bg:   #2a0d0d;
  --danger-border:#e53935;
}

/* ───── RESET ───── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body { font-family: 'Sora', sans-serif; background: var(--bg); color: var(--txt); line-height: 1.75; min-height: 100vh; }

/* ───── PROGRESS BAR ───── */
#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 9999; transition: width .1s;
}

/* ───── TOP NAV ───── */
#topnav {
  position: fixed; top: 3px; left: 0; right: 0; height: var(--hdr-h);
  background: var(--sidebar-bg); z-index: 200;
  display: flex; align-items: center; padding: 0 1.25rem;
  gap: 1rem; border-bottom: 1px solid #2a2a36;
}
.logo { display: flex; align-items: center; gap: .6rem; text-decoration: none; flex-shrink: 0; }
.logo-icon {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; color: #fff; letter-spacing: -.5px;
}
.logo-name { font-size: 15px; font-weight: 600; color: #fff; letter-spacing: -.3px; }
.logo-version {
  font-size: 10px; font-weight: 500; padding: 2px 7px; border-radius: 20px;
  background: #2a2a3e; color: var(--sidebar-muted); margin-left: 2px;
}
#nav-search-wrap { flex: 1; max-width: 380px; position: relative; }
#nav-search {
  width: 100%; height: 34px; border-radius: 6px; border: 1px solid #2f2f3e;
  background: #1e1e2a; color: #bbb; font-family: 'Sora', sans-serif;
  font-size: 13px; padding: 0 12px 0 34px; outline: none;
  transition: border var(--trans), background var(--trans);
}
#nav-search:focus { border-color: var(--accent); background: #23233a; color: #eee; }
#nav-search::placeholder { color: #555570; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; color: #666; pointer-events: none; }
#search-results {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 400; max-height: 320px; overflow-y: auto;
}
.sr-item {
  padding: .65rem 1rem; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background var(--trans);
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover, .sr-item.active { background: var(--accent-lite); }
.sr-item-title { font-size: 13px; font-weight: 500; color: var(--txt); }
.sr-item-section { font-size: 11px; color: var(--txt-3); margin-top: 1px; }
.sr-item mark { background: transparent; color: var(--accent); font-weight: 600; }
.nav-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.nav-btn {
  width: 32px; height: 32px; border-radius: 6px; border: 1px solid #2f2f3e;
  background: transparent; color: var(--sidebar-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--trans); font-size: 14px;
}
.nav-btn:hover { background: #2a2a3a; color: #fff; border-color: #444458; }
#hamburger { display: none; padding: 0 5px;}

/* ───── LAYOUT SHELL ───── */
#shell { display: flex; padding-top: calc(var(--hdr-h) + 3px); min-height: 100vh; }

/* ───── SIDEBAR ───── */
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: fixed; top: calc(var(--hdr-h) + 3px); bottom: 0;
  background: var(--sidebar-bg); overflow-y: auto; overflow-x: hidden;
  z-index: 100; padding: 1.25rem 0 2rem;
  scrollbar-width: thin; scrollbar-color: #2e2e40 transparent;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: #2e2e40; border-radius: 4px; }
.nav-section { margin-bottom: .25rem; }
.nav-section-label {
  font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--sidebar-muted); font-weight: 600;
  padding: 1rem 1.25rem .4rem; display: flex; align-items: center;
  justify-content: space-between; user-select: none; cursor: pointer;
}
.nav-section-label svg { width: 12px; transition: transform var(--trans); flex-shrink: 0; }
.nav-section.collapsed .nav-section-label svg { transform: rotate(-90deg); }
.nav-links { overflow: hidden; }
.nav-section.collapsed .nav-links { display: none; }
.nav-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .4rem 1.25rem; text-decoration: none; font-size: 13.5px;
  color: var(--sidebar-txt); border-left: 3px solid transparent;
  transition: all var(--trans); cursor: pointer;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.04); }
.nav-link.active {
  color: var(--sidebar-active); background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-accent); font-weight: 500;
}

/* ───── MAIN CONTENT ───── */
#content {
  margin-left: var(--sidebar-w); margin-right: var(--toc-w);
  flex: 1; min-width: 0; padding: 3rem 3.5rem 5rem; max-width: 100%;
}

/* ───── TOC ───── */
#toc {
  width: var(--toc-w); flex-shrink: 0;
  position: fixed; top: calc(var(--hdr-h) + 3px); right: 0; bottom: 0;
  padding: 2rem 1rem 2rem 1.25rem;
  overflow-y: auto; border-left: 1px solid var(--border); background: var(--bg);
}
.toc-title {
  font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--txt-3); font-weight: 600; margin-bottom: .75rem; padding-left: 8px;
}
.toc-link {
  display: block; font-size: 12.5px; color: var(--txt-3); text-decoration: none;
  padding: .25rem .5rem .25rem 8px; border-left: 2px solid var(--border);
  margin-bottom: 2px; transition: all var(--trans); border-radius: 0 4px 4px 0; line-height: 1.4;
}
.toc-link:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-lite); }
.toc-link.active { color: var(--accent); border-color: var(--accent); font-weight: 500; }
.toc-link.toc-h3 { padding-left: 20px; font-size: 12px; }

/* ───── TYPOGRAPHY ───── */
.page-tag {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .8px;
  text-transform: uppercase; color: var(--accent); margin-bottom: .75rem;
}
h1 { font-size: 2rem; font-weight: 600; letter-spacing: -.5px; line-height: 1.25; margin-bottom: .5rem; color: var(--txt); }
.page-subtitle { font-size: 1.05rem; color: var(--txt-2); margin-bottom: 2rem; line-height: 1.65; border-bottom: 1px solid var(--border); padding-bottom: 1.5rem; }
h2 { font-size: 1.3rem; font-weight: 600; letter-spacing: -.3px; margin: 2.5rem 0 .75rem; color: var(--txt); scroll-margin-top: 80px; }
h3 { font-size: 1.05rem; font-weight: 600; margin: 1.75rem 0 .6rem; color: var(--txt); scroll-margin-top: 80px; }
p { margin-bottom: 1rem; color: var(--txt-2); font-size: .95rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; color: var(--txt); }
ul, ol { margin: .75rem 0 1rem 1.25rem; }
li { color: var(--txt-2); font-size: .95rem; margin-bottom: .3rem; }
li::marker { color: var(--accent); }
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ───── INLINE CODE ───── */
code {
  font-family: 'JetBrains Mono', monospace; font-size: .82em;
  background: var(--bg-3); color: var(--accent); padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border);
}

/* ───── CODE BLOCKS ───── */
.code-block { margin: 1.25rem 0; border-radius: var(--radius); overflow: hidden; border: 1px solid #2a2a3e; }
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  background: #191927; padding: .5rem 1rem; border-bottom: 1px solid #252538;
}
.code-lang { font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: #7070a0; font-family: 'JetBrains Mono', monospace; }
.code-copy {
  font-size: 11px; font-weight: 500; color: #7070a0; border: 1px solid #2f2f44;
  background: transparent; border-radius: 4px; padding: 3px 9px; cursor: pointer;
  font-family: 'Sora', sans-serif; transition: all var(--trans); display: flex; align-items: center; gap: 4px;
}
.code-copy:hover { color: #bbb; border-color: #555570; background: #252538; }
.code-copy.copied { color: #4ade80; border-color: #1a3a28; }
pre {
  background: var(--code-bg); padding: 1.1rem 1.25rem; overflow-x: auto; margin: 0;
  scrollbar-width: thin; scrollbar-color: #333 transparent;
}
pre code {
  background: none; color: var(--code-txt); border: none; padding: 0;
  font-size: .855rem; line-height: 1.7;
}
.token-comment { color: #6272a4; font-style: italic; }
.token-string  { color: #f1fa8c; }
.token-keyword { color: #ff79c6; }
.token-fn      { color: #50fa7b; }
.token-var     { color: #8be9fd; }
.token-num     { color: #bd93f9; }

/* ───── CALLOUT BOXES ───── */
.callout {
  display: flex; gap: .85rem; padding: 1rem 1.15rem;
  border-radius: var(--radius); margin: 1.25rem 0; border-left: 3px solid;
}
.callout-icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.callout-body { flex: 1; }
.callout-title { font-size: .875rem; font-weight: 600; margin-bottom: .2rem; }
.callout p { font-size: .875rem; margin: 0; line-height: 1.6; }
.callout.note    { background: var(--note-bg);   border-color: var(--note-border); }
.callout.warning { background: var(--warn-bg);   border-color: var(--warn-border); }
.callout.tip     { background: var(--tip-bg);    border-color: var(--tip-border); }
.callout.danger  { background: var(--danger-bg); border-color: var(--danger-border); }
.callout.note    .callout-title { color: #4f46e5; }
.callout.warning .callout-title { color: #b45309; }
.callout.tip     .callout-title { color: #047857; }
.callout.danger  .callout-title { color: #b91c1c; }

/* ───── PARAMS TABLE ───── */
.params-table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; font-size: .875rem; }
.params-table th {
  text-align: left; padding: .6rem .9rem; background: var(--bg-3);
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  font-weight: 600; color: var(--txt-3); border-bottom: 1px solid var(--border);
}
.params-table td { padding: .65rem .9rem; border-bottom: 1px solid var(--border); color: var(--txt-2); vertical-align: top; }
.params-table tr:last-child td { border-bottom: none; }
.params-table tr:hover td { background: var(--bg-2); }
.param-type { font-family: 'JetBrains Mono', monospace; font-size: .78rem; color: var(--accent-2); }

/* ───── BREADCRUMBS ───── */
.breadcrumbs { display: flex; align-items: center; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.bc-item { font-size: 12.5px; color: var(--txt-3); }
.bc-item a { color: var(--txt-3); text-decoration: none; }
.bc-item a:hover { color: var(--accent); }
.bc-sep { font-size: 11px; color: var(--border); }
.bc-item.current { color: var(--txt-2); }

/* ───── PREV / NEXT ───── */
.nav-footer {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem;
  padding-top: 2rem; border-top: 1px solid var(--border);
}
.nav-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem;
  text-decoration: none; transition: all var(--trans); display: block; background: var(--bg);
}
.nav-card:hover { border-color: var(--accent); background: var(--accent-lite); box-shadow: var(--shadow); }
.nav-card-dir { font-size: 11px; color: var(--txt-3); margin-bottom: .25rem; }
.nav-card-title { font-size: .9rem; font-weight: 600; color: var(--txt); }
.nav-card.next { text-align: right; }

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

/* ───── STEPS ───── */
.steps { margin: 1.25rem 0 1.5rem; }
.step { display: flex; gap: 1rem; margin-bottom: 1.5rem; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 600; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; margin-top: .15rem;
}
.step-body { flex: 1; }
.step-title { font-size: .95rem; font-weight: 600; color: var(--txt); margin-bottom: .3rem; }
.step p { margin-bottom: .5rem; }

/* ───── TABS ───── */
.tab-group { margin: 1.25rem 0; }
.tab-list { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 0; list-style: none; }
.tab-btn {
  padding: .5rem 1.1rem; font-size: .875rem; font-weight: 500; cursor: pointer;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--txt-3); font-family: 'Sora', sans-serif; margin-bottom: -1px;
  transition: all var(--trans);
}
.tab-btn:hover { color: var(--txt); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ───── SCREENSHOTS ───── */
.screenshot { margin: 1.25rem 0; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.screenshot img { width: 100%; height: auto; display: block; }
.screenshot-caption { padding: .6rem 1rem; font-size: .82rem; color: var(--txt-3); background: var(--bg-2); }

/* ───── MOBILE ───── */
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 90; }
.mobile-toc { display: none; }
@media (max-width: 1100px) {
  #toc { display: none !important;  }
  #content { margin-right: 0; }
  .mobile-toc { display: block; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 2rem; }
  .mobile-toc-title { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--txt-3); margin-bottom: .6rem; }
  .mobile-toc a { display: block; font-size: 13px; color: var(--txt-2); padding: .2rem 0; text-decoration: none; }
  .mobile-toc a:hover { color: var(--accent); }
}
@media (max-width: 820px) {
  #sidebar { transform: translateX(-100%); transition: transform .28s ease; }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay.open { display: block; }
  #content { margin-left: 0; padding: 2rem 1.5rem 4rem; }
  #hamburger { display: flex; }
  .nav-footer { grid-template-columns: 1fr; }
  h1 { font-size: 1.65rem; }
}
@media (max-width: 500px) {
  #content { padding: 1.5rem 1rem 4rem; }
  #nav-search-wrap { display: none; }
}
