:root {
  color-scheme: light;
  /* original palette */
  --bg: #f7fbff;
  --ink: #172033;
  --muted: #607086;
  --line: #dbe7f3;
  --blue: #2f7cf6;
  --green: #21a67a;
  --yellow: #f7c948;
  --coral: #ff7a59;
  --white: #ffffff;
  --shadow: 0 18px 50px rgba(34, 76, 122, 0.12);
  /* phase-5 unified tokens (alias originals) */
  --primary:   #2f7cf6;
  --text:      #172033;
  --text-muted:#607086;
  --card-bg:   #ffffff;
  --border:    #dbe7f3;
  --surface:   #f0f6ff;
}

/* ── DARK MODE ── */
[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0f1117;
  --ink:       #e8edf4;
  --muted:     #8b97a8;
  --line:      #2a3040;
  --blue:      #4d9aff;
  --green:     #34d399;
  --yellow:    #fcd34d;
  --coral:     #fb7185;
  --white:     #1a2030;
  --shadow:    0 18px 50px rgba(0,0,0,.45);
  --primary:   #4d9aff;
  --text:      #e8edf4;
  --text-muted:#8b97a8;
  --card-bg:   #1a2030;
  --border:    #2a3040;
  --surface:   #151b27;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 3;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 36px);
}

h2 {
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1.15;
  margin-bottom: 12px;
}

h3 {
  margin-bottom: 8px;
  font-size: 20px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.nav {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
}

.icon-button.active,
.icon-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

main {
  padding: 28px clamp(18px, 4vw, 48px) 48px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.ai-console {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 36px);
}

.ai-copy {
  max-width: 760px;
}

.ai-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin: 24px 0 12px;
}

.ai-form input,
.section-head input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: #fbfdff;
  color: var(--ink);
}

.ai-form button,
.primary-button {
  border: 0;
  border-radius: 8px;
  padding: 0 20px;
  background: var(--blue);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.quick-actions button,
.text-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}

.ai-response {
  display: grid;
  gap: 12px;
}

.resource-card,
.panel,
.topic-card,
.progress-item,
.player-panel,
.task-item,
.assessment-panel,
.plan-panel,
.english-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.resource-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.resource-card p {
  color: var(--muted);
  margin-bottom: 0;
}

.resource-card button {
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.3fr) minmax(220px, 0.8fr) minmax(220px, 0.9fr);
  gap: 16px;
  margin-top: 18px;
}

.panel {
  padding: 18px;
}

.panel p {
  color: var(--muted);
}

