/* ===================================================================
   PTE 79+ Trainer — component library
   =================================================================== */

/* =============== SIDEBAR NAV =============== */
.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--nav);
  border-right: 1px solid var(--border);
  z-index: var(--z-sticky);
}

.sidebar__brand {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-5) var(--s-4) var(--s-4);
  flex: none;
}
.sidebar__logo {
  width: 34px; height: 34px; flex: none;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--skill-speaking), var(--skill-listening));
  color: #fff; font-weight: 800; font-size: var(--fs-sm);
  letter-spacing: -.03em;
  box-shadow: var(--shadow-2);
}
.sidebar__wordmark { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sidebar__wordmark b { font-size: var(--fs-base); font-weight: 700; }
.sidebar__wordmark span { font-size: var(--fs-xs); color: var(--text-3); }

.sidebar__nav {
  flex: 1; overflow-y: auto;
  padding: var(--s-2) var(--s-3) var(--s-4);
  display: flex; flex-direction: column; gap: 1px;
}
.sidebar__group {
  padding: var(--s-4) var(--s-3) var(--s-2);
  font-size: var(--fs-xs); font-weight: 650;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3);
}

.navlink {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--fs-base); font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
  text-align: left; width: 100%;
}
.navlink:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.navlink[aria-current="page"] {
  background: var(--accent-sunk);
  color: var(--accent);
  font-weight: 600;
}
.navlink[aria-current="page"]::before {
  content: ""; position: absolute; left: -var(--s-3); left: -12px;
  top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.navlink__icon { flex: none; width: 18px; height: 18px; opacity: .85; }
.navlink__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navlink__badge {
  flex: none; font-size: var(--fs-xs); font-weight: 700;
  padding: 1px 6px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-2);
}
.navlink__badge--live { background: var(--danger); color: #fff; }

.sidebar__foot { flex: none; padding: var(--s-3); border-top: 1px solid var(--border-soft); }

/* User switcher */
.userpick {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; padding: var(--s-2);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.userpick:hover { background: var(--hover); }
.userpick__meta { flex: 1; min-width: 0; text-align: left; line-height: 1.25; }
.userpick__meta b { display: block; font-size: var(--fs-base); font-weight: 600; }
.userpick__meta span { font-size: var(--fs-xs); color: var(--text-3); }

.avatar {
  flex: none; width: 30px; height: 30px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  font-size: var(--fs-sm); font-weight: 700; color: #fff;
  letter-spacing: -.02em;
}
.avatar--lg { width: 46px; height: 46px; font-size: var(--fs-md); }
.avatar--xl { width: 64px; height: 64px; font-size: var(--fs-xl); }

@media (max-width: 1000px) {
  .sidebar__wordmark, .navlink__label, .userpick__meta, .sidebar__group { display: none; }
  .sidebar__brand { justify-content: center; padding: var(--s-4) 0; }
  .navlink { justify-content: center; padding: var(--s-3) 0; }
  .navlink[aria-current="page"]::before { display: none; }
  .userpick { justify-content: center; }
}
@media (max-width: 720px) {
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0;
    height: auto; flex-direction: row;
    border-right: none; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar__brand, .sidebar__foot { display: none; }
  .sidebar__nav {
    flex-direction: row; overflow-x: auto; padding: var(--s-2);
    gap: var(--s-1);
  }
  .navlink { min-width: 54px; }
  body { padding-bottom: 64px; }
}

/* =============== CARD =============== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.card--flush { padding: 0; overflow: hidden; }
.card--sunk { background: var(--surface-2); }
.card--raise { box-shadow: var(--shadow-2); }
.card--pad-lg { padding: var(--s-6) var(--s-8); }

.card__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-4); margin-bottom: var(--s-4);
}
.card__title { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-md); font-weight: 650; }
.card__sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }
.card__foot {
  margin-top: var(--s-4); padding-top: var(--s-4);
  border-top: 1px solid var(--border-soft);
}

/* Clickable card */
.card--link {
  display: block; text-align: left; width: 100%;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.card--link:hover {
  border-color: var(--border-loud);
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  text-decoration: none;
}
.card--link:active { transform: translateY(0); }

/* =============== GRID =============== */
.grid { display: grid; gap: var(--s-4); }
.grid--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid--auto-lg { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid--sidebar-r { grid-template-columns: minmax(0,1fr) 320px; }

@media (max-width: 1000px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid--sidebar-r { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
}

/* =============== BUTTON =============== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-base); font-weight: 550;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast),
              transform var(--t-fast), opacity var(--t-fast);
}
.btn:hover { background: var(--hover); border-color: var(--border-loud); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; transform: none; background: var(--surface-2); }

.btn--primary {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-text); font-weight: 600;
}
.btn--primary:hover { background: var(--accent-hov); border-color: var(--accent-hov); }
.btn--primary:disabled { background: var(--accent); border-color: var(--accent); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--hover); border-color: transparent; color: var(--text); }

.btn--danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn--ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn--ok:hover { filter: brightness(1.08); }

.btn--lg { min-height: 46px; padding: var(--s-3) var(--s-6); font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn--sm { min-height: 28px; padding: var(--s-1) var(--s-3); font-size: var(--fs-sm); }
.btn--icon { padding: var(--s-2); min-width: 36px; }
.btn--block { width: 100%; }
.btn__icon { width: 16px; height: 16px; flex: none; }
.btn__kbd {
  font-size: var(--fs-xs); font-family: var(--ff-mono);
  opacity: .6; padding-left: var(--s-1);
}

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); margin-left: 0; }
.btn-group .btn:last-child  { border-radius: 0 var(--r-md) var(--r-md) 0; }

/* Segmented control */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
}
.segmented__opt {
  padding: var(--s-1) var(--s-3);
  border-radius: calc(var(--r-md) - 3px);
  font-size: var(--fs-sm); font-weight: 550; color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.segmented__opt:hover { color: var(--text); }
.segmented__opt[aria-pressed="true"] {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-1); font-weight: 600;
}

/* =============== FORM =============== */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field__hint { font-size: var(--fs-xs); color: var(--text-3); }
.field__error { font-size: var(--fs-xs); color: var(--danger); font-weight: 550; }

.input, .select, .textarea {
  width: 100%;
  padding: var(--s-2) var(--s-3);
  min-height: 36px;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent); background: var(--surface);
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.select {
  appearance: none;
  padding-right: var(--s-8);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%236f7d8c' d='M6 8.5 2 4.5h8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
}

.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }

/* The writing-task editor: bigger, calmer, exam-like */
.textarea--compose {
  min-height: 240px;
  font-size: var(--fs-md);
  line-height: 1.7;
  padding: var(--s-4);
  background: var(--surface);
}
.textarea--compose:focus { background: var(--surface); }

.checkbox, .radio {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  background: var(--surface);
}
.checkbox:hover, .radio:hover { background: var(--hover); border-color: var(--border); }
.checkbox input, .radio input { margin: 3px 0 0; flex: none; accent-color: var(--accent); width: 16px; height: 16px; }
.checkbox--on, .radio--on { border-color: var(--accent); background: var(--accent-sunk); }
.checkbox__body, .radio__body { flex: 1; min-width: 0; line-height: 1.5; }

/* Option feedback states (after an answer is checked) */
.opt--correct   { border-color: var(--ok) !important;     background: var(--ok-bg) !important; }
.opt--wrong     { border-color: var(--danger) !important; background: var(--danger-bg) !important; }
.opt--missed    { border-color: var(--warn) !important;   background: var(--warn-bg) !important;
                  border-style: dashed !important; }
.opt__tag {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; margin-left: auto; flex: none; padding-left: var(--s-2);
}

/* =============== BADGE / PILL / TAG =============== */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 2px var(--s-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 650;
  letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
}
.badge--ok     { background: var(--ok-bg);     color: var(--ok); }
.badge--warn   { background: var(--warn-bg);   color: var(--warn); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info   { background: var(--info-bg);   color: var(--info); }
.badge--accent { background: var(--accent-sunk); color: var(--accent); }
.badge--solid  { background: var(--text); color: var(--bg); }

.badge--speaking  { background: color-mix(in srgb, var(--skill-speaking) 16%, transparent);  color: var(--skill-speaking); }
.badge--writing   { background: color-mix(in srgb, var(--skill-writing) 16%, transparent);   color: var(--skill-writing); }
.badge--reading   { background: color-mix(in srgb, var(--skill-reading) 16%, transparent);   color: var(--skill-reading); }
.badge--listening { background: color-mix(in srgb, var(--skill-listening) 16%, transparent); color: var(--skill-listening); }

.pill {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 550;
  background: var(--surface);
}

.dot { width: 8px; height: 8px; border-radius: var(--r-full); flex: none; background: var(--text-3); }
.dot--pulse { animation: dotPulse 1.4s ease-in-out infinite; }
@keyframes dotPulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%     { opacity: .45; transform: scale(.8); }
}

/* =============== SCORE DIAL (the hero number) =============== */
.dial { position: relative; display: inline-grid; place-items: center; }
.dial svg { transform: rotate(-90deg); display: block; }
.dial__track { fill: none; stroke: var(--surface-3); }
.dial__fill {
  fill: none; stroke-linecap: round;
  transition: stroke-dashoffset var(--t-slow), stroke var(--t-base);
}
.dial__mid {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  line-height: 1;
}
.dial__value { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.03em; }
.dial__label {
  font-size: var(--fs-xs); color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; font-weight: 650;
}
.dial--lg .dial__value { font-size: var(--fs-4xl); }
.dial--sm .dial__value { font-size: var(--fs-lg); }

/* =============== SKILL METER (horizontal bar to 79 target) =============== */
.meter { display: flex; flex-direction: column; gap: var(--s-2); padding-bottom: 14px; }
.meter__top {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2);
  font-size: var(--fs-sm);
}
/* long task names must not shove the score off the row */
.meter__name {
  font-weight: 600; display: flex; align-items: center; gap: var(--s-2);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.meter__name .dot { flex: none; }
.meter__num { font-weight: 700; font-size: var(--fs-md); }
.meter__delta { font-size: var(--fs-xs); font-weight: 650; }

.meter__track {
  position: relative; height: 9px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: visible;
}
.meter__fill {
  position: absolute; inset: 0 auto 0 0;
  border-radius: var(--r-full);
  transition: width var(--t-slow);
  min-width: 4px;
}
/* the per-skill goal line — the most important mark in this app. The number
   is supplied by JS via --goal-label, because each skill now has a DIFFERENT
   target (it used to be a hardcoded "79"). */
.meter__goal {
  position: absolute; top: -4px; bottom: -4px;
  width: 2px; border-radius: 2px;
  background: var(--text); opacity: .55;
}
.meter__goal::after {
  content: var(--goal-label, "");
  /* BELOW the track: above it, a tick near the right end landed on top of the
     score/delta readout (e.g. "37 ▼17" overlapping "88") */
  position: absolute; top: 100%; margin-top: 5px;
  left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 750; color: var(--text-3); letter-spacing: .04em;
  font-family: var(--ff-mono);
}
/* nudge inboard at the extremes so the number never clips the track edge */
.meter__goal--near-end::after { left: auto; right: 0; transform: none; }
.meter__goal--near-start::after { left: 0; transform: none; }
.meter__scale {
  display: flex; justify-content: space-between;
  font-size: 9px; color: var(--text-3); font-weight: 600;
}

/* =============== STAT TILE =============== */
.stat {
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
}
.stat__label {
  font-size: var(--fs-xs); font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-3);
  display: flex; align-items: center; gap: var(--s-2);
}
.stat__value {
  font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.03em;
  line-height: 1.1;
}
.stat__value small { font-size: var(--fs-md); font-weight: 600; color: var(--text-3); letter-spacing: 0; }
.stat__foot { font-size: var(--fs-xs); color: var(--text-2); }
.stat__spark { margin-top: var(--s-1); height: 28px; }

.trend { display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-xs); font-weight: 700; }
.trend--up   { color: var(--ok); }
.trend--down { color: var(--danger); }
.trend--flat { color: var(--text-3); }

/* =============== PROGRESS BAR =============== */
.bar {
  height: 6px; background: var(--surface-3);
  border-radius: var(--r-full); overflow: hidden;
}
.bar__fill {
  height: 100%; background: var(--accent);
  border-radius: var(--r-full);
  transition: width var(--t-base);
}
.bar--thick { height: 10px; }

/* =============== COUNTDOWN / TIMER =============== */
.timer {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  font-family: var(--ff-mono);
  font-size: var(--fs-base); font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.timer--warn   { background: var(--warn-bg);   color: var(--warn);   border-color: transparent; }
.timer--danger {
  background: var(--danger-bg); color: var(--danger); border-color: transparent;
  animation: timerPulse .9s ease-in-out infinite;
}
@keyframes timerPulse { 50% { opacity: .55; } }

/* Ring countdown used during prep/record phases */
.ring-timer { position: relative; width: 74px; height: 74px; flex: none; }
.ring-timer svg { transform: rotate(-90deg); }
.ring-timer__track { fill: none; stroke: var(--surface-3); stroke-width: 6; }
.ring-timer__fill {
  fill: none; stroke-width: 6; stroke-linecap: round;
  stroke: var(--accent);
  transition: stroke-dashoffset 1s linear, stroke var(--t-base);
}
.ring-timer__mid {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--ff-mono); font-size: var(--fs-lg); font-weight: 700;
}

/* =============== AUDIO: waveform + mic =============== */
.recorder {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-5);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
}
.recorder__status {
  display: flex; align-items: center; gap: var(--s-3);
  font-size: var(--fs-sm); font-weight: 600;
}

