:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface-2:   #1c2128;
  --border:      #21262d;
  --border-soft: #30363d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --text-subtle: #6e7681;
  --accent:      #5c9a2e;
  --accent-glow: rgba(92, 154, 46, 0.18);
  --accent-dim:  #3e6b1f;
  --warn-bg:     #221a00;
  --warn-border: #5a4300;
  --warn-text:   #e3b341;
  --tip-bg:      #0c1f3a;
  --tip-border:  #1f4b8e;
  --code-bg:     #1c2128;
  --scrollbar:   #30363d;
  --sidebar-w:   240px;
  --content-max: 860px;
  --radius:      6px;
  --radius-sm:   4px;


  --syn-keyword:  #ff7b72;
  --syn-string:   #a5d6ff;
  --syn-comment:  #8b949e;
  --syn-number:   #79c0ff;
  --syn-property: #d2a8ff;
  --syn-function: #d2a8ff;
  --syn-tag:      #7ee787;
  --syn-attr:     #79c0ff;
  --syn-value:    #a5d6ff;
  --syn-punct:    #e6edf3;
  --syn-selector: #7ee787;
  --syn-prop-name:#79c0ff;
  --syn-json-key: #7ee787;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:          #ffffff;
    --surface:     #f6f8fa;
    --surface-2:   #eaeef2;
    --border:      #d0d7de;
    --border-soft: #d8dee4;
    --text:        #1f2328;
    --text-muted:  #57606a;
    --text-subtle: #6e7781;
    --accent:      #4a7d24;
    --accent-glow: rgba(74, 125, 36, 0.12);
    --accent-dim:  #316b18;
    --warn-bg:     #fff8c5;
    --warn-border: #d4a72c;
    --warn-text:   #7d4e00;
    --tip-bg:      #ddf4ff;
    --tip-border:  #54aeff;
    --code-bg:     #f6f8fa;
    --scrollbar:   #c9d1d9;
    --syn-keyword:  #cf222e;
    --syn-string:   #0a3069;
    --syn-comment:  #57606a;
    --syn-number:   #0550ae;
    --syn-property: #6639ba;
    --syn-function: #6639ba;
    --syn-tag:      #116329;
    --syn-attr:     #0550ae;
    --syn-value:    #0a3069;
    --syn-selector: #116329;
    --syn-prop-name:#0550ae;
    --syn-json-key: #116329;
  }
}

:root[data-theme="dark"] {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface-2:   #1c2128;
  --border:      #21262d;
  --border-soft: #30363d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --text-subtle: #6e7681;
  --accent:      #5c9a2e;
  --accent-glow: rgba(92, 154, 46, 0.18);
  --accent-dim:  #3e6b1f;
  --warn-bg:     #221a00;
  --warn-border: #5a4300;
  --warn-text:   #e3b341;
  --tip-bg:      #0c1f3a;
  --tip-border:  #1f4b8e;
  --code-bg:     #1c2128;
  --scrollbar:   #30363d;
  --syn-keyword:  #ff7b72;
  --syn-string:   #a5d6ff;
  --syn-comment:  #8b949e;
  --syn-number:   #79c0ff;
  --syn-property: #d2a8ff;
  --syn-function: #d2a8ff;
  --syn-tag:      #7ee787;
  --syn-attr:     #79c0ff;
  --syn-value:    #a5d6ff;
  --syn-selector: #7ee787;
  --syn-prop-name:#79c0ff;
  --syn-json-key: #7ee787;
}

:root[data-theme="light"] {
  --bg:          #ffffff;
  --surface:     #f6f8fa;
  --surface-2:   #eaeef2;
  --border:      #d0d7de;
  --border-soft: #d8dee4;
  --text:        #1f2328;
  --text-muted:  #57606a;
  --text-subtle: #6e7781;
  --accent:      #4a7d24;
  --accent-glow: rgba(74, 125, 36, 0.12);
  --accent-dim:  #316b18;
  --warn-bg:     #fff8c5;
  --warn-border: #d4a72c;
  --warn-text:   #7d4e00;
  --tip-bg:      #ddf4ff;
  --tip-border:  #54aeff;
  --code-bg:     #f6f8fa;
  --scrollbar:   #c9d1d9;
  --syn-keyword:  #cf222e;
  --syn-string:   #0a3069;
  --syn-comment:  #57606a;
  --syn-number:   #0550ae;
  --syn-property: #6639ba;
  --syn-function: #6639ba;
  --syn-tag:      #116329;
  --syn-attr:     #0550ae;
  --syn-value:    #0a3069;
  --syn-selector: #116329;
  --syn-prop-name:#0550ae;
  --syn-json-key: #116329;
}


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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}


::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }


.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.logo span {
  color: var(--accent);
}

.version-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  white-space: nowrap;
}

.version-badge .dot {
  color: var(--border-soft);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 8px;
  font-size: 0.8rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}

.theme-toggle:hover { color: var(--text); border-color: var(--accent); }


.layout {
  display: flex;
  flex: 1;
  align-items: flex-start;
  position: relative;
}


.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 20px 0;
  background: var(--surface);
  flex-shrink: 0;
}

.sidebar-section {
  padding: 0 16px 16px;
}

