:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #111c2d;
  --panel-strong: #16263b;
  --line: rgba(148, 163, 184, 0.2);
  --text: #e5edf7;
  --muted: #a9b8ca;
  --accent: #67e8f9;
  --accent-strong: #38bdf8;
  --warm: #fbbf24;
  --max: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(56, 189, 248, 0.15), transparent 34rem),
    radial-gradient(circle at 90% 12%, rgba(139, 92, 246, 0.14), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.75;
}

a { color: var(--accent); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.9);
  backdrop-filter: blur(16px);
}

.header-inner,
.page-shell {
  width: min(calc(100% - 32px), var(--max));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
}

.brand {
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.header-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.9rem;
}

.hero {
  padding: 78px 0 54px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1,
h2,
h3 {
  color: #f8fbff;
  line-height: 1.3;
}

h1 {
  max-width: 900px;
  margin: 0 0 20px;
  font-size: clamp(2rem, 5vw, 4.1rem);
  letter-spacing: -0.04em;
}

.hero-lead {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.hero-badges,
.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 25px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid rgba(103, 232, 249, 0.3);
  border-radius: 999px;
  background: rgba(103, 232, 249, 0.1);
  color: #c8f7ff;
  font-size: 0.84rem;
  font-weight: 700;
}

.notice {
  margin: 28px 0 0;
  padding: 15px 18px;
  border-left: 4px solid var(--warm);
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.09);
  color: #fce7a2;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 22px;
}

.section-heading h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.2rem); }
.section-heading p { margin: 0; color: var(--muted); }

.progress-panel,
.study-panel,
.lesson-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(17, 28, 45, 0.85);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}

.progress-panel {
  margin: 0 0 58px;
  padding: 20px 22px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #23344b;
}

.progress-value {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), #a78bfa);
  transition: width 0.25s ease;
}

.mock-exam-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin: 0 0 58px;
  padding: 24px 26px;
  border: 1px solid rgba(103, 232, 249, 0.34);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(14, 116, 144, 0.24), rgba(76, 29, 149, 0.22)),
    rgba(17, 28, 45, 0.92);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}

.mock-exam-copy { min-width: 0; }
.mock-exam-eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 0.78rem; font-weight: 900; letter-spacing: 0.12em; }
.mock-exam-copy h2 { margin: 0 0 8px; font-size: clamp(1.35rem, 3vw, 2rem); }
.mock-exam-copy p:last-child { max-width: 720px; margin: 0; color: var(--muted); }

.mock-exam-entry-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid rgba(103, 232, 249, 0.55);
  border-radius: 12px;
  background: rgba(8, 47, 73, 0.72);
  color: #e0fbff;
  font-weight: 900;
  text-decoration: none;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.mock-exam-entry-button:hover,
.mock-exam-entry-button:focus-visible {
  border-color: var(--accent);
  background: rgba(14, 116, 144, 0.72);
  transform: translateY(-2px);
}

.stage-section { margin: 0 0 42px; }

.stage-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.stage-header h3 { margin: 0; font-size: 1.35rem; }
.stage-header span { color: var(--muted); font-size: 0.9rem; }

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 12px;
}

.deep-dive-section { margin: 62px 0 70px; }
.deep-dive-eyebrow { margin-bottom: 6px; }
.deep-dive-heading { flex-wrap: wrap; align-items: flex-start; }
.deep-dive-heading > div { min-width: 0; }
.deep-dive-heading p { max-width: 760px; margin-top: 8px; line-height: 1.65; }
.deep-dive-heading .badge { flex: 0 0 auto; }

