﻿/* ============================================================ tokens ===== */

:root {
  color-scheme: light;

  --plane: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f2f1ed;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --ring: rgba(42, 120, 214, 0.35);

  /* categorical slots 1-2 (validated all-pairs, light) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  /* meter track: a lighter step of the fill's own blue ramp (blue-100) */
  --meter-track: #cde2fb;

  /* status palette - reserved, always shipped with an icon + label */
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --success-text: #006300;

  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px rgba(11, 11, 11, 0.04);
  --radius: 14px;
  --radius-sm: 9px;

  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --ring: rgba(57, 135, 229, 0.45);
    --series-1: #3987e5;
    --series-2: #d95926;
    --meter-track: #0d366b; /* blue-700: recedes against the dark surface */
    --success-text: #0ca30c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --ring: rgba(57, 135, 229, 0.45);
  --series-1: #3987e5;
  --series-2: #d95926;
  --meter-track: #0d366b; /* blue-700: recedes against the dark surface */
  --success-text: #0ca30c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ============================================================== base ===== */

* {
  box-sizing: border-box;
}

/* component classes below set display, which would otherwise beat the UA's
 * [hidden] rule and leave "hidden" elements on screen */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--plane);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.4rem;
}
h2 {
  font-size: 1.05rem;
}
h3 {
  font-size: 0.9rem;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================ topbar ===== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  white-space: nowrap;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
}

.brand__mark svg {
  display: block;
  border-radius: 6px;
}

.tabs {
  display: flex;
  gap: 2px;
  margin-left: auto;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 11px;
}

.tab {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
}

.tab:hover {
  color: var(--text-primary);
}

.tab[aria-current='page'] {
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.topbar__actions {
  display: flex;
  gap: 6px;
}

/* ------ level badge (always visible in the top bar) ------ */

.levelbadge {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 11px 4px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  white-space: nowrap;
  transition: border-color 0.12s, background 0.12s;
}

.levelbadge:hover {
  border-color: var(--series-1);
  background: var(--surface-2);
}

.levelbadge__code {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--series-1);
}

.levelbadge__meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.levelbadge__count {
  font-size: 0.66rem;
  color: var(--muted);
  line-height: 1;
}

.levelbadge__track {
  display: block;
  width: 74px;
  height: 4px;
  border-radius: 999px;
  background: var(--meter-track);
  overflow: hidden;
}

.levelbadge__fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--series-1);
  transition: width 0.35s ease;
}

@media (max-width: 860px) {
  .levelbadge__meta {
    display: none;
  }
}

/* ------ level card on the stats page ------ */

.levelcard__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.levelcard__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 2px;
}

.levelcard__code {
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.levelcard__name {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.levelcard__blurb {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
  max-width: 46ch;
  line-height: 1.6;
}

.levelcard__count {
  text-align: right;
}

.levelcard__progress {
  margin-top: 16px;
}

.levelcard__progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.83rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* the whole ladder, so the next rung is always visible */
.levelscale {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  overflow-x: auto;
}

.levelscale__step {
  flex: 1;
  min-width: 58px;
  text-align: center;
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  opacity: 0.55;
}

.levelscale__step--done {
  opacity: 1;
  border-color: transparent;
  background: color-mix(in srgb, var(--series-1) 16%, transparent);
}

.levelscale__step--now {
  opacity: 1;
  border-color: var(--series-1);
  background: color-mix(in srgb, var(--series-1) 12%, transparent);
}

.levelscale__code {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
}

.levelscale__at {
  display: block;
  font-size: 0.66rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: 9px;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
}

.icon-btn:hover {
  color: var(--text-primary);
}

/* =============================================================== app ===== */

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px 20px 90px;
}

.loading {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
}

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

.view-head p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card__sub {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 2px 0 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

/* =========================================================== controls ==== */

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--series-1);
  border-color: transparent;
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--series-1) 88%, #000);
}

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

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text-primary);
}

.btn--sm {
  min-height: 30px;
  padding: 0 11px;
  font-size: 0.82rem;
}

