:root {
  --bg-base: #090d16;
  --bg-surface: #0f1624;
  --bg-elevated: #162033;
  --bg-inset: #070a12;
  --bg-highlight: rgba(56, 189, 248, 0.07);
  --bg-purple-tint: rgba(168, 85, 247, 0.07);
  --bg-emerald-tint: rgba(16, 185, 129, 0.07);
  --bg-amber-tint: rgba(245, 158, 11, 0.07);

  --text-main: #e5e7eb;
  --text-sub: #9ca3af;
  --text-muted: #64748b;
  --text-heading: #f9fafb;

  --cyan: #38bdf8;
  --cyan-dim: #0284c7;
  --purple: #c084fc;
  --emerald: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;

  --border: #1e293b;
  --border-strong: #334155;

  --sidebar-width: 290px;
  --header-height: 60px;
}

[data-theme="light"] {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-inset: #e2e8f0;
  --bg-highlight: rgba(2, 132, 199, 0.06);
  --bg-purple-tint: rgba(126, 34, 206, 0.06);
  --bg-emerald-tint: rgba(5, 150, 105, 0.06);
  --bg-amber-tint: rgba(217, 119, 6, 0.06);

  --text-main: #1e293b;
  --text-sub: #475569;
  --text-muted: #64748b;
  --text-heading: #0f172a;

  --cyan: #0284c7;
  --cyan-dim: #0369a1;
  --purple: #7e22ce;
  --emerald: #059669;
  --amber: #d97706;
  --rose: #e11d48;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-main);
  line-height: 1.78;
  font-size: 15.5px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Top Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-toggle {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-heading);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.logo-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--cyan);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.doc-type-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: none;
}

@media (min-width: 768px) {
  .doc-type-label {
    display: inline-block;
  }
}

.theme-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 0.38rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  transition: border-color 0.15s;
}

.theme-btn:hover {
  border-color: var(--cyan);
}

/* App Shell */
.doc-layout {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* Left Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 1.5rem 1rem 3rem;
  z-index: 150;
}

.sidebar-section {
  margin-bottom: 1.75rem;
}

.sidebar-heading {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  padding: 0 0.6rem;
  font-weight: 700;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-sub);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.4;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.nav-link:hover {
  background-color: var(--bg-elevated);
  color: var(--text-heading);
}

.nav-link.active {
  background-color: var(--bg-highlight);
  color: var(--cyan);
  border-color: rgba(56, 189, 248, 0.25);
  font-weight: 700;
}

.nav-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.05rem;
  flex-shrink: 0;
}

.nav-link.active .nav-num {
  color: var(--cyan);
}

.page-toc-list {
  list-style: none;
  padding-left: 0.6rem;
  border-left: 1px solid var(--border);
  margin-left: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.page-toc-link {
  display: block;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s;
}

.page-toc-link:hover {
  color: var(--cyan);
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  max-width: 1020px;
  padding: 2.5rem 3rem 5rem;
}

@media (max-width: 960px) {
  .menu-toggle {
    display: inline-block;
  }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    padding: 2rem 1.25rem 4rem;
  }
}

/* Document Header & Breadcrumbs */
.breadcrumbs {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.breadcrumbs span.current {
  color: var(--cyan);
  font-weight: 600;
}

.doc-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.75rem;
  margin-bottom: 2.25rem;
}

.doc-title {
  font-size: clamp(1.65rem, 3.2vw, 2.25rem);
  font-weight: 800;
  color: var(--text-heading);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 0.85rem;
}

.doc-lead {
  font-size: 1.02rem;
  color: var(--text-sub);
  line-height: 1.75;
}

/* Section Headings */
section.doc-section {
  margin-bottom: 3.5rem;
}

h2.sec-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-heading);
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--border);
  margin: 2.75rem 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.sec-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--cyan);
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
}

h3.sub-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 2rem 0 0.8rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--cyan);
}

h4.minor-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cyan);
  margin: 1.25rem 0 0.45rem;
}

p {
  margin-bottom: 1.15rem;
}

ul, ol {
  margin: 0.75rem 0 1.25rem 1.5rem;
}

li {
  margin-bottom: 0.45rem;
}

strong {
  color: var(--text-heading);
  font-weight: 700;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.86em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  color: var(--cyan);
}