.sidebar-label {
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 8px 8px 4px;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav a {
  display: block;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  line-height: 1.4;
  transition: color 0.1s, background 0.1s;
  border-left: 2px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.sidebar-nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-glow);
  font-weight: 500;
}


.content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 80px;
}

.content-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}


.doc-section {
  padding-top: 40px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.doc-section:last-child {
  border-bottom: none;
}

.section-eyebrow {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin-bottom: 12px;
  scroll-margin-top: 80px;
}

.section-title a {
  color: inherit;
  text-decoration: none;
}

.section-title a:hover { color: var(--accent); }

.section-intro {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 680px;
  margin-bottom: 24px;
}


p {
  color: var(--text-muted);
  margin-bottom: 12px;
  font-size: 0.92rem;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 8px;
}

h4 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 20px 0 6px;
}

ul, ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

li {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 4px;
}

li code, p code {
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  font-size: 0.82em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--syn-property);
}


.code-block {
  position: relative;
  margin: 16px 0 24px;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 6px 12px 6px 10px;
  gap: 8px;
}

.lang-badge {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
}

.lang-badge.js   { background: #2d2005; color: #e3b341; border: 1px solid #5a4300; }
.lang-badge.css  { background: #0c1f3a; color: #79c0ff; border: 1px solid #1f4b8e; }
.lang-badge.html { background: #1a0f1f; color: #d2a8ff; border: 1px solid #4b2e83; }
.lang-badge.json { background: #0d2114; color: #7ee787; border: 1px solid #2a5e3a; }

.copy-btn {
  background: none;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 3px 9px;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); }

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  line-height: 1.55;
}

pre code {
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  font-size: 0.82rem;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  display: block;
  white-space: pre;
}


.tok-keyword   { color: var(--syn-keyword); }
.tok-string    { color: var(--syn-string); }
.tok-comment   { color: var(--syn-comment); font-style: italic; }
.tok-number    { color: var(--syn-number); }
.tok-function  { color: var(--syn-function); }
.tok-property  { color: var(--syn-property); }
.tok-tag       { color: var(--syn-tag); }
.tok-attr      { color: var(--syn-attr); }
.tok-value     { color: var(--syn-value); }
.tok-punct     { color: var(--syn-punct); }
.tok-selector  { color: var(--syn-selector); }
.tok-prop-name { color: var(--syn-prop-name); }
.tok-json-key  { color: var(--syn-json-key); }


.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}


.callout {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 16px 0 24px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.callout-warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
}

.callout-tip {
  background: var(--tip-bg);
  border: 1px solid var(--tip-border);
}

.callout-icon {
  font-size: 1rem;
  line-height: 1.6;
  flex-shrink: 0;
}

.callout-body {
  flex: 1;
  min-width: 0;
}

.callout-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--warn-text);
  margin-bottom: 4px;
}

.callout-tip .callout-title {
  color: #79c0ff;
}

.callout-body p {
  font-size: 0.82rem;
  color: var(--warn-text);
  margin-bottom: 0;
}

.callout-tip .callout-body p {
  color: #a5d6ff;
}

.callout-body code {
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  font-size: 0.85em;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  padding: 1px 4px;
  color: inherit;
}


.gotcha-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.gotcha-item {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.gotcha-item .icon {
  flex-shrink: 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.gotcha-item p {
  font-size: 0.83rem;
  color: var(--warn-text);
  margin: 0;
}

.gotcha-item code {
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  font-size: 0.85em;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  padding: 1px 4px;
  color: inherit;
  border: none;
}


.api-table-wrap {
  overflow-x: auto;
  margin: 12px 0 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.api-table thead th {
  background: var(--surface);
  color: var(--text-subtle);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 8px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.api-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.api-table tbody tr:last-child { border-bottom: none; }

.api-table tbody tr:hover { background: var(--surface); }

.api-table td {
  padding: 8px 14px;
  vertical-align: top;
}

.api-table td:first-child {
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  color: var(--syn-property);
  white-space: nowrap;
}

.api-table td:nth-child(2) {
  color: var(--syn-string);
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  white-space: nowrap;
}

.api-table td:last-child {
  color: var(--text-muted);
}


.css-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin: 16px 0 24px;
}

.css-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  font-size: 0.75rem;
  color: var(--syn-prop-name);
}

.css-pill .values {
  display: block;
  font-size: 0.68rem;
  color: var(--text-subtle);
  margin-top: 1px;
}


.hero {
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.04em;
  text-wrap: balance;
  margin-bottom: 12px;
  line-height: 1.15;
}

.hero-title em {
  font-style: normal;
  color: var(--accent);
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 600px;
  margin-bottom: 24px;
  line-height: 1.65;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hero-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}


.file-tree {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  font-size: 0.82rem;
  line-height: 2;
  margin: 16px 0 24px;
}

.tree-dir { color: var(--syn-tag); }
.tree-file { color: var(--text-muted); }
.tree-comment { color: var(--syn-comment); }
.tree-indent { margin-left: 20px; display: block; }
.tree-indent2 { margin-left: 40px; display: block; }


.mobile-nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 10px;
  font-size: 0.8rem;
}

@media (max-width: 768px) {
  .mobile-nav-toggle { display: block; }

  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.4);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    padding: 24px 20px 60px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .hero-title { font-size: 1.6rem; }

  .css-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

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