.wave {
  height: 68px; width: 100%;
  border-radius: var(--r-md);
  background: var(--bg-sunk);
  display: block;
}
.wave--live { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 35%, transparent); }

/* Volume "are they loud enough" indicator — a real problem in PTE */
.vol { display: flex; align-items: center; gap: 3px; height: 20px; }
.vol__seg {
  width: 5px; border-radius: 2px; background: var(--surface-3);
  transition: background 90ms linear, height 90ms linear;
}
.vol__seg--on { background: var(--ok); }
.vol__seg--hot { background: var(--warn); }
.vol__seg--clip { background: var(--danger); }

.mic-btn {
  width: 62px; height: 62px; flex: none;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  border: none;
  box-shadow: var(--shadow-2);
  transition: transform var(--t-fast), background var(--t-base);
}
.mic-btn:hover { transform: scale(1.05); }
.mic-btn--rec { background: var(--danger); animation: micPulse 1.6s ease-out infinite; }
@keyframes micPulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent); }
  100% { box-shadow: 0 0 0 20px transparent; }
}
.mic-btn:disabled { background: var(--surface-3); color: var(--text-3); box-shadow: none; }

/* Audio player for TTS-driven listening tasks */
.player {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
}
.player__btn {
  width: 44px; height: 44px; flex: none;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text);
  transition: background var(--t-fast), transform var(--t-fast);
}
.player__btn:hover { background: var(--hover); transform: scale(1.06); }
.player__btn--primary { background: var(--accent); color: #fff; }
.player__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.player__meta { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-3); }

