/* ==========================================================================
   Hui Kao drill system / style.css  (v4 - colour, restrained)
   Mobile-first, hand-written, no external assets, no emoji characters.
   Owner: visual-designer. Scope: this file only.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* contract tokens (engine only reads --color-primary / --color-line) */
  --color-primary: #58cc02;
  --color-primary-dark: #46a302;
  --color-blue: #1cb0f6;
  --color-blue-dark: #1899d6;
  --color-red: #ff4b4b;
  --color-red-dark: #ea2b2b;
  --color-yellow: #ffc800;
  --color-purple: #ce82ff;
  --color-purple-dark: #a568cc;
  --color-orange: #ff9600;
  --color-orange-dark: #e08600;
  --color-text: #3c3c3c;
  --color-muted: #6f6f6f;
  --color-bg: #ffffff;
  --color-bg-soft: #f7f7f7;
  --color-line: #e5e5e5;
  --radius: 14px;
  --radius-lg: 20px;

  /* neutral ink scale - every step keeps >=4.5:1 on white */
  --ink: #2b2b2b;
  --ink-2: #3c3c3c;
  --ink-3: #5f5f5f;
  --ink-4: #6f6f6f;
  --line: #e5e5e5;
  --bg: #ffffff;
  --bg-soft: #f7f7f7;
  --fill-1: #f7f7f7;
  --fill-2: #f0f0f0;
  --fill-3: #e7e7e7;

  /* tint pairs: soft fill / soft border / readable ink */
  --green-soft: #e9ffd6;
  --green-line: #a5ed6e;
  --green-ink: #3d7a00;
  --blue-soft: #ddf4ff;
  --blue-line: #84d8ff;
  --blue-ink: #0b6c9e;
  --purple-soft: #f4e6ff;
  --purple-line: #ddc0ff;
  --purple-ink: #7b36b8;
  --orange-soft: #fff1dc;
  --orange-line: #ffd08a;
  --orange-ink: #98560a;
  --red-soft: #ffe2e3;
  --red-line: #ffb3b5;
  --red-ink: #bf2424;
  --yellow-soft: #fff7d9;
  --yellow-line: #ffe27a;
  --yellow-ink: #7d5a00;

  /* solid call-to-action: bright green face, darker green edge.
     ink on the face is a near-black green so the label clears 7:1
     (white on #58cc02 is only 2.09:1 and fails outright). */
  --solid: var(--color-primary);
  --solid-fg: #0f2c00;
  --solid-edge: var(--color-primary-dark);

  --code-bg: #f4f4f4;
  --shadow-1: 0 1px 2px rgba(20, 20, 20, 0.05);
  --shadow-2: 0 10px 24px rgba(20, 20, 20, 0.14);
  --tabbar-h: 62px;

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Cascadia Mono", "Courier New", monospace;

  color-scheme: light;
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
p,
figure,
pre {
  margin: 0;
}

b,
strong {
  font-weight: 800;
}

em {
  font-style: normal;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

svg {
  display: block;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
  border-radius: 8px;
}

/* --------------------------------------------------------------------------
   3. Utilities
   -------------------------------------------------------------------------- */
.is-hidden {
  display: none !important;
}

.center {
  text-align: center;
}

.muted {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.7;
  color: var(--ink-4);
  margin-top: 20px;
}

.section-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.2px;
  color: var(--ink);
  margin: 22px 0 11px;
}

.section-title small {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink-4);
}

.page-head {
  margin-bottom: 14px;
}

.page-head h1 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.4px;
  color: var(--ink);
  margin-bottom: 6px;
}

.page-head p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-4);
}

.page-head b {
  color: var(--ink-2);
}

/* --------------------------------------------------------------------------
   4. App shell
   -------------------------------------------------------------------------- */
.app {
  min-height: 100dvh;
}

.main {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px calc(88px + env(safe-area-inset-bottom));
}

