:root {
  color-scheme: light;
  --bg: #eef2f1;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --surface-green: #eef8f3;
  --text: #17211d;
  --muted: #4f5e58;
  --line: #dde5e2;
  --brand: #00733f;
  --brand-dark: #005a32;
  --brand-soft: #e8f6ef;
  --yellow: #f5c84b;
  --orange: #f47b20;
  --blue: #0d5fb3;
  --danger: #d93025;
  --success: #078241;
  --shadow: 0 16px 45px rgba(19, 32, 28, 0.12);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(0, 115, 63, 0.08), transparent 28%),
    linear-gradient(180deg, #f7faf9 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Noto Sans Thai", "Inter", "Segoe UI", system-ui, sans-serif;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.material-symbols-rounded {
  font-family: "Material Symbols Rounded";
  font-feature-settings: "liga";
  font-size: 24px;
  line-height: 1;
}

.hidden {
  display: none !important;
}

.app-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 28px;
}

.phone-frame {
  background: var(--surface);
  border: 1px solid rgba(27, 45, 39, 0.1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  height: min(844px, calc(100vh - 56px));
  max-height: 844px;
  overflow: hidden;
  position: relative;
  width: min(390px, calc(100vw - 24px));
}

.screen {
  background: var(--surface);
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
}

.screen-scroll {
  overflow-y: auto;
  padding: 16px;
}

.app-header,
.quiz-header {
  align-items: center;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 82px;
  padding: 18px 16px 14px;
}

.brand {
  align-items: center;
  color: inherit;
  display: flex;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-md);
  display: inline-flex;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.brand strong,
.brand small,
.quiz-header strong,
.quiz-header small {
  display: block;
}

.brand strong,
.quiz-header strong {
  font-size: 1.08rem;
  font-weight: 800;
}

.brand small,
.quiz-header small {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
}

.language-switch select {
  appearance: none;
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-radius: var(--radius-full);
  color: var(--brand-dark);
  font-size: 0.8rem;
  font-weight: 800;
  min-height: 34px;
  padding: 0 12px;
}

.coach-card {
  align-items: center;
  background: var(--brand-soft);
  border: 1px solid #cfe8dc;
  border-radius: var(--radius-md);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 112px;
  padding: 16px;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.coach-card h1 {
  font-size: 1.38rem;
  line-height: 1.18;
  margin: 0 0 8px;
}

.coach-card p,
.guide-callout p,
.ad-slot p,
.translation-text,
.recommendation-item span {
  color: var(--muted);
}

.confidence-ring {
  align-items: center;
  aspect-ratio: 1;
  background:
    radial-gradient(circle, #fff 57%, transparent 58%),
    conic-gradient(var(--success) 0 274deg, #dbe5e1 274deg 360deg);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.confidence-ring strong {
  color: var(--success);
  font-size: 1.85rem;
  font-weight: 900;
}

.confidence-ring span {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.1;
}

.metric-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.metric-strip > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
}

.metric-strip span.material-symbols-rounded,
.section-title .small-count {
  color: var(--brand);
}

.metric-strip .warning {
  color: var(--yellow) !important;
}

.metric-strip small,
.action-row small,
.next-step small {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
}

.metric-strip strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 900;
  margin-top: 4px;
}

.action-stack {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.action-row,
.guide-callout,
.next-step,
.answer-button,
.tool-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  min-height: 84px;
  padding: 14px;
  text-align: left;
  width: 100%;
}

.action-row strong {
  display: block;
  font-size: 1.05rem;
}

.action-primary,
.path-card-primary,
.primary-action,
.primary-step {
  background: linear-gradient(180deg, #02864c, var(--brand-dark));
  border-color: transparent;
  color: #fff;
}

.action-primary small,
.path-card-primary small,
.action-primary .row-arrow,
.action-primary .action-icon {
  color: rgba(255, 255, 255, 0.86);
}

.action-primary .action-icon {
  background: rgba(255, 255, 255, 0.16);
}

.action-icon {
  align-items: center;
  background: var(--brand);
  border-radius: var(--radius-md);
  color: #fff;
  display: inline-flex;
  height: 52px;
  justify-content: center;
  width: 52px;
}

.muted-row .action-icon {
  background: #8d9894;
}

.row-arrow {
  color: var(--muted);
}

.pill-count {
  background: var(--brand);
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 10px;
}

.guide-callout {
  background: #eef5ff;
  border-color: #b9d5f8;
  margin-top: 18px;
  min-height: 78px;
}

.guide-callout > .material-symbols-rounded:first-child {
  color: var(--blue);
}

.loading-message {
  background: #eef5ff;
  border: 1px solid #b9d5f8;
  border-radius: var(--radius-md);
  color: #164a7d;
  margin: 14px 0 0;
  padding: 12px;
}

.bottom-nav {
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 74px;
  padding: 8px 8px 10px;
}

.bottom-nav a,
.bottom-nav button {
  align-items: center;
  background: transparent;
  color: #65706c;
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
  text-decoration: none;
}

.bottom-nav .active {
  color: var(--brand);
  font-weight: 800;
}

.bottom-nav small {
  font-size: 0.75rem;
}

.icon-button {
  align-items: center;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.timer-chip {
  align-items: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: var(--radius-full);
  display: inline-flex;
  font-weight: 800;
  gap: 6px;
  padding: 8px 10px;
}

.quiz-scroll {
  padding-bottom: 18px;
}

.progress-dots {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(20, 1fr);
  margin-bottom: 16px;
}

.progress-dots span {
  background: #cbd6d2;
  border-radius: var(--radius-full);
  height: 8px;
}

.progress-dots span.done {
  background: var(--brand);
}

.progress-dots span.current {
  outline: 2px solid rgba(0, 115, 63, 0.2);
}

.category-row {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.category-row .material-symbols-rounded {
  color: var(--brand);
}

.category-row strong {
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: auto;
}

.question-panel h2 {
  font-size: 1.42rem;
  line-height: 1.36;
  margin: 0 0 10px;
}

.question-image-wrap {
  align-items: center;
  background: #f9fbfa;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  max-height: 220px;
  overflow: hidden;
  padding: 12px;
}

.question-image-wrap img {
  display: block;
  max-height: 196px;
  max-width: 100%;
  object-fit: contain;
}

.translation-text {
  font-size: 0.98rem;
  line-height: 1.55;
  margin-bottom: 0;
}

.coach-tip {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 14px 0 0;
  padding: 10px 12px;
}

.answers-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.answer-button {
  grid-template-columns: 42px minmax(0, 1fr) auto;
  min-height: 74px;
}

.answer-button .answer-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}

.answer-copy strong,
.answer-copy small {
  display: block;
}

.answer-copy strong {
  font-size: 1.02rem;
  line-height: 1.35;
}

.answer-copy small {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  margin-top: 3px;
}

.answer-label {
  align-items: center;
  background: #a2aaa7;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  font-size: 1.1rem;
  font-weight: 900;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.answer-button.selected,
.answer-button.correct {
  background: #eefaf4;
  border-color: var(--brand);
}

.answer-button.selected .answer-label,
.answer-button.correct .answer-label {
  background: var(--brand);
}

.answer-check {
  color: transparent;
}

.answer-button.selected .answer-check,
.answer-button.correct .answer-check {
  color: var(--brand);
}

.answer-button.incorrect {
  background: #fff2ef;
  border-color: #f2b7ae;
}

.feedback-panel {
  border-radius: var(--radius-md);
  line-height: 1.5;
  margin-top: 14px;
  padding: 12px;
}

.feedback-panel.correct,
.feedback-panel.neutral {
  background: #eefaf4;
  border: 1px solid #bfe8d2;
}

.feedback-panel.incorrect {
  background: #fff2ef;
  border: 1px solid #f2b7ae;
}

.quiz-tools {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.tool-button {
  font-size: 0.78rem;
  grid-template-columns: 24px minmax(0, 1fr);
  min-height: 52px;
}

.sticky-footer {
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  padding: 10px 16px 16px;
}

.progress-track {
  background: #dfe8e4;
  border-radius: var(--radius-full);
  height: 6px;
  margin-bottom: 10px;
  overflow: hidden;
}

#progressBar {
  background: var(--brand);
  height: 100%;
  transition: width 180ms ease;
  width: 0;
}

.primary-action {
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 900;
  min-height: 56px;
  width: 100%;
}

.share-icon {
  opacity: 0.9;
}

.result-hero {
  text-align: center;
}

.result-badge {
  align-items: center;
  background: var(--brand);
  border: 1px solid var(--brand-dark);
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  font-size: 48px;
  height: 84px;
  justify-content: center;
  margin-bottom: 12px;
  width: 84px;
}

  margin-bottom: 8px;
}

.score-board {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-top: 16px;
  padding: 18px;
}

.score-board strong {
  color: var(--text);
  display: block;
  font-size: 3.6rem;
}

.weak-section {
  margin-top: 18px;
}

.section-title {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title strong,
.section-title small {
  display: block;
}

.section-title small {
  color: var(--muted);
}

.small-count {
  background: var(--brand-soft);
  border-radius: var(--radius-full);
  font-weight: 900;
  padding: 6px 10px;
}

.weak-areas {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.weak-pill {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  font-size: 0.78rem;
  justify-content: center;
  min-height: 50px;
  padding: 8px;
  text-align: center;
}

.recommendation-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.weak-bars {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.weak-bar {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 94px;
  padding: 12px;
}

.weak-bar strong,
.weak-bar small {
  display: block;
}

.weak-bar small {
  color: var(--muted);
  font-size: 0.78rem;
}

.weak-bar > span {
  background: #dfe8e4;
  border-radius: var(--radius-full);
  display: block;
  height: 8px;
  overflow: hidden;
}

.weak-bar i {
  background: var(--brand);
  border-radius: inherit;
  display: block;
  height: 100%;
  width: var(--bar);
}

.recommendation-item {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 3px;
  padding: 12px;
}

.next-step-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.next-step {
  grid-template-columns: 34px minmax(0, 1fr) 24px;
  min-height: 58px;
}

.primary-step {
  background: linear-gradient(180deg, #02864c, var(--brand-dark));
.primary-step {
  border-color: transparent;
}
  border: 1px dashed #bfcac6;
  border-radius: var(--radius-md);
  color: var(--muted);
  margin-top: 18px;
  padding: 18px;
  text-align: center;
}

.ad-slot span {
  background: #eef0ef;
  border-radius: var(--radius-sm);
  color: #5d6864;
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 900;
  margin-bottom: 10px;
  padding: 5px 10px;
}

.ad-slot strong {
  color: var(--text);
  display: block;
}

.mistake-summary {
  align-items: center;
  background: #fff8e6;
  border: 1px solid #f1d58d;
  border-radius: var(--radius-md);
  display: grid;
  gap: 12px;
  grid-template-columns: 44px minmax(0, 1fr);
  padding: 14px;
}

.mistake-summary > .material-symbols-rounded {
  color: var(--yellow);
  font-size: 36px;
}

.mistake-summary strong,
.mistake-summary p {
  display: block;
  margin: 0;
}

.mistake-summary p {
  color: var(--muted);
  margin-top: 3px;
}

.filter-row {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-row button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
  font-weight: 700;
  min-height: 42px;
  padding: 0 14px;
}

.filter-row .active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.mistake-list {
  display: grid;
  gap: 10px;
}

.mistake-row {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 12px;
  grid-template-columns: 44px minmax(0, 1fr) 68px;
  padding: 12px;
}

.mistake-row > .material-symbols-rounded {
  align-items: center;
  background: var(--brand-soft);
  border-radius: var(--radius-md);
  color: var(--brand);
  display: flex;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.mistake-row strong,
.mistake-row small,
.mistake-row em,
.mistake-row b {
  display: block;
}

.mistake-row strong {
  font-size: 0.92rem;
  line-height: 1.35;
  max-height: 2.7em;
  overflow: hidden;
}

.mistake-row small {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.mistake-row em {
  color: var(--brand);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  margin-top: 5px;
}

.mistake-row aside {
  text-align: right;
}

.mistake-row b {
  color: var(--danger);
  font-size: 1rem;
}

.empty-state {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

@media (min-width: 860px) {
  .phone-frame {
    transform: scale(0.98);
  }
}

@media (max-width: 859px) and (min-width: 461px) {
  .phone-frame {
    border: 0;
    box-shadow: none;
    height: 100vh;
    max-height: none;
    width: 100%;
    border-radius: 0;
  }
  .app-shell {
    padding: 0;
  }
}

@media (max-width: 460px) {
  .app-shell {
    padding: 0;
  }

  .phone-frame {
    border: 0;
    box-shadow: none;
    height: 100vh;
    max-height: none;
    width: 100vw;
  }
}

/* ── Phase 2: Progress bars ─────────────────────────────────────── */
.progress-section {
  margin: 16px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.progress-section .section-title {
  margin-bottom: 12px;
}
.progress-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.progress-label {
  width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}
.progress-track-mini {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.progress-track-mini i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
  transition: width 0.5s;
}
.progress-value {
  width: 36px;
  text-align: right;
  font-weight: 600;
  color: var(--brand);
  font-size: 12px;
}

/* ── Phase 2: Category list (practice screen) ───────────────────── */
.category-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.category-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  transition: background 0.15s;
}
.category-card:hover {
  background: var(--surface-soft);
}
.category-card .material-symbols-rounded:first-child {
  font-size: 24px;
  color: var(--brand);
}
.category-card strong {
  font-size: 14px;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