.progress-ring {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border: 10px solid #d9efe8;
  border-top-color: var(--green);
  border-radius: 50%;
  font-weight: 800;
  margin-bottom: 12px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.section-head input {
  max-width: 320px;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.topic-card {
  padding: 16px;
}

.topic-meta {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.topic-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topic-actions button {
  border: 1px solid var(--line);
  background: #fbfdff;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

/* Topic availability badges */
.topic-availability { margin-bottom: 8px; }
.avail-ok { color: #1a7f37; font-weight: 600; }
.avail-none { color: var(--muted); }

/* Topic video list (expand) */
.topic-video-list {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.topic-video-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 13px;
  background: transparent;
  transition: background 0.15s;
}

.topic-video-row:hover { background: #f4f8ff; }
.topic-video-row.done .video-row-title { color: var(--muted); text-decoration: line-through; }
.topic-video-row.unavailable { opacity: 0.55; }

.video-status-icon { flex-shrink: 0; font-size: 14px; width: 20px; text-align: center; }
.video-row-title { flex: 1; line-height: 1.4; }

.video-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}
.video-badge.soon { background: #fff3cd; color: #856404; }
.video-badge.pending { background: #f0f0f0; color: #666; }

.video-open-btn {
  flex-shrink: 0;
  font-size: 12px !important;
  padding: 3px 10px !important;
  border: 1px solid var(--accent) !important;
  color: var(--accent) !important;
  border-radius: 6px !important;
  background: white !important;
}
.video-open-btn:hover { background: var(--accent) !important; color: white !important; }
.video-open-btn.pending {
  border-color: #c4c4c4 !important;
  color: #666 !important;
}
.video-open-btn.pending:hover { background: #e0e0e0 !important; color: #333 !important; }

.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  margin-top: 16px;
}

.video-shell {
  background: #102033;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  color: white;
}

/* placeholder（沒 YouTube ID 時顯示「待補連結」訊息）需要 grid 置中 */
.video-shell .video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}

.document-shell {
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  overflow: hidden;
}

.document-shell iframe {
  width: 100%;
  height: 620px;
  border: 0;
}

.document-fallback {
  padding: 24px;
  color: var(--muted);
}

/* YouTube iframe（YT.Player 動態注入）需要完全填滿 video-shell */
.video-shell iframe,
#youtube-player-host,
#youtube-player-host iframe {
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

.player-panel {
  padding: 18px;
}

.player-panel p {
  color: var(--muted);
}

.note-box {
  margin-top: 18px;
}

.note-box label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

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

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

.plan-note {
  border: 1px solid #bee9d8;
  border-radius: 8px;
  background: #f0fbf7;
  padding: 10px;
}

.plan-note strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.plan-note span {
  color: var(--muted);
  font-size: 13px;
}

.task-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  text-align: left;
}

.task-item:hover {
  border-color: var(--blue);
}

.task-item.done {
  border-color: #bee9d8;
  background: #f8fffc;
}

.task-item.queued {
  border-style: dashed;
  background: #fbfdff;
}

.task-open {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.task-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e9f2ff;
  color: var(--blue);
  font-weight: 800;
}

.task-item strong {
  display: block;
}

.task-item span {
  color: var(--muted);
  font-size: 13px;
}

.task-complete {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 36px;
  padding: 0 10px;
  background: var(--white);
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
}

.task-complete:disabled {
  background: #f3f5f7;
  color: var(--muted);
  cursor: default;
}

.task-item.done .task-complete {
  border-color: #bee9d8;
  background: #eaf8f3;
  color: var(--green);
}

.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--green);
  color: white;
  text-decoration: none;
  font-weight: 700;
}

.side-ai {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.mastery-check {
  border: 1px solid #dcebf5;
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px;
  margin-top: 10px;
}

.mastery-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.mastery-head strong {
  font-size: 13px;
}

.mastery-head span {
  color: var(--muted);
  font-size: 12px;
}

.mastery-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.mastery-options button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.mastery-options button.active {
  border-color: var(--green);
  background: #eaf8f3;
  color: #176449;
}

.side-ai-log {
  min-height: 90px;
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.side-message {
  border-radius: 8px;
  background: #f3f8ff;
  padding: 10px;
  color: var(--muted);
  font-size: 14px;
}

.context-card {
  border: 1px solid #cfe1f7;
  border-radius: 8px;
  background: #f7fbff;
  padding: 12px;
  color: var(--muted);
}

.context-card strong {
  display: block;
  color: var(--ink);
  margin: 8px 0 4px;
}

.context-card p {
  margin-bottom: 0;
}

.context-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.context-tag {
  max-width: 100%;
  border-radius: 999px;
  background: #e9f2ff;
  color: var(--blue);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
  align-items: start;
  margin-top: 8px;
}

.message-row span {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  border-radius: 8px;
  background: var(--white);
  color: var(--blue);
  font-weight: 800;
  font-size: 12px;
}

.message-row p {
  margin: 0;
  color: var(--ink);
  line-height: 1.55;
}

.message-row.ai p {
  color: var(--muted);
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.message-actions button {
  border: 1px solid #ffd36e;
  border-radius: 8px;
  background: #fff8df;
  color: #7a4d00;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.message-actions button:disabled {
  border-color: var(--line);
  background: #eef5f0;
  color: #3e7c59;
  cursor: default;
}

.side-ai-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.side-ai-form input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.side-ai-form button {
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  padding: 0 12px;
  font-weight: 700;
  cursor: pointer;
}

.progress-item {
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #e9f2ff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.planner-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr);
  gap: 18px;
}

.assessment-panel,
.plan-panel {
  padding: 18px;
}

.assessment-panel {
  display: grid;
  gap: 18px;
}

.wizard-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.wizard-dot {
  display: grid;
  justify-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
  padding: 6px 4px;
  cursor: pointer;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.15;
}

.wizard-dot span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #e9f2ff;
  color: var(--blue);
}

.wizard-dot.active {
  border-color: var(--blue);
  color: var(--ink);
}

.wizard-dot.active span {
  background: var(--blue);
  color: white;
}

.planner-step {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.planner-step.active {
  display: block;
}

.step-head {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  align-items: start;
  margin-bottom: 8px;
}

.step-head > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-weight: 800;
}

.step-head h3 {
  margin-bottom: 0;
}

.assessment-group {
  display: grid;
  gap: 7px;
}

.assessment-group.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.range-row,
.field-row {
  display: grid;
  gap: 8px;
}

.field-row span {
  color: var(--ink);
  font-weight: 700;
}

.field-row strong {
  color: var(--blue);
}

.range-card {
  display: grid;
  grid-template-columns: minmax(112px, 0.34fr) minmax(130px, 1fr);
  gap: 4px 10px;
  align-items: center;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  padding: 7px 9px;
  background: var(--white);
}

.range-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.range-score {
  color: var(--blue);
  font-size: 17px;
  line-height: 1;
  min-width: 34px;
}

.range-title {
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.range-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.range-scale {
  display: grid;
  grid-column: 2;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.range-scale small {
  color: var(--muted);
  line-height: 1.35;
}

.range-scale small:last-child {
  text-align: right;
}

input[type="range"] {
  width: 100%;
  height: 20px;
  accent-color: var(--blue);
  cursor: pointer;
  touch-action: pan-y;
}

input[type="range"]::-webkit-slider-thumb {
  cursor: grab;
}

input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
}

.field-row input[type="date"],
.field-row select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfdff;
  color: var(--ink);
}

.exam-date-field.is-hidden {
  display: grid;
}

.pressure-card {
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  background: #eaf8f3;
  border: 1px solid #bee9d8;
}

.pressure-card.warn {
  background: #fff8e3;
  border-color: #f7df8a;
}

.pressure-card.danger {
  background: #fff0ec;
  border-color: #ffc6b6;
}

.pressure-card strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.pressure-card p,
.plan-summary p {
  margin-bottom: 0;
}

.plan-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
}

.plan-steps {
  display: grid;
  gap: 10px;
}

.plan-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.plan-step strong {
  display: block;
  margin-bottom: 4px;
}

.plan-step p {
  margin-bottom: 0;
  color: var(--muted);
}

.actionable-step {
  display: grid;
  gap: 8px;
}

.actionable-step p {
  margin-bottom: 0;
}

.actionable-step .text-button {
  justify-self: start;
}

.english-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.english-panel {
  padding: 18px;
}

.english-head h3 {
  margin-bottom: 0;
}

.level-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.level-tabs button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
  min-height: 42px;
  font-weight: 800;
  cursor: pointer;
}

.level-tabs button span {
  display: block;
  font-size: 11px;
  font-weight: 600;
}

.level-tabs button.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #f3f8ff;
}

.english-question {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 0 0 10px;
}

.english-question legend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  font-weight: 800;
}

.mini-tool {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

.mini-tool.active {
  border-color: var(--yellow);
  background: #fff8e3;
  color: #a36d00;
}

.english-question legend span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #e9f2ff;
  color: var(--blue);
  font-size: 12px;
}

.english-question p {
  color: var(--muted);
  margin-bottom: 10px;
}

.vocab-help {
  display: none;
  border: 1px solid #cfe1f7;
  border-radius: 8px;
  background: #f7fbff;
  padding: 10px;
  margin-bottom: 10px;
}

.vocab-help.active {
  display: block;
}

.vocab-help strong {
  display: block;
  margin-bottom: 4px;
}

.vocab-help p {
  margin-bottom: 6px;
}

.vocab-help small {
  color: var(--muted);
}

.english-options {
  display: grid;
  gap: 8px;
}

.english-options label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.english-options input {
  accent-color: var(--blue);
}

.vocab-unfamiliar {
  margin-top: 8px;
}

.english-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.english-actions .primary-button,
.english-actions .text-button {
  min-height: 42px;
}

.english-result {
  margin-bottom: 12px;
}

.english-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.english-stats-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px;
}