body[data-view="drill"] .main {
  padding-bottom: calc(122px + env(safe-area-inset-bottom));
}

body[data-view="drill"]:has(.feedback:not(.is-hidden)) .main {
  padding-bottom: calc(300px + env(safe-area-inset-bottom));
}

@media (min-width: 760px) {
  .main {
    padding: 18px 20px 92px;
  }
}

/* --- top bar -------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px max(16px, calc((100vw - 720px) / 2));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand__mark {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--color-primary);
  color: var(--solid-fg);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 0 var(--color-primary-dark);
}

.brand__name {
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--ink);
  white-space: nowrap;
}

.topbar__stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--fill-1);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-4);
  white-space: nowrap;
}

.pill b {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.pill--sm {
  padding: 4px 9px;
  font-size: 11px;
  border: 1px solid var(--line);
}

.pill--sm b {
  font-size: 11.5px;
  color: var(--green-ink);
}

/* --- bottom tab bar ------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 65;
  margin: 0 auto;
  max-width: 720px;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 14px rgba(20, 20, 20, 0.06);
}

.tab {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 9px 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--ink-4);
  transition: color 0.15s ease;
}

/* inline SVG icons carry no presentation attributes - size + stroke are ours */
.tab__icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke-width 0.15s ease;
}

.tab > span {
  font-size: 11px;
  line-height: 1;
}

.tab.is-active {
  color: var(--green-ink);
}

.tab.is-active .tab__icon {
  stroke-width: 2.5;
}

.tab.is-active > span {
  font-weight: 800;
}

.tab.is-active::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--color-primary);
}

@media (hover: hover) {
  .tab:hover {
    color: var(--ink-2);
  }

  .tab.is-active:hover {
    color: var(--green-ink);
  }
}

/* --------------------------------------------------------------------------
   5. Home hero (green gradient block)
   -------------------------------------------------------------------------- */
.hero-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(150deg, #6ade0a 0%, #58cc02 46%, #46a302 100%);
  color: #ffffff;
  box-shadow: 0 10px 24px -12px rgba(70, 163, 2, 0.8);
}

.hero-card__mark {
  flex: none;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #ffffff;
  color: var(--color-primary-dark);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 1px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}

.hero-card__text {
  flex: 1;
  min-width: 0;
}

.hero-card__text h1 {
  font-size: 17.5px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.hero-card__text p {
  margin-top: 5px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.55;
  color: #f0ffe2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  text-wrap: pretty;
}

/* --------------------------------------------------------------------------
   6. Mode picker (blue / purple / orange)
   -------------------------------------------------------------------------- */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.mode-card {
  --mc: var(--color-blue);
  --mc-soft: var(--blue-soft);
  --mc-line: var(--blue-line);
  --mc-ink: var(--blue-ink);
  --mc-edge: var(--color-blue-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 12px 8px 11px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--mc);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 4px 0 var(--mc-edge);
  text-align: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.mode-card--single {
  --mc: var(--color-blue);
  --mc-soft: var(--blue-soft);
  --mc-line: var(--blue-line);
  --mc-ink: var(--blue-ink);
  --mc-edge: var(--color-blue-dark);
}

.mode-card--multi {
  --mc: var(--color-purple);
  --mc-soft: var(--purple-soft);
  --mc-line: var(--purple-line);
  --mc-ink: var(--purple-ink);
  --mc-edge: var(--color-purple-dark);
}

.mode-card--tf {
  --mc: var(--color-orange);
  --mc-soft: var(--orange-soft);
  --mc-line: var(--orange-line);
  --mc-ink: var(--orange-ink);
  --mc-edge: var(--color-orange-dark);
}

.mode-card:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--mc-edge);
}

@media (hover: hover) {
  .mode-card:hover {
    border-color: var(--mc-line);
    border-top-color: var(--mc);
  }
}

.mode-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
}

.mode-card__icon {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--mc-soft);
  color: var(--mc-ink);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.2px;
}