/* Equaliser bars shown while TTS is speaking — the visual cue that audio is live */
.eq { display: flex; align-items: flex-end; gap: 2px; height: 22px; }
.eq span {
  width: 3px; background: var(--skill-listening);
  border-radius: 2px; height: 20%;
}
.eq--on span { animation: eqBounce .9s ease-in-out infinite; }
.eq--on span:nth-child(1) { animation-delay: 0s; }
.eq--on span:nth-child(2) { animation-delay: .12s; }
.eq--on span:nth-child(3) { animation-delay: .24s; }
.eq--on span:nth-child(4) { animation-delay: .36s; }
.eq--on span:nth-child(5) { animation-delay: .18s; }
.eq--on span:nth-child(6) { animation-delay: .06s; }
@keyframes eqBounce { 0%,100% { height: 20%; } 50% { height: 100%; } }

/* =============== WORD-LEVEL FEEDBACK (the core learning surface) =============== */
.diff {
  font-size: var(--fs-md); line-height: 2.1;
  display: flex; flex-wrap: wrap; gap: 4px 5px;
  padding: var(--s-4);
  background: var(--bg-sunk);
  border-radius: var(--r-md);
}
.w {
  padding: 1px 5px; border-radius: var(--r-sm);
  position: relative;
  transition: background var(--t-fast);
}
.w--hit   { background: color-mix(in srgb, var(--ok) 20%, transparent);     color: var(--text); }
.w--near  { background: color-mix(in srgb, var(--warn) 24%, transparent);   color: var(--text);
            text-decoration: underline; text-decoration-style: wavy;
            text-decoration-color: var(--warn); text-underline-offset: 3px; }