.english-stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.english-stats-grid strong {
  color: var(--ink);
  font-size: 18px;
}

.review-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.review-head,
.review-empty,
.review-word {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px;
}

.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.review-empty p {
  color: var(--muted);
  margin: 4px 0 0;
}

.review-word {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.review-word span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.review-word strong {
  display: block;
}

.review-word p {
  color: var(--muted);
  margin: 2px 0 0;
}

.diagnosis-report {
  display: grid;
  gap: 16px;
}

.diagnosis-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.diagnosis-card,
.diagnosis-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 14px;
}

.diagnosis-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.diagnosis-card strong {
  display: block;
  color: var(--ink);
  font-size: 24px;
  margin-bottom: 6px;
}

.diagnosis-card p,
.diagnosis-band p {
  color: var(--muted);
  margin-bottom: 0;
}

.diagnosis-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.diagnosis-band h3 {
  margin-bottom: 6px;
}

.memory-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 14px;
}

.memory-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px;
}

.memory-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.memory-item strong {
  display: block;
  margin-bottom: 4px;
}

.memory-item p {
  color: var(--muted);
  margin-bottom: 0;
}

.memory-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.wizard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.wizard-actions .primary-button,
.wizard-actions .text-button {
  min-height: 42px;
}

.confirm-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.confirm-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 12px;
}

.confirm-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.confirm-card strong {
  color: var(--ink);
}

.sprint-plan {
  display: grid;
  gap: 10px;
  border: 1px solid #bee9d8;
  border-radius: 8px;
  background: #f0fbf7;
  padding: 12px;
}

.sprint-plan h4 {
  margin: 0;
}

.sprint-plan ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.activation-status {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
  padding: 8px 10px;
  margin-top: 10px;
  font-size: 13px;
}

.activation-status:empty {
  display: none;
}

.activation-status.success {
  border-color: #bee9d8;
  background: #f0fbf7;
  color: var(--green);
}

.activation-status.error {
  border-color: #ffc6b6;
  background: #fff0ec;
  color: #b8432d;
}