.btn--danger {
  color: var(--critical);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field > label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input,
select.input,
textarea.input {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input:focus {
  outline: none;
  border-color: var(--series-1);
  box-shadow: 0 0 0 3px var(--ring);
}

.input::placeholder {
  color: var(--muted);
}

textarea.input {
  min-height: 88px;
  resize: vertical;
  line-height: 1.55;
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 10px;
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
}

.seg button[aria-pressed='true'] {
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ==================================================== confidence chips === */
/*
 * Confidence is a status scale (needs work / getting there / solid), so it uses
 * the reserved status palette. Colour never carries it alone - every chip and
 * every chart segment ships an icon and a text label.
 */

.conf-set {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.conf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.conf-btn .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.conf-btn .glyph {
  font-size: 0.95em;
  line-height: 1;
}

.conf-btn:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}

.conf-btn[aria-pressed='true'] {
  color: var(--text-primary);
  background: var(--surface-2);
  border-color: currentColor;
}

.conf-0 .dot,
.dot--conf-0 {
  background: var(--critical);
}
.conf-1 .dot,
.dot--conf-1 {
  background: var(--warning);
}
.conf-2 .dot,
.dot--conf-2 {
  background: var(--good);
}

.conf-btn.conf-0[aria-pressed='true'] {
  border-color: var(--critical);
  box-shadow: inset 0 0 0 1px var(--critical);
}
.conf-btn.conf-1[aria-pressed='true'] {
  border-color: var(--warning);
  box-shadow: inset 0 0 0 1px var(--warning);
}
.conf-btn.conf-2[aria-pressed='true'] {
  border-color: var(--good);
  box-shadow: inset 0 0 0 1px var(--good);
}

.conf-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.conf-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ========================================================== add form ===== */

.addbar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

@media (max-width: 720px) {
  .addbar {
    grid-template-columns: 1fr;
  }
}

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

/* accent bar - inserts Spanish characters a US keyboard can't type directly */

.accentbar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.accentbar__label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-right: 2px;
}

.accent-key {
  min-width: 32px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, transform 0.06s;
}

.accent-key:hover {
  background: var(--surface-2);
  border-color: var(--axis);
}

.accent-key:active {
  transform: translateY(1px);
}

.accent-key--target {
  border-style: dashed;
  color: var(--muted);
  cursor: default;
  font-size: 0.75rem;
  padding: 0 9px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

.chip {
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}

.chip:hover {
  border-style: solid;
  color: var(--text-primary);
  background: var(--surface-2);
}

/* ========================================================== word list ==== */

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .input {
  max-width: 260px;
}

.toolbar__spacer {
  margin-left: auto;
}

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

.word {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: center;
}

.word--conf-0 {
  border-left-color: var(--critical);
}
.word--conf-1 {
  border-left-color: var(--warning);
}
.word--conf-2 {
  border-left-color: var(--good);
}

.word__text {
  min-width: 0;
}

.word__es {
  font-size: 1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.word__en {
  color: var(--text-secondary);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.word__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 0.73rem;
  color: var(--muted);
}

.word__side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.word__tools {
  display: flex;
  gap: 2px;
}

@media (max-width: 640px) {
  .word {
    grid-template-columns: 1fr;
  }
  .word__side {
    justify-content: flex-start;
  }
}

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty strong {
  display: block;
  color: var(--text-primary);
  font-size: 1rem;
  margin-bottom: 6px;
}

/* ====================================================== pronunciation ==== */

.phonetic {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.phonetic--card {
  justify-content: center;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  margin: -4px 0 0;
}

.speak-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85em;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  opacity: 0.65;
  vertical-align: middle;
  transition: opacity 0.12s, background 0.12s;
}

.speak-btn:hover {
  opacity: 1;
  background: var(--surface-2);
}

.speak-btn--lg {
  font-size: 1.05rem;
  padding: 6px;
}

/* ============================================================== read ===== */

.reader-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 940px) {
  .reader-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.reader-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 74px;
}

@media (max-width: 940px) {
  .reader-side {
    position: static;
  }
}

.reader-text {
  font-size: 1.08rem;
  line-height: 2.05;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/*
 * Tokens keep text-coloured ink and carry state in a tinted wash plus a solid
 * underline, so the passage stays readable and the colour is never the only cue
 * (legend above, title on hover, full state named in the side panel on click).
 */
.tok {
  font: inherit;
  color: inherit;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 4px 4px 0 0;
  padding: 1px 3px;
  margin: 0 -1px;
  cursor: pointer;
  background: transparent;
  transition: background 0.1s;
}

.tok:hover {
  filter: brightness(1.08);
}

.tok--conf-0 {
  border-bottom-color: var(--critical);
  background: color-mix(in srgb, var(--critical) 15%, transparent);
}

.tok--conf-1 {
  border-bottom-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 22%, transparent);
}

.tok--conf-2 {
  border-bottom-color: var(--good);
  background: color-mix(in srgb, var(--good) 15%, transparent);
}

.tok--new {
  border-bottom-color: var(--series-1);
  background: color-mix(in srgb, var(--series-1) 15%, transparent);
}

.tok--selected {
  outline: 2px solid var(--text-primary);
  outline-offset: 1px;
}

/* a proven word-to-word link between the two panes */
.tok--linked,
.entok--linked {
  outline: 2px solid var(--series-2);
  outline-offset: 1px;
  border-radius: 4px;
}

/* the weaker claim: we only know which sentence it came from */
.tok--sentence,
.en-sentence--active {
  background: color-mix(in srgb, var(--series-2) 14%, transparent);
  border-radius: 4px;
}

/* ---- the English pane ---- */

.en-pane {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--grid);
}

.en-pane__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.en-pane__title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.reader-text--en {
  font-size: 0.98rem;
  line-height: 1.9;
  color: var(--text-secondary);
}

.entok {
  font: inherit;
  color: inherit;
  border: 0;
  background: transparent;
  padding: 1px 2px;
  margin: 0 -1px;
  border-radius: 4px;
  cursor: pointer;
}

.entok:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.en-missing {
  color: var(--muted);
  font-style: italic;
}

#reader-input {
  min-height: 130px;
}

.genbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--grid);
}

