/* 墨園 mockup v0 — 前台（學習者）共用樣式
   全部離線可用：不載外部字體／CDN，字體走系統 fallback 鏈。 */

:root {
  /* 色彩：墨、宣紙、朱印、淡墨 */
  --paper: #f5f0e6;
  --paper-deep: #ebe3d3;
  --paper-card: #fbf8f2;
  --ink: #1d1b18;
  --ink-soft: #4a4640;
  --ink-faint: #8a847a;
  --line: #d8cfbd;
  --seal: #a8322a;
  --seal-soft: #f3dcd6;
  --jade: #4f6b5a;
  --jade-soft: #dfe7df;
  --gold: #9a7b3f;

  /* 字體：明體（內文）、楷體（標題/範字） */
  --font-body: "Noto Serif TC", "Noto Serif CJK TC", "Source Han Serif TC",
    "Songti TC", "PMingLiU", "MingLiU", "Noto Serif CJK SC", serif;
  --font-kai: "TW-Kai", "BiauKai", "DFKai-SB", "標楷體", "Kaiti TC", "STKaiti",
    "KaiTi", "AR PL UKai TW", "AR PL UKai CN", var(--font-body);
  --font-ui: system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei",
    "Noto Sans TC", "Noto Sans CJK TC", sans-serif;

  --radius: 6px;
  --shadow: 0 1px 2px rgba(29, 27, 24, .06), 0 6px 20px rgba(29, 27, 24, .06);
  --max: 1280px;
  --gutter: clamp(16px, 4vw, 56px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  /* 宣紙纖維感：純 CSS 漸層，無圖檔 */
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.55), transparent 40%),
    radial-gradient(circle at 85% 70%, rgba(154,123,63,.05), transparent 45%);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.85;
  letter-spacing: .02em;
  overflow-x: hidden;
}
img { max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-kai); font-weight: 400; line-height: 1.35; margin: 0 0 .5em; letter-spacing: .06em; }
h1 { font-size: clamp(2rem, 4.2vw, 3.6rem); }
h2 { font-size: clamp(1.5rem, 2.4vw, 2.1rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--ink-faint); }
.kai { font-family: var(--font-kai); }