.mode-card--single .mode-card__icon {
  font-size: 15px;
}

.mode-card--multi .mode-card__icon,
.mode-card--tf .mode-card__icon {
  font-size: 12px;
  letter-spacing: -0.5px;
}

.mode-card__count {
  flex: none;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--fill-1);
  color: var(--ink-4);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mode-card__title {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.2px;
  color: var(--ink);
}

.mode-card__hint {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink-4);
}

.mode-card__stat {
  margin-top: auto;
  padding-top: 8px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink-4);
  overflow-wrap: break-word;
}

/* --- unit chips ----------------------------------------------------------- */
.mode-units {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.unit-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: 0 2px 0 var(--line);
  text-align: left;
  transition: transform 0.08s ease, box-shadow 0.08s ease,
    border-color 0.16s ease;
}

.unit-chip:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--line);
}

@media (hover: hover) {
  .unit-chip:hover {
    border-color: var(--green-line);
  }
}

.unit-chip__idx {
  flex: none;
  min-width: 30px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green-ink);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

.unit-chip__body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.unit-chip__title {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-chip__meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   7. Buttons (3D press)
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  text-align: center;
  user-select: none;
  color: var(--btn-fg, var(--ink));
  background: var(--btn-bg, var(--bg));
  box-shadow: 0 4px 0 var(--btn-edge, var(--line));
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.15s ease,
    background 0.15s ease;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--btn-edge, var(--line));
}

.btn--primary,
.btn--success {
  --btn-bg: var(--solid);
  --btn-fg: var(--solid-fg);
  --btn-edge: var(--solid-edge);
}

.btn--danger {
  --btn-bg: var(--color-red-dark);
  --btn-fg: #ffffff;
  --btn-edge: #b81f1f;
}

.btn--ghost {
  --btn-bg: var(--bg);
  --btn-fg: var(--ink-2);
  --btn-edge: var(--line);
  border: 1.5px solid var(--ink-4);
}

.btn--soft {
  --btn-bg: var(--green-soft);
  --btn-fg: var(--green-ink);
  --btn-edge: var(--green-line);
  border: 1px solid var(--green-line);
}

.btn--sm {
  min-height: 44px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 11px;
  box-shadow: 0 3px 0 var(--btn-edge, var(--line));
}

.btn--sm:active {
  box-shadow: 0 1px 0 var(--btn-edge, var(--line));
}

.btn--lg {
  min-height: 58px;
  padding: 0 22px;
  font-size: 16.5px;
  border-radius: 16px;
  letter-spacing: 0.4px;
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn.is-disabled {
  opacity: 0.55;
  pointer-events: none;
  box-shadow: 0 4px 0 var(--line);
  --btn-bg: var(--fill-2);
  --btn-fg: var(--ink-4);
  --btn-edge: var(--line);
}

@media (hover: hover) {
  .btn:not(.is-disabled):hover {
    filter: brightness(1.05);
  }
}

/* --------------------------------------------------------------------------
   8. Drill view
   -------------------------------------------------------------------------- */
#btn-mix {
  margin-top: 12px;
}

.drill {
  padding: 12px 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg);
  box-shadow: var(--shadow-1);
}

.drill__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  margin-left: -6px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-3);
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:active {
  background: var(--fill-2);
}

@media (hover: hover) {
  .icon-btn:hover {
    background: var(--fill-1);
    color: var(--ink);
  }
}

