
:root {
  --paper: #f7f4ec;
  --surface: #fffdf7;
  --ink: #172321;
  --muted: #63706c;
  --line: #d9d0bd;
  --teal: #1e6b64;
  --red: #b65235;
  --blue: #334f7d;
  --gold: #9a7118;
  --shadow: 0 18px 54px rgba(23, 35, 33, .12);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --body: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  --serif: "Songti TC", "Noto Serif TC", "PMingLiU", serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(30,107,100,.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(154,113,24,.055) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
  font-family: var(--body);
  line-height: 1.75;
}
a { color: var(--teal); text-decoration-thickness: .08em; text-underline-offset: .18em; }
button, input { font: inherit; }
.reading-bar { position: fixed; inset: 0 auto auto 0; height: 4px; width: 0; background: linear-gradient(90deg, var(--red), var(--gold), var(--teal)); z-index: 10; }
.side-nav {
  position: fixed;
  inset: 0 auto 0 0;
  width: 292px;
  overflow-y: auto;
  padding: 22px 18px 36px;
  border-right: 1px solid var(--line);
  background: rgba(255,253,247,.94);
  backdrop-filter: blur(14px);
}
.brand { display: grid; gap: 2px; color: var(--ink); text-decoration: none; margin-bottom: 20px; }
.brand span { color: var(--muted); font-size: 13px; letter-spacing: .06em; }
.brand strong { font-family: var(--serif); font-size: 28px; line-height: 1.1; }
.side-nav section { padding: 16px 0 10px; border-top: 1px solid var(--line); }
.side-nav h2 { margin: 0 0 8px; font-size: 13px; color: var(--red); letter-spacing: .08em; }
.nav-link, .nav-home {
  display: block;
  padding: 7px 9px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}
.nav-link:hover, .nav-home:hover, .nav-link.active { background: #e9f2ef; color: #0f524b; }
.nav-link.done::after, .chapter-row.done::after, .week-pill.done::after { content: "✓"; color: var(--teal); margin-left: 8px; }
.content-shell {
  margin-left: 292px;
  display: grid;
  grid-template-columns: minmax(0, 860px) 260px;
  gap: 34px;
  padding: 22px clamp(24px, 5vw, 72px) 64px;
}
.topbar { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  width: min(100%, 560px);
  border: 1px solid var(--line);
  background: rgba(255,253,247,.9);
  padding: 8px 12px;
  border-radius: 6px;
}
.search-box.large { width: 100%; max-width: none; padding: 12px 14px; }
.search-box span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.search-box input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--ink); }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--teal); color: var(--teal); }
.lesson {
  background: rgba(255,253,247,.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: clamp(28px, 5vw, 62px);
  border-radius: 8px;
}
.lesson-kicker { color: var(--red); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 10px; }
.lesson h1 {
  font-family: var(--serif);
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.15;
  margin: 0 0 24px;
  color: #102b29;
}
.lesson h2 {
  font-family: var(--serif);
  font-size: clamp(24px, 2.8vw, 34px);
  margin: 44px 0 12px;
  padding-top: 8px;
  border-top: 2px solid #eadfc8;
}
.lesson h3 { font-size: 20px; margin: 28px 0 8px; color: var(--blue); }
.lesson blockquote { margin: 24px 0; padding: 16px 20px; border-left: 5px solid var(--gold); background: #fbf4df; }
.lesson table { width: 100%; border-collapse: collapse; margin: 22px 0; font-size: 15px; }
.lesson th, .lesson td { border: 1px solid var(--line); padding: 10px 12px; vertical-align: top; }
.lesson th { background: #eef3ef; color: #173c3a; text-align: left; }
.lesson code { font-family: var(--mono); background: #eee7d7; padding: 2px 5px; border-radius: 4px; }
.lesson pre { overflow-x: auto; background: #172321; color: #f7f4ec; padding: 18px; border-radius: 8px; }
.lesson-figure {
  margin: 22px 0 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.lesson-figure a { display: block; background: #f9f7f0; }
.lesson-figure img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}
.lesson-figure figcaption {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fffdf7;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}
.lesson-figure figcaption span { color: var(--muted); font-size: 13px; }
.figure-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0 34px;
}
.figure-card {
  position: relative;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fffdf7;
  color: var(--ink);
  text-decoration: none;
}
.figure-card:hover { border-color: var(--teal); box-shadow: 0 10px 28px rgba(23,35,33,.08); }
.figure-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #f9f7f0;
  border-bottom: 1px solid var(--line);
}
.figure-card strong, .figure-card small, .figure-card p { margin: 0 12px; }
.figure-card strong { font-size: 14px; line-height: 1.35; }
.figure-card small { color: var(--muted); line-height: 1.35; }
.figure-card p { color: #34423f; font-size: 13px; line-height: 1.45; margin-bottom: 12px; }
.fig-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255,253,247,.94);
  border: 1px solid var(--line);
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
}
.toc-panel {
  position: sticky;
  top: 22px;
  align-self: start;
  border-left: 3px solid var(--line);
  padding-left: 16px;
  max-height: calc(100vh - 44px);
  overflow-y: auto;
}
.toc-panel h2 { font-size: 14px; color: var(--red); letter-spacing: .08em; margin-top: 0; }
.toc-panel a { display: block; color: var(--muted); text-decoration: none; font-size: 13px; margin: 8px 0; line-height: 1.35; }
.toc-panel .toc-l3 { padding-left: 12px; }
.page-footer {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
  margin-top: 8px;
}
.page-footer .page-step:last-child { justify-self: end; }
.page-step {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--ink);
}
.search-results {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 12px;
}
.search-results a { display: block; padding: 10px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.search-results a:hover { background: #eef3ef; }
.search-results small { color: var(--muted); display: block; }
.home-shell { max-width: 1280px; margin: 0 auto; padding: 34px clamp(18px, 4vw, 54px) 72px; }
.home-intro {
  min-height: 430px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  gap: 36px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.home-intro h1 { font-family: var(--serif); font-size: clamp(44px, 7vw, 82px); line-height: 1.04; margin: 0 0 18px; color: #102b29; }
.lead { font-size: 20px; color: #34423f; max-width: 760px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.primary-action, .secondary-action {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 6px;
  text-decoration: none;
}
.primary-action { background: var(--teal); color: white; }
.secondary-action { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.course-map { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.dashboard { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 28px; padding-top: 34px; }
.dashboard h2 { font-family: var(--serif); font-size: 28px; margin: 26px 0 12px; }
.chapter-list { display: grid; gap: 8px; }
.chapter-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,253,247,.9);
  color: var(--ink);
  text-decoration: none;
}
.chapter-row:hover { border-color: var(--teal); background: #eef3ef; }
.chapter-row span { color: var(--red); font-family: var(--mono); }
.dashboard-side section {
  border-top: 3px solid var(--ink);
  padding: 14px 0 20px;
}
.week-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.week-pill {
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 0;
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
}
.resource-stack { display: grid; gap: 8px; }
.resource-link { border-bottom: 1px solid var(--line); padding: 7px 0; text-decoration: none; color: var(--ink); }
.nav-toggle { display: none; }
@media (max-width: 1040px) {
  .side-nav { transform: translateX(-100%); transition: transform .2s ease; z-index: 9; }
  body.nav-open .side-nav { transform: translateX(0); }
  .nav-toggle { display: block; position: fixed; z-index: 11; top: 12px; left: 12px; width: 42px; height: 42px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); }
  .content-shell { margin-left: 0; grid-template-columns: 1fr; padding-top: 68px; }
  .toc-panel { position: static; max-height: none; }
  .home-intro, .dashboard { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .lesson { padding: 24px 18px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .page-footer { grid-template-columns: 1fr; }
  .home-actions { display: grid; }
  .week-grid { grid-template-columns: repeat(3, 1fr); }
}
@media print {
  body { background: white; }
  .side-nav, .topbar, .toc-panel, .page-footer, .nav-toggle, .reading-bar, .search-results { display: none !important; }
  .content-shell { margin: 0; display: block; padding: 0; }
  .lesson { border: 0; box-shadow: none; padding: 0; }
  a { color: black; text-decoration: none; }
}
