/* ============ 面試練習室 — 設計系統 ============ */
/* Palette: 讀書房 —— 暖紙白 × 松墨綠 × 琥珀待核 */
:root,
[data-theme='light'] {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --timer-xl: clamp(2.5rem, 1.6rem + 3.5vw, 4rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem; --space-16: 4rem;

  --bg: #f5f3ee;
  --surface: #fbfaf7;
  --surface-2: #fdfcf9;
  --offset: #efede6;
  --border: #dcd8cf;
  --text: #26221b;
  --muted: #6f6a5f;
  --faint: #6d685c;
  --accent: #0d5c50;
  --accent-hover: #09443a;
  --accent-soft: #dfeae5;
  --amber: #96660b;
  --amber-soft: #f4e7c5;
  --danger: #a12c2c;
  --danger-soft: #f3dcdc;

  --radius-sm: 0.375rem; --radius-md: 0.5rem; --radius-lg: 0.75rem; --radius-xl: 1rem; --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(38, 34, 27, 0.06);
  --shadow-md: 0 4px 12px rgba(38, 34, 27, 0.08);
  --shadow-lg: 0 12px 32px rgba(38, 34, 27, 0.14);
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --font-display: 'Boska', Georgia, serif;
  --font-body: 'Satoshi', 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #141614;
    --surface: #191c1a;
    --surface-2: #1d201e;
    --offset: #1f2321;
    --border: #333734;
    --text: #d3d4d0;
    --muted: #8b8d88;
    --faint: #8f918b;
    --accent: #5aa79b;
    --accent-hover: #7cbdb2;
    --accent-soft: #243531;
    --amber: #d9a94e;
    --amber-soft: #3a3222;
    --danger: #d97f7f;
    --danger-soft: #3c2828;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}

/* ============ base ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: none; text-rendering: optimizeLegibility; scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.15; text-wrap: balance; }
p, li, figcaption { text-wrap: pretty; max-width: 72ch; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-sm); }
a, button, [role='button'], input, textarea { transition: color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.is-hidden { display: none !important; }

/* ============ header ============ */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 880px; margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex; flex-wrap: wrap; gap: var(--space-3);
  align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand-mark {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  background: var(--accent); color: var(--surface-2);
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text h1 { font-size: var(--text-lg); font-weight: 700; letter-spacing: 0.02em; }
.brand-text p { font-size: var(--text-xs); color: var(--muted); line-height: 1.4; }
.tabs { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.tab {
  font-size: var(--text-sm); font-weight: 500;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  color: var(--muted);
}
.tab:hover { background: var(--offset); color: var(--text); }
.tab.is-active { background: var(--accent); color: var(--surface-2); font-weight: 700; }

/* ============ layout ============ */
main { max-width: 880px; margin: 0 auto; padding: var(--space-8) var(--space-4) var(--space-16); }
.view { display: block; }
.page-head {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--space-6);
}
.page-title { font-size: var(--text-xl); font-weight: 700; margin-bottom: var(--space-2); }
.page-sub { font-size: var(--text-sm); color: var(--muted); }
.legend { display: flex; gap: var(--space-4); font-size: var(--text-xs); color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: var(--space-1); }
.dot { width: 8px; height: 8px; border-radius: var(--radius-full); display: inline-block; }
.dot-ready { background: var(--accent); }
.dot-fill { background: var(--amber); }
.dot-block { background: var(--danger); }

/* ============ cards & question list ============ */
.q-list { display: grid; gap: var(--space-3); }
.q-card {
  width: 100%; text-align: left;
  display: grid; grid-template-columns: auto 1fr; gap: var(--space-4);
  align-items: start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
}
.q-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.q-card:active { transform: translateY(0); }
.q-num {
  font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600;
  color: var(--accent); line-height: 1.2; padding-top: 2px; white-space: nowrap;
}
.q-card-main { min-width: 0; }
.q-card .q-en, .q-card .q-zh { display: block; }
.q-en { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 500; line-height: 1.3; margin-bottom: var(--space-1); overflow-wrap: anywhere; }
.q-zh { font-size: var(--text-sm); color: var(--muted); }
.q-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); align-items: center; }
.badge {
  font-size: var(--text-xs); font-weight: 500;
  padding: 2px var(--space-3); border-radius: var(--radius-full);
  background: var(--offset); color: var(--muted); white-space: nowrap;
}
.badge-priority { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.badge-fill { background: var(--amber-soft); color: var(--amber); font-weight: 700; }
.badge-block { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.practice-count { font-size: var(--text-xs); color: var(--faint); margin-left: auto; white-space: nowrap; }

/* ============ generic card ============ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.section-title { font-size: var(--text-base); font-weight: 700; margin: var(--space-6) 0 var(--space-3); }
.section-title:first-child { margin-top: 0; }
.plain-text { font-size: var(--text-sm); color: var(--muted); }

/* ============ buttons ============ */
.btn {
  font-size: var(--text-sm); font-weight: 700;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: var(--surface-2); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-danger-ghost { color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { border-color: var(--danger); }
.linklike { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.hint { font-size: var(--text-xs); color: var(--faint); margin-top: var(--space-3); }

.site-footer {
  margin-top: var(--space-10);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.6;
}
.site-footer p + p { margin-top: var(--space-1); }

.io-buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

/* ============ mock setup/run ============ */
.mock-setup { text-align: center; padding: var(--space-10); }
.mock-note { font-size: var(--text-xs); color: var(--faint); margin-bottom: var(--space-4); }
.mock-note + .btn-primary { margin-top: 0; }
.mock-progress-line { font-size: var(--text-sm); font-weight: 700; color: var(--accent); margin-bottom: var(--space-3); }
.mock-actions { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; margin-top: var(--space-6); }
.rescue-peek {
  margin-top: var(--space-4);
  background: var(--offset); border: 1px dashed var(--border);
  border-radius: var(--radius-md); padding: var(--space-4);
  font-size: var(--text-sm);
}
.rescue-peek .rp-line { display: grid; gap: 2px; margin-bottom: var(--space-3); }
.rescue-peek .rp-line:last-child { margin-bottom: 0; }
.rescue-peek .rp-en { font-weight: 700; }
.rescue-peek .rp-zh { color: var(--muted); font-size: var(--text-xs); }

/* ============ timer ============ */
.timer-block { position: relative; width: 148px; height: 148px; margin: var(--space-6) auto; }
.timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--offset); stroke-width: 8; }
.ring-bar {
  fill: none; stroke: var(--accent); stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.7; /* 2πr, r=52 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s linear, stroke var(--transition);
}
.timer-block.is-danger .ring-bar { stroke: var(--danger); }
.timer-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: var(--timer-xl); font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.timer-chips { display: flex; gap: var(--space-2); justify-content: center; }
.chip {
  font-size: var(--text-sm); font-weight: 500;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full); border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--surface-2); font-weight: 700; }
.timer-actions { display: flex; gap: var(--space-3); justify-content: center; margin-top: var(--space-4); flex-wrap: wrap; }

/* ============ record ============ */
.record-block {
  margin-top: var(--space-8);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-5);
  display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center;
}
.btn-record {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-weight: 700; font-size: var(--text-sm);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  background: var(--surface); border: 1px solid var(--border);
}
.btn-record:hover { border-color: var(--danger); }
.rec-dot { width: 10px; height: 10px; border-radius: var(--radius-full); background: var(--faint); flex: none; }
.btn-record.is-recording .rec-dot { background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
.btn-record.is-recording { border-color: var(--danger); color: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.record-status { font-size: var(--text-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.record-block audio { width: 100%; }
#audio-download { font-size: var(--text-sm); color: var(--accent); font-weight: 700; }

/* ============ reveal / model answer ============ */
.reveal-block { margin-top: var(--space-8); }
.reveal-block .btn-primary { width: 100%; }
.model-answer {
  font-family: var(--font-display);
  font-size: var(--text-lg); line-height: 1.7;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md); padding: var(--space-5);
}
.model-answer .mark { color: var(--amber); font-weight: 600; }
.phrase-list { list-style: none; display: grid; gap: var(--space-2); }
.phrase-list li {
  font-size: var(--text-sm); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
}
.followup-list { display: grid; gap: var(--space-4); }
.followup-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-4);
}
.followup-q { font-weight: 700; font-size: var(--text-sm); margin-bottom: var(--space-1); overflow-wrap: anywhere; }
.followup-a { font-size: var(--text-sm); color: var(--muted); overflow-wrap: anywhere; }

/* ============ status callout ============ */
.status-callout {
  border-radius: var(--radius-md); padding: var(--space-4) var(--space-5);
  font-size: var(--text-sm); margin-top: var(--space-4);
  border: 1px solid var(--amber); background: var(--amber-soft); color: var(--text);
}
.status-callout strong { color: var(--amber); }

/* ============ my version ============ */
.my-version-block { margin-top: var(--space-8); }
.my-version-block textarea {
  width: 100%; margin-top: var(--space-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-4);
  font-size: var(--text-sm); line-height: 1.6; resize: vertical;
}
.my-version-block textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

/* ============ rate ============ */
.rate-block {
  margin-top: var(--space-8); display: flex; flex-wrap: wrap;
  gap: var(--space-2); align-items: center;
  padding-top: var(--space-6); border-top: 1px solid var(--border);
}
.rate-label { font-size: var(--text-sm); color: var(--muted); }
.btn-rate { border: 1px solid var(--border); border-radius: var(--radius-full); padding: var(--space-2) var(--space-5); font-size: var(--text-sm); }
.btn-rate:hover { border-color: var(--accent); }
.btn-rate.is-picked { background: var(--accent); border-color: var(--accent); color: var(--surface-2); font-weight: 700; }

/* ============ rescue view ============ */
.rescue-group { margin-bottom: var(--space-6); }
.rescue-group > h3 { font-size: var(--text-base); font-weight: 700; margin-bottom: var(--space-3); }
.rescue-lines { display: grid; gap: var(--space-3); }
.rescue-line {
  display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-4);
}
.rescue-line .rp-en { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 500; overflow-wrap: anywhere; }
.rescue-line .rp-zh { font-size: var(--text-sm); color: var(--muted); }
.rescue-line .rp-note { font-size: var(--text-xs); color: var(--faint); }
.rescue-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.rescue-table th, .rescue-table td { text-align: left; padding: var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.rescue-table th { font-size: var(--text-xs); color: var(--muted); font-weight: 700; }
.rescue-table td { overflow-wrap: anywhere; }

/* ============ progress ============ */
.progress-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.stat {
  background: var(--offset); border-radius: var(--radius-md);
  padding: var(--space-4); text-align: center;
}
.stat-num { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--text-xs); color: var(--muted); margin-top: var(--space-1); }
.progress-list { display: grid; gap: var(--space-2); margin-bottom: var(--space-6); }
.progress-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-3); align-items: center;
  font-size: var(--text-sm);
}
.progress-row .p-num { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.progress-row .p-bar { height: 6px; background: var(--offset); border-radius: var(--radius-full); overflow: hidden; }
.progress-row .p-bar span { display: block; height: 100%; background: var(--accent); border-radius: var(--radius-full); }
.progress-row .p-count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ============ overlay ============ */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in oklab, var(--bg) 72%, rgba(0,0,0,0.28));
  overflow-y: auto; padding: var(--space-4);
  display: flex; justify-content: center; align-items: flex-start;
}
.overlay-panel {
  width: 100%; max-width: 720px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: var(--space-6);
  margin: var(--space-4) 0 var(--space-16);
  box-shadow: var(--shadow-lg);
}
.overlay-top { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.badge-set { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.q-en-big { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 500; line-height: 1.25; margin-bottom: var(--space-2); overflow-wrap: anywhere; }
.target-line { font-size: var(--text-xs); color: var(--faint); font-weight: 700; letter-spacing: 0.04em; }

/* ============ toast ============ */
.toast {
  position: fixed; left: 50%; bottom: var(--space-8); transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  font-size: var(--text-sm); font-weight: 500;
  padding: var(--space-3) var(--space-6); border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg); z-index: 80; max-width: min(92vw, 480px); text-align: center;
}

/* ============ mobile ============ */
@media (max-width: 640px) {
  .header-inner { justify-content: center; text-align: center; }
  .tabs { justify-content: center; }
  .q-card { grid-template-columns: 1fr; gap: var(--space-2); padding: var(--space-4); }
  .q-num { padding-top: 0; }
  .overlay { padding: var(--space-2); }
  .overlay-panel { padding: var(--space-4); }
  .timer-block { width: 128px; height: 128px; }
}