.drill__mode {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drill__stat {
  flex: none;
  max-width: 60%;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- question ------------------------------------------------------------- */
.lesson__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.q-type {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.q-type[data-type="multi"] {
  background: var(--purple-soft);
  color: var(--purple-ink);
}

.q-type[data-type="tf"] {
  background: var(--orange-soft);
  color: var(--orange-ink);
}

.q-index {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

.q-stem {
  font-size: 18.5px;
  font-weight: 700;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
  text-wrap: pretty;
  margin-bottom: 15px;
}

.q-stem--code {
  padding: 13px 13px 13px 15px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--color-blue);
  border-radius: 10px;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.7;
  letter-spacing: 0.1px;
  overflow-x: auto;
}

/* --- options -------------------------------------------------------------- */
.options {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.options--tf {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  min-height: 54px;
  padding: 11px 12px;
  border: 1.5px solid var(--opt-line, var(--line));
  border-bottom-width: 3px;
  border-bottom-color: var(--opt-edge, var(--line));
  border-radius: 12px;
  background: var(--opt-bg, var(--bg));
  text-align: left;
  transition: transform 0.08s ease, background 0.16s ease,
    border-color 0.16s ease;
}

.option:active {
  transform: translateY(2px);
}

.option__key {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--opt-key-line, var(--line));
  border-radius: 7px;
  background: var(--opt-key-bg, var(--bg));
  color: var(--opt-key-fg, var(--ink-4));
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.option__text {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink-2);
  overflow-wrap: break-word;
  word-break: break-word;
}

.option__mark {
  flex: none;
  width: 19px;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  color: var(--opt-mark, transparent);
}

@media (hover: hover) {
  .option:not(.is-disabled):not(.option--selected):hover {
    --opt-bg: var(--fill-1);
  }
}

/* selected: blue frame, result not judged yet */
.option--selected {
  --opt-bg: var(--blue-soft);
  --opt-line: var(--color-blue);
  --opt-edge: var(--color-blue-dark);
  --opt-key-line: var(--color-blue-dark);
  --opt-key-bg: var(--color-blue);
  --opt-key-fg: #ffffff;
  border-style: solid;
}

/* correct: soft green fill + green frame + tick */
.option--correct {
  --opt-bg: var(--green-soft);
  --opt-line: var(--color-primary);
  --opt-edge: var(--color-primary-dark);
  --opt-key-line: var(--color-primary-dark);
  --opt-key-bg: var(--color-primary);
  --opt-key-fg: #ffffff;
  --opt-mark: var(--green-ink);
  border-style: solid;
}

.option--correct .option__text {
  font-weight: 700;
  color: var(--ink);
}

/* wrong: soft red fill + red frame + cross */
.option--wrong {
  --opt-bg: var(--red-soft);
  --opt-line: var(--color-red);
  --opt-edge: var(--color-red-dark);
  --opt-key-line: var(--color-red-dark);
  --opt-key-bg: var(--color-red);
  --opt-key-fg: #ffffff;
  --opt-mark: var(--red-ink);
  border-style: solid;
}

.option--wrong .option__text {
  color: var(--ink-2);
}

.option--muted {
  opacity: 0.45;
}

.option.is-disabled {
  cursor: default;
  pointer-events: none;
  transform: none;
}

/* --- drill footer (fixed) ------------------------------------------------- */
.lesson__foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  margin: 0 auto;
  max-width: 720px;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 14px rgba(20, 20, 20, 0.06);
}

.lesson__foot .btn--primary,
.lesson__foot .btn--success,
.lesson__foot .btn--danger {
  flex: 1;
}

.lesson__foot .btn--ghost {
  flex: none;
  min-width: 96px;
}

/* --------------------------------------------------------------------------
   9. Feedback bar
   -------------------------------------------------------------------------- */
.feedback {
  --fb-bg: var(--bg);
  --fb-line: var(--line);
  --fb-ink: var(--ink);
  --fb-text: var(--ink-2);
  --fb-icon: var(--ink-3);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  margin: 0 auto;
  max-width: 720px;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--fb-bg);
  border-top: 2px solid var(--fb-line);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 24px rgba(20, 20, 20, 0.14);
  transform: translateY(0);
  animation: feedbackIn 0.28s cubic-bezier(0.22, 0.9, 0.28, 1.1) both;
}

.feedback--ok {
  --fb-bg: #daffc0;
  --fb-line: var(--color-primary);
  --fb-ink: #2f6400;
  --fb-text: #3d6f10;
  --fb-icon: var(--color-primary-dark);
}

.feedback--bad {
  --fb-bg: #ffe2e3;
  --fb-line: var(--color-red);
  --fb-ink: var(--red-ink);
  --fb-text: #8f2b2b;
  --fb-icon: var(--color-red-dark);
}

.feedback__inner {
  padding: 14px 16px 16px;
}

.feedback__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.feedback__icon {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--fb-icon);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: var(--fb-icon);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.feedback__body {
  min-width: 0;
}

.feedback__title {
  display: block;
  font-size: 15.5px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.2px;
  color: var(--fb-ink);
}

.feedback__text {
  margin-top: 3px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--fb-text);
  overflow-wrap: break-word;
}

