:root, [data-theme="midnight"] {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border: #30363d;
  --text-primary: #c9d1d9;
  --text-secondary: #b0b8c0;
  --text-muted: #484f58;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --success: #3fb950;
  --danger: #f85149;
  --warning: #d2991d;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --font-mono: 'Consolas', 'Fira Code', 'JetBrains Mono', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}


[data-theme="dark"] {
  --bg-primary: #1e1e1e;
  --bg-secondary: #252526;
  --bg-tertiary: #2d2d2d;
  --border: #3e3e3e;
  --text-primary: #cccccc;
  --text-secondary: #999999;
  --text-muted: #5a5a5a;
  --accent: #569cd6;
  --accent-hover: #6aace8;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eaeef2;
  --border: #d0d7de;
  --text-primary: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8c959f;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --success: #1a7f37;
  --danger: #cf222e;
  --warning: #9a6700;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

[data-theme="amoled"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #141414;
  --border: #1f1f1f;
  --text-primary: #e6e6e6;
  --text-secondary: #999999;
  --text-muted: #555555;
  --accent: #4da6ff;
  --accent-hover: #80bfff;
  --success: #2ea043;
  --danger: #da3633;
  --warning: #bb8009;
  --shadow: 0 1px 3px rgba(0,0,0,0.5);
}

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

body {
  background: var(--bg-primary); color: var(--text-primary);
  font-family: var(--font-sans); line-height: 1.6; min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

code, pre { font-family: var(--font-mono); font-size: 0.9em; }

button {
  cursor: pointer; font-family: var(--font-sans); font-size: 0.95rem;
  border: none; border-radius: var(--radius); padding: 0.6em 1.2em;
  transition: background 0.15s, transform 0.1s;
}
button:active { transform: scale(0.97); }

hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }

.theme-btn {
  background: none; border: none; font-size: 1.1rem; padding: 0.3em 0.35em;
  cursor: pointer; line-height: 1; transition: transform 0.15s;
  position: relative; display: inline-flex; align-items: center;
}
.theme-btn:hover { transform: scale(1.15); }

.theme-dropdown {
  position: absolute; top: 100%; right: 0;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); min-width: 170px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 300;
  display: none; overflow: hidden;
}
.theme-dropdown.open { display: block; }
.theme-option {
  padding: 0.55rem 0.85rem; font-size: 0.85rem; cursor: pointer;
  color: var(--text-secondary); transition: background 0.1s, color 0.1s;
}
.theme-option:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.theme-option.active { color: var(--accent); font-weight: 600; background: rgba(88,166,255,0.08); }

.search-wrap { position: relative; margin-left: auto; margin-right: 0.5rem; }
.search-input {
  background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.35em 0.7em; font-size: 0.85rem; width: 200px;
  transition: border-color 0.15s, width 0.2s;
}
.search-input:focus { outline: none; border-color: var(--accent); width: 280px; }
.search-input::placeholder { color: var(--text-muted); }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); max-height: 360px; overflow-y: auto;
  z-index: 200; display: none; box-shadow: var(--shadow);
}
.search-results.active { display: block; }
.search-result-item {
  display: block; padding: 0.5rem 0.75rem; color: var(--text-primary);
  border-bottom: 1px solid var(--border); font-size: 0.85rem; cursor: pointer;
}
.search-result-item:hover { background: var(--bg-tertiary); text-decoration: none; color: var(--text-primary); }
.search-result-note { font-size: 0.7rem; color: var(--text-muted); }
.search-result-empty { padding: 0.75rem; color: var(--text-muted); font-size: 0.85rem; text-align: center; }
.search-highlight { background: rgba(88,166,255,0.25); border-radius: 2px; padding: 0 2px; }

.footnotes { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.footnotes h3 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.75rem; }
.footnote-item { font-size: 0.85rem; margin-bottom: 0.4rem; }