@media (max-width: 820px) {
  .topbar,
  .section-head,
  .player-layout {
    display: block;
  }

  .nav {
    margin-top: 14px;
  }

  .ai-form,
  .dashboard-grid,
  .planner-layout,
  .english-layout,
  .diagnosis-grid,
  .diagnosis-band,
  .memory-item,
  .assessment-group.two-col,
  .confirm-summary {
    grid-template-columns: 1fr;
  }

  .range-card {
    grid-template-columns: minmax(92px, 0.38fr) minmax(120px, 1fr);
    gap: 3px 8px;
  }

  .wizard-progress {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .wizard-dot {
    font-size: 11px;
    padding: 5px 2px;
  }

  .wizard-dot span {
    width: 22px;
    height: 22px;
  }

  .level-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .english-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .range-title {
    font-size: 13px;
  }

  .range-score {
    font-size: 16px;
    min-width: 31px;
  }

  .ai-form button {
    min-height: 44px;
  }

  .section-head input {
    max-width: none;
  }

  .player-panel {
    margin-top: 14px;
  }
}

/* =====================================================================
   AUTH & LANDING — added 2026-05-24
   ===================================================================== */

/* ---------- Topbar user area ---------- */
.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.auth-topbar-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  transition: opacity .15s;
}
.auth-topbar-btn:hover { opacity: .85; }
.auth-login-link {
  font-size: 14px;
  color: var(--muted);
}
.tier-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-trial  { background: #fff3cd; color: #856404; }
.badge-free   { background: #e2e8f0; color: #475569; }
.badge-pro    { background: #d1fae5; color: #065f46; }
.user-name {
  font-size: 14px;
  color: var(--ink);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Trial banner ---------- */
.trial-banner {
  padding: 10px clamp(18px,4vw,48px);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.trial-banner.trial { background: #fffbeb; border-bottom: 1px solid #fde68a; color: #92400e; }
.trial-banner.free  { background: #f0f9ff; border-bottom: 1px solid #bae6fd; color: #0c4a6e; }
.trial-banner .text-button.inline {
  font-size: inherit;
  color: var(--blue);
  font-weight: 700;
}

/* ---------- AI quota info ---------- */
.ai-quota-info {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  padding-left: 2px;
}

/* ---------- Auth modal ---------- */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23,32,51,.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-modal-overlay[hidden] { display: none; }

.auth-dialog {
  background: var(--white);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 440px;
  position: relative;
  box-shadow: var(--shadow);
}
.auth-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}
.auth-close-btn:hover { background: var(--bg); }

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0;
}
.auth-tab {
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.auth-tab.active {
  color: var(--blue);
  border-color: var(--blue);
}

.auth-panel { }
.google-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.google-btn:hover { background: var(--bg); border-color: var(--blue); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-fields input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  background: var(--bg);
  transition: border-color .15s;
}
.auth-fields input:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--white);
}
.auth-error {
  color: var(--coral);
  font-size: 13px;
  margin: 0;
  min-height: 18px;
}
.auth-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin: 16px 0 0;
}

/* ---------- Landing page ---------- */
#landing {
  padding: 0;
}

.landing-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
  padding: clamp(40px,6vw,80px) clamp(18px,6vw,80px);
  max-width: 1200px;
  margin: 0 auto;
}
.landing-hero-copy h2 {
  font-size: clamp(28px,4vw,52px);
  line-height: 1.1;
  margin-bottom: 16px;
}
.landing-subtitle {
  font-size: 17px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 28px;
}
.landing-ctas {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.landing-cta-btn {
  font-size: 16px;
  padding: 14px 28px;
  border-radius: 10px;
}
.landing-fine {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.landing-features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.landing-feature {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.landing-feature-icon { font-size: 28px; display: block; margin-bottom: 8px; }
.landing-feature h4 { margin: 0 0 6px; font-size: 15px; }
.landing-feature p  { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.5; }

.landing-topics-section {
  background: var(--white);
  padding: clamp(32px,5vw,60px) clamp(18px,6vw,80px);
  text-align: center;
  border-top: 1px solid var(--line);
}
.landing-topics-section h3 { margin-bottom: 20px; }
.landing-topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.landing-topic-chip {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.landing-pricing-section {
  padding: clamp(40px,6vw,80px) clamp(18px,6vw,80px);
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}
.landing-pricing-section h3 { margin-bottom: 32px; }
.landing-plan-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  text-align: left;
}
.landing-plan-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.landing-plan-card.plan-featured {
  border-color: var(--blue);
  position: relative;
}
.plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
}
.plan-price {
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
  margin: 4px 0;
}
.plan-price small { font-size: 14px; font-weight: 400; color: var(--muted); }
.plan-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  flex: 1;
}
.plan-features li { display: flex; gap: 6px; }
.plan-locked { color: var(--muted); }
.landing-plan-card .primary-button,
.landing-plan-card .secondary-button {
  margin-top: auto;
}
.secondary-button {
  background: var(--white);
  color: var(--blue);
  border: 1.5px solid var(--blue);
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s;
}
.secondary-button:hover { background: var(--bg); }

@media (max-width: 700px) {
  .landing-hero { grid-template-columns: 1fr; gap: 32px; }
  .landing-features-grid { grid-template-columns: 1fr; }
  .landing-plan-cards { grid-template-columns: 1fr; }
  .user-name { display: none; }
  .auth-dialog { padding: 24px 18px; }
}

/* ============================================================
   SPRINT START PAGE
   ============================================================ */
#sprint-start {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  min-height: 100%;
}
.sprint-start-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 48px 40px 40px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
}
.ss-rocket {
  font-size: 56px;
  margin-bottom: 16px;
  animation: ss-bounce 1s ease infinite alternate;
}
@keyframes ss-bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-8px); }
}
.ss-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 800;
  margin: 0 0 8px;
  color: var(--ink);
}
.ss-subtitle {
  color: var(--muted);
  font-size: 15px;
  margin: 0 0 24px;
}
.ss-phase-badge {
  display: inline-block;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 18px;
  border-radius: 20px;
  margin-bottom: 24px;
}
.ss-day-ring {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 4px solid var(--accent);
  margin: 0 auto 20px;
  background: var(--surface);
}
.ss-day-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.ss-day-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.ss-exam-cd {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 20px;
}
.ss-tasks-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px 20px;
  text-align: left;
  margin-bottom: 28px;
}
.ss-tasks-label {
  font-weight: 700;
  font-size: 14px;
  margin: 0 0 10px;
  color: var(--ink);
}
.ss-task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ss-task-item {
  font-size: 14px;
  color: var(--ink);
}
.ss-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ss-actions .primary-button {
  width: 100%;
  max-width: 300px;
  font-size: 16px;
  padding: 14px 0;
}

