/* ===== Design system ===== */
:root {
  --bg: #0b1120;
  --bg-soft: #0f172a;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;
  --line: #e2e8f0;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --radius: 18px;
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.25);
  --shadow-sm: 0 2px 8px -3px rgba(15, 23, 42, 0.2);
  --maxw: 960px;
}
body[data-theme='insurance'] {
  --accent: #0e7490;
  --accent-2: #06b6d4;
  --tint: #ecfeff;
}
body[data-theme='real-estate'] {
  --accent: #b45309;
  --accent-2: #059669;
  --tint: #fffbeb;
}
body[data-theme='neutral'] {
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --tint: #eef2ff;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang HK', 'PingFang TC', 'Microsoft JhengHei',
    'Noto Sans HK', 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 600px at 80% -10%, var(--tint), transparent 60%), #f1f5f9;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.boot {
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-faint);
}
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 18px 80px;
}
h1,
h2,
h3,
h4 {
  line-height: 1.3;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.pad {
  padding: 20px 22px;
}
.prose p {
  margin: 0.5em 0;
}
.prose ul {
  margin: 0.4em 0;
  padding-left: 1.2em;
}
.prose h4 {
  margin: 0.8em 0 0.3em;
}

/* ===== buttons ===== */
button {
  font-family: inherit;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: 0;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn-primary:hover {
  filter: brightness(1.06);
}
.btn-primary:active {
  transform: translateY(1px);
}
.btn-primary.block {
  display: block;
  width: 100%;
  margin-top: 14px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 600;
}
.btn-ghost:hover {
  background: var(--surface-2);
}

/* ===== topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ===== login ===== */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  border: 1px solid var(--line);
}
.login-logo {
  font-size: 54px;
}
.login-card h1 {
  font-size: 24px;
  margin: 8px 0 6px;
}
.login-card .sub {
  color: var(--ink-soft);
  margin: 0 0 22px;
}
.login-card .who {
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 14px;
}
.login-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.login-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 10px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
  transition: all 0.15s ease;
}
.login-choice:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.lc-emoji {
  font-size: 40px;
}
.lc-name {
  font-weight: 800;
  font-size: 18px;
}

/* ===== hero + dashboard ===== */
.hero h1 {
  font-size: 26px;
  margin: 6px 0;
}
.hero p {
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 18px 0;
}
.dash-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border-top: 5px solid var(--accent);
}
.dash-top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.dash-emoji {
  font-size: 34px;
}
.dash-name {
  font-weight: 800;
  font-size: 18px;
}
.dash-tag {
  color: var(--ink-faint);
  font-size: 13px;
}
.metric-group {
  margin-bottom: 12px;
}
.metric-h {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.bar-row {
  margin: 6px 0;
}
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.bar-pct {
  font-weight: 700;
}
.bar {
  height: 8px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width 0.4s ease;
}
.exam-badge {
  display: inline-block;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-soft);
}
.exam-badge.pass {
  background: var(--good-bg);
  color: #15803d;
}
.exam-badge.fail {
  background: #fef3c7;
  color: #b45309;
}
.method ol {
  margin: 6px 0 0;
  padding-left: 1.2em;
  color: var(--ink-soft);
}
.method li {
  margin: 6px 0;
}

