:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e7ecf3;
  --muted: #94a3b8;
  --border: #334155;
  --accent: #60a5fa;
  --index-callout: #1e3a5f;
  --font-mono: "Consolas", "Cascadia Code", "Fira Code", monospace;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

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

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

a:hover {
  text-decoration: underline;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-title {
  margin: 0;
  padding: 0.75rem 1.25rem 0.25rem;
  font-size: 1.35rem;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.site-subtitle {
  margin: 0;
  padding: 0 1.25rem 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Section intro (below tabs, above search) */
.section-intro {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
}

.section-intro p {
  margin: 0;
  max-width: 72rem;
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.55;
}

.page-intro {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.55;
}

.entry-learn {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.6;
}

.entry-learn strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-heading {
  margin: 1rem 0 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.supplement-examples {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: 8px;
  border: 1px dashed var(--border);
}

.supplement-examples h4 {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.supplement-block {
  margin-bottom: 1rem;
}

.supplement-block:last-child {
  margin-bottom: 0;
}

.example-label {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  color: #94a3b8;
  font-weight: 600;
}

.code-wrap.supplement,
.code-wrap.primary-example {
  margin-top: 0;
}

.status-ref-wrap {
  margin: 1rem 0;
}

.status-ref-wrap h4 {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.status-ref-table th,
.status-ref-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.status-ref-table th {
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-ref-table tr:last-child td {
  border-bottom: none;
}

.status-ref-table code {
  font-family: var(--font-mono);
  color: #7dd3fc;
}

.external-resources {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.external-resources h4 {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.external-resources ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.external-resources .ext-item {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.external-resources .ext-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.external-resources .ext-item p {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.guide-nav .sidebar-nav a.active {
  font-weight: 600;
}

.ext-guide-section {
  margin-bottom: 2rem;
}

.ext-guide-section h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--accent);
}

.flow-diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-size: 0.88rem;
  line-height: 1.7;
  color: #cbd5e1;
}

/* Tabs */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 0.5rem 0;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-block;
}

a.tab-btn:hover {
  text-decoration: none;
  color: var(--text);
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--tab-color, var(--accent));
}

.tab-btn[data-tab="index"].active {
  border-bottom-color: var(--accent);
}

/* Search */
.search-wrap {
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-input {
  width: 100%;
  max-width: 480px;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.search-results {
  margin-top: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
}

.search-hit {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  font-size: 0.88rem;
  color: var(--text);
}

.search-hit:hover {
  background: var(--surface2);
  text-decoration: none;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 140px);
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 200px;
  }
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  overflow-y: auto;
  position: sticky;
  top: 7.5rem;
  align-self: start;
  max-height: calc(100vh - 8rem);
}

.sidebar h3 {
  margin: 0 0 0.5rem;
  padding: 0 1rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav a {
  display: block;
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  color: var(--text);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--surface2);
  text-decoration: none;
  border-left-color: var(--theme-color, var(--accent));
}

.main {
  padding: 1.25rem 1.5rem 3rem;
  overflow-x: hidden;
}

/* Index callout */
.index-callout {
  background: linear-gradient(135deg, var(--index-callout), #0f2744);
  border: 1px solid #2563eb55;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.index-callout h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.index-callout p {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.92rem;
}

/* Theme sections */
.theme-section {
  margin-bottom: 2rem;
}

.theme-section h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--theme-color);
}

.theme-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--theme-color);
}

/* Function type grid */
.ft-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.ft-card {
  display: block;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-left: 4px solid var(--theme-color);
  color: var(--text);
  font-size: 0.88rem;
}

.ft-card:hover {
  background: var(--surface2);
  text-decoration: none;
}

.ft-card .count {
  color: var(--muted);
  font-size: 0.78rem;
}

/* Session timeline */
.session-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.session-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.session-order {
  flex: 0 0 2rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Entry cards */
.entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.entry-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.entry-header h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.entry-meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--theme-color);
  color: #fff;
}

.entry-desc {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: #cbd5e1;
}

.code-wrap {
  position: relative;
}

.code-wrap pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.45;
  background: #0d1117;
  color: #e6edf3;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--surface);
}

.copy-btn.copied {
  border-color: #10b981;
  color: #10b981;
}

/* Site map */
.sitemap {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.sitemap h2 {
  font-size: 1.1rem;
  margin: 0 0 1rem;
}

.sitemap-tree {
  font-size: 0.88rem;
  line-height: 1.7;
}

.sitemap-tree ul {
  list-style: none;
  padding-left: 1.25rem;
  margin: 0.2rem 0;
}

.sitemap-tree > ul {
  padding-left: 0;
}

.sitemap-tree li::before {
  content: "▸ ";
  color: var(--muted);
}

/* Empty state */
.empty {
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

.duplicate-note {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0 1rem 0.75rem;
}

.hidden {
  display: none !important;
}