/* explanation stays neutral so it never fights the green/red feedback fill */
.feedback__explain {
  margin-top: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-4);
  border-radius: 8px;
  background: var(--bg);
}

.feedback__explain-label {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--ink-4);
  border-radius: 4px;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  line-height: 1.6;
}

.feedback__explain-text {
  margin-top: 7px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.65;
  color: var(--ink-2);
  overflow-wrap: break-word;
  max-height: 130px;
  overflow-y: auto;
}

.feedback .btn--block {
  margin-top: 12px;
}

/* engine hides .feedback inside nextQuestion(); keep a belt-and-braces rule */
body:not([data-view="drill"]) .feedback {
  display: none !important;
}

@keyframes feedbackIn {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   10. Round summary
   -------------------------------------------------------------------------- */
.summary {
  padding: 16px 0 8px;
  text-align: center;
}

.summary__badge {
  width: 94px;
  height: 94px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border: 3px solid var(--color-primary);
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green-ink);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
  box-shadow: 0 4px 0 var(--green-line);
}

.summary__title {
  margin-top: 14px;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.4px;
  color: var(--ink);
}

.summary__sub {
  max-width: 440px;
  margin: 8px auto 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-4);
}

.result__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.result__card {
  --accent: var(--color-blue);
  --accent-soft: var(--blue-soft);
  --accent-ink: var(--blue-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px 13px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 12px;
  background: var(--bg);
}

.result__card--ok {
  --accent: var(--color-blue);
  --accent-soft: var(--blue-soft);
  --accent-ink: var(--blue-ink);
}

.result__card--xp {
  --accent: var(--color-primary);
  --accent-soft: var(--green-soft);
  --accent-ink: var(--green-ink);
}

.result__card--bad {
  --accent: var(--color-red);
  --accent-soft: var(--red-soft);
  --accent-ink: var(--red-ink);
}

.result__card--time {
  --accent: var(--color-purple);
  --accent-soft: var(--purple-soft);
  --accent-ink: var(--purple-ink);
}

.result__card span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--ink-4);
}

.result__card b {
  font-size: 23px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.result__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

@media (min-width: 620px) {
  .result__actions {
    flex-direction: row;
  }

  .result__actions .btn {
    flex: 1;
  }
}

/* --------------------------------------------------------------------------
   11. Wrong-answer book
   -------------------------------------------------------------------------- */
.wrong-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 13px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.stat-card__icon {
  flex: none;
  min-width: 26px;
  height: 22px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.2px;
}

/* four tinted icon chips, in order: green / blue / purple / orange */
.stat-card:nth-child(4n + 1) .stat-card__icon {
  background: var(--green-soft);
  color: var(--green-ink);
}

.stat-card:nth-child(4n + 2) .stat-card__icon {
  background: var(--blue-soft);
  color: var(--blue-ink);
}

.stat-card:nth-child(4n + 3) .stat-card__icon {
  background: var(--purple-soft);
  color: var(--purple-ink);
}

.stat-card:nth-child(4n) .stat-card__icon {
  background: var(--orange-soft);
  color: var(--orange-ink);
}

.stat-card__value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-card__label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-4);
}