/* ============================================================
   REVIEW MODULE
   ============================================================ */
#review {
  padding: 24px 20px 40px;
}
.review-wrap {
  max-width: 720px;
}
.review-gate {
  text-align: center;
  padding: 60px 20px;
}
.review-weak-item,
.review-note-item,
.review-ai-item {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 16px;
}


/* ============================================================
   QUIZ HUB
   ============================================================ */
#quiz { padding: 0 20px 40px; }

.quiz-wrong-badge {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 700;
}

.quiz-hub-content { max-width: 900px; }

.quiz-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.quiz-mode-label { font-size: 14px; color: var(--muted); }

.quiz-topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.quiz-topic-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.quiz-topic-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
.qtc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.qtc-code { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: .05em; text-transform: uppercase; }
.qtc-name { font-weight: 700; font-size: 14px; margin: 0 0 2px; color: var(--ink); }
.qtc-sub  { font-size: 11px; color: var(--muted); margin: 0 0 8px; }
.qtc-count { font-size: 12px; color: var(--muted); margin: 0; }

/* Active quiz */
.quiz-active-wrap { max-width: 680px; }
.quiz-active-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.quiz-topic-tag {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
}
.quiz-q-count { font-size: 13px; color: var(--muted); margin-left: auto; }

.quiz-hub-form { display: flex; flex-direction: column; gap: 20px; }

