/* 德語自學講義 — 共用樣式
   原則：德文一律用襯線字 Literata，中文說明用無襯線字。
   藍色 = 句框兩端（助動詞與 Partizip II），黃色 = 螢光筆標示。 */

:root {
  --paper: #f5f7f8;
  --surface: #ffffff;
  --ink: #1e2a33;
  --ink-soft: #52616b;
  --rule: #d5dde2;
  --klammer: #2547d0;
  --klammer-tint: #e6ebfb;
  --marker: #ffe27a;
  --right: #1f7a4d;
  --right-tint: #e3f3ea;
  --wrong: #b3261e;
  --wrong-tint: #fbe7e5;

  /* Partizip II 分段顏色 */
  --pz-ge: #b81f6f;
  --pz-end: #0a7a6c;
  --pz-pre: #9a5800;
  --pz-untr: #6b7780;

  --font-de: "Literata", Georgia, serif;
  --font-zh: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;

  --measure: 42rem;
  --radius-s: 4px;
  --radius-m: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12191e;
    --surface: #1a232a;
    --ink: #e4eaee;
    --ink-soft: #9fb0ba;
    --rule: #2e3b44;
    --klammer: #8ea6ff;
    --klammer-tint: #1f2a4d;
    --marker: #6b5a12;
    --right: #6fd19c;
    --right-tint: #163326;
    --wrong: #ff8a80;
    --wrong-tint: #3a1d1b;
    --pz-ge: #ff7ab8;
    --pz-end: #4fd1bf;
    --pz-pre: #e8a84e;
    --pz-untr: #9aa8b1;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-zh);
  font-size: 1.0625rem;
  line-height: 1.75;
}

a { color: var(--klammer); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--klammer);
  outline-offset: 2px;
}

/* 德文片段 */
.de, [lang="de"] { font-family: var(--font-de); line-height: 1.8; }

/* ---------- 頁首 ---------- */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.site-header .inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-name {
  font-family: var(--font-de);
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--ink);
  text-decoration: none;
}
.site-name small { font-family: var(--font-zh); font-weight: 400; color: var(--ink-soft); margin-left: 0.4em; font-size: 0.85rem; }
.crumbs { font-size: 0.9rem; color: var(--ink-soft); }
.crumbs a { color: var(--ink-soft); }