.stat-card--sm {
  gap: 3px;
  padding: 9px 4px 10px;
  border-radius: 10px;
}

.stat-card--sm .stat-card__icon {
  height: 19px;
  min-width: 21px;
  padding: 0 4px;
  font-size: 9.5px;
}

.stat-card--sm .stat-card__value {
  font-size: 18px;
}

.stat-card--sm .stat-card__label {
  font-size: 10px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-4);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.07s ease, border-color 0.16s ease,
    background 0.16s ease, color 0.16s ease;
}

.chip:active {
  transform: translateY(2px);
}

.chip--active {
  border-color: var(--color-primary-dark);
  border-bottom-color: #357a00;
  background: var(--color-primary);
  color: var(--solid-fg);
}

.quick-actions {
  display: flex;
  gap: 10px;
  margin: 0 0 14px;
}

.quick-actions .btn {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  padding: 0 10px;
  white-space: nowrap;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.review-item {
  padding: 13px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-1);
}

.review-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 9px;
}

.badge {
  flex: none;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.review-item__unit {
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-item__meta {
  margin-left: auto;
  flex: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.review-item__stem {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

.review-item__stem.q-stem--code {
  margin-top: 2px;
  font-size: 12.5px;
  padding: 10px 11px 10px 13px;
}

.review-item__answer {
  margin-top: 9px;
  padding: 8px 10px;
  border-left: 3px solid var(--color-primary);
  border-radius: 0 6px 6px 0;
  background: var(--green-soft);
  color: var(--green-ink);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: break-word;
}

/* explanation under the answer: neutral, quieter than the green answer row */
.review-item__explain {
  margin-top: 8px;
  padding: 9px 10px;
  border-left: 3px solid var(--ink-4);
  border-radius: 0 6px 6px 0;
  background: var(--fill-1);
}

.review-item__explain-label {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--ink-4);
  border-radius: 3px;
  color: var(--ink-3);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  line-height: 1.7;
}

.review-item__explain-text {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.65;
  color: var(--ink-3);
  overflow-wrap: break-word;
}

.review-item__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.empty {
  padding: 42px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg);
  text-align: center;
}

.empty__icon {
  font-size: 34px;
  font-weight: 300;
  line-height: 1;
  color: var(--line);
  margin-bottom: 12px;
}

.empty p {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-4);
}

/* --------------------------------------------------------------------------
   12. Stats
   -------------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.type-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.type-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
}

.type-row__name {
  flex: none;
  width: 76px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.type-row__track {
  flex: 1;
  min-width: 0;
  height: 10px;
  border-radius: 999px;
  background: var(--fill-2);
  overflow: hidden;
}

.type-row__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ce62f, var(--color-primary));
  transition: width 0.5s ease;
}

.type-row__num {
  flex: none;
  min-width: 62px;
  text-align: right;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- 7 day bar chart: fixed track, bars grow from the bottom -------------- */
.bar-chart {
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: 176px;
  padding: 18px 12px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.bar-col {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 6px;
  align-items: end;
  justify-items: center;
}

.bar {
  position: relative;
  align-self: end;
  width: 100%;
  max-width: 32px;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #7ce62f, var(--color-primary));
  transition: height 0.45s ease;
}

.bar__value {
  position: absolute;
  left: 50%;
  top: -17px;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 800;
  color: var(--green-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bar__label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.unit-progress {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.unit-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.unit-row__idx {
  flex: none;
  min-width: 26px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--green-soft);
  color: var(--green-ink);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  font-variant-numeric: tabular-nums;
}

.unit-row__mid {
  flex: 1;
  min-width: 0;
}

.unit-row__title {
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-row__track {
  height: 8px;
  border-radius: 999px;
  background: var(--fill-2);
  overflow: hidden;
}

.unit-row__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ce62f, var(--color-primary));
  transition: width 0.5s ease;
}

.unit-row__num {
  flex: none;
  min-width: 38px;
  text-align: right;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   13. Settings
   -------------------------------------------------------------------------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.setting-row > div {
  min-width: 0;
}

.setting-row b {
  display: block;
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--ink);
}

.setting-row small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink-4);
}

.setting-row--danger {
  border-color: var(--red-line);
  background: #fff6f6;
  box-shadow: inset 3px 0 0 var(--color-red);
}

.switch {
  position: relative;
  flex: none;
  display: inline-block;
  width: 52px;
  height: 30px;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.switch__slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--fill-3);
  transition: background 0.2s ease;
}