/* ---------- mockup 標示列 ---------- */
.mock-banner {
  font-family: var(--font-ui); font-size: 12px; letter-spacing: .04em;
  background: var(--ink); color: #e9e2d2; text-align: center; padding: 4px 12px;
}
.mock-banner b { color: #f0b9ad; font-weight: 600; }

/* ---------- 頂部導覽 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(245, 240, 230, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 28px; min-height: 68px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-seal {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--seal); color: #fff4ef; border-radius: 4px;
  font-family: var(--font-kai); font-size: 15px; line-height: 1.05; text-align: center;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
}
.brand-name { font-family: var(--font-kai); font-size: 1.45rem; letter-spacing: .25em; }
.brand-sub { font-family: var(--font-ui); font-size: 11px; color: var(--ink-faint); letter-spacing: .12em; display: block; line-height: 1; }
.nav-links { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; flex: 1; flex-wrap: wrap; }
.nav-links a {
  display: block; padding: 6px 14px; text-decoration: none; font-size: 15px;
  color: var(--ink-soft); border-radius: var(--radius); letter-spacing: .1em;
}
.nav-links a:hover { background: var(--paper-deep); color: var(--ink); }
.nav-links a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--seal); border-radius: 0; }
.nav-user { display: flex; align-items: center; gap: 10px; font-family: var(--font-ui); font-size: 14px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--jade); color: #fff;
  display: grid; place-items: center; font-family: var(--font-kai); font-size: 15px;
}

/* ---------- 按鈕 / 標籤 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: var(--font-ui); font-size: 15px; letter-spacing: .08em;
  padding: 10px 22px; border-radius: var(--radius); text-decoration: none;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  transition: transform .1s ease, background .15s ease;
}
.btn:hover { background: #000; transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--paper-deep); }
.btn.seal { background: var(--seal); border-color: var(--seal); color: #fff; }
.btn.seal:hover { background: #8e2820; }
.btn.sm { padding: 6px 14px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

.tag {
  display: inline-block; font-family: var(--font-ui); font-size: 12px; letter-spacing: .06em;
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft);
  background: var(--paper-card); white-space: nowrap;
}
.tag.script { border-color: var(--ink-soft); }
.tag.lv1 { background: var(--jade-soft); border-color: transparent; color: var(--jade); }
.tag.lv2 { background: #efe6d2; border-color: transparent; color: var(--gold); }
.tag.lv3 { background: var(--seal-soft); border-color: transparent; color: var(--seal); }
.tag.status-wait { background: #efe6d2; border-color: transparent; color: var(--gold); }
.tag.status-done { background: var(--jade-soft); border-color: transparent; color: var(--jade); }
.tag.status-redo { background: var(--seal-soft); border-color: transparent; color: var(--seal); }

/* 朱印小章 */
.seal-stamp {
  display: inline-grid; place-items: center; width: 54px; height: 54px;
  border: 2px solid var(--seal); color: var(--seal); border-radius: 4px;
  font-family: var(--font-kai); font-size: 15px; line-height: 1.1; text-align: center;
  transform: rotate(-6deg); opacity: .9;
}

/* 待討論註記（給 PM/USER 看的設計註解） */
.note {
  font-family: var(--font-ui); font-size: 13px; line-height: 1.6;
  border-left: 3px solid var(--gold); background: rgba(154,123,63,.08);
  padding: 8px 12px; color: var(--ink-soft); border-radius: 0 var(--radius) var(--radius) 0;
}
.note::before { content: "💬 待討論　"; font-weight: 600; color: var(--gold); }

/* ---------- 版面 ---------- */
main { padding: 40px 0 80px; }
.page-head { margin-bottom: 32px; }
.page-head .crumb { font-family: var(--font-ui); font-size: 13px; color: var(--ink-faint); margin-bottom: 6px; }
.page-head .crumb a { text-decoration: none; }
.page-head .crumb a:hover { text-decoration: underline; }
.card {
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}
.grid { display: grid; gap: 24px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.split { display: grid; gap: 32px; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); align-items: start; }
@media (max-width: 960px) { .split { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
hr.brush { border: 0; height: 10px; margin: 40px 0;
  background: radial-gradient(ellipse at 30% 50%, var(--ink) 0 35%, transparent 60%) center / 100% 3px no-repeat; opacity: .25; }

/* ---------- 字帖 placeholder：米字格 ---------- */
.grid-cell {
  position: relative; aspect-ratio: 1; background: #fffdf8;
  border: 2px solid var(--seal); display: grid; place-items: center; overflow: hidden;
}
.grid-cell::before, .grid-cell::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(50% - .5px), rgba(168,50,42,.35) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), rgba(168,50,42,.35) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px));
}
.grid-cell.mi::after {
  background:
    linear-gradient(45deg, transparent calc(50% - .5px), rgba(168,50,42,.22) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), rgba(168,50,42,.22) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px));
}
.grid-cell .glyph { font-family: var(--font-kai); font-size: clamp(3rem, 9vw, 7rem); line-height: 1; position: relative; z-index: 1; }
.grid-cell .glyph.trace { color: rgba(168,50,42,.22); }
.grid-cell canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; cursor: crosshair; touch-action: none; }
.grid-cell .cap { position: absolute; bottom: 6px; right: 8px; font-family: var(--font-ui); font-size: 11px; color: var(--ink-faint); z-index: 1; }

