:root {
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-sidebar: #121a24;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --highlight: #f59e0b;
  --highlight-soft: rgba(245, 158, 11, 0.15);
  --success: #10b981;
  --border: #2d3a4d;
  --sidebar-w: 240px;
  --radius: 10px;
  --font: 'Noto Sans TC', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.logo-icon {
  font-size: 1.5rem;
  width: 40px; height: 40px;
  background: var(--accent-soft);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-header strong { display: block; font-size: 0.9rem; }
.sidebar-header small { color: var(--text-muted); font-size: 0.75rem; }

.nav-links { list-style: none; }
.nav-links a {
  display: block;
  padding: 0.55rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
}

/* Content */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  max-width: 960px;
  padding: 2rem 2.5rem 4rem;
}

.section {
  margin-bottom: 4rem;
  scroll-margin-top: 1rem;
}

.section h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.ch-num {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.section h3 {
  font-size: 1.1rem;
  margin: 1.75rem 0 1rem;
  color: var(--text);
}

/* Hero */
.hero {
  padding: 2rem 0 3rem;
}

.hero-badge {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  margin-bottom: 1.25rem;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-card.highlight {
  border-color: var(--highlight);
  background: var(--highlight-soft);
}

.stat-num {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
}

.stat-card.highlight .stat-num { color: var(--highlight); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

.hero-quote {
  background: var(--bg-card);
  border-left: 4px solid var(--accent);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.hero-quote strong { color: var(--text); }

.hero-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.hero-flow span {
  background: var(--bg-card);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.hero-flow .arrow { background: none; border: none; color: var(--text-muted); padding: 0; }
.hero-flow .highlight-text { border-color: var(--highlight); color: var(--highlight); }

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.card.accent { border-color: var(--accent); background: var(--accent-soft); }
.card h3 { font-size: 0.95rem; margin-bottom: 0.5rem; color: var(--accent); }
.card p { font-size: 0.88rem; color: var(--text-muted); }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.data-table th, .data-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table .highlight-row td { background: var(--highlight-soft); }
.data-table .us-col { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.note { font-size: 0.85rem; color: var(--text-muted); font-style: italic; }

/* Region tabs */
.region-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  transition: all 0.2s;
}

.tab:hover, .tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.region-panel { display: none; }
.region-panel.active { display: block; }
.panel-highlight {
  background: var(--highlight-soft);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.market-stats {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.market-stat {
  background: var(--bg-card);
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.market-stat strong { display: block; font-size: 1.25rem; color: var(--accent); font-family: var(--mono); }
.market-stat span { font-size: 0.8rem; color: var(--text-muted); }

/* Team */
.team-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.team-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.team-role { font-weight: 600; color: var(--accent); margin-bottom: 0.35rem; }
.team-card p { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.team-wp { font-size: 0.75rem; color: var(--highlight); }

/* Patent */
.patent-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.pt-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
}

.pt-item.highlight { border-color: var(--highlight); background: var(--highlight-soft); }
.pt-month { display: block; font-family: var(--mono); font-size: 0.75rem; color: var(--accent); margin-bottom: 0.25rem; }

.patent-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.patent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.patent-card strong { color: var(--highlight); display: block; margin-bottom: 0.35rem; }

/* Architecture */
.arch-diagram {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.arch-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.arch-row.sub { margin-top: 0.5rem; }
.arch-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.85rem;
}

.arch-box.input { border-color: var(--success); }
.arch-box.process { border-color: var(--accent); }
.arch-box.output { border-color: var(--highlight); }
.arch-box.module { font-size: 0.75rem; padding: 0.5rem 0.75rem; }
.arch-box small { display: block; color: var(--text-muted); font-size: 0.7rem; margin-top: 0.2rem; }
.arch-arrow { color: var(--text-muted); font-size: 1.1rem; }
.arch-arrow.down { transform: rotate(90deg); }

/* Gantt */
.gantt {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.gantt-header, .gantt-row {
  display: grid;
  grid-template-columns: 100px repeat(12, 1fr);
  gap: 2px;
  align-items: center;
  min-width: 600px;
}

.gantt-header span:not(.gantt-label) {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.gantt-label { font-size: 0.75rem; color: var(--text-muted); }
.gantt-row { margin-bottom: 4px; position: relative; height: 28px; }

.gantt-row .bar {
  position: absolute;
  left: calc(100px + (var(--start) * (100% - 100px) / 12));
  width: calc(var(--len) * (100% - 100px) / 12 - 4px);
  height: 20px;
  background: var(--accent);
  border-radius: 4px;
  opacity: 0.85;
  top: 4px;
}

.gantt-row .bar.blue { background: #3b82f6; }
.gantt-row .bar.orange { background: #f59e0b; }
.gantt-row .bar.green { background: #10b981; }
.gantt-row .bar.purple { background: #8b5cf6; }

/* Milestones */
.milestones {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.ms {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.ms.highlight { border-color: var(--highlight); }
.ms-month { font-family: var(--mono); font-size: 0.75rem; color: var(--accent); }
.ms strong { display: block; margin: 0.35rem 0; font-size: 0.9rem; }
.ms p { font-size: 0.8rem; color: var(--text-muted); }

/* Budget chart */
.budget-chart { margin-bottom: 1.5rem; }

.budget-bar-wrap {
  display: flex;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.budget-bar {
  width: calc(var(--pct) * 1%);
  background: linear-gradient(180deg, var(--accent) 0%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  transition: width 0.5s;
}

.budget-bar:nth-child(2) { background: linear-gradient(180deg, #6366f1, #4f46e5); }
.budget-bar:nth-child(3) { background: linear-gradient(180deg, #10b981, #059669); }
.budget-bar:nth-child(4) { background: linear-gradient(180deg, #f59e0b, #d97706); }
.budget-bar:nth-child(5) { background: linear-gradient(180deg, #ec4899, #db2777); }
.budget-bar:nth-child(6) { background: linear-gradient(180deg, #8b5cf6, #7c3aed); }
.budget-bar:nth-child(7) { background: linear-gradient(180deg, #64748b, #475569); }

.budget-bar span {
  font-size: 0.65rem;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}

/* Deliverables */
.deliverables {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.deliver-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.deliver-card.highlight { border-color: var(--highlight); background: var(--highlight-soft); }
.deliver-icon { font-size: 1.75rem; display: block; margin-bottom: 0.5rem; }
.deliver-card h4 { font-size: 0.9rem; margin-bottom: 0.35rem; }
.deliver-card p { font-size: 0.8rem; color: var(--text-muted); }

/* Phase compare */
.phase-compare {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.phase-box {
  flex: 1;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.phase-box.active { border-color: var(--accent); }
.phase-box.phase2 { opacity: 0.85; border-style: dashed; }
.phase-tag { font-size: 0.75rem; color: var(--accent); margin-bottom: 0.5rem; }
.phase-box h3 { font-family: var(--mono); margin-bottom: 1rem; }
.phase-box ul { list-style: none; font-size: 0.88rem; color: var(--text-muted); }
.phase-box li { padding: 0.35rem 0; padding-left: 1rem; position: relative; }
.phase-box li::before { content: '•'; position: absolute; left: 0; color: var(--accent); }
.phase-arrow { display: flex; align-items: center; color: var(--text-muted); font-size: 0.9rem; }

.gng-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.gng-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.88rem;
}

.gng-item.required { border-color: var(--highlight); background: var(--highlight-soft); }
.gng-check {
  display: inline-block;
  font-size: 0.7rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-right: 0.5rem;
  font-family: var(--mono);
}

/* Decision */
.decision-box {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(59,130,246,0.08) 100%);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 2rem;
}

.decision-box h3 { font-size: 1.3rem; margin-bottom: 1.25rem; text-align: center; }

.decision-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.decision-grid div {
  text-align: center;
  background: var(--bg);
  padding: 1rem;
  border-radius: 8px;
}

.decision-grid strong { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.decision-grid span { font-family: var(--mono); font-size: 0.95rem; color: var(--accent); }

.decision-why ol { padding-left: 1.25rem; font-size: 0.9rem; color: var(--text-muted); }
.decision-why li { margin-bottom: 0.75rem; }
.decision-why strong { color: var(--text); }
.decision-cta { text-align: center; margin-top: 1.25rem; font-size: 0.9rem; color: var(--highlight); }

/* Footer */
.footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-note { font-size: 0.75rem; margin-top: 0.35rem; opacity: 0.7; }

/* Technical sections */
.tech-summary {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 1rem 0 1.5rem;
}
.tech-summary strong { color: var(--text); }

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.type-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.type-card.selected { border-color: var(--highlight); background: var(--highlight-soft); }
.type-tag {
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.type-card.selected .type-tag { color: var(--highlight); background: rgba(245,158,11,0.2); }
.type-card h4 { margin: 0.5rem 0; font-size: 1rem; }
.type-card p { font-size: 0.85rem; color: var(--text-muted); }

.struct-diagram { margin-bottom: 1.5rem; }
.ascii-diagram {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
  color: var(--text-muted);
}

.formula-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.formula-title { font-size: 0.8rem; color: var(--accent); margin-bottom: 0.5rem; font-weight: 600; }
.formula {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--text);
  padding: 0.5rem 0;
}
.formula-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }

.tech-list {
  padding-left: 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.tech-list li { margin-bottom: 0.65rem; }
.tech-list strong { color: var(--text); }

.design-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
}
.df-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  min-width: 90px;
  text-align: center;
}
.df-step.highlight { border-color: var(--highlight); }
.df-step span {
  display: inline-block;
  width: 22px; height: 22px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  font-size: 0.75rem;
  line-height: 22px;
  margin-bottom: 0.35rem;
}
.df-step strong { display: block; font-size: 0.8rem; }
.df-step p { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.2rem; }
.df-arrow { color: var(--text-muted); font-size: 0.9rem; }

/* 三年佈局表 */
.industry-problem {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.industry-problem strong {
  display: block;
  color: var(--highlight);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
.industry-problem p { font-size: 0.9rem; color: var(--text-muted); margin: 0; }

.year-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.ys-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.ys-card span {
  display: inline-block;
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.ys-card.y116 span { color: #3b82f6; }
.ys-card.y117 span { color: #10b981; }
.ys-card.y118 span { color: #f59e0b; }
.ys-card strong { display: block; font-size: 0.85rem; margin-bottom: 0.25rem; }
.ys-card p { font-size: 0.75rem; color: var(--text-muted); }

.plan-matrix { overflow-x: auto; margin-bottom: 1rem; }
.plan-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.plan-table th, .plan-table td {
  border: 1px solid var(--border);
  padding: 0.85rem;
  vertical-align: top;
  text-align: left;
}
.plan-table thead th {
  background: var(--bg-card);
  font-weight: 600;
  text-align: center;
}
.plan-row-h {
  background: var(--bg-sidebar);
  width: 100px;
  min-width: 100px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.plan-y116 { background: rgba(59,130,246,0.08); }
.plan-y117 { background: rgba(16,185,129,0.08); }
.plan-y118 { background: rgba(245,158,11,0.08); }
.plan-table td strong { color: var(--text); display: block; margin-bottom: 0.4rem; }
.plan-table ul, .plan-table ol {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-muted);
}
.plan-table li { margin-bottom: 0.3rem; }
.spec-ranked li { margin-bottom: 0.4rem; }
.diagram-placeholder {
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
}
.diagram-placeholder p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .content { margin-left: 0; padding: 4rem 1.25rem 3rem; }
  .hero-stats, .card-grid, .team-grid, .milestones, .deliverables, .decision-grid, .gng-grid, .patent-cards {
    grid-template-columns: 1fr;
  }
  .hero h1 { font-size: 1.65rem; }
  .type-grid { grid-template-columns: 1fr; }
  .design-flow { flex-direction: column; align-items: stretch; }
  .df-arrow { text-align: center; transform: rotate(90deg); }
  .phase-compare { flex-direction: column; }
  .phase-arrow { justify-content: center; transform: rotate(90deg); }
}