.switch__slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(20, 20, 20, 0.3);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch__slider {
  background: var(--color-primary);
}

.switch input:checked + .switch__slider::after {
  transform: translateX(22px);
}

.switch input:focus-visible + .switch__slider {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}

.select {
  flex: none;
  max-width: 150px;
  padding: 9px 11px;
  border: 1.5px solid var(--ink-4);
  border-radius: 11px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   14. Toast
   -------------------------------------------------------------------------- */
.toast-layer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}

body[data-view="drill"] .toast-layer,
body[data-view="summary"] .toast-layer {
  bottom: calc(120px + env(safe-area-inset-bottom));
}

.toast {
  max-width: 400px;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(43, 43, 43, 0.96);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  box-shadow: var(--shadow-2);
  animation: toastIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.toast--out {
  animation: toastOut 0.28s ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(5px);
  }
}

/* --------------------------------------------------------------------------
   15. Responsive tuning
   -------------------------------------------------------------------------- */
@media (max-width: 375px) {
  .mode-units {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 359px) {
  .mode-card {
    padding: 10px 6px 9px;
    gap: 2px;
  }

  .mode-card__title {
    font-size: 12.5px;
  }

  .mode-card__hint,
  .mode-card__stat {
    font-size: 9.5px;
  }

  .mode-card__icon {
    width: 28px;
    height: 28px;
  }

  .q-stem {
    font-size: 17px;
  }

  .option__text {
    font-size: 14.5px;
  }

  .type-row__name {
    width: 66px;
    font-size: 11.5px;
  }

  .type-row__num {
    min-width: 54px;
    font-size: 10.5px;
  }

  .hero-card__text h1 {
    font-size: 15.5px;
  }

  .summary__badge {
    width: 84px;
    height: 84px;
    font-size: 28px;
  }
}

@media (min-width: 480px) {
  .mode-grid {
    gap: 12px;
  }

  .mode-card {
    padding: 14px 10px 13px;
  }

  .mode-card__title {
    font-size: 15px;
  }

  .mode-card__hint {
    font-size: 11px;
  }

  .mode-card__stat {
    font-size: 10.5px;
  }

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

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

@media (min-width: 760px) {
  .hero-card {
    padding: 20px;
    gap: 16px;
  }

  .hero-card__mark {
    width: 64px;
    height: 64px;
    font-size: 16px;
  }

  .hero-card__text h1 {
    font-size: 20px;
  }

  .hero-card__text p {
    font-size: 12.5px;
  }

  .mode-card {
    padding: 16px 12px 14px;
  }

  .mode-card__icon {
    width: 36px;
    height: 36px;
  }

  .mode-card--single .mode-card__icon {
    font-size: 17px;
  }

  .mode-card__title {
    font-size: 16px;
  }

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

  .q-stem {
    font-size: 20px;
  }

  .bar-chart {
    height: 200px;
  }

  .summary__badge {
    width: 108px;
    height: 108px;
    font-size: 38px;
  }

  .summary__title {
    font-size: 27px;
  }

  .brand__mark {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .brand__name {
    font-size: 18px;
  }
}

/* --------------------------------------------------------------------------
   16. Dark mode
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-text: #e6e6e6;
    --color-muted: #9a9a9a;
    --color-line: #333333;
    --color-bg: #1e1e1e;
    --color-bg-soft: #151515;

    --ink: #ededed;
    --ink-2: #dcdcdc;
    --ink-3: #b4b4b4;
    --ink-4: #9a9a9a;
    --line: #333333;
    --bg: #1e1e1e;
    --bg-soft: #151515;
    --fill-1: #262626;
    --fill-2: #2d2d2d;
    --fill-3: #383838;

    --green-soft: #1b3a0c;
    --green-line: #357014;
    --green-ink: #8fe84f;
    --blue-soft: #0e2c3c;
    --blue-line: #1f6a8f;
    --blue-ink: #6fd0ff;
    --purple-soft: #2b1840;
    --purple-line: #5b3a7d;
    --purple-ink: #d9a8ff;
    --orange-soft: #34230a;
    --orange-line: #7a5518;
    --orange-ink: #ffc078;
    --red-soft: #3a1a1a;
    --red-line: #7a2a2a;
    --red-ink: #ff9c9c;
    --yellow-soft: #332b0a;
    --yellow-line: #6b5410;
    --yellow-ink: #ffd75e;

    /* on dark, the CTA stays bright green with near-black text */
    --solid: var(--color-primary);
    --solid-fg: #0f2c00;
    --solid-edge: #3f8a02;

    --code-bg: #181818;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 10px 24px rgba(0, 0, 0, 0.6);

    color-scheme: dark;
  }

  .hero-card {
    background: linear-gradient(150deg, #74e014 0%, #58cc02 46%, #3f8f02 100%);
    box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.8);
  }

  .hero-card__text p {
    color: #e6ffd4;
  }

  .brand__mark {
    color: #0f2c00;
  }

  .feedback--ok {
    --fb-bg: #1d3d0d;
    --fb-ink: #b6f08a;
    --fb-text: #9fdc72;
    --fb-icon: #8fe84f;
  }

  .feedback--bad {
    --fb-bg: #3d1a1a;
    --fb-ink: #ff9c9c;
    --fb-text: #f0a8a8;
    --fb-icon: #ff7a7a;
  }

  .feedback__icon {
    background: rgba(0, 0, 0, 0.35);
  }

  .feedback__explain {
    border-color: var(--line);
    border-left-color: var(--ink-4);
  }

  .summary__badge {
    background: #1b3a0c;
    box-shadow: 0 4px 0 #2a5c10;
  }

  .stat-card__icon {
    color: var(--blue-ink);
  }

  .tab.is-active {
    color: var(--green-ink);
  }

  .chip--active {
    color: #0f2c00;
  }

  .setting-row--danger {
    background: #2a1414;
  }

  .toast {
    background: rgba(238, 238, 238, 0.96);
    color: #1a1a1a;
  }

  .switch__slider::after {
    background: #f2f2f2;
  }

  .switch input:checked + .switch__slider::after {
    background: #ffffff;
  }

  .lesson__foot,
  .tabbar {
    box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.55);
  }

  .feedback {
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6);
  }
}

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

/* --------------------------------------------------------------------------
   18. 小结评级徽章分色（engine 写入 .summary__badge[data-grade]）
   A+ 绿（默认） / B 蓝 / C 橙 / D 红 / 未答 灰
   -------------------------------------------------------------------------- */
.summary__badge[data-grade="B"] {
  border-color: var(--color-blue);
  background: var(--blue-soft);
  color: var(--blue-ink);
  box-shadow: 0 4px 0 var(--blue-line);
}

.summary__badge[data-grade="C"] {
  border-color: var(--color-orange);
  background: var(--orange-soft);
  color: var(--orange-ink);
  box-shadow: 0 4px 0 var(--orange-line);
}

.summary__badge[data-grade="D"] {
  border-color: var(--color-red);
  background: var(--red-soft);
  color: var(--red-ink);
  box-shadow: 0 4px 0 var(--red-line);
}

.summary__badge[data-grade="none"] {
  border-color: var(--color-line);
  background: var(--color-bg-soft);
  color: var(--color-muted);
  box-shadow: 0 4px 0 var(--color-line);
}