.quiz-q-block {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}
.quiz-q-text {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--ink);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.quiz-q-num {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  min-width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}
.quiz-q-num.num-ok { background: #16a34a; }
.quiz-q-num.num-err { background: #dc2626; }

.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  transition: background .1s;
}
.quiz-option-label:hover { background: var(--surface); }
.quiz-option-label input { margin-top: 2px; flex-shrink: 0; }

.quiz-submit-bar { text-align: center; padding-top: 8px; }

/* Result */
.quiz-result-wrap { max-width: 680px; display: flex; flex-direction: column; gap: 20px; }

.quiz-result-score-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.quiz-score-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 4px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.quiz-score-num { font-size: 28px; font-weight: 800; line-height: 1; }
.quiz-score-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.quiz-grade-label { font-size: 18px; font-weight: 700; margin: 0; }

.quiz-result-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.quiz-result-q {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.quiz-result-q.q-correct { border-color: #bbf7d0; background: #f0fdf4; }
.quiz-result-q.q-wrong   { border-color: #fca5a5; background: #fff8f8; }

.quiz-opt-result {
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
}
.quiz-opt-result.correct { background: #dcfce7; color: #15803d; font-weight: 600; }
.quiz-opt-result.wrong   { background: #fee2e2; color: #dc2626; font-weight: 600; }

.quiz-explanation {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.5;
}

/* Wrong Answer Book */
.wrong-book-wrap { max-width: 680px; }
.wrong-book-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.wrong-topic-section { margin-bottom: 24px; }
.wrong-topic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 14px;
}
.wrong-q-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.wrong-q-text { font-size: 14px; font-weight: 600; margin: 0 0 10px; color: var(--ink); }
.wrong-q-opts { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.wrong-opt {
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
}
.wrong-opt.correct { background: #dcfce7; color: #15803d; font-weight: 600; }
.wrong-opt.wrong   { background: #fee2e2; color: #dc2626; }


/* ============================================================
   PHASE 4 — DIAGNOSIS REPORT
   ============================================================ */
#report { padding: 0 20px 40px; }
#report .section-head { margin-bottom: 20px; }

.diag-warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 4px solid #f97316;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  color: #9a3412;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* Score row */
.diag-score-row {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  position: relative;
}
.diag-readiness-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 5px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.diag-readiness-num { font-size: 30px; font-weight: 800; line-height: 1; }
.diag-readiness-sub { font-size: 10px; color: var(--muted); margin-top: 2px; text-align: center; }
.diag-readiness-label {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 14px;
  font-weight: 700;
}
.diag-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  flex: 1;
  min-width: 280px;
}
.diag-kpi { display: flex; flex-direction: column; align-items: center; text-align: center; }
.diag-kpi-val  { font-size: 22px; font-weight: 800; color: var(--ink); }
.diag-kpi-label { font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }
.diag-kpi-sub  { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* Topic panel */
.diag-topic-panel { margin-bottom: 20px; }
.diag-topic-list { display: flex; flex-direction: column; gap: 10px; }
.diag-topic-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  align-items: center;
  gap: 12px;
}
.diag-topic-meta { display: flex; flex-direction: column; min-width: 0; }
.diag-topic-name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diag-topic-score { font-size: 12px; font-weight: 700; }
.diag-bar-wrap {
  background: #f0f0f0;
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
}
.diag-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width .4s ease;
  min-width: 3px;
}
.diag-video-prog { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Action cards */
.diag-action-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  background: var(--surface);
  border-radius: 10px;
}
.diag-action-icon { font-size: 22px; flex-shrink: 0; margin-top: 2px; }
.diag-action-body { flex: 1; }
.diag-action-body strong { font-size: 14px; display: block; margin-bottom: 4px; }
.diag-action-body p { font-size: 13px; color: var(--muted); margin: 0; }
.diag-action-btn { flex-shrink: 0; }

@media (max-width: 600px) {
  .diag-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .diag-topic-row { grid-template-columns: 1fr 1.5fr auto; }
  .diag-action-card { flex-wrap: wrap; }
}


/* ============================================================
   PROGRESS VIEW
   ============================================================ */
#progress { padding: 0 20px 40px; }

.prog-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.prog-stat-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}
.prog-stat-num   { font-size: 26px; font-weight: 800; color: var(--ink); line-height: 1; }
.prog-stat-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.prog-stat-sub   { font-size: 12px; color: var(--muted); }

.prog-topic-list { display: flex; flex-direction: column; gap: 10px; }
.prog-topic-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
.prog-topic-left { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.prog-topic-names { display: flex; flex-direction: column; }
.prog-topic-names strong { font-size: 13px; color: var(--ink); }
.prog-topic-en   { font-size: 11px; color: var(--muted); }
.pro
/* ══════════════════════════════════════════════
   VOCAB FLASHCARD MODULE  (Phase 5b)
═══════════════════════════════════════════════ */
.vocab-wrap { padding: 0 0 3rem; }

/* ---- filter bar ---- */
.vocab-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
  align-items: center;
}
.vocab-filter-bar select,
.vocab-filter-bar input[type="search"] {
  padding: .45rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  font-size: .85rem;
}
.vocab-filter-bar input[type="search"] { flex: 1; min-width: 160px; }
.vocab-filter-label {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.vocab-stats-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.vocab-stat {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .5rem 1rem;
  font-size: .85rem;
  color: var(--text-muted);
}
.vocab-stat strong { color: var(--text); font-size: 1rem; }

/* ---- card area ---- */
.vocab-card-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.vocab-card-scene {
  width: 100%;
  max-width: 520px;
  height: 280px;
  perspective: 1000px;
  cursor: pointer;
}
.vocab-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.4,0,.2,1);
}
.vocab-card-scene.flipped .vocab-card-inner {
  transform: rotateY(180deg);
}
.vocab-card-front,
.vocab-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: .75rem;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.vocab-card-front {
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: #fff;
}
.vocab-card-back {
  background: var(--card-bg);
  border: 2px solid var(--border);
  transform: rotateY(180deg);
  color: var(--text);
}
.vc-difficulty {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  opacity: .75;
  text-transform: uppercase;
}
.vc-english {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}
.vc-front-topic {
  font-size: .8rem;
  opacity: .8;
}
.vc-hint {
  font-size: .78rem;
  opacity: .6;
  margin-top: .25rem;
}
.vc-chinese {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}
.vc-explanation {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 400px;
}
.vc-example {
  font-size: .78rem;
  color: var(--text-muted);
  font-style: italic;
  border-top: 1px solid var(--border);
  padding-top: .5rem;
  width: 100%;
}
.vc-exam-note {
  font-size: .72rem;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  padding: .25rem .6rem;
}

/* ---- card controls ---- */
.vocab-card-controls {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: center;
}
.vc-btn {
  padding: .55rem 1.2rem;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  background: var(--card-bg);
  color: var(--text);
}
.vc-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.1); }
.vc-btn-know  { background: #22c55e; color: #fff; border-color: #16a34a; }
.vc-btn-unknown { background: #ef4444; color: #fff; border-color: #dc2626; }
.vc-btn-skip  { background: var(--card-bg); color: var(--text-muted); }
.vc-btn-flip  { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- progress bar ---- */
.vocab-progress-row {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .82rem;
  color: var(--text-muted);
}
.vocab-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.vocab-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #6366f1);
  border-radius: 99px;
  transition: width .4s;
}

/* ---- completed banner ---- */
.vocab-done-banner {
  text-align: center;
  padding: 2.5rem 1rem;
  background: var(--card-bg);
  border: 2px dashed var(--border);
  border-radius: 16px;
  max-width: 520px;
  margin: 0 auto;
}
.vocab-done-banner h3 { font-size: 1.5rem; margin-bottom: .5rem; }
.vocab-done-banner p  { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.25rem; }

/* ---- known list ---- */
.vocab-known-section {
  margin-top: 2rem;
}
.vocab-known-section h4 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .75rem;
}
.vocab-known-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.vocab-known-chip {
  background: #dcfce7;
  color: #15803d;
  border-radius: 20px;
  padding: .3rem .8rem;
  font-size: .78rem;
  font-weight: 600;
}
.vocab-unknown-chip {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 20px;
  padding: .3rem .8rem;
  font-size: .78rem;
  font-weight: 600;
}

/* ══════════════════════════════════════════════
   DAILY GOAL WIDGET  (Phase 5c)
═══════════════════════════════════════════════ */
.daily-goal-widget {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
}
.dg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.dg-title {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.dg-streak {
  font-size: .82rem;
  color: #f97316;
  font-weight: 700;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 20px;
  padding: .2rem .6rem;
}
.dg-goals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.dg-goal-item {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: .65rem 1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.dg-goal-item.done {
  border-color: #86efac;
  background: #f0fdf4;
}
.dg-goal-icon { font-size: 1.3rem; }
.dg-goal-text { flex: 1; }
.dg-goal-label { font-size: .8rem; color: var(--text-muted); }
.dg-goal-value { font-size: .95rem; font-weight: 700; color: var(--text); }
.dg-goal-check { font-size: 1.1rem; }
.dg-bar-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .5rem;
}
.dg-bar-label { font-size: .82rem; color: var(--text-muted); width: 80px; }
.dg-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.dg-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .5s;
}
.dg-bar-pct { font-size: .78rem; color: var(--text-muted); width: 34px; text-align: right; }
.dg-motivate {
  text-align: center;
  margin-top: .75rem;
  font-size: .85rem;
  color: var(--text-muted);
  font-style: italic;
}
.dg-actions {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.dg-action-btn {
  flex: 1;
  min-width: 120px;
  padding: .5rem .8rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.dg-action-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ══════════════════════════════════════════════
   TOPIC NOTES  (Phase 5d)
═══════════════════════════════════════════════ */
.topic-notes-area {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px dashed var(--border);
}
.topic-notes-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .35rem;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.topic-note-textarea {
  width: 100%;
  min-height: 72px;
  max-height: 200px;
  padding: .55rem .7rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: .82rem;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
  transition: border-color .15s;
  box-sizing: border-box;
}
.topic-note-textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.topic-note-save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .35rem;
  gap: .5rem;
}
.topic-note-save-btn {
  padding: .3rem .85rem;
  border-radius: 7px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.topic-note-save-btn:hover { opacity: .85; }
.topic-note-status {
  font-size: .72rem;
  color: #15803d;
  opacity: 0;
  transition: opacity .3s;
}
.topic-note-status.visible { opacity: 1; }
.topic-note-char {
  font-size: .72rem;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════
   EXAM COUNTDOWN  (Phase 5e)
═══════════════════════════════════════════════ */
.exam-countdown-card {
  background: linear-gradient(135deg, #1e3a8a 0%, #4f46e5 100%);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.ecc-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
}
.ecc-days {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.02em;
}
.ecc-days-label {
  font-size: .75rem;
  font-weight: 600;
  opacity: .75;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-top: .1rem;
}
.ecc-right {
  flex: 1;
}
.ecc-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .2rem;
}
.ecc-date {
  font-size: .82rem;
  opacity: .75;
  margin-bottom: .6rem;
}
.ecc-phase-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
}
.ecc-phase-badge {
  background: rgba(255,255,255,.2);
  border-radius: 20px;
  padding: .2rem .65rem;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.ecc-urgency {
  opacity: .8;
}
.ecc-progress-row {
  margin-top: .6rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .78rem;
  opacity: .85;
}
.ecc-bar-wrap {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,.25);
  border-radius: 99px;
  overflow: hidden;
}
.ecc-bar-fill {
  height: 100%;
  background: #fff;
  border-radius: 99px;
}
.ecc-no-date {
  background: var(--card-bg);
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 1rem 1.5rem;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.ecc-no-date a {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

/* ── Dark mode component overrides ── */
[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
[data-theme="dark"] .topbar {
  background: rgba(26, 32, 48, 0.92);
  border-color: var(--line);
}
[data-theme="dark"] .panel,
[data-theme="dark"] .topic-card,
[data-theme="dark"] .dashboard-grid article { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .auth-modal-box { background: var(--card-bg); }
[data-theme="dark"] .vocab-card-back { background: var(--card-bg); }
[data-theme="dark"] .quiz-option-label:hover { background: var(--surface); }
[data-theme="dark"] .wrong-q-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .diag-kpi { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .prog-stat-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .daily-goal-widget { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .dg-goal-item { background: var(--bg); }
[data-theme="dark"] .dg-goal-item.done { background: #052e16; border-color: #166534; }
[data-theme="dark"] .topic-note-textarea { background: var(--surface); color: var(--text); }
[data-theme="dark"] .vc-exam-note { background: #422006; color: #fcd34d; }
[data-theme="dark"] .vocab-known-chip { background: #052e16; color: #34d399; }
[data-theme="dark"] .vocab-unknown-chip { background: #450a0a; color: #fb7185; }
[data-theme="dark"] .ecc-no-date { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .sprint-start-card { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .review-note-item { background: var(--surface); }

/* dark mode toggle button */
#dark-toggle {
  background: none;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: .3rem .55rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--ink);
  transition: all .2s;
  line-height: 1;
}
#dark-toggle:hover { background: var(--line); }

/* ══════════════════════════════════════════════
   TOPIC DEEP-DIVE  (Progress view expand)
═══════════════════════════════════════════════ */
.prog-topic-row {
  cursor: pointer;
  transition: background .15s;
  border-radius: 8px;
  padding: 6px 4px;
}
.prog-topic-row:hover { background: var(--surface, #f0f6ff); }
.prog-topic-row.expanded { background: var(--surface, #f0f6ff); }

.prog-topic-expand-icon {
  font-size: .7rem;
  color: var(--text-muted, var(--muted));
  margin-left: .3rem;
  transition: transform .2s;
  display: inline-block;
}
.prog-topic-row.expanded .prog-topic-expand-icon { transform: rotate(180deg); }

.prog-topic-detail {
  display: none;
  padding: .75rem 1rem 1rem;
  margin: 4px 0 8px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #dbe7f3);
  border-radius: 10px;
  font-size: .84rem;
}
.prog-topic-detail.open { display: block; }

.ptd-section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted, var(--muted));
  margin: .6rem 0 .35rem;
}
.ptd-video-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: .5rem; }
.ptd-video-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  padding: 3px 0;
}
.ptd-video-row.done { color: var(--green, #21a67a); }
.ptd-video-row.unavail { color: var(--text-muted, var(--muted)); }

.ptd-quiz-history { display: flex; flex-wrap: wrap; gap: .4rem; }
.ptd-quiz-chip {
  background: var(--surface, #f0f6ff);
  border: 1px solid var(--border, #dbe7f3);
  border-radius: 20px;
  padding: .18rem .6rem;
  font-size: .75rem;
  font-weight: 600;
}
.ptd-quiz-chip.good { background: #dcfce7; color: #15803d; border-color: #86efac; }
.ptd-quiz-chip.bad  { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }

.ptd-note-preview {
  background: var(--surface, #f0f6ff);
  border-radius: 7px;
  padding: .5rem .75rem;
  font-size: .8rem;
  white-space: pre-wrap;
  color: var(--text, #172033);
  max-height: 80px;
  overflow: hidden;
  position: relative;
}
.ptd-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .75rem;
}
.ptd-action-btn {
  padding: .3rem .8rem;
  border-radius: 7px;
  border: 1px solid var(--border, #dbe7f3);
  background: var(--card-bg, #fff);
  color: var(--text, #172033);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.ptd-action-btn:hover {
  background: var(--primary, #2f7cf6);
  color: #fff;
  border-color: var(--primary, #2f7cf6);
}

/* ══════════════════════════════════════════════
   TIMED QUIZ MODE  (Phase 5g)
═══════════════════════════════════════════════ */
.quiz-mode-toggle {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  color: var(--text-muted, var(--muted));
}
.quiz-mode-switch {
  display: flex;
  border: 1.5px solid var(--border, var(--line));
  border-radius: 8px;
  overflow: hidden;
}
.qms-btn {
  padding: .3rem .75rem;
  border: none;
  background: var(--card-bg, #fff);
  color: var(--text-muted, var(--muted));
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.qms-btn.active {
  background: var(--primary, #2f7cf6);
  color: #fff;
}

/* timer bar */
.quiz-timer-bar-wrap {
  height: 5px;
  background: var(--border, #dbe7f3);
  border-radius: 0;
  overflow: hidden;
  margin-bottom: -.5rem;
}
.quiz-timer-bar {
  height: 100%;
  border-radius: 0;
  background: #22c55e;
  transition: width 1s linear, background .5s;
}
.quiz-timer-bar.warn  { background: #f59e0b; }
.quiz-timer-bar.danger{ background: #ef4444; }

/* per-question timer display */
.quiz-q-timer {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  font-weight: 700;
  padding: .25rem .6rem;
  border-radius: 20px;
  background: #f0f6ff;
  color: #1e3a8a;
  transition: all .3s;
}
.quiz-q-timer.warn   { background: #fef3c7; color: #92400e; }
.quiz-q-timer.danger { background: #fee2e2; color: #b91c1c; animation: pulse .5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.6} }

.quiz-active-header-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border, var(--line));
  margin-bottom: .75rem;
}