/* ---------- 版面 ---------- */
.layout {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem 5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
@media (min-width: 960px) {
  .layout { grid-template-columns: 13rem minmax(0, var(--measure)); justify-content: center; gap: 3.5rem; }
}

.toc { font-size: 0.92rem; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.75rem;
  border-left: 2px solid var(--rule);
  color: var(--ink-soft);
  text-decoration: none;
}
.toc a::before { content: counter(toc) ". "; }
.toc a:hover { color: var(--ink); border-left-color: var(--ink-soft); }
.toc a.active { color: var(--klammer); border-left-color: var(--klammer); }
.toc details summary { cursor: pointer; font-weight: 600; padding: 0.5rem 0; }
@media (min-width: 960px) {
  .toc { position: sticky; top: 1.5rem; align-self: start; padding-top: 3rem; }
  .toc details summary { display: none; }
}
@media (max-width: 959px) {
  .toc { border-bottom: 1px solid var(--rule); padding-bottom: 0.5rem; }
}

main { min-width: 0; }

/* ---------- 單元開頭 ---------- */
.lesson-head { padding: 2.5rem 0 1rem; }
.lesson-head .level { font-size: 0.9rem; color: var(--ink-soft); margin: 0; }
.lesson-head h1 {
  font-size: clamp(1.75rem, 4vw, 2.4rem);
  line-height: 1.25;
  margin: 0.25rem 0 0.5rem;
  font-weight: 700;
}
.lesson-head h1 .de { font-weight: 600; }
.lesson-head .lede { color: var(--ink-soft); margin: 0; }

/* 句框主視覺 */
.klammer-hero {
  margin: 2rem 0 2.5rem;
  padding: 2rem 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
}
.klammer {
  font-family: var(--font-de);
  font-size: clamp(1.3rem, 6vw, 2.6rem);
  line-height: 1.3;
  margin: 0;
}
.klammer .frame {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
  border: 3px solid var(--klammer);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  padding: 0 0.15em 0.35em;
}
.klammer .aux, .klammer .part { color: var(--klammer); font-weight: 600; }
.klammer-legend {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-top: 0.75rem;
}
.klammer-legend b { color: var(--klammer); font-weight: 600; }
.klammer-hero .note { font-size: 0.95rem; margin: 1rem 0 0; }

/* ---------- 段落 ---------- */
section.part { padding-top: 2.5rem; }
section.part > h2 {
  font-size: 1.5rem;
  line-height: 1.35;
  margin: 0 0 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}
section.part > h2 .num { color: var(--klammer); margin-right: 0.4em; }
h3 { font-size: 1.15rem; margin: 2rem 0 0.5rem; }
p { margin: 0 0 1rem; }

.goals { margin: 1rem 0 0; padding-left: 1.25rem; }
.goals li { margin-bottom: 0.25rem; }

/* 小提醒 */
.tip {
  border-left: 4px solid var(--marker);
  background: var(--surface);
  padding: 0.75rem 1rem;
  margin: 1.25rem 0;
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  font-size: 0.97rem;
}
.tip strong:first-child { display: block; margin-bottom: 0.15rem; }
.tip p:last-child { margin-bottom: 0; }

/* Partizip II 分段：HTML 寫 <span class="pz">auf·ge·stand·en</span>，由 app.js 上色 */
.pz-ge { color: var(--pz-ge); font-weight: 600; }
.pz-stem { color: var(--ink); font-weight: 600; }
.pz-end { color: var(--pz-end); font-weight: 600; }
.pz-pre { color: var(--pz-pre); font-weight: 600; }
.pz-untr { color: var(--pz-untr); font-weight: 600; text-decoration: underline dotted; text-underline-offset: 3px; }
.solution .pz-stem { color: inherit; }
.pz-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; font-family: var(--font-zh); font-size: 0.92rem; color: var(--ink-soft); }
.pz-legend > span > span { font-family: var(--font-de); font-size: 1.05rem; margin-right: 0.2em; }

mark, .mark { background: var(--marker); color: inherit; padding: 0 0.1em; border-radius: 2px; }
.blue { color: var(--klammer); font-weight: 600; }

/* 例句清單 */
.examples { list-style: none; padding: 0; margin: 1rem 0; }
.examples li {
  padding: 0.6rem 0;
  border-bottom: 1px dashed var(--rule);
}
.examples li:last-child { border-bottom: 0; }
.examples .de { font-size: 1.1rem; }
.examples .zh { display: block; color: var(--ink-soft); font-size: 0.95rem; }

/* 表格 */
.table-wrap { overflow-x: auto; margin: 1rem 0 1.5rem; }
table { border-collapse: collapse; width: 100%; font-size: 0.97rem; background: var(--surface); }
th, td { text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 600; background: var(--paper); }
td .de { font-size: 1.02rem; }

/* 發音按鈕 */
.say-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  margin-left: 0.35rem;
  vertical-align: middle;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
}
.say-btn:hover { color: var(--klammer); border-color: var(--klammer); }
.say-btn.speaking { color: var(--surface); background: var(--klammer); border-color: var(--klammer); }
.say-btn svg { width: 1rem; height: 1rem; }

/* ---------- 練習 ---------- */
.exercise {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  padding: 1.25rem;
  margin: 1.5rem 0;
}
.exercise > h3 { margin: 0 0 0.25rem; }
.exercise > .instr { color: var(--ink-soft); font-size: 0.95rem; }
.exercise ol.items { padding-left: 1.5rem; margin: 1rem 0; }
.exercise ol.items > li { margin-bottom: 0.9rem; }