/* 圖位 placeholder（字帖掃描 / 示範影片） */
.ph {
  display: grid; place-items: center; text-align: center; color: var(--ink-faint);
  background: repeating-linear-gradient(45deg, var(--paper-deep) 0 10px, #e6dcc8 10px 20px);
  border: 1px dashed #c7bba2; border-radius: var(--radius); font-family: var(--font-ui); font-size: 13px;
  min-height: 160px; padding: 16px;
}
.ph .big { font-family: var(--font-kai); font-size: 2.6rem; color: var(--ink-soft); display: block; line-height: 1.2; }

/* ---------- Landing ---------- */
.hero { padding: clamp(56px, 10vw, 140px) 0 clamp(48px, 7vw, 96px); position: relative; overflow: hidden; }

/* hero 水墨淡背景：5 張水墨圖 full-bleed 鋪在 hero 後面、交叉淡入淡出。
   可讀性第一：圖本身壓到很低 opacity，再疊一層由左往右的宣紙色漸層，
   把左側文字區壓亮，墨色只在右側若隱若現。 */
.hero-bg {
  position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  /* 整個水墨背景層（圖 + 宣紙遮罩）往下淡出到透明，溶進下方宣紙底、消除硬分界 */
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 58%, transparent 92%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 58%, transparent 92%);
}
.hero-bg .slide {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 1.5s ease-in-out; will-change: opacity;
}
.hero-bg .slide.is-active { opacity: 1; }
.hero-bg .slide img {
  width: 100%; height: 100%; display: block;
  object-fit: cover; object-position: 78% 50%;  /* 墨色主體偏右、避開左側文字 */
  opacity: .16;                                  /* 水墨若隱若現 */
  filter: saturate(.9) contrast(1.02);
}
/* 宣紙色遮罩：左濃右淡（壓亮文字側）＋ 底部回到宣紙（讓下一區塊自然銜接） */
.hero-bg::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(100deg, var(--paper) 0%, rgba(245,240,230,.9) 30%, rgba(245,240,230,.58) 60%, rgba(245,240,230,.22) 100%),
    linear-gradient(to top, var(--paper) 0%, rgba(245,240,230,0) 34%);
}

.hero-inner { position: relative; z-index: 1; }
.hero-copy { max-width: 40em; }
.hero .eyebrow { font-family: var(--font-ui); font-size: 13px; letter-spacing: .3em; color: var(--seal); }
.hero h1 { margin-top: 12px; }
.hero .lead { font-size: 1.15rem; color: var(--ink-soft); max-width: 34em; }

@media (prefers-reduced-motion: reduce) {
  .hero-bg .slide { transition: none; }
}

.feature { text-align: left; }
.feature .num { font-family: var(--font-kai); font-size: 2.4rem; color: var(--seal); line-height: 1; }
.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 0; counter-reset: step; }
.flow li { list-style: none; padding: 20px 18px; border-left: 1px solid var(--line); position: relative; }
.flow li:first-child { border-left: 0; }
.flow li::before { counter-increment: step; content: counter(step, cjk-ideographic); font-family: var(--font-kai); font-size: 1.6rem; color: var(--seal); display: block; }
.flow a { text-decoration: none; }
.flow a:hover h3 { text-decoration: underline; }

.teacher { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 32px; align-items: center; }
@media (max-width: 640px) { .teacher { grid-template-columns: minmax(0, 1fr); } }
.teacher .portrait { aspect-ratio: 3/4; }

/* ---------- 老師目錄（墨園＝多老師的學院） ---------- */
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.t-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
a.t-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(29,27,24,.12); }
.t-card .portrait { aspect-ratio: 4/3; min-height: 0; border-radius: 0; border-width: 0 0 1px; }
.t-card .t-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.t-card h3 { margin: 0; }
.t-card p { margin: 0; font-size: 15px; }
.t-card .meta { font-family: var(--font-ui); font-size: 13px; color: var(--ink-faint); margin-top: auto; display: flex; justify-content: space-between; }
.t-badge { font-family: var(--font-ui); font-size: 12px; color: var(--seal); letter-spacing: .1em; }
.t-badge.quiet { color: var(--ink-faint); }
.t-join { border-style: dashed; background: transparent; }
/* 課程卡上的授課老師 */
.by { display: flex; align-items: center; gap: 8px; font-family: var(--font-ui); font-size: 13px; color: var(--ink-soft); }
.by .avatar { width: 24px; height: 24px; font-size: 12px; }
.filters .lbl { font-size: 13px; color: var(--ink-faint); align-self: center; margin-right: 2px; }
.filters .break { flex-basis: 100%; height: 0; }

