/* Ported from the Wika Contributor Hub (outsource-data/frontend/app/globals.css +
   design_handoff_contributor_hub/design-references/design-system.md): same tokens,
   same two registers -- interactive = .wk-push (hard tinted ledge that collapses
   on press), data = .wk-card (hairline border + neutral ledge). */
:root {
  --primary: #624185;
  --primary-light: #7d56a0;
  --primary-fill: #624185;
  --primary-faint: #f0ebf7;
  --primary-pill: #e2d8ef;
  --push-primary: #4a3066;
  --secondary: #ffa345;
  --secondary-fill: #a85600;
  --secondary-text: #a85600;
  --secondary-faint: #fff3e6;
  --success: #2d7d46;
  --success-bg: #d7ffb8;
  --error: #c0392b;
  --error-bg: #fff1f2;
  --gold: #d4a017;
  --gold-bg: #fff8e6;
  --gold-text: #8a6500;
  --ink: #2e3133;
  --muted: #5f6470;
  --faint: #6e6a75;
  --canvas: #f7f7f8;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border-gray: #e8e8ea;
  --border-light: #e2e8f0;
  --table-head: #f8f8f9;
  --ledge: #e5e5e7;
  --shadow-ledge: 0 3px 0 0 var(--ledge);
  --shadow-soft-md: 0 4px 8px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #a084d4; --primary-light: #6a4b9c; --primary-fill: #7c5bb0;
    --primary-faint: #2c2438; --primary-pill: #473c5c; --push-primary: #4b3470;
    --secondary-text: #ffa345; --secondary-faint: #2e2316;
    --success: #57a862; --success-bg: #16261c; --error: #ef5350; --error-bg: #2c1517;
    --gold-bg: #2c2308; --gold-text: #d4a017;
    --ink: #f1eef4; --muted: #b0aab9; --faint: #8a8390; --canvas: #16141b;
    --surface: #201c27; --surface-hover: #2a2534; --border-gray: #6f6680;
    --border-light: #6f6680; --table-head: #251f2d; --ledge: #2f2a38;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #a084d4; --primary-light: #6a4b9c; --primary-fill: #7c5bb0;
  --primary-faint: #2c2438; --primary-pill: #473c5c; --push-primary: #4b3470;
  --secondary-text: #ffa345; --secondary-faint: #2e2316;
  --success: #57a862; --success-bg: #16261c; --error: #ef5350; --error-bg: #2c1517;
  --gold-bg: #2c2308; --gold-text: #d4a017;
  --ink: #f1eef4; --muted: #b0aab9; --faint: #8a8390; --canvas: #16141b;
  --surface: #201c27; --surface-hover: #2a2534; --border-gray: #6f6680;
  --border-light: #6f6680; --table-head: #251f2d; --ledge: #2f2a38;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--canvas); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: 16px/1.5 Figtree, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
::placeholder { color: var(--faint); opacity: 1; }
a { color: var(--primary); font-weight: 700; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 800; margin: 0; }
h2 { font-size: 18px; font-weight: 800; margin: 24px 0 10px; }
h3 { font-size: 15px; font-weight: 800; margin: 18px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }

/* ---- shell ---------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: env(safe-area-inset-top) 12px 0; background: var(--surface);
  border-bottom: 2px solid var(--border-gray);
}
.topbar .home { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.lang-pill {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 999px;
  background: var(--primary-faint); color: var(--primary); padding: 6px 12px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
}
.lang-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--table-head); }
main { max-width: 480px; margin: 0 auto; padding: 20px 16px 48px; }
main.wide { max-width: 1280px; }

.lockup { display: flex; align-items: center; justify-content: center; gap: 12px; }
.lockup b { display: block; font-size: 30px; line-height: 1.05; font-weight: 800; }
.lockup small { display: block; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.lead { text-align: center; color: var(--muted); font-size: 15px; line-height: 1.55; margin: 16px auto 22px; max-width: 420px; }

/* ---- registers ------------------------------------------------------------ */
.wk-card { background: var(--surface); border: 2px solid var(--border-gray); border-radius: 16px; box-shadow: var(--shadow-ledge); }
.wk-label { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--secondary-text); }

.btn, button.btn {
  --push-tint: var(--ledge); --push-depth: 3px;
  font: inherit; font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 11px 18px; border-radius: 12px; cursor: pointer; text-decoration: none;
  background: var(--surface); color: var(--ink); border: 2px solid var(--border-gray);
  box-shadow: 0 var(--push-depth) 0 0 var(--push-tint);
  transition: transform .06s, box-shadow .06s, background-color .15s;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(var(--push-depth)); box-shadow: 0 0 0 0 var(--push-tint); }
.btn.primary { --push-tint: var(--push-primary); background: var(--primary-fill); color: #fff; border-color: var(--push-primary); }
.btn.primary:hover { background: var(--primary-light); }
.btn.xl { --push-depth: 4px; font-size: 16px; text-transform: none; letter-spacing: 0; min-height: 56px; padding: 16px 24px; border-radius: 16px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.squish { transition: transform .06s; }
.squish:active:not(:disabled) { transform: scale(0.94); }
@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled), .squish:active:not(:disabled) { transform: none; }
}
:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }

/* ---- forms ---------------------------------------------------------------- */
.field > label, .field > .flabel { display: block; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  font: inherit; width: 100%; min-height: 52px; padding: 12px 16px; border-radius: 14px;
  border: 2px solid var(--border-light); background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink); }