.exercise input[type="text"] {
  font-family: var(--font-de);
  font-size: 1.05rem;
  border: 0;
  border-bottom: 2px solid var(--ink-soft);
  background: transparent;
  color: var(--ink);
  padding: 0.05rem 0.25rem;
  width: 8.5em;
  border-radius: 0;
}
.exercise input.short { width: 5em; }
.exercise input.right { border-bottom-color: var(--right); background: var(--right-tint); }
.exercise input.wrong { border-bottom-color: var(--wrong); background: var(--wrong-tint); }
.hint { color: var(--ink-soft); font-size: 0.9rem; }
.solution { display: none; color: var(--right); font-family: var(--font-de); margin-left: 0.5rem; }
.exercise.revealed .solution { display: inline; }

.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 0.5rem; }
.btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-s);
  border: 1px solid var(--klammer);
  background: var(--klammer);
  color: #fff;
  cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--klammer); }
.btn:hover { filter: brightness(1.08); }
.result { font-size: 0.95rem; font-weight: 600; }
.result.all { color: var(--right); }

/* 二選一 */
.choice-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px dashed var(--rule); }
.choice-item:last-of-type { border-bottom: 0; }
.choice-item .de { flex: 1 1 10rem; font-size: 1.1rem; }
.choice-item button {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.choice-item button.right { background: var(--right-tint); border-color: var(--right); color: var(--right); }
.choice-item button.wrong { background: var(--wrong-tint); border-color: var(--wrong); color: var(--wrong); }
.choice-item .why { flex-basis: 100%; font-size: 0.9rem; color: var(--ink-soft); display: none; }
.choice-item.done .why { display: block; }

/* 排序 */
.order-item { margin-bottom: 1.25rem; }
.order-line {
  min-height: 2.6rem;
  border-bottom: 2px solid var(--ink-soft);
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  padding: 0.3rem 0;
}
.order-line.right { border-bottom-color: var(--right); }
.order-line.wrong { border-bottom-color: var(--wrong); }
.tiles { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.tile {
  font-family: var(--font-de);
  font-size: 1.02rem;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.order-line .tile { background: var(--klammer-tint); border-color: transparent; }
.order-item .solution { display: none; margin: 0.25rem 0 0; }
.exercise.revealed .order-item .solution { display: block; }

/* 閱讀短文 */
.letter {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  padding: 1.25rem 1.5rem;
  font-family: var(--font-de);
  font-size: 1.08rem;
}
.letter p { margin-bottom: 0.8rem; }
.letter .pf { transition: background-color 0.2s; border-radius: 2px; }
.letter.show-perfekt .pf { background: var(--marker); }
.letter.show-perfekt .pf .aux, .letter.show-perfekt .pf .part { color: var(--klammer); font-weight: 600; }

/* 寫作 */
textarea {
  width: 100%;
  min-height: 11rem;
  font-family: var(--font-de);
  font-size: 1.05rem;
  line-height: 1.7;
  padding: 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  resize: vertical;
}
.checklist { list-style: none; padding: 0; margin: 0.75rem 0; font-size: 0.95rem; }
.checklist label { display: flex; gap: 0.5rem; align-items: baseline; cursor: pointer; }
.model { display: none; margin-top: 1rem; }
.model.open { display: block; }

/* 提交作文 */
.submit-box {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--surface);
}
.submit-box h3 { margin-top: 0; }
.submit-box .fields { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; margin: 0.75rem 0; }
.submit-box label { display: flex; flex-direction: column; font-size: 0.9rem; color: var(--ink-soft); gap: 0.2rem; }
.submit-box input[type="text"] {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  padding: 0.4rem 0.6rem;
  width: 14rem;
  max-width: 100%;
}
.submit-box .btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.submit-status { font-size: 0.95rem; }
.submit-status.ok { color: var(--right); font-weight: 600; }
.submit-status.err { color: var(--wrong); font-weight: 600; }
.feedback { margin-top: 1rem; border-top: 1px solid var(--rule); padding-top: 0.75rem; }
.feedback h4 { margin: 0 0 0.5rem; }
.feedback-body { white-space: pre-wrap; line-height: 1.8; }

.sb-who.err { color: var(--wrong); }
.modes { border: 0; padding: 0; margin: 0.75rem 0; display: grid; gap: 0.5rem; }
.modes legend { font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 0.25rem; }
.modes label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  column-gap: 0.6rem;
  align-items: baseline;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
}
.modes label:has(input:checked) { border-color: var(--klammer); background: var(--klammer-tint); }
.modes label.off { opacity: 0.55; cursor: not-allowed; }
.modes .m-price { font-variant-numeric: tabular-nums; font-weight: 600; }
.modes .m-note { grid-column: 2 / 4; color: var(--ink-soft); font-size: 0.85rem; }
.site-footer .student-link { margin: 0.5rem 0 0; }

/* 學員專區 */
.student { max-width: var(--measure); margin: 0 auto; padding: 2rem 1rem 5rem; }
.student h1 { font-size: clamp(1.8rem, 4vw, 2.3rem); margin: 0 0 1rem; }
.student h2 { margin-top: 2.5rem; }
.st-form { display: grid; gap: 0.9rem; max-width: 22rem; margin-top: 1.25rem; }
.st-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; color: var(--ink-soft); }
.st-form input {
  font: inherit; font-size: 1rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 0.5rem 0.65rem;
}
.st-form .btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.st-hello { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.st-hello p { margin: 0; }
.st-credit { margin: 1.25rem 0; padding: 1.25rem; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--surface); }
.st-balance { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.st-balance .label { color: var(--ink-soft); }
.st-balance strong { font-family: var(--font-de); font-size: 2.2rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.st-lots { margin: 0.5rem 0 0.75rem; padding-left: 1.2rem; font-size: 0.95rem; }
.st-credit .hint { margin: 0.25rem 0; }
.st-rules, .st-password { margin: 1rem 0; }
.st-rules summary, .st-password summary { cursor: pointer; color: var(--klammer); }
.st-rules ul { font-size: 0.95rem; }
.st-password { margin-top: 3rem; }
.st-empty { color: var(--ink-soft); }
.st-essay { border-top: 1px solid var(--rule); padding: 0.25rem 0; }
.st-essay:last-child { border-bottom: 1px solid var(--rule); }
.st-essay summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; align-items: baseline; padding: 0.6rem 0; }
.st-when { color: var(--ink-soft); font-variant-numeric: tabular-nums; min-width: 6.5rem; font-size: 0.9rem; }
.st-lesson { flex: 1 1 14rem; }
.st-meta { display: flex; gap: 0.6rem; font-size: 0.85rem; }
.st-mode { color: var(--ink-soft); }
.st-status { padding: 0 0.45rem; border-radius: var(--radius-s); background: var(--paper); border: 1px solid var(--rule); }
.st-status.done { color: var(--right); background: var(--right-tint); border-color: transparent; }
.st-status.fail { color: var(--wrong); background: var(--wrong-tint); border-color: transparent; }
.st-essay h4 { margin: 1rem 0 0.35rem; font-size: 0.95rem; }
.st-text { font-family: var(--font-de); white-space: pre-wrap; line-height: 1.7; padding: 0.75rem; background: var(--paper); border-radius: var(--radius-s); }
.st-teacher { border-left: 3px solid var(--klammer); padding-left: 0.75rem; }


/* 字彙欄位 */
.vocab td:first-child { white-space: nowrap; }

/* ---------- 首頁 ---------- */
.home { max-width: 52rem; margin: 0 auto; padding: 0 1rem 5rem; }
.home-hero { padding: 3.5rem 0 2rem; }
.home-hero h1 { font-size: clamp(2rem, 5vw, 2.8rem); line-height: 1.2; margin: 0 0 0.75rem; }
.home-hero p { color: var(--ink-soft); max-width: 36rem; }
.level-block { padding-top: 2rem; }
.level-block h2 { font-family: var(--font-de); font-size: 1.6rem; margin: 0 0 0.25rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.level-block > p { color: var(--ink-soft); margin-bottom: 0.75rem; }
.units { list-style: none; padding: 0; margin: 0; }
.units li { display: flex; gap: 1rem; align-items: baseline; padding: 0.55rem 0; border-bottom: 1px dashed var(--rule); }
.units .n { color: var(--ink-soft); min-width: 2.5rem; font-variant-numeric: tabular-nums; }
.units .title { flex: 1; }
.units .topics { display: block; font-size: 0.9rem; color: var(--ink-soft); }
.units .soon { font-size: 0.85rem; color: var(--ink-soft); white-space: nowrap; }
.units a { font-weight: 600; }

.site-footer { border-top: 1px solid var(--rule); color: var(--ink-soft); font-size: 0.85rem; }
.site-footer .inner { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* 字母表 */
.letter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 0.4rem; margin: 1rem 0 1.5rem; }
.letter-grid .lt {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.35rem 0.5rem 0.35rem 0.75rem;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-s);
  font-family: var(--font-de); font-size: 1.15rem; font-weight: 600;
}
.letter-grid .say-btn { margin-left: 0.25rem; }

/* 上一頁／下一頁 */
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.pager a { font-weight: 600; }

/* 對話 */
.dialog {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m);
  padding: 1rem 1.25rem; font-family: var(--font-de); font-size: 1.05rem; margin: 0.75rem 0 1rem;
}
.dialog p { margin: 0 0 0.5rem; padding-left: 6.5em; text-indent: -6.5em; }
.dialog p:last-child { margin-bottom: 0; }
.dialog b { font-weight: 600; color: var(--ink-soft); display: inline-block; min-width: 6.5em; text-indent: 0; }
@media (max-width: 600px) {
  .dialog p { padding-left: 0; text-indent: 0; }
  .dialog b { display: block; min-width: 0; }
}