/* ---------- 課程卡 ---------- */
[hidden] { display: none !important; } /* 篩選用 hidden 屬性；避免被 .course 的 display:flex 蓋掉 */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; font-family: var(--font-ui); }
.chip {
  border: 1px solid var(--line); background: var(--paper-card); border-radius: 999px;
  padding: 5px 16px; font-size: 14px; cursor: pointer; font-family: inherit; color: var(--ink-soft);
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.course { display: flex; flex-direction: column; padding: 0; overflow: hidden; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.course:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(29,27,24,.12); }
.course .cover {
  aspect-ratio: 16 / 9; display: grid; place-items: center; position: relative;
  background: linear-gradient(160deg, #fffdf8, var(--paper-deep));
  border-bottom: 1px solid var(--line); font-family: var(--font-kai); font-size: clamp(3rem, 5vw, 4.2rem); letter-spacing: .15em;
}
.course .cover .seal-stamp { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; font-size: 12px; }
.course .body { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.course .meta { font-family: var(--font-ui); font-size: 13px; color: var(--ink-faint); margin-top: auto; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.progress { height: 4px; background: var(--paper-deep); border-radius: 2px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--seal); }

/* ---------- 課程閱讀 ---------- */
.lesson-nav { font-family: var(--font-ui); font-size: 14px; }
.lesson-nav ol { list-style: none; padding: 0; margin: 0; }
.lesson-nav li a { display: flex; gap: 10px; padding: 8px 10px; text-decoration: none; border-radius: var(--radius); color: var(--ink-soft); }
.lesson-nav li a:hover { background: var(--paper-deep); }
.lesson-nav li a.current { background: var(--ink); color: var(--paper); }
.lesson-nav .done::after { content: "✓"; margin-left: auto; color: var(--jade); }
.prose { max-width: 42em; }
.prose h2 { margin-top: 1.6em; }
.strokes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 110px), 1fr)); gap: 14px; }
.stroke { text-align: center; font-family: var(--font-ui); font-size: 13px; }
.stroke .grid-cell { margin-bottom: 6px; }
.stroke .grid-cell .glyph { font-size: 3.2rem; }
.keypoints { list-style: none; padding: 0; margin: 0; counter-reset: kp; }
.keypoints li { padding: 10px 0 10px 46px; position: relative; border-bottom: 1px dashed var(--line); }
.keypoints li::before {
  counter-increment: kp; content: counter(kp); position: absolute; left: 0; top: 10px;
  width: 30px; height: 30px; display: grid; place-items: center; border: 1.5px solid var(--seal);
  color: var(--seal); border-radius: 3px; font-family: var(--font-ui); font-size: 13px;
}
.cta-box { position: sticky; top: 96px; }
.cta-box .btn { width: 100%; justify-content: center; }

/* ---------- 練習 / tabs ---------- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 28px; flex-wrap: wrap; }
.tab {
  background: none; border: 0; padding: 12px 22px; font-family: var(--font-kai); font-size: 1.15rem;
  letter-spacing: .12em; color: var(--ink-faint); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--seal); }
.tab small { font-family: var(--font-ui); font-size: 11px; display: block; letter-spacing: .05em; }
[role="tabpanel"][hidden] { display: none; }
.practice-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 16px; }
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-family: var(--font-ui); font-size: 14px; }
.quiz-glyph { width: min(100%, 260px); margin: 0 auto; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 12px; }
.option {
  padding: 16px; border: 1px solid var(--line); background: var(--paper-card); border-radius: var(--radius);
  font-family: var(--font-kai); font-size: 1.2rem; cursor: pointer; text-align: center; color: var(--ink);
}
.option:hover { border-color: var(--ink); }
.option.right { background: var(--jade-soft); border-color: var(--jade); }
.option.wrong { background: var(--seal-soft); border-color: var(--seal); }
.score { font-family: var(--font-ui); display: flex; gap: 24px; flex-wrap: wrap; }
.score b { font-family: var(--font-kai); font-size: 1.8rem; font-weight: 400; display: block; }

/* ---------- 作業 ---------- */
.dropzone {
  border: 2px dashed #c7bba2; border-radius: var(--radius); padding: 40px 24px; text-align: center;
  background: #fffdf8; cursor: pointer; transition: background .15s ease, border-color .15s ease;
}
.dropzone:hover, .dropzone.over { background: var(--paper-deep); border-color: var(--ink-soft); }
.dropzone .big { font-family: var(--font-kai); font-size: 2.4rem; display: block; }
.hw-list { list-style: none; padding: 0; margin: 0; }
.hw { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 560px) { .hw { grid-template-columns: 64px minmax(0, 1fr); } .hw > :last-child { grid-column: 1 / -1; justify-self: start; } }
.hw .thumb { aspect-ratio: 1; min-height: 0; padding: 0; font-size: 11px; }
.hw .thumb .big { font-size: 2rem; }
.hw h3 { font-size: 1.1rem; margin: 0; }
.hw .sub { font-family: var(--font-ui); font-size: 13px; color: var(--ink-faint); }
.review {
  margin-top: 10px; padding: 12px 16px; background: #fffdf8; border: 1px solid var(--line); border-left: 3px solid var(--seal);
  font-size: 15px; border-radius: 0 var(--radius) var(--radius) 0;
}
.review .who { font-family: var(--font-ui); font-size: 12px; color: var(--seal); letter-spacing: .1em; }
.review mark { background: none; color: var(--seal); text-decoration: underline wavy rgba(168,50,42,.5); text-underline-offset: 4px; }