.genbar__controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mix-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.mix-counts b {
  color: var(--text-primary);
}

.newword-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 230px;
  overflow-y: auto;
}

.newword {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--grid);
}

.newword:last-child {
  border-bottom: 0;
}

.newword__text {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
}

.newword__text .phonetic {
  margin-top: 0;
}

.newword__gloss {
  color: var(--text-secondary);
  font-size: 0.82rem;
}

/* ============================================================ grammar ==== */

.gchips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 6px 0 2px;
  justify-content: inherit;
}

.gchip {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--surface-2);
  white-space: nowrap;
}

/* an inferred fact is drawn as a hedge, not as a statement */
.gchip--guess {
  border-style: dashed;
  color: var(--muted);
  background: transparent;
}

.gchip--guess span {
  opacity: 0.7;
  margin-left: 1px;
}

.gchip--soft {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding-left: 2px;
}

.flashcard .gchips {
  justify-content: center;
}

.activity {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 10px;
  font-size: 0.73rem;
  color: var(--muted);
}

.flashcard .activity {
  justify-content: center;
  margin-top: 6px;
}

/* ============================================================ numbers ==== */

.numbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

@media (max-width: 560px) {
  .numbar {
    grid-template-columns: 1fr;
  }
}

.num-preview {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.num-preview__row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.num-preview__value {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}

.num-preview__text {
  min-width: 0;
}

.num-preview__es {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.numgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.numcard {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-top: 3px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.numcard--conf-0 {
  border-top-color: var(--critical);
}
.numcard--conf-1 {
  border-top-color: var(--warning);
}
.numcard--conf-2 {
  border-top-color: var(--good);
}

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

.numcard__value {
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.numcard__es {
  font-size: 1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.numcard__en {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.numcard .conf-set {
  gap: 4px;
}

.numcard .conf-btn {
  min-height: 28px;
  padding: 0 8px;
  font-size: 0.74rem;
}

.numcard__del {
  align-self: flex-start;
  margin-top: 6px;
  padding-left: 0;
}

/* =========================================================== practice ==== */

.practice {
  max-width: 660px;
  margin: 0 auto;
}

.flashcard {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 44px 32px;
  text-align: center;
  min-height: 290px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.flashcard__prompt-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.flashcard__prompt {
  font-size: 2.1rem;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.flashcard__answer {
  font-size: 1.35rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.flashcard__notes {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.flashcard__hidden {
  color: var(--muted);
  font-size: 0.9rem;
}

.practice__rate {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.rate-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 13px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s;
}

.rate-btn:hover {
  background: var(--surface-2);
}

.rate-btn__glyph {
  font-size: 1.15rem;
  line-height: 1;
}

.rate-btn__key {
  font-size: 0.7rem;
  color: var(--muted);
}

.rate-btn--0:hover {
  border-color: var(--critical);
}
.rate-btn--1:hover {
  border-color: var(--warning);
}
.rate-btn--2:hover {
  border-color: var(--good);
}

/* example sentence on the flashcard */

.example {
  margin: 14px auto 0;
  max-width: 460px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: left;
}

.example--loading,
.example--none {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  background: transparent;
  border-style: dashed;
}

.example__es {
  font-size: 0.98rem;
  line-height: 1.5;
}

.example__es b {
  font-weight: 700;
  border-bottom: 2px solid var(--series-1);
}

.example__en {
  font-size: 0.87rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.example__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.7rem;
  color: var(--muted);
}

.fixit {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
}

.practice__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.practice__stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 18px;
  font-size: 0.8rem;
  color: var(--muted);
}

.practice__stats b {
  color: var(--text-primary);
  font-weight: 600;
}

/* ============================================================== stats ==== */

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

.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow);
}

.tile__label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.tile__value {
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1.15;
  margin-top: 3px;
}

.tile__delta {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
}

.tile__delta--up {
  color: var(--success-text);
}

.hero {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
}

.hero__figure {
  font-size: 3.4rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}

.hero__label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.hero__spark {
  margin-left: auto;
}

/* charts */

.chart-wrap {
  width: 100%;
  overflow-x: auto;
}

.chart {
  display: block;
  width: 100%;
  min-width: 320px;
}

.chart text {
  font-family: var(--font);
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart .axis-line {
  stroke: var(--axis);
  stroke-width: 1;
}

.chart .grid-line {
  stroke: var(--grid);
  stroke-width: 1;
}

.chart .bar-hit {
  fill: transparent;
  cursor: pointer;
}

.chart .bar-hit:hover + .bar-group path,
.chart .bar-hit:focus-visible + .bar-group path {
  opacity: 0.78;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend__swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: none;
}

.tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
  padding: 8px 11px;
  font-size: 0.79rem;
  color: var(--text-primary);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s;
}

.tooltip[data-show='true'] {
  opacity: 1;
}

.tooltip__row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.tooltip__title {
  color: var(--text-secondary);
  margin-bottom: 3px;
}

/* mix bar (part-to-whole, ordered status scale) */

.mixbar {
  display: flex;
  width: 100%;
  height: 34px;
  gap: 2px; /* 2px surface gap between fills - never a stroke */
  margin: 4px 0 14px;
}

.mixbar__seg {
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 0.76rem;
  font-weight: 600;
  color: #fff;
  min-width: 2px;
}

.mixbar__seg:first-child {
  border-radius: 6px 0 0 6px;
}

.mixbar__seg:last-child {
  border-radius: 0 6px 6px 0;
}

/* data table (the WCAG-clean twin of every chart) */

.datatable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.datatable th,
.datatable td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--grid);
}

.datatable th {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.76rem;
}

.datatable td.num,
.datatable th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.datatable tr:last-child td {
  border-bottom: 0;
}

details.table-view {
  margin-top: 12px;
}

details.table-view > summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-secondary);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

details.table-view > summary::-webkit-details-marker {
  display: none;
}

details.table-view > summary::before {
  content: 'â–¸';
  font-size: 0.7em;
}

details.table-view[open] > summary::before {
  content: 'â–¾';
}

.table-scroll {
  overflow-x: auto;
  margin-top: 8px;
}

/* ============================================================== goals ==== */

.goal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.goal__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

.goal__title {
  font-weight: 600;
}

.goal__sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.goal__numbers {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0 8px;
}

.goal__count {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
}

.goal__target {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* meter: fill and track are steps of one ramp, so state reads across the bar */
.meter {
  height: 9px;
  border-radius: 999px;
  background: var(--meter-track);
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--series-1);
  transition: width 0.3s ease;
}

.meter--done .meter__fill {
  background: var(--good);
}

.goal__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  font-size: 0.78rem;
  color: var(--muted);
}

.goal-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

/* ============================================================= toasts ==== */

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.toast {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--series-1);
  border-radius: 10px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.14);
  padding: 10px 14px;
  font-size: 0.85rem;
  max-width: 340px;
  animation: toast-in 0.18s ease;
}

.toast--error {
  border-left-color: var(--critical);
}

.toast--good {
  border-left-color: var(--good);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==================================================== translation check == */

.recheck-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.recheck {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-2);
}

.recheck--done {
  opacity: 0.55;
}

.recheck__word {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.recheck__flag {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--critical);
}

/* a missing accent is a question, not a verdict - warning, not critical */
.recheck__flag--accent {
  background: var(--warning);
  color: #0b0b0b;
}

.accent-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.accent-hint .chip {
  border-style: solid;
  border-color: var(--warning);
}

.recheck__row {
  display: flex;
  gap: 8px;
  font-size: 0.85rem;
  line-height: 1.6;
}

.recheck__label {
  flex: none;
  width: 72px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 3px;
}

.recheck__cur {
  color: var(--text-secondary);
  text-decoration: line-through;
  text-decoration-color: var(--muted);
}

.recheck__new {
  color: var(--text-primary);
  font-weight: 500;
}

.recheck__actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* ============================================================= dialog ==== */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 0;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.dialog__body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------- footer ---
   Licence attribution for Wiktionary (CC BY-SA) and Tatoeba (CC BY). This is a
   legal obligation of using those sources, so it is deliberately always
   rendered and never collapsed behind a toggle. */
.sitefoot {
  margin-top: 3rem;
  padding: 1.25rem 1rem 2rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.sitefoot__inner {
  max-width: 60rem;
  margin: 0 auto;
}

.sitefoot__credits,
.sitefoot__note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.sitefoot__note {
  margin-top: 0.35rem;
}

.sitefoot a {
  color: var(--text-secondary);
  text-decoration: underline;
}

.sitefoot a:hover,
.sitefoot a:focus-visible {
  color: var(--text-primary);
}

/* ----------------------------------------------------------------- login ---
   Standalone page shown before a session exists. Uses only the shared tokens
   so it stays in step with the app's light and dark themes. */
.loginpage {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--surface-2);
}

.loginbox {
  width: min(22rem, calc(100vw - 2rem));
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-1);
  text-align: center;
}

.loginbox__brand {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.loginbox__title {
  margin: 0 0 1.5rem;
  font-size: 1.125rem;
  color: var(--text-primary);
}

.loginbox__label {
  display: block;
  margin-bottom: 0.35rem;
  text-align: left;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.loginbox__input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-primary);
  font: inherit;
}

.loginbox__input:focus-visible {
  outline: 2px solid var(--text-secondary);
  outline-offset: 1px;
}

.loginbox__button {
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.6rem 0.7rem;
  border: 0;
  border-radius: 8px;
  background: #aa151b;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.loginbox__button:disabled {
  opacity: 0.6;
  cursor: default;
}

.loginbox__error {
  margin: 0.9rem 0 0;
  color: #c0392b;
  font-size: 0.8125rem;
}