.w--miss  { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger);
            text-decoration: line-through; text-decoration-thickness: 2px; }
.w--extra { background: var(--surface-3); color: var(--text-3); font-style: italic; }
.w--sub   { background: color-mix(in srgb, var(--danger) 14%, transparent); }

/* what they actually said, shown under a missed word */
.w__said {
  display: block;
  font-size: 10px; font-weight: 600; font-family: var(--ff-mono);
  color: var(--danger); opacity: .85;
  text-decoration: none; margin-top: -4px;
}

.legend { display: flex; flex-wrap: wrap; gap: var(--s-4); font-size: var(--fs-xs); color: var(--text-2); }
.legend__item { display: flex; align-items: center; gap: var(--s-2); }
.legend__swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }

/* =============== SELECTABLE TEXT (Highlight Incorrect Words) =============== */
.picktext {
  font-size: var(--fs-exam); line-height: var(--lh-exam);
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
}
.pickword {
  cursor: pointer; padding: 1px 3px; border-radius: 4px;
  transition: background var(--t-fast);
  border-bottom: 2px solid transparent;
}
.pickword:hover { background: var(--hover); }
.pickword--on {
  background: var(--accent-sunk); color: var(--accent);
  border-bottom-color: var(--accent); font-weight: 600;
}
.pickword--right { background: var(--ok-bg); color: var(--ok); border-bottom-color: var(--ok); font-weight: 600; }
.pickword--wrong { background: var(--danger-bg); color: var(--danger); border-bottom-color: var(--danger); }
.pickword--should { background: var(--warn-bg); color: var(--warn); border-bottom-color: var(--warn);
                    border-bottom-style: dashed; font-weight: 600; }