/* ---------- AI 家教 ---------- */
.tutor { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 24px; align-items: stretch; }
@media (max-width: 900px) { .tutor { grid-template-columns: minmax(0, 1fr); } }
.chat { display: flex; flex-direction: column; min-height: 640px; padding: 0; overflow: hidden; }
.chat-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chat-log { flex: 1; padding: 24px 20px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; max-height: 62vh; }
.msg { max-width: min(78%, 640px); padding: 12px 16px; border-radius: 12px; font-size: 16px; line-height: 1.75; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--paper); border-bottom-right-radius: 3px; }
.msg.ai { align-self: flex-start; background: #fffdf8; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg.ai .who { font-family: var(--font-ui); font-size: 12px; color: var(--jade); letter-spacing: .08em; margin-bottom: 4px; }
.cite {
  display: inline-block; font-family: var(--font-ui); font-size: 12px; margin: 6px 6px 0 0;
  padding: 2px 8px; border-radius: 4px; background: var(--jade-soft); color: var(--jade); text-decoration: none;
}
.cite::before { content: "📖 "; }
.chat-input { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--paper); flex-wrap: wrap; }
.chat-input input {
  flex: 1; min-width: 180px; font: inherit; font-size: 15px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fffdf8; color: var(--ink);
}
.suggest { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 12px; background: var(--paper); }
.suggest button { font-family: var(--font-ui); font-size: 13px; }
.ground { font-family: var(--font-ui); font-size: 14px; }
.ground .src { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fffdf8; margin-bottom: 8px; }
.ground .src b { font-family: var(--font-kai); font-weight: 400; font-size: 1.05rem; display: block; }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--ink-faint); animation: blink 1s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- 我的學習 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 16px; }
.stat b { font-family: var(--font-kai); font-weight: 400; font-size: 2.2rem; display: block; line-height: 1.2; }
.stat span { font-family: var(--font-ui); font-size: 13px; color: var(--ink-faint); }
.streak { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.streak i { aspect-ratio: 1; border-radius: 2px; background: var(--paper-deep); }
.streak i.on { background: var(--ink); } .streak i.half { background: var(--ink-faint); }

/* ---------- 頁尾 ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; font-family: var(--font-ui); font-size: 13px; color: var(--ink-faint); }
.site-footer .wrap { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

@media (max-width: 720px) {
  body { font-size: 16px; }
  .nav { gap: 12px; padding-top: 8px; padding-bottom: 8px; } /* 只動上下：保留 .wrap 的左右 gutter */
  .nav-links a { padding: 4px 10px; font-size: 14px; }
  .brand-name { font-size: 1.2rem; }
}