.check input { margin-top: 2px; width: 20px; height: 20px; flex: none; accent-color: var(--primary); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  font: inherit; font-size: 14px; font-weight: 700; min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 2px solid var(--border-light); background: var(--surface); color: var(--faint); cursor: pointer;
}
.choice[aria-pressed=true] { background: var(--primary-faint); color: var(--primary); border-color: var(--primary); }

/* ---- notices / badges ----------------------------------------------------- */
.notice { display: flex; gap: 12px; align-items: flex-start; border-radius: 16px; border: 2px solid; padding: 16px; font-size: 14px; }
.notice .g { font-weight: 800; }
.notice b { display: block; font-size: 15px; }
.notice.success { background: var(--success-bg); border-color: var(--success-bg); color: var(--success); }
.notice.warn { background: var(--gold-bg); border-color: var(--gold-bg); color: var(--ink); }
.notice.info { background: var(--primary-faint); border-color: var(--primary-faint); color: var(--primary); }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.badge.saved { background: var(--success-bg); color: var(--success); }
.badge.practice { background: var(--gold-bg); color: var(--gold-text); }

.progress { height: 12px; background: var(--primary-faint); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; width: 0; transition: width .3s; }

/* ---- the card ------------------------------------------------------------- */
.flash { padding: 22px 20px 24px; animation: card-in .25s ease-out; }
.flash.out { animation: card-out .2s ease-in forwards; }
@keyframes card-in { from { opacity: 0; transform: translateX(32px); } }
@keyframes card-out { to { opacity: 0; transform: translateX(-48px); } }
@media (prefers-reduced-motion: reduce) { .flash, .flash.out { animation: none; } }
.listen { display: flex; align-items: center; gap: 14px; background: var(--primary-faint); border-radius: 14px; padding: 12px; margin-top: 14px; }
.play {
  --push-depth: 4px; flex: none; width: 56px; height: 56px; border-radius: 50%; cursor: pointer;
  background: var(--primary-fill); color: #fff; border: 2px solid var(--push-primary); font-size: 20px;
  box-shadow: 0 var(--push-depth) 0 0 var(--push-primary); transition: transform .06s, box-shadow .06s;
  display: inline-flex; align-items: center; justify-content: center;
}
.play:active { transform: translateY(var(--push-depth)); box-shadow: none; }
.play.small { width: 40px; height: 40px; font-size: 14px; --push-depth: 3px; }
.listen .meta { font-size: 14px; font-weight: 700; color: var(--primary); }
.listen .meta span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.track { height: 8px; background: var(--surface); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.track > div { height: 100%; width: 0; background: var(--primary); border-radius: 999px; }

.sentence { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 8px; }
.word {
  font: inherit; font-size: 20px; font-weight: 800; color: var(--ink); cursor: pointer; user-select: none;
  min-height: 44px; padding: 4px 12px; border-radius: 12px; border: 2px dashed var(--border-light); background: var(--surface);
}
.word.mis { background: var(--error-bg); border: 2px solid var(--error); color: var(--error); text-decoration: underline wavy; text-underline-offset: 4px; }
.word.stress { background: var(--secondary-faint); border: 2px solid var(--secondary); color: var(--secondary-text); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

.q { margin-top: 22px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.scale .btn { padding: 0; min-height: 52px; font-size: 20px; letter-spacing: 0; }
.scale .btn[aria-pressed=true] { --push-tint: var(--push-primary); background: var(--primary-fill); color: #fff; border-color: var(--push-primary); }
.ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 8px; }
.picked { font-size: 14px; font-weight: 700; color: var(--primary); min-height: 21px; margin-top: 4px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--canvas); padding: 12px 16px; border-radius: 14px; max-width: calc(100% - 32px); z-index: 10; font-size: 14px; font-weight: 600; }

/* ---- admin (calm register) ------------------------------------------------ */
.card { background: var(--surface); border: 2px solid var(--border-gray); border-radius: 16px; box-shadow: var(--shadow-ledge); padding: 18px; margin: 14px 0; }
button { font: inherit; }
:where(main.wide button:not(.btn)) {   /* zero specificity: every other button rule wins */ min-height: 40px; padding: 8px 14px; border-radius: 12px; border: 2px solid var(--border-gray); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 700; }
main.wide button.primary { background: var(--primary-fill); color: #fff; font-weight: 800; border-color: var(--push-primary); box-shadow: 0 3px 0 0 var(--push-primary); }
label { font-weight: 700; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border-gray); vertical-align: top; }
th { background: var(--table-head); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
tr:hover td { background: var(--primary-faint); }
tr.floor td { color: var(--muted); font-style: italic; }
tr.anchor td { color: var(--muted); }
.scroll { overflow-x: auto; }
.ci { color: var(--muted); font-size: 11px; white-space: nowrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.tabs button { font-size: 13px; font-weight: 800; min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--border-light); background: var(--surface); color: var(--faint); cursor: pointer; }
.tabs button[aria-selected=true] { background: var(--primary-faint); color: var(--primary); border-color: var(--primary); }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.filters > div { min-width: 150px; }
.filters select, .filters input { min-height: 44px; }
.w { padding: 1px 3px; border-radius: 4px; }
.flagauto { box-shadow: inset 0 -2px 0 var(--secondary); }
.kpi { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi div { background: var(--surface); border: 2px solid var(--border-gray); border-radius: 12px; padding: 12px 14px; }
.kpi b { display: block; font-size: 22px; font-weight: 800; color: var(--primary); }
audio { width: 220px; height: 32px; }