.deep-dive-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.deep-dive-resource-link {
  width: fit-content;
  padding: 2px 2px 4px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.deep-dive-resource-link:hover,
.deep-dive-resource-link:focus-visible {
  color: #c8f7ff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lesson-card-wrap {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.lesson-card {
  position: relative;
  display: block;
  min-height: 112px;
  padding: 16px 18px 16px 58px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(22, 38, 59, 0.72);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.lesson-card:hover,
.lesson-card:focus-visible {
  border-color: rgba(103, 232, 249, 0.75);
  background: rgba(30, 52, 78, 0.9);
  transform: translateY(-2px);
}

.lesson-card.is-complete { border-color: rgba(74, 222, 128, 0.5); }

.lesson-number {
  position: absolute;
  top: 16px;
  left: 18px;
  color: var(--accent);
  font-size: 0.83rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.lesson-card-title { display: block; font-weight: 800; line-height: 1.45; }
.lesson-card-state { display: block; margin-top: 6px; color: var(--muted); font-size: 0.78rem; }
.lesson-card-types { display: block; margin-top: 8px; color: var(--muted); font-size: 0.72rem; line-height: 1.4; }

.study-panel {
  margin: 70px 0 80px;
  padding: 24px;
}

@media (max-width: 620px) {
  .deep-dive-section { margin: 48px 0 56px; }
  .deep-dive-heading { gap: 10px; }
}

.study-panel h2 { margin-top: 0; }
.study-panel ol { margin-bottom: 0; padding-left: 1.5rem; }

.site-footer {
  padding: 35px 0 55px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

/* Lesson reader */
.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 28px;
  align-items: start;
  padding: 44px 0 70px;
}

.lesson-panel { min-width: 0; padding: clamp(22px, 5vw, 56px); }
.lesson-header { padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.lesson-header h1 { margin-bottom: 0; font-size: clamp(1.9rem, 4vw, 3.2rem); }
.lesson-source { color: var(--muted); font-size: 0.82rem; }

.lesson-content { padding-top: 28px; }
.lesson-content h1 { margin-top: 0; font-size: clamp(1.7rem, 3vw, 2.4rem); }
.lesson-content h2 { margin: 2.4em 0 0.7em; font-size: clamp(1.35rem, 2.5vw, 1.85rem); }
.lesson-content h3 { margin: 1.8em 0 0.55em; font-size: 1.2rem; }
.lesson-content p { margin: 0.8em 0; color: #dbe6f2; }
.lesson-content strong { color: #fff; }
.lesson-content blockquote { margin: 1.3em 0; padding: 0.6em 1.15em; border-left: 4px solid var(--accent); background: rgba(103, 232, 249, 0.08); color: #d7f8ff; }
.lesson-content ul,
.lesson-content ol { padding-left: 1.6rem; }
.lesson-content li + li { margin-top: 0.35em; }
.lesson-content code { padding: 0.15em 0.4em; border-radius: 5px; background: #1e293b; color: #c4f1ff; font-size: 0.9em; }
.lesson-content pre { overflow: auto; margin: 1.2em 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #07101c; }
.lesson-content pre code { padding: 0; background: transparent; color: #d5e8f8; white-space: pre; }
.lesson-content .formula-block {
  overflow-x: auto;
  margin: 1.25em 0;
  padding: 14px 16px;
  border: 1px solid rgba(103, 232, 249, 0.28);
  border-radius: 10px;
  background: #0c1b2b;
  color: #f4fbff;
  text-align: center;
}
.lesson-content math.lesson-formula {
  display: inline-block;
  max-width: 100%;
  color: #f4fbff;
  font-size: 1.08em;
  text-align: left;
}
.lesson-content math.lesson-formula[display="block"] { display: block; margin: 0 auto; }
.lesson-content .formula-block + p { margin-top: 1em; }
.lesson-content hr { margin: 2.2em 0; border: 0; border-top: 1px solid var(--line); }
.table-scroll { overflow-x: auto; margin: 1.3em 0; }
.lesson-content table { width: 100%; min-width: 620px; border-collapse: collapse; }
.lesson-content th,
.lesson-content td { padding: 10px 12px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.lesson-content th { background: rgba(56, 189, 248, 0.13); color: #d8f7ff; }

.lesson-sidebar {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(17, 28, 45, 0.82);
}

.sidebar-label { margin: 0 0 10px; color: var(--accent); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; }
.toc-list { margin: 0; padding: 0; list-style: none; }
.toc-list li + li { margin-top: 4px; }
.toc-list a { display: block; padding: 5px 8px; border-radius: 7px; color: var(--muted); font-size: 0.84rem; line-height: 1.45; text-decoration: none; }
.toc-list a:hover,
.toc-list a:focus-visible { background: rgba(103, 232, 249, 0.1); color: var(--text); }
.toc-list .toc-h3 { padding-left: 18px; font-size: 0.78rem; }

.lesson-end {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 42px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.lesson-end-link {
  display: block;
  min-height: 78px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(22, 38, 59, 0.68);
  color: var(--text);
  text-decoration: none;
}

.lesson-end-link:hover,
.lesson-end-link:focus-visible { border-color: var(--accent); }
.lesson-end-link.next { text-align: right; }
.lesson-end-label { display: block; margin-bottom: 4px; color: var(--accent); font-size: 0.75rem; font-weight: 800; }
.lesson-end-title { display: block; font-weight: 800; line-height: 1.45; }
.lesson-end-link.disabled { opacity: 0.45; pointer-events: none; }

.completion-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  padding: 13px 15px;
  border-radius: 10px;
  background: rgba(74, 222, 128, 0.08);
  color: var(--muted);
  font-size: 0.9rem;
}

.completion-control button {
  padding: 7px 12px;
  border: 1px solid rgba(74, 222, 128, 0.5);
  border-radius: 8px;
  background: transparent;
  color: #bbf7d0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.error-box { padding: 28px; border: 1px solid #f87171; border-radius: 12px; background: rgba(127, 29, 29, 0.24); color: #fecaca; }

@media (max-width: 800px) {
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-sidebar { position: static; max-height: none; order: -1; }
  .toc-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px; }
}

@media (max-width: 560px) {
  .header-inner { align-items: flex-start; flex-direction: column; padding: 12px 0; }
  .hero { padding-top: 48px; }
  .lesson-end { grid-template-columns: 1fr; }
  .lesson-end-link.next { text-align: left; }
  .completion-control { align-items: flex-start; flex-direction: column; }
  .mock-exam-entry { align-items: stretch; flex-direction: column; gap: 18px; }
  .mock-exam-entry-button { justify-content: center; }
}