/* =============== BLANKS (fill-in-the-blank inline) =============== */
.blanktext { font-size: var(--fs-exam); line-height: 2.4; }

.blank {
  display: inline-block; min-width: 116px;
  padding: 3px var(--s-2); margin: 0 3px;
  border: none; border-bottom: 2px solid var(--border-loud);
  background: var(--surface-2);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  text-align: center; font-weight: 600;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.blank:focus { border-bottom-color: var(--accent); background: var(--accent-sunk); outline: none; }
.blank--filled { border-bottom-color: var(--accent); }
.blank--right { border-bottom-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.blank--wrong { border-bottom-color: var(--danger); background: var(--danger-bg); color: var(--danger); }

/* Drop-target blank for drag-and-drop R&W FIB */
.blank-drop {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 130px; min-height: 30px;
  padding: 2px var(--s-2); margin: 0 3px;
  border: 2px dashed var(--border-loud);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  vertical-align: middle;
  font-weight: 600;
  transition: all var(--t-fast);
}
.blank-drop--over { border-color: var(--accent); background: var(--accent-sunk); transform: scale(1.04); }
.blank-drop--filled { border-style: solid; border-color: var(--accent); background: var(--accent-sunk); }
.blank-drop--right { border-style: solid; border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.blank-drop--wrong { border-style: solid; border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }

/* Word bank of draggable options */
.wordbank { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  padding: var(--s-2) var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-weight: 600; font-size: var(--fs-base);
  cursor: grab;
  user-select: none;
  transition: all var(--t-fast);
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip:active { cursor: grabbing; }
.chip--used { opacity: .3; pointer-events: none; }
.chip--drag { opacity: .5; }

/* =============== REORDER (drag list) =============== */
.reorder { display: flex; flex-direction: column; gap: var(--s-2); }
.reorder__item {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: grab;
  line-height: 1.6;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.reorder__item:hover { border-color: var(--border-loud); }
.reorder__item--drag { opacity: .4; }
.reorder__item--over { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-sunk); }
.reorder__item--right { border-color: var(--ok); background: var(--ok-bg); }
.reorder__item--wrong { border-color: var(--danger); background: var(--danger-bg); }
.reorder__grip { flex: none; color: var(--text-3); cursor: grab; padding-top: 2px; }
.reorder__ord {
  flex: none; width: 24px; height: 24px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 750;
}
.reorder__zone {
  min-height: 60px; padding: var(--s-3);
  border: 2px dashed var(--border); border-radius: var(--r-md);
  display: grid; place-items: center;
  color: var(--text-3); font-size: var(--fs-sm);
}

/* =============== TIP / CALLOUT =============== */
.tip {
  display: flex; gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  border-left: 3px solid var(--accent);
  background: var(--accent-sunk);
  font-size: var(--fs-base); line-height: 1.6;
}
.tip__icon { flex: none; font-size: var(--fs-md); line-height: 1.4; }
.tip__body { flex: 1; min-width: 0; }
.tip__body b { display: block; margin-bottom: 2px; }
.tip--ok     { border-left-color: var(--ok);     background: var(--ok-bg); }
.tip--warn   { border-left-color: var(--warn);   background: var(--warn-bg); }
.tip--danger { border-left-color: var(--danger); background: var(--danger-bg); }
.tip--info   { border-left-color: var(--info);   background: var(--info-bg); }
.tip--plain  { border-left-color: var(--border-loud); background: var(--surface-2); }

/* Live coaching hint that appears during a task */
.coach {
  position: relative;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  font-size: var(--fs-sm);
  animation: coachIn var(--t-base) both;
}
@keyframes coachIn { from { opacity: 0; transform: translateX(-6px); } }
.coach--good { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-bg); }
.coach--bad  { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-bg); }
.coach--warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-bg); }