/* ---------- 角色切換（mockup 假登入；前台、後台共用，放在最上方 mockup 標示列） ---------- */
.mock-banner { display: flex; align-items: center; justify-content: center; gap: 8px 18px; flex-wrap: wrap; }
.role-switch { display: inline-flex; align-items: center; gap: 0; border: 1px solid rgba(233,226,210,.4); border-radius: 999px; overflow: hidden; }
.role-switch > * { padding: 3px 14px; text-decoration: none; color: #e9e2d2; font-size: 12px; line-height: 1.6; }
.role-switch a:hover { background: rgba(255,255,255,.12); }
.role-switch [aria-current] { background: var(--seal); color: #fff; font-weight: 600; }
.role-switch .off { opacity: .4; cursor: not-allowed; }
.role-switch-label { opacity: .75; }

/* =====================================================================
   RWD — 手機（≤480）／平板（≤1024）
   原則：所有規則都包在 max-width media query 裡（或預設 display:none 的新元件），
   桌面 >1024（USER review 用的 1440）外觀完全不變。
   斷點：1024 平板橫 ｜ 900 前台導覽收成漢堡 ｜ 720 手機/平板直 ｜ 480 小手機
   ===================================================================== */

/* 窄螢幕才出現的元件：桌面一律隱藏 */
.nav-toggle, .mock-toggle, .side-toggle, .side-scrim { display: none; }


/* 漢堡鈕（前台 .nav-toggle、後台 .side-toggle 共用外觀） */
.nav-toggle, .side-toggle {
  align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-card);
  font-family: var(--font-ui); font-size: 14px; letter-spacing: .08em; color: var(--ink);
}
.nav-toggle .bars, .side-toggle .bars {
  position: relative; width: 18px; height: 2px; background: currentColor; border-radius: 1px; transition: background .15s ease;
}
.nav-toggle .bars::before, .nav-toggle .bars::after,
.side-toggle .bars::before, .side-toggle .bars::after {
  content: ""; position: absolute; left: 0; width: 18px; height: 2px; background: currentColor; border-radius: 1px;
  transition: transform .15s ease;
}
.nav-toggle .bars::before, .side-toggle .bars::before { top: -6px; }
.nav-toggle .bars::after, .side-toggle .bars::after { top: 6px; }
[aria-expanded="true"] > .bars { background: transparent; }
[aria-expanded="true"] > .bars::before { transform: translateY(6px) rotate(45deg); }
[aria-expanded="true"] > .bars::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 1024px) {
  /* 寬表格：HTML 包了一層 .table-scroll；只在窄螢幕變成可橫向捲動容器（桌面上是無樣式的 div） */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .table-scroll .switch { position: relative; } /* 隱藏的 checkbox 是 absolute，要留在捲動容器內 */
  main { padding: 32px 0 64px; }
  .cta-box { top: 84px; }
}

/* ---------- 前台導覽：≤900 收成漢堡選單 ---------- */
@media (max-width: 900px) {
  .site-header .nav { gap: 12px; min-height: 60px; padding-top: 8px; padding-bottom: 8px; }
  .site-header .nav-toggle { display: inline-flex; margin-left: auto; }
  .site-header .nav-links, .site-header .nav-user { display: none; }
  .site-header .nav.is-open { max-height: calc(100vh - 40px); overflow-y: auto; }
  .nav.is-open .nav-links {
    display: flex; flex-direction: column; flex: 1 1 100%; gap: 2px; padding: 8px 0 4px; border-top: 1px solid var(--line);
  }
  .nav.is-open .nav-links a { padding: 11px 12px; font-size: 16px; border-radius: var(--radius); }
  .nav.is-open .nav-links a[aria-current="page"] { background: var(--paper-deep); box-shadow: inset 3px 0 0 var(--seal); border-radius: 0 var(--radius) var(--radius) 0; }
  .nav.is-open .nav-user { display: flex; flex: 1 1 100%; flex-wrap: wrap; padding: 4px 0 12px; }
  .nav.is-open .nav-user .btn { min-height: 40px; }
  .cta-box { position: static; }
  /* AI 家教：手機上聊天在前、依據教材在後 */
  .tutor > .ground { order: 2; }
}