/* woher / wo / wohin 主視覺 */
.wwh { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem 0.75rem; text-align: center; }
.wwh > div { flex: 1 1 0; min-width: min-content; display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.wwh b { font-family: var(--font-de); font-size: clamp(1.15rem, 4.5vw, 2rem); color: var(--klammer); }
.wwh .say { font-family: var(--font-de); font-size: 1.05rem; }
.wwh small { color: var(--ink-soft); font-family: var(--font-zh); }

/* 首頁主題連結 */
.units .topics { display: flex; flex-wrap: wrap; gap: 0.15rem 1rem; margin-top: 0.15rem; }
.units .topics .soon-topic { color: var(--ink-soft); font-weight: 400; }

/* 名詞性別顏色：der 藍、die 紅、das 綠 */
:root { --g-m: #1d62c4; --g-f: #c0392b; --g-n: #2e7d32; --g-pl: #7a5c00; }
@media (prefers-color-scheme: dark) { :root { --g-m: #7fb0ff; --g-f: #ff8a7a; --g-n: #7fd48a; --g-pl: #e3c26a; } }
.g-m { color: var(--g-m); font-weight: 600; }
.g-f { color: var(--g-f); font-weight: 600; }
.g-n { color: var(--g-n); font-weight: 600; }
.g-pl { color: var(--g-pl); font-weight: 600; }
.wwh b.g-m { color: var(--g-m); }
.wwh b.g-f { color: var(--g-f); }
.wwh b.g-n { color: var(--g-n); }
.show-akk .akk { background: var(--marker); border-radius: 3px; padding: 0 0.15em; }