/* Inline Term Highlight */
.term-ref {
  border-bottom: 1px dashed var(--cyan);
  color: var(--cyan);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.term-ref:hover {
  background: var(--bg-highlight);
}

/* Specification & Comparison Tables */
.table-container {
  overflow-x: auto;
  margin: 1.5rem 0 2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
}

table.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.6;
}

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

table.spec-table th {
  background: var(--bg-elevated);
  color: var(--text-heading);
  font-weight: 700;
  white-space: nowrap;
}

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

table.spec-table td.col-key {
  font-weight: 700;
  color: var(--cyan);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.01);
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.15rem;
  margin: 1.5rem 0;
}

/* Info / Technical Boxes */
.tech-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.35rem;
}

.tech-card.highlight-cyan {
  border-top: 3px solid var(--cyan);
}

.tech-card.highlight-purple {
  border-top: 3px solid var(--purple);
}

.tech-card.highlight-emerald {
  border-top: 3px solid var(--emerald);
}

.tech-card.highlight-amber {
  border-top: 3px solid var(--amber);
}

.card-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
  display: inline-block;
  color: var(--cyan);
}

.tech-card h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 0.6rem;
}

.tech-card p {
  font-size: 0.9rem;
  color: var(--text-sub);
  margin-bottom: 0.5rem;
}

.tech-card p:last-child {
  margin-bottom: 0;
}

/* Notice / Alert Panels */
.panel {
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.panel-info {
  background: var(--bg-highlight);
  border-left: 4px solid var(--cyan);
}

.panel-purple {
  background: var(--bg-purple-tint);
  border-left: 4px solid var(--purple);
}

.panel-emerald {
  background: var(--bg-emerald-tint);
  border-left: 4px solid var(--emerald);
}

.panel-amber {
  background: var(--bg-amber-tint);
  border-left: 4px solid var(--amber);
}

.panel-title {
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.96rem;
}

/* Schematic & Diagram Container */
.schematic-box {
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 1.5rem;
  margin: 1.75rem 0;
  overflow-x: auto;
}

.schematic-caption {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.85rem;
  text-align: center;
}

.svg-diagram {
  width: 100%;
  height: auto;
  min-width: 640px;
  display: block;
  margin: 0 auto;
}

/* Step-by-step Hardware Pipeline */
.pipeline-steps {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 1.5rem 0;
}

.pipeline-step {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1.15rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.15rem 1.35rem;
  align-items: start;
}

@media (max-width: 640px) {
  .pipeline-step {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

.step-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--cyan);
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  text-align: center;
}

/* Deep-Dive Glossary Section on Every Page */
.glossary-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 2rem;
  margin-top: 3.5rem;
}

.glossary-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.glossary-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-heading);
  margin-bottom: 0.35rem;
}

.glossary-header p {
  font-size: 0.9rem;
  color: var(--text-sub);
  margin-bottom: 0;
}

.glossary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.15rem;
}

.term-card {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-left: 4px solid var(--cyan);
  border-radius: 8px;
  padding: 1.25rem 1.4rem;
}

.term-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 0.5rem;
}

.term-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-heading);
}

.term-en {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--cyan);
}

.term-summary {
  font-weight: 700;
  color: var(--emerald);
  font-size: 0.92rem;
  margin-bottom: 0.55rem;
}

.term-detail {
  font-size: 0.9rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.term-analogy {
  font-size: 0.86rem;
  color: var(--text-sub);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0.65rem 0.9rem;
  border-radius: 6px;
  margin-top: 0.6rem;
}

/* Page Footer Navigation (Prev / Next) */
.page-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.page-nav-link {
  display: flex;
  flex-direction: column;
  padding: 1.1rem 1.35rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-surface);
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}

.page-nav-link:hover {
  border-color: var(--cyan);
  background: var(--bg-elevated);
}

.page-nav-link.next {
  text-align: right;
}

.page-nav-dir {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.page-nav-title {
  font-weight: 700;
  color: var(--cyan);
  font-size: 0.95rem;
}

/* Site Footer */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Filter Search Input on Glossary Page */
.search-bar-wrap {
  margin-bottom: 1.5rem;
}

.search-input {
  width: 100%;
  padding: 0.85rem 1.1rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-heading);
}

.search-input:focus {
  outline: none;
  border-color: var(--cyan);
}