/* ---------- 手機／平板直：≤720 ---------- */
@media (max-width: 720px) {
  /* 頁頂黑色 mockup 列：收成一行「MOCKUP v0｜視角：xx ▾」，點開才展開說明＋角色切換 */
  .mock-banner { justify-content: space-between; text-align: left; padding: 6px var(--gutter); gap: 6px 10px; }
  .mock-desc { flex: 1 1 0; min-width: 0; }
  .mock-desc-more { display: none; }
  .mock-banner.is-open .mock-desc-more { display: block; line-height: 1.5; opacity: .85; }
  .mock-toggle {
    display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 32px; padding: 2px 12px; cursor: pointer;
    font: inherit; font-size: 12px; color: #e9e2d2; background: transparent;
    border: 1px solid rgba(233,226,210,.4); border-radius: 999px;
  }
  .mock-toggle::after { content: "▾"; font-size: 10px; }
  .mock-toggle[aria-expanded="true"]::after { content: "▴"; }
  .mock-banner .role-switch { display: none; }
  .mock-banner.is-open .role-switch {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); flex: 1 1 100%; border-radius: 8px; margin: 2px 0 4px;
  }
  .mock-banner .role-switch .role-switch-label { display: none; }
  .mock-banner.is-open .role-switch > :not(.role-switch-label) { display: grid; place-items: center; text-align: center; min-height: 40px; padding: 4px 6px; font-size: 13px; }
  .mock-banner.is-open .role-switch > :not(.role-switch-label) + * { border-left: 1px solid rgba(233,226,210,.25); }

  main { padding: 24px 0 56px; }
  .page-head { margin-bottom: 24px; }
  .card { padding: 18px; }
  .grid { gap: 16px; }
  .split { gap: 24px; }
  hr.brush { margin: 28px 0; }

  /* 觸控：點擊區至少 ~40px */
  .btn { min-height: 44px; }
  .btn.sm { min-height: 36px; }
  .chip { min-height: 36px; padding: 6px 16px; }
  .tab { padding: 10px 16px; font-size: 1.05rem; }
  .lesson-nav li a { padding: 10px 10px; }

  .hero .lead { font-size: 1.05rem; }
  .flow li { border-left: 0; border-top: 1px solid var(--line); padding: 16px 4px; }
  .flow li:first-child { border-top: 0; }
  .msg { max-width: 88%; font-size: 15px; }
  .chat { min-height: 0; }
  .chat-log { max-height: 60vh; padding: 18px 14px; }
  .chat-input input { min-width: 0; }
  .hw { gap: 12px; }
  /* 表格在手機保留合理欄寬、改成橫向捲動（不擠成直排字） */
  .table-scroll > table { min-width: 600px; }
  .t-card .portrait { aspect-ratio: 2 / 1; }
  .score { gap: 16px; }
  .site-footer { padding: 24px 0 32px; }
}

/* ---------- 小手機：≤480 ---------- */
@media (max-width: 480px) {
  body { font-size: 15.5px; line-height: 1.8; }
  .brand-sub { display: none; }
  .brand-seal { width: 34px; height: 34px; font-size: 13px; }
  .nav-toggle-txt { display: none; }
  .nav-toggle, .side-toggle { padding: 0 12px; min-width: 44px; justify-content: center; }
  .card { padding: 16px; }
  .course .body { padding: 14px 16px 18px; }
  .t-card .t-body { padding: 14px 16px 18px; }
  .dropzone { padding: 28px 16px; }
  .stroke .grid-cell .glyph { font-size: 2.6rem; }
  .keypoints li { padding-left: 40px; }
  .practice-board { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .chat-input { gap: 8px; padding: 12px; }
}

/* ---------- 觸控裝置：hover 抬升效果改成按下回饋，避免「黏住的 hover」 ---------- */
@media (hover: none) {
  .btn:hover, .course:hover, a.t-card:hover, .t-card:hover, .tpl:hover, .node:hover { transform: none; }
  .course:active, a.t-card:active, .t-card:active { transform: scale(.99); }
  .btn:active { transform: translateY(1px); }
}