/* =============== TABLE =============== */
.table { font-size: var(--fs-base); }
.table th {
  text-align: left; font-size: var(--fs-xs); font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: var(--s-3);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table--num td:not(:first-child), .table--num th:not(:first-child) { text-align: right; }

/* =============== MODAL =============== */
.scrim {
  position: fixed; inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  z-index: var(--z-overlay);
  display: grid; place-items: center;
  padding: var(--s-4);
  animation: fadeIn var(--t-base);
}
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
  z-index: var(--z-modal);
  animation: modalIn var(--t-slow) both;
}
.modal--lg { max-width: 820px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.modal__head {
  padding: var(--s-5) var(--s-6) var(--s-3);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
}
.modal__body { padding: 0 var(--s-6) var(--s-5); }
.modal__foot {
  padding: var(--s-4) var(--s-6) var(--s-5);
  display: flex; justify-content: flex-end; gap: var(--s-3);
  flex-wrap: wrap;
}

/* =============== TOAST =============== */
.toasts {
  position: fixed; bottom: var(--s-6); right: var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-2);
  z-index: var(--z-toast);
  pointer-events: none;
  max-width: 380px;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  font-size: var(--fs-sm);
  animation: toastIn var(--t-slow) both;
  pointer-events: auto;
}
.toast--ok     { border-left-color: var(--ok); }
.toast--warn   { border-left-color: var(--warn); }
.toast--danger { border-left-color: var(--danger); }
.toast--out { animation: toastOut var(--t-base) both; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(16px); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(16px); height: 0; margin: 0; padding: 0; } }

@media (max-width: 720px) {
  .toasts { left: var(--s-3); right: var(--s-3); bottom: 76px; max-width: none; }
}

/* =============== EMPTY STATE =============== */
.empty {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--s-3); padding: var(--s-12) var(--s-6);
  text-align: center; color: var(--text-2);
}
.empty__icon { font-size: var(--fs-3xl); opacity: .5; }
.empty h4 { color: var(--text); }
.empty p { max-width: 44ch; font-size: var(--fs-sm); }

/* =============== TOOLTIP =============== */
.tt { position: relative; }
.tt::after {
  content: attr(data-tt);
  position: absolute; bottom: calc(100% + 7px); left: 50%;
  transform: translateX(-50%) translateY(3px);
  padding: var(--s-2) var(--s-3);
  background: var(--text); color: var(--bg);
  font-size: var(--fs-xs); font-weight: 550; line-height: 1.4;
  border-radius: var(--r-sm);
  white-space: pre-line; width: max-content; max-width: 260px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
  z-index: var(--z-toast);
  box-shadow: var(--shadow-2);
  text-align: left;
}
.tt:hover::after, .tt:focus-visible::after { opacity: 1; transform: translateX(-50%); }

/* =============== KEY HINT =============== */
kbd {
  display: inline-block;
  padding: 1px 5px; min-width: 18px; text-align: center;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-size: 11px; font-weight: 650; font-family: var(--ff-sans);
  color: var(--text-2);
}

/* =============== SKELETON =============== */
.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skel 1.3s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes skel { to { background-position: -200% 0; } }