/* ===== domain ===== */
.domain-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 5px solid var(--accent);
  padding: 4px 0 4px 14px;
  margin-bottom: 14px;
}
.domain-head h1 {
  font-size: 22px;
  margin: 0;
}
.back {
  align-self: flex-start;
}
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}
.tab {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  padding: 9px 14px;
  border-radius: 99px;
  font-weight: 600;
  font-size: 14px;
}
.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.section-intro {
  color: var(--ink-soft);
  background: var(--tint);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.facts h4 {
  margin-top: 0;
}
.card + .card {
  margin-top: 14px;
}
.model,
.debate {
  position: relative;
}
.model-num {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  background: var(--tint);
  padding: 3px 10px;
  border-radius: 99px;
  margin-bottom: 6px;
}
.model h3,
.debate h3 {
  margin: 4px 0 6px;
  font-size: 19px;
}
.oneliner {
  color: var(--accent);
  font-weight: 700;
  font-style: italic;
  margin: 0 0 10px;
}
.kv {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.kv-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 2px;
}
.kv-tag.matters {
  background: var(--tint);
  color: var(--accent);
}
.kv-tag.eg {
  background: #f1f5f9;
  color: var(--ink-soft);
}
.kv-tag.unresolved {
  background: #fef3c7;
  color: #b45309;
}
.sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.side {
  border-radius: 12px;
  padding: 12px 14px;
}
.side-a {
  background: #eff6ff;
}
.side-b {
  background: #f0fdf4;
}
.side-label {
  font-weight: 800;
  margin-bottom: 6px;
}
.side ul {
  margin: 0;
  padding-left: 1.1em;
}
.side li {
  margin: 4px 0;
}
.checklist li {
  margin: 5px 0;
}
.mark-row {
  margin: 18px 0 6px;
  text-align: center;
}
.btn-mark {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 12px 22px;
  border-radius: 12px;
  font-weight: 700;
}
.btn-mark.done {
  background: var(--good-bg);
  color: #15803d;
}

/* ===== quiz ===== */
.quiz-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 8px 0;
}
.mode-btn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: var(--surface-2);
  transition: all 0.15s ease;
}
.mode-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.mode-emoji {
  font-size: 28px;
}
.mode-t {
  font-weight: 800;
  font-size: 17px;
}
.mode-d {
  font-size: 13px;
  color: var(--ink-soft);
}
.bank-note {
  color: var(--ink-faint);
  font-size: 13px;
  margin: 6px 0 0;
}
.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.q-counter {
  font-weight: 800;
  color: var(--accent);
}
.q-topic {
  font-size: 13px;
  color: var(--ink-faint);
}
.exam-progress {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  margin-bottom: 12px;
  overflow: hidden;
}
.exam-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}
.q-text {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
}
.opts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  border: 2px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 15px;
  transition: all 0.12s ease;
}
.opt:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--tint);
}
.opt:disabled {
  cursor: default;
}
.opt-key {
  font-weight: 800;
  color: var(--accent);
  background: var(--tint);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: none;
}
.opt.picked {
  border-color: var(--accent);
  background: var(--tint);
}
.opt.correct {
  border-color: var(--good);
  background: var(--good-bg);
}
.opt.correct .opt-key {
  background: var(--good);
  color: #fff;
}
.opt.wrong {
  border-color: var(--bad);
  background: var(--bad-bg);
  opacity: 0.85;
}
.opt.wrong .opt-key {
  background: var(--bad);
  color: #fff;
}
.feedback {
  margin-top: 12px;
}
.fb {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  margin-top: 8px;
}
.fb-correct {
  background: var(--good-bg);
  color: #166534;
}
.fb-wrong {
  background: var(--bad-bg);
  color: #991b1b;
}
.retry {
  font-weight: 700;
  opacity: 0.8;
}
.teach {
  margin-top: 10px;
  background: var(--tint);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink-soft);
}
.q-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 10px;
}

/* ===== results ===== */
.result {
  text-align: center;
}
.result-emoji {
  font-size: 48px;
}
.big-score {
  font-size: 44px;
  font-weight: 900;
  color: var(--accent);
}
.score-pct {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.result.pass .big-score {
  color: var(--good);
}
.result.fail .big-score {
  color: #b45309;
}
.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}
.review-h {
  margin: 22px 0 10px;
}
.review-q .rq-head {
  font-weight: 800;
  margin-bottom: 8px;
}
.r-opt {
  border-radius: 10px;
  padding: 10px 12px;
  margin: 6px 0;
  background: var(--surface-2);
  font-size: 14px;
}
.r-opt.rc {
  background: var(--good-bg);
}
.r-opt.rw {
  background: var(--bad-bg);
}
.rtag {
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 6px;
}
.rtag-c {
  background: var(--good);
  color: #fff;
}
.rtag-w {
  background: var(--bad);
  color: #fff;
}
.r-exp {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 4px;
}

/* ===== TTS play button ===== */
.readable.has-tts {
  position: relative;
}
.card.readable.has-tts,
.section-intro.readable.has-tts {
  padding-right: 56px;
}
.tts-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  z-index: 3;
  padding: 0;
  transition: transform 0.1s ease, background 0.15s ease;
}
.tts-btn:hover {
  background: var(--tint);
  transform: scale(1.08);
}
.tts-btn[data-st='playing'] {
  background: var(--accent);
  color: #fff;
  animation: ttspulse 1.1s ease-in-out infinite;
}
.tts-btn[data-st='loading'] {
  opacity: 0.65;
}
@keyframes ttspulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(8, 145, 178, 0.4);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(8, 145, 178, 0);
  }
}
.q-text.readable.has-tts,
.fb.readable.has-tts,
.teach.readable.has-tts {
  position: relative;
  padding-right: 40px;
}
.q-text .tts-btn,
.fb .tts-btn,
.teach .tts-btn {
  top: 2px;
  right: 2px;
  width: 28px;
  height: 28px;
  font-size: 13px;
}

/* ===== responsive ===== */
@media (max-width: 680px) {
  .dash-grid,
  .quiz-modes,
  .sides,
  .login-choices {
    grid-template-columns: 1fr;
  }
  .q-text {
    font-size: 16px;
  }
  .hero h1 {
    font-size: 22px;
  }
}
