/* Speak in 90 Days. Visa paper, card stock, stamp-ink violet and passport oxblood.
   Light tokens here; the dark ones ("the passport at night") are repeated for the
   system setting and for an explicit choice in Settings (applyTheme sets data-theme).
   The stamp is the one loud thing: everything else stays flat and quiet. */
:root {
  --bg: #E9EFE4;          /* visa paper */
  --surface: #FBFCF8;     /* card stock */
  --surface-2: #DCE4D4;   /* deeper paper: tiles, tracks */
  --line: #DCE4D4;        /* dividers inside cards */
  --line-strong: #C7D1BE; /* rules and outlines on paper */
  --text: #1E1B2E;        /* ink */
  --text-2: #3A3750;
  --muted: #4A4760;
  --faint: #5F6670;       /* skipped days, future days */
  --violet: #4433B8;      /* stamp ink: stamps, main buttons, links */
  --violet-hover: #3A2AA3;
  --violet-tint: #DCD8F4;
  --on-violet: #FFFFFF;
  --accent-text: #2E2290;
  --oxblood: #5C1A2B;     /* passport cover */
  --oxblood-2: #6E2537;
  --on-oxblood: #F1E9DA;
  --on-oxblood-muted: #D9C6B4;
  --gold: #D2AE5A;        /* foil: only ever on oxblood */
  --red: #B8322A;         /* the other stamp inks, which double as the card grades */
  --red-text: #8E271D;
  --red-tint: #F3D9D3;
  --ochre: #A87316;
  --ochre-text: #6F4808;
  --ochre-tint: #F1E3C4;
  --green: #1F6B43;
  --green-text: #185A37;
  --green-tint: #D3E8D8;
  --new-bg: #DCD8F4;
  --new-text: #2E2290;
  --due-bg: #1E1B2E;
  --due-text: #FBFCF8;
  --ink: #1E1B2E;         /* dark buttons and selected segments: ink on paper, paper on dark */
  --on-ink: #FBFCF8;
  --k-mature: #1E1B2E;
  --k-young: #4433B8;
  --k-learning: #A87316;
  --k-new: #B9B2EC;
  --k-susp: #C7D1BE;
  --shadow-card: 0 2px 0 var(--line-strong); /* the edge of a card, not a glow */
  --shadow-float: 0 0 0 1px var(--line-strong), 0 24px 50px -24px rgba(30, 27, 46, 0.45);
  --font: "Golos Text", "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Big Shoulders", "Golos Text", "Arial Narrow", system-ui, sans-serif;
  --font-ka: "Noto Sans Georgian", "Noto Sans", "Sylfaen", system-ui, sans-serif;
  /* Looped Thai, as in textbooks: the loops tell apart letters like ด and ค. */
  --font-th: "Noto Sans Thai Looped", "Noto Sans Thai", "Leelawadee UI", "Thonburi", "Noto Sans", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16141F;
    --surface: #221F2E;
    --surface-2: #2E2A3D;
    --line: #2E2A3D;
    --line-strong: #4A4560;
    --text: #ECEFE6;
    --text-2: #CBCDC4;
    --muted: #A9ACB6;
    --faint: #8E92A1;
    --violet: #8E82F2;
    --violet-hover: #A398F5;
    --violet-tint: #2F2A55;
    --on-violet: #16141F;
    --accent-text: #B9B0F8;
    --oxblood: #4A1524;
    --oxblood-2: #5E1E31;
    --gold: #DDBC6B;
    --red: #E58175;
    --red-text: #F4ACA3;
    --red-tint: #3F2326;
    --ochre: #DCA84C;
    --ochre-text: #F1CF8E;
    --ochre-tint: #3A2F1C;
    --green: #62C48F;
    --green-text: #93DAB1;
    --green-tint: #1C3527;
    --new-bg: #2F2A55;
    --new-text: #CBC4FB;
    --due-bg: #ECEFE6;
    --due-text: #16141F;
    --ink: #ECEFE6;
    --on-ink: #16141F;
    --k-mature: #ECEFE6;
    --k-young: #8E82F2;
    --k-learning: #DCA84C;
    --k-new: #4D4687;
    --k-susp: #4A4560;
    --shadow-card: 0 2px 0 #0B0A10;
    --shadow-float: 0 0 0 1px var(--line-strong), 0 24px 50px -20px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #16141F;
  --surface: #221F2E;
  --surface-2: #2E2A3D;
  --line: #2E2A3D;
  --line-strong: #4A4560;
  --text: #ECEFE6;
  --text-2: #CBCDC4;
  --muted: #A9ACB6;
  --faint: #8E92A1;
  --violet: #8E82F2;
  --violet-hover: #A398F5;
  --violet-tint: #2F2A55;
  --on-violet: #16141F;
  --accent-text: #B9B0F8;
  --oxblood: #4A1524;
  --oxblood-2: #5E1E31;
  --gold: #DDBC6B;
  --red: #E58175;
  --red-text: #F4ACA3;
  --red-tint: #3F2326;
  --ochre: #DCA84C;
  --ochre-text: #F1CF8E;
  --ochre-tint: #3A2F1C;
  --green: #62C48F;
  --green-text: #93DAB1;
  --green-tint: #1C3527;
  --new-bg: #2F2A55;
  --new-text: #CBC4FB;
  --due-bg: #ECEFE6;
  --due-text: #16141F;
  --ink: #ECEFE6;
  --on-ink: #16141F;
  --k-mature: #ECEFE6;
  --k-young: #8E82F2;
  --k-learning: #DCA84C;
  --k-new: #4D4687;
  --k-susp: #4A4560;
  --shadow-card: 0 2px 0 #0B0A10;
  --shadow-float: 0 0 0 1px var(--line-strong), 0 24px 50px -20px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* Georgian and Thai always get their own fonts; Russian falls through to Noto Sans in every stack. */
.ka,
[lang="ka"] { font-family: var(--font-ka); }
[lang="th"],
.letter[lang="th"] { font-family: var(--font-th); }
.rom { color: var(--muted); font-style: italic; }

a { color: inherit; }

:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }

/* Screen titles in Big Shoulders, the tall condensed face of the stamps; section
   headings stay in the reading face so the display type keeps its weight. */
h1 {
  margin: 22px 0 14px;
  font: 900 48px/0.92 var(--font-display);
  letter-spacing: -0.005em;
  text-wrap: balance;
}

h2 {
  margin: 30px 0 12px;
  font: 700 19px/1.25 var(--font);
}

kbd {
  font: 700 11px/1 var(--font);
  padding: 3px 5px;
  border-radius: 6px;
  border: 1.5px solid currentColor;
  opacity: 0.6;
  margin-left: 8px;
}

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
#app { padding-bottom: 40px; }

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

/* ---------- stamps ---------- */
/* The brand's one device: a rubber stamp, slightly turned, with rough ink (the #ink
   filter in index.html). Under 64px the texture and inner ring are left off. */

.brand-mark { display: block; flex: none; overflow: visible; }
.brand-mark path,
.brand-mark rect,
.brand-mark circle { fill: none; stroke: currentColor; stroke-linejoin: round; }
.brand-mark .n { fill: currentColor; stroke: none; }
.stamp { display: block; flex: none; overflow: visible; color: var(--violet); }
.stamp path,
.stamp rect,
.stamp circle { fill: none; stroke: currentColor; stroke-linejoin: round; }
.stamp text { fill: currentColor; font-family: var(--font-display); font-weight: 900; }
.stamp.mile { color: var(--green); }
.stamp.final { color: var(--red); }
.stamp.slot { color: var(--violet); }
.stamp.slot path { stroke-dasharray: 11 8; }
.stamp.slot text { font-family: var(--font); font-weight: 600; }
.stamp.skip { color: var(--line-strong); }
.stamp.skip text { fill: var(--faint); font-weight: 800; }

/* ---------- buttons ---------- */

/* A plain .btn is the outline; .primary (stamp violet), .dark, .danger and .danger-fill fill it. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 14px;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  font: 700 16px/1.2 var(--font);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }

.btn.primary { background: var(--violet); border-color: var(--violet); color: var(--on-violet); }
.btn.primary:hover { background: var(--violet-hover); border-color: var(--violet-hover); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.dark:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.btn.danger { background: var(--red-tint); border-color: var(--red-tint); color: var(--red-text); }
.btn.danger:hover { background: color-mix(in srgb, var(--red) 18%, var(--red-tint)); }
.btn.danger-fill { background: var(--red); border-color: var(--red); color: #FFFFFF; }
.btn.danger-fill:hover { background: var(--red-text); border-color: var(--red-text); }
:root[data-theme="dark"] .btn.danger-fill { color: #16141F; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.danger-fill { color: #16141F; } }
/* The second choice beside a primary one: an outline in stamp ink. */
.btn.on-navy { border-color: var(--violet); color: var(--accent-text); }
.btn.on-navy:hover { background: var(--violet-tint); }
.btn.block { display: flex; width: 100%; }

.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font: 700 15px/1.2 var(--font);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.text-btn:hover:not(:disabled) { color: var(--text); }
.text-btn:disabled { opacity: 0.45; cursor: default; }
.text-btn.danger { color: var(--red-text); }

.link-btn {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

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

/* Speaker: a stamp-ink ring on cards, a small chip in lists (40 px, with a 44 px tap area). */
.speak {
  width: 56px;
  height: 56px;
  box-shadow: inset 0 0 0 2px var(--violet);
  color: var(--violet);
}

.speak:hover { color: var(--violet); background: var(--violet-tint); }
.speak svg { width: 24px; height: 24px; }

.speak.small {
  position: relative;
  width: 40px;
  height: 40px;
  box-shadow: none;
  background: var(--surface-2);
  color: var(--text);
}

.speak.small:hover { background: var(--line-strong); color: var(--text); }
.speak.small svg { width: 16px; height: 16px; }
.speak.small::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.center { justify-content: center; margin-top: 18px; }
.row.end { justify-content: flex-end; }

/* ---------- count chips ---------- */
/* The label is always in the text ("4 due"), so colour is never the only signal. */

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

.count {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.count.c-new { background: var(--new-bg); color: var(--new-text); }
.count.c-learn { background: var(--ochre-tint); color: var(--ochre-text); }
.count.c-rev { background: var(--due-bg); color: var(--due-text); }
.count.zero { background: var(--surface-2); color: var(--muted); }

/* ---------- form controls ---------- */

input[type="search"],
input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font: 500 16px var(--font);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder { color: var(--muted); opacity: 1; font-weight: 400; }

input[type="search"]:focus-visible,
input[type="text"]:focus-visible,
input[type="number"]:focus-visible,
input[type="password"]:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 4px var(--violet-tint);
}

textarea {
  width: 100%;
  min-height: 96px;
  padding: 14px 16px;
  border-radius: 14px;
  font: 400 17px/1.45 var(--font);
  resize: vertical;
}

.form-error { margin: 0; color: var(--red-text); font-size: 15px; font-weight: 600; }
.form-error:empty { display: none; }

/* ---------- header ---------- */
/* On paper: the stamp logo, language and account; then the four tabs, which sit along
   the bottom of the screen on phones. Study and stories have the screen to themselves. */

.top { padding-top: env(safe-area-inset-top, 0px); }

body[data-view="study"] .top { display: none; }

/* Signed out, nothing to switch between until they sign up: just the logo and Sign in. */
body.locked .tabs,
body.locked .lang-menu { display: none; }
body.locked .top-inner { padding-bottom: 14px; }

.top-inner { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  flex: none;
  color: var(--text);
  text-decoration: none;
}

.brand .brand-mark { color: var(--violet); }
.brand-name { font: 800 23px/1 var(--font-display); white-space: nowrap; }

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

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding-bottom: 10px;
}

.tabs a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a[aria-current="page"] { color: var(--accent-text); background: var(--violet-tint); font-weight: 700; }
.tabs .ico { flex: none; }

/* Phones: the tabs become a bar along the bottom, icon over label. */
@media (max-width: 719px) {
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    gap: 0;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    box-shadow: 0 -1px 0 var(--line-strong);
  }
  .tabs a { flex-direction: column; gap: 3px; min-height: 54px; font-size: 12px; }
  .tabs a[aria-current="page"] { background: none; color: var(--violet); }
  body:not(.locked):not([data-view="study"]):not([data-view="story"]):not([data-view="landing"]) #app { padding-bottom: 112px; }
  body:not(.locked):not([data-view="study"]):not([data-view="story"]):not([data-view="landing"]) #toast { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
}

.flag {
  display: block;
  flex: none;
  width: 22px;
  height: 15px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent);
}

/* Language: a pill showing the current language, opening a menu of all seven. */
.lang-menu { position: relative; min-width: 0; }

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 44px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 600 15px/1.2 var(--font);
  cursor: pointer;
}

.lang-btn:hover { background: var(--surface-2); }
.lang-btn .chev { flex: none; color: var(--muted); transition: transform 0.15s ease; }
.lang-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.lang-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lang-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: max-content;
  min-width: 240px;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-float);
}

.lang-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 6px 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text);
  font: 600 15px/1.25 var(--font);
  text-align: left;
  cursor: pointer;
}

.lang-item:hover,
.lang-item:focus { background: var(--surface-2); }
.lang-item:focus-visible { outline-offset: -2px; }
.lang-item .flag { grid-row: 1 / span 2; }
.lang-en { grid-column: 2; }
.lang-native { grid-column: 2; color: var(--muted); font-size: 13px; font-weight: 500; }
.lang-item .tick { grid-column: 3; grid-row: 1 / span 2; color: var(--violet); visibility: hidden; }
.lang-item[aria-checked="true"] .tick { visibility: visible; }

/* Account: the person icon, with the name beside it where there's room. */
.nav-account {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: none;
  min-width: 44px;
  height: 44px;
  padding: 0 14px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.nav-account:hover { background: var(--surface-2); }
.nav-account[aria-current="page"] { border-color: var(--violet); color: var(--accent-text); background: var(--violet-tint); }
.nav-account svg { flex: none; }
.acct-label { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 560px) {
  .nav-account { width: 44px; padding: 0; }
  .acct-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* Narrow phones: the logo keeps its stamp, and the name shortens; the flag and chevron
   stay in the language button, its name in the label. */
@media (max-width: 400px) {
  .brand-name { font-size: 20px; }
}

@media (max-width: 360px) {
  .lang-name { display: none; }
}

/* ---------- decks ---------- */
/* The day first: which of the 90 it is, today's stamp and the week, then the decks as
   rows in one card. */

.home { padding-top: 6px; padding-bottom: 40px; }

.day-block { display: flex; flex-direction: column; gap: 18px; padding: 14px 0 4px; }
.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.today-count { min-width: 0; }
.today-count h1 { margin: 0; font-size: clamp(80px, 25vw, 112px); line-height: 0.8; white-space: nowrap; }
.today-count p { margin: 20px 0 0; color: var(--muted); font-size: 16px; }
.today-stamp { display: block; flex: none; margin-bottom: 28px; border-radius: 16px; color: var(--violet); }
.today-stamp .stamp { width: clamp(92px, 27vw, 112px); height: auto; }
.today-stamp:hover .stamp.slot path { stroke-dasharray: none; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 0; list-style: none; }
.week li { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.week .stamp { width: auto; max-width: 100%; height: 38px; }
.week .stamp.mile { height: 36px; }
.wk-label { color: var(--muted); font-size: 12px; }
.wk-today .wk-label { color: var(--accent-text); font-weight: 700; }

.today-go { display: flex; flex-direction: column; gap: 12px; }
.today-go p { margin: 0; font-size: 17px; line-height: 1.4; }
.today-go .btn { min-height: 56px; font-size: 18px; }

@media (min-width: 720px) {
  .day-block { padding-top: 26px; }
  .today-go { flex-direction: row; align-items: center; justify-content: space-between; gap: 24px; }
  .today-go .btn { flex: none; width: auto; padding: 0 32px; }
}

.decks-head { margin: 36px 0 12px; }

.decks {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.deck { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.deck + .deck { border-top: 1px solid var(--line); }
.deck.quiet { padding-top: 14px; padding-bottom: 14px; }

.deck-head { display: flex; align-items: center; gap: 14px; }

.deck-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: 800 22px/1 var(--font-display);
}

.deck-icon .thousand { font-size: 17px; font-weight: 900; }
.deck-icon.ink { background: var(--ink); color: var(--on-ink); }
.deck-icon.custom { background: var(--violet-tint); color: var(--accent-text); }

.deck-title { flex: 1; min-width: 0; }

.deck h2 {
  margin: 0;
  font: 700 16px/1.3 var(--font);
}

.deck-sub { color: var(--muted); font-size: 14px; }
.deck-done { display: grid; place-items: center; flex: none; color: var(--green); }
.deck-blurb { margin: 0; color: var(--text-2); font-size: 15px; }

/* What the everyday phrases teach: a fold-out on their deck, stage by stage. */
.learn { border: 1px solid var(--line); border-radius: 18px; }
.learn summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  list-style: none;
  cursor: pointer;
}
.learn summary::-webkit-details-marker { display: none; }
.learn .chev { flex: none; transition: transform 0.15s ease; }
.learn[open] .chev { transform: rotate(180deg); }
.learn-body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.learn-lead { margin: 12px 0 0; color: var(--text-2); font-size: 15px; }
.learn-stages { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 0; padding: 0; list-style: none; }
.learn-stage { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px; background: var(--line); }
.learn-stage.here { box-shadow: inset 0 0 0 2px var(--violet); }
.learn-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; font-size: 16px; }
.learn-here { padding: 2px 10px; border-radius: 999px; background: var(--violet-tint); color: var(--accent-text); font-size: 13px; font-weight: 700; }
.learn-span { color: var(--muted); font-size: 14px; }
.learn-stage p { margin: 0; color: var(--text-2); font-size: 15px; }
.learn-stage .learn-frames { color: var(--muted); font-size: 14px; }
.learn-ex { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
.learn-ex li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.learn-term { font-weight: 700; }
.learn-ex .rom { font-size: 14px; }
.learn-en { color: var(--muted); font-size: 14px; }

.progress { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.progress > * { display: block; height: 100%; border-radius: 999px; background: var(--violet); }

.deck-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; }
.deck-actions { display: flex; align-items: center; gap: 4px; flex: none; margin-left: auto; }
.deck-actions .btn { padding: 0 20px; }

.deck-make {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 20px 18px;
  border: 2px dashed var(--line-strong);
  border-radius: 20px;
}

.decks + .deck-make { margin-top: 12px; }
.deck-make h2 { margin: 0; font: 700 17px/1.3 var(--font); }
.deck-make p { margin: 0; max-width: 52ch; color: var(--text-2); font-size: 15px; }

/* How to review a finished deck: flip cards or Fill the gap. */
.review-mode { min-width: 0; margin: 0; padding: 0; border: 0; }
.review-mode legend { margin-bottom: 6px; padding: 0; color: var(--muted); font-size: 13px; font-weight: 600; }

.mode-seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
}

.mode-seg button {
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: 600 15px/1.2 var(--font);
  cursor: pointer;
}

.mode-seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); font-weight: 700; }

.sync-note { max-width: 44ch; margin: 28px auto 0; color: var(--muted); font-size: 14px; text-align: center; }
.sync-note a { color: var(--accent-text); font-weight: 700; }

/* ---------- go further ---------- */
/* A ruled list under the decks: each row opens a deck (or the topic packs), with a chip
   saying when it helps most, then how far along it is. */

.further-head { margin: 36px 0 10px; }
.further-head .decks-head { margin: 0 0 2px; }
.further-head p { margin: 0; max-width: 60ch; color: var(--muted); font-size: 15px; }

.further { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line-strong); }
.further li { border-bottom: 1px solid var(--line-strong); }

.further-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 2px;
  color: var(--text);
  text-decoration: none;
}

.further-row:hover .further-text b { text-decoration: underline; text-underline-offset: 3px; }
.further-row:focus-visible { outline-offset: -2px; border-radius: 12px; }

.further-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
}

.further-glyph { font: 900 15px/1 var(--font-display); white-space: nowrap; }
.further-glyph[lang="ka"] { font-family: var(--font-ka); font-size: 14px; font-weight: 700; }
.further-glyph[lang="th"] { font-family: var(--font-th); font-size: 15px; font-weight: 700; }

.further-text { display: flex; flex-direction: column; min-width: 0; }
.further-text b { font-size: 16px; font-weight: 700; line-height: 1.3; }
.further-text span { color: var(--muted); font-size: 14px; line-height: 1.4; }

.further-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.further-chip.ready { background: var(--green-tint); color: var(--green-text); }
.further-chip.go { background: var(--violet); color: var(--on-violet); font-weight: 700; }

/* Topic packs: a page of six tiles, two to a row. */
.topics { display: flex; flex-direction: column; gap: 14px; padding-top: 12px; }
.topics h1 { margin: 0; }
.topics-intro { margin: -4px 0 0; max-width: 56ch; color: var(--text-2); font-size: 15px; }

.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: 10px; }

.pack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--text);
  text-decoration: none;
}

.pack:hover { box-shadow: inset 0 0 0 2px var(--line); }

.pack-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
}

.pack-name { display: flex; flex-direction: column; min-width: 0; }
.pack-name b { font: 700 16px/1.3 var(--font); }
.pack-native { color: var(--muted); font-size: 14px; }
.pack .progress { height: 6px; }
.pack-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; margin-top: auto; color: var(--muted); font-size: 13px; font-weight: 600; }
.pack-foot .count,
.pack-foot .further-chip { min-height: 26px; padding: 0 9px; font-size: 12px; }

/* ---------- short stories ---------- */
/* The library: today's story on navy, the ones already read in a list, then Reading words. */

.stories { display: flex; flex-direction: column; gap: 14px; padding-top: 12px; }
.stories h1 { margin: 0; }
.stories .decks-head { margin: 14px 0 0; }

.story-today {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.story-today .kicker { color: var(--muted); }
.story-today-title { font: 700 22px/1.25 var(--font); }
.story-today-title[lang="ka"] { font-family: var(--font-ka); }
.story-today-title[lang="th"] { font-family: var(--font-th); }
.story-about { color: var(--text-2); font-size: 15px; }
.story-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.story-foot .btn { padding: 0 22px; }

.story-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.story-row-text { display: flex; flex-direction: column; min-width: 0; }
.story-row-title { font-size: 16px; font-weight: 700; }
.story-row-text > span:last-child { color: var(--muted); font-size: 14px; }
.story-row .btn { min-height: 44px; padding: 0 16px; font-size: 15px; }
.story-more { margin: 0; color: var(--muted); font-size: 14px; }

/* The reader: the whole screen, on paper. Every word is a button; new ones are
   underlined with dots, and the one whose card is open is highlighted. */
body[data-view="story"] .top { display: none; }
body[data-view="story"] #toast { top: calc(16px + env(safe-area-inset-top, 0px)); bottom: auto; }

.reader {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 640px;
  margin: 0 auto;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}

.reader.has-sheet { padding-bottom: 300px; } /* room to read on above the card */

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

.reader-bar .back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.reader .tool-btn { background: var(--surface-2); color: var(--text); }
.reader .tool-btn:hover:not(:disabled) { background: var(--line); }
.reader .tool-btn[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.reader-head { display: flex; flex-direction: column; gap: 8px; }
.reader-head h1 { margin: 0; }
.reader-head .counts:empty { display: none; }

/* The key for new words: a stretch of the dotted underline. */
.new-key::before { content: ""; width: 14px; margin-right: 6px; border-bottom: 2px dotted currentColor; }

.story { display: flex; flex-direction: column; gap: 16px; font-size: 20px; line-height: 1.7; }
.story p { margin: 0; }
.story .story-en { margin-top: -8px; color: var(--text-2); font-size: 16px; line-height: 1.5; }

.w {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.wc { white-space: nowrap; }
.w:hover { background: var(--surface-2); }
.w.new { border-bottom: 2px dotted var(--violet); border-radius: 0; }
.w.sel { padding: 1px 4px; border-radius: 6px; background: var(--violet-tint); box-shadow: inset 0 -2px 0 var(--violet); color: var(--accent-text); font-weight: 600; }
.reader-finish { min-height: 56px; margin-top: 6px; font-size: 17px; }

/* A word's card: a sheet over the bottom of the screen, the story still readable above. */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
  max-height: 70vh;
  margin: 0 auto;
  overflow-y: auto;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--line), 0 -18px 40px -12px rgba(30, 27, 46, 0.35);
}

.sheet-grip { align-self: center; flex: none; width: 44px; height: 5px; border-radius: 999px; background: var(--line); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-words { display: flex; flex-direction: column; min-width: 0; }
.sheet-word { font-size: 32px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.sheet-en { font-size: 18px; font-weight: 800; }
.sheet .speak { width: 52px; height: 52px; }
.sheet .speak svg { width: 22px; height: 22px; }
.sheet-form { margin: -4px 0 0; color: var(--muted); font-size: 14px; }
.sheet-form .term { color: var(--text); font-weight: 700; }
.sheet-note { margin: 0; padding: 12px 14px; border-radius: 16px; background: var(--bg); font-size: 15px; }
.sheet-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; }
.sheet-actions.one { grid-template-columns: 1fr; }
.sheet-actions .btn { min-height: 52px; }
.sheet-count { color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- study ---------- */
/* On paper, in a 560 px column: the study bar, the chips, the card (which grows to fill
   the screen) and the answer buttons. The card is card stock with a ticket's perforation
   between the question and the answer, and a stub saying where the card sits. */

body[data-view="study"] #app {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  padding-bottom: 28px;
}

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

.study-bar .back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 44px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

.study-bar .back svg { flex: none; }
.back-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.study-tools { display: flex; flex: none; gap: 6px; }

.tool-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: 600 14px/1 var(--font);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tool-btn::after { content: ""; position: absolute; inset: -3px 0; } /* a 44 px tap area */
.tool-btn:hover:not(:disabled) { background: var(--surface-2); }
.tool-btn:disabled { color: var(--faint); cursor: default; }
.tool-btn[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }
.tool-btn[aria-pressed="true"]:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }

/* The chip for the current card's type is filled; the others stay pale. */
body[data-view="study"] .count.current { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
body[data-view="study"] .count.c-new.current { background: var(--violet); color: var(--on-violet); }

.card {
  position: relative;
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  align-items: center;
  min-height: min(460px, 58vh);
  padding: 22px 22px 0;
  overflow: hidden;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--text);
  text-align: center;
  cursor: pointer;
}

.card.revealed { cursor: default; }

.face { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; }
.face.front { flex: 1; justify-content: center; padding-bottom: 22px; }
.card.revealed .face.front { flex: none; gap: 12px; padding-bottom: 18px; }
.card.revealed .face.back { flex: 1; gap: 14px; padding: 18px 0 8px; }
.card.revealed .speak { width: 52px; height: 52px; }
.card.revealed .speak svg { width: 22px; height: 22px; }

/* The perforation: a dashed rule with a notch cut from each edge of the card. It sits
   over the stub on the front, and between the faces once the answer shows. */
.card:not(.revealed) .card-stub,
.card.revealed .face.back { position: relative; border-top: 2px dashed var(--line-strong); }

.card:not(.revealed) .card-stub::before,
.card:not(.revealed) .card-stub::after,
.card.revealed .face.back::before,
.card.revealed .face.back::after {
  content: "";
  position: absolute;
  top: -15px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
}

.card:not(.revealed) .card-stub::before,
.card.revealed .face.back::before { left: -36px; }
.card:not(.revealed) .card-stub::after,
.card.revealed .face.back::after { right: -36px; }

.card-stub {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 12px;
  width: 100%;
  padding: 14px 0 18px;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
}

.card-stub span:empty { display: none; }

.kicker { align-self: flex-start; color: var(--muted); font-size: 15px; }
.face.front .kicker { margin-bottom: auto; }
.card.revealed .face.front .kicker { display: none; }

.word {
  display: block;
  max-width: 100%;
  font-size: clamp(46px, 14vw, 60px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.word.phrase {
  max-width: 22ch;
  font-size: clamp(30px, 8.5vw, 40px);
  line-height: 1.2;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.face.front .kicker + .word,
.face.front .kicker + .en,
.face.front .kicker + .letter-row,
.face.front .kicker + .roman-big { margin-top: auto; }
.face.front > :last-child { margin-bottom: auto; }
.card.revealed .word { font-size: clamp(40px, 12vw, 52px); }
.card.revealed .word.phrase { font-size: clamp(26px, 7.4vw, 34px); }

/* The meaning: on the back, and as the prompt on the front of a reverse card. */
.en { max-width: 22ch; font-size: 26px; font-weight: 700; line-height: 1.25; text-wrap: balance; }
.face.front .en { font-size: clamp(30px, 8.5vw, 40px); line-height: 1.15; }

.roman { color: var(--muted); font-size: 18px; font-style: italic; }
.word + .roman { margin-top: -8px; }

.hint {
  color: var(--text-2);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.note {
  align-self: stretch;
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg);
  font-size: 16px;
  text-align: left;
}

/* Word-for-word breakdown: each piece over its meaning; the pieces of one word share a pill. */
.lit { width: 100%; }
.lit-label { margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.lit-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.lit-word { display: inline-flex; max-width: 100%; border-radius: 12px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-strong); }
.lit-part { display: flex; flex-direction: column; align-items: center; min-width: 0; padding: 6px 10px 7px; line-height: 1.3; }
.lit-part + .lit-part { border-left: 1px dashed var(--line-strong); }
.lit-t { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.lit-r { color: var(--muted); font-size: 12px; font-style: italic; }
.lit-g { margin-top: 1px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.lit-one { font-size: 17px; font-weight: 600; }

/* Letter decks: the letter in Big Shoulders beside its speaker. */
.letter-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px; }

.letter {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(80px, 28vw, 120px);
  font-weight: 800;
  line-height: 1;
}

.letter[lang="ka"] { font-family: var(--font-ka); font-size: clamp(64px, 23vw, 96px); font-weight: 600; }
.letter[lang="th"] { font-size: clamp(64px, 23vw, 96px); font-weight: 600; }
.letter.long { font-size: clamp(48px, 15vw, 68px); }
.roman-big { font: 800 52px/1.05 var(--font-display); }
.sound { max-width: 24ch; margin: 0; font-size: 22px; font-weight: 600; line-height: 1.3; text-wrap: balance; }
.sub { color: var(--muted); font-size: 15px; }
.sub b { color: var(--text); }

.example {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 10px;
  align-self: stretch;
  padding: 16px;
  border-radius: 14px;
  background: var(--bg);
}

.ex-word { font-size: 30px; font-weight: 600; line-height: 1.25; }
.ex-en { color: var(--text-2); font-size: 17px; }

.example b {
  color: var(--accent-text);
  font-weight: inherit;
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}

/* Show answer, then the four grades in the stamp inks: label first, interval underneath. */
.answer-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.answer-bar.single { grid-template-columns: 1fr; }
.answer-bar .show { min-height: 58px; font-size: 18px; }

.grade {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 64px;
  padding: 6px 4px;
  border: 0;
  border-radius: 14px;
  font-family: var(--font);
  line-height: 1.3;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.grade:hover { filter: brightness(0.96) saturate(1.1); }
.grade:active { transform: translateY(1px); }
.g-label { font-size: 16px; font-weight: 700; }
.grade .ivl { font-size: 12px; font-weight: 500; }
.grade kbd { display: none; }
.grade.again { background: var(--red-tint); color: var(--red-text); }
.grade.hard { background: var(--ochre-tint); color: var(--ochre-text); }
.grade.good { background: var(--violet); color: var(--on-violet); }
.grade.easy { background: var(--green-tint); color: var(--green-text); }

.keys-hint { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }

@media (hover: none), (max-width: 600px) {
  .keys-hint, .show kbd, .hint kbd { display: none; }
}

/* Phones: the answer buttons stay in reach at the bottom of the screen. */
@media (max-width: 600px) {
  body[data-view="study"] #app { padding-bottom: 16px; }
  body[data-view="study"] .answer-bar {
    position: sticky;
    bottom: 0;
    margin-top: -12px; /* its top padding sits over the card's gap */
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to bottom, transparent, var(--bg) 25%);
  }
}

body[data-view="study"] #toast { bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }

/* With three tools in the study bar, phones show just their icons. */
@media (max-width: 420px) {
  .study-tools.three .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- fill the gap ---------- */
/* The card's example sentence with a gap, the answer box under it with the letters a
   keyboard may be missing, then once checked how close it was and the grades, with the
   one picked for them ringed. */

.gap-card { gap: 18px; padding-bottom: 22px; cursor: default; }
.gap-card .kicker { margin-bottom: 0; }
.gap-card.revealed { gap: 14px; }
.gap-sent { max-width: 22ch; margin: auto 0 0; font-size: clamp(24px, 7.4vw, 30px); font-weight: 600; line-height: 1.35; text-wrap: balance; }
.gap-card.revealed .gap-sent { margin-top: 0; }

.gap {
  display: inline-block;
  width: 96px;
  height: 1.1em;
  vertical-align: -0.2em;
  border-radius: 4px;
  box-shadow: inset 0 -3px 0 var(--violet);
}

.gap-word { color: var(--accent-text); font-weight: 700; text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 5px; }
.gap-roman { margin: -6px 0 0; font-size: 16px; }
.gap-en { max-width: 30ch; margin: 0; color: var(--text-2); font-size: 17px; text-wrap: balance; }
.gap-card:not(.revealed) .gap-hint { margin-bottom: auto; }

.gap-hint {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.gap-form { display: flex; flex-direction: column; gap: 8px; }
.gap-label { color: var(--text); font-size: 14px; font-weight: 600; }

input.gap-in {
  min-height: 56px;
  padding: 0 16px;
  border-radius: 14px;
  border-color: var(--text);
  font: 500 20px var(--font);
}

input.gap-in:focus-visible { border-color: var(--violet); box-shadow: 0 0 0 4px var(--violet-tint); }

.gap-keys { display: flex; flex-wrap: wrap; gap: 4px; }

.gap-key {
  flex: 1 0 34px;
  max-width: 64px;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 600 17px var(--font);
  cursor: pointer;
}

.gap-key:hover { background: var(--surface-2); }
.gap-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; }
.gap-actions .btn { min-height: 58px; font-size: 17px; }
.gap-actions .btn.primary { font-size: 18px; }

/* How close it was, in ink: green for right, ochre for nearly, red for not quite. */
.verdict {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: stretch;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--red-tint);
  color: var(--red-text);
  text-align: left;
}

.verdict.v-right { background: var(--green-tint); color: var(--green-text); }
.verdict.v-near { background: var(--ochre-tint); color: var(--ochre-text); }
.verdict.v-shown { background: var(--bg); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.verdict-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 16px; }

.verdict-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--red);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
}

.v-right .verdict-chip { background: var(--green); }
.v-near .verdict-chip { background: var(--ochre); }
.v-shown .verdict-chip { background: var(--muted); }
:root[data-theme="dark"] .verdict-chip { color: #16141F; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .verdict-chip { color: #16141F; } }
.verdict-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; align-items: baseline; margin: 0; color: var(--text); }
.verdict-grid dt { color: var(--muted); font-size: 14px; font-weight: 600; }
.verdict-grid dd { margin: 0; font-size: 22px; font-weight: 600; overflow-wrap: anywhere; }
.verdict-grid .rom { font-size: 15px; font-weight: 400; }
.verdict-grid del { color: var(--red-text); text-decoration-thickness: 2px; }

.grade.picked { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px currentColor; }
.grade.good.picked { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--violet); }
.grade.picked .g-label { font-weight: 800; }
.gap-pick { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- done for today ---------- */
/* The day's stamp, the one loud moment: it comes down onto the page once, when it's
   just been earned. */

.done {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 12px 4px;
  text-align: center;
}

.done-badge {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px var(--green);
  color: var(--green);
}

.done h1 { margin: 0; font-size: clamp(40px, 12vw, 60px); line-height: 0.92; }
.done-lead { margin: 0; max-width: 30ch; font-size: 18px; font-weight: 600; line-height: 1.35; }

.done-stamp { display: grid; place-items: center; margin-bottom: 6px; }
.done-stamp .stamp { width: min(250px, 62vw); height: auto; transform: rotate(-6deg); }
.done-stamp .stamp.final { transform: none; }
.done-stamp .stamp.thump { animation: thump 0.6s cubic-bezier(0.2, 0.75, 0.3, 1) 0.25s both; }
.done-stamp .stamp.final.thump { animation-name: thump-flat; }

@keyframes thump {
  0% { transform: scale(1.7) rotate(-15deg); opacity: 0; }
  55% { transform: scale(0.93) rotate(-6deg); opacity: 1; }
  72% { transform: scale(1.03) rotate(-6deg); }
  100% { transform: scale(1) rotate(-6deg); opacity: 1; }
}

@keyframes thump-flat {
  0% { transform: scale(1.7) rotate(-9deg); opacity: 0; }
  55% { transform: scale(0.93); opacity: 1; }
  72% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

.done-chip {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0 8px;
  min-height: 34px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 15px;
}

.done-chip b { color: var(--text); }
.done-copy { margin: 0; max-width: 34ch; color: var(--text-2); font-size: 16px; }

.done-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 400px; margin: 4px 0 0; text-align: left; }
.done-facts div { padding: 12px 16px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-card); }
.done-facts dt { color: var(--muted); font-size: 14px; }
.done-facts dd { margin: 2px 0 0; font: 900 34px/1 var(--font-display); }

.done-actions { display: flex; flex-direction: column; gap: 10px; }
.done-actions .btn { min-height: 56px; font-size: 18px; }
.done-actions .btn.on-navy { min-height: 52px; font-size: 16px; }

/* ---------- browse ---------- */

.search { position: relative; }
.search .ico { position: absolute; top: 16px; left: 16px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; min-height: 52px; padding: 0 16px 0 46px; font-weight: 500; }

.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.filter { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 700; }
.filter select { width: 100%; min-height: 46px; padding: 0 12px; border-radius: 14px; font-size: 15px; font-weight: 700; }

.b-count { margin: 14px 0; color: var(--muted); font-size: 14px; font-weight: 600; }

.b-list {
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.b-list li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--surface-2);
}

.b-list li:last-child { border-bottom: 0; }
.b-list.wide li { grid-template-columns: 46px minmax(0, 1fr) auto; } /* ranks past 1,000 */
.b-rank { color: var(--muted); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.b-main { min-width: 0; }
.b-term { display: flex; align-items: center; gap: 6px; min-width: 0; }
.b-word { min-width: 0; font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.b-main .rom { font-size: 14px; }
.b-en { color: var(--text-2); font-size: 14px; }
.b-cat { color: var(--muted); font-size: 13px; }
.b-side { display: flex; flex-direction: column; align-items: flex-end; }

/* Status: the label says it all; colour only backs it up. */
.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.new { background: var(--new-bg); color: var(--new-text); }
.status.learning { background: var(--ochre-tint); color: var(--ochre-text); }
.status.due { background: var(--due-bg); color: var(--due-text); }
.status.later { background: var(--surface-2); color: var(--text); }
.status.suspended { border: 1.5px dashed color-mix(in srgb, var(--muted) 60%, transparent); color: var(--muted); }

.b-susp { position: relative; min-height: 40px; padding: 0 4px; font-size: 13px; }
.b-susp::after { content: ""; position: absolute; inset: -2px 0; }
.b-susp.danger { font-weight: 800; }

.b-list li.suspended { background: var(--bg); }
.b-list li.suspended .b-main,
.b-list li.suspended .b-en { color: var(--muted); }
.b-list li.suspended .b-word { text-decoration: line-through; text-decoration-thickness: 1.5px; }

.b-more { min-height: 48px; padding: 0 24px; }

/* ---------- passport (stats) ---------- */
/* The cover in oxblood and foil, then the visa page: one slot for each of the 90 days,
   inked as they're stamped. Then the cards, what's coming up and the totals. */

.panel { border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-card); }

.passport-cover {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
  padding: 22px 22px 24px;
  border-radius: 24px;
  background: var(--oxblood);
  color: var(--on-oxblood);
}

.pc-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pc-top h1 { margin: 0; color: var(--gold); font-size: clamp(56px, 17vw, 72px); line-height: 0.85; }
.pc-top .brand-mark { color: var(--gold); }
.pc-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 0; }
.pc-facts dt { color: var(--on-oxblood-muted); font-size: 13px; }
.pc-facts dd { display: flex; align-items: center; gap: 8px; margin: 2px 0 0; font-size: 16px; font-weight: 700; }

@media (min-width: 720px) {
  .pc-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.visa-page { margin-top: 28px; }
.visa-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.visa-head h2 { margin: 0; }
.visa-head span { color: var(--muted); font-size: 14px; }

.visa {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px 2px;
  margin: 0;
  padding: 16px 10px;
  list-style: none;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.visa li { display: grid; place-items: center; min-width: 0; height: 32px; }
.visa .stamp { width: auto; max-width: 100%; height: 28px; }
.visa .stamp.mile { height: 27px; }
.slot-later { color: var(--faint); font: 700 16px/1 var(--font-display); }

@media (min-width: 560px) {
  .visa { gap: 10px 6px; padding: 20px 18px; }
  .visa li { height: 40px; }
  .visa .stamp { height: 36px; }
  .visa .stamp.mile { height: 34px; }
  .slot-later { font-size: 19px; }
}

.visa-key { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.visa-key span { display: inline-flex; align-items: center; gap: 6px; }
.visa-key i { width: 12px; height: 12px; border-radius: 3px; }
.visa-key .k-day { background: var(--violet); }
.visa-key .k-mile { border-radius: 50%; background: var(--green); }
.visa-key .k-final { border-radius: 2px; background: var(--red); }
.visa-page .foot-note { margin-top: 6px; }

.words-met { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.words-met div { padding-top: 8px; border-top: 3px solid var(--ink); }
.words-met .wm-known { border-color: var(--violet); }
.words-met .wm-learning { border-color: var(--ochre); }
.words-met dt { color: var(--muted); font-size: 13px; }
.words-met dd { margin: 0; font: 900 44px/1 var(--font-display); font-variant-numeric: tabular-nums; }

/* Three tiles a row on phones, one row of six on wider screens (never five and one). */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(105px, 100%), 1fr)); gap: 8px; }

@media (min-width: 380px) and (max-width: 719px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.stat b { font: 900 30px/1.05 var(--font-display); overflow-wrap: anywhere; }
.stat span { color: var(--muted); font-size: 13px; }

.deck-stats { display: flex; flex-direction: column; gap: 20px; padding: 18px; }
.deck-stat { display: flex; flex-direction: column; gap: 8px; }
.deck-stat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.deck-stat-head b { font-weight: 700; }
.deck-stat-head span { flex: none; color: var(--muted); font-size: 13px; }

.stack { display: flex; gap: 2px; height: 12px; overflow: hidden; border-radius: 999px; }
.stack > span { min-width: 4px; }

.key { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--text-2); font-size: 13px; }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 10px; height: 10px; border-radius: 3px; }

.k-mature { background: var(--k-mature); }
.k-young { background: var(--k-young); }
.k-learning { background: var(--k-learning); }
.k-new { background: var(--k-new); }
.k-susp { background: var(--k-susp); }

.foot-note { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
h2 + .foot-note { margin: 0 0 14px; }

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

.forecast {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  align-items: end;
  gap: 4px;
  height: 170px;
}

.fc-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; height: 100%; min-width: 0; }
.fc-n { color: var(--muted); font-size: 10px; font-weight: 600; line-height: 13px; font-variant-numeric: tabular-nums; }
.fc-bar { width: 100%; border-radius: 4px 4px 2px 2px; background: var(--k-mature); }
.fc-col.today .fc-n { color: var(--accent-text); font-weight: 800; }
.fc-col.today .fc-bar { background: var(--violet); }

.fc-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.fc-axis .today { color: var(--accent-text); }

/* ---------- settings ---------- */

.page-note { margin: -10px 0 0; color: var(--muted); font-size: 14px; }

.section-label { margin: 28px 0 12px; font: 700 19px/1.25 var(--font); }

.set-limits { overflow: hidden; }
.set-block { display: flex; flex-direction: column; gap: 4px; padding: 16px 16px 6px; border-bottom: 1px solid var(--line); }
.set-block:last-child { border-bottom: 0; }
.further-limits { border-top: 1px solid var(--line); }
.set-deck { margin: 0; font: 700 16px/1.5 var(--font); }

.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; }
.set-row label { font-weight: 600; }

.set-row input {
  flex: none;
  width: 84px;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 12px;
  background: var(--bg);
  font-weight: 800;
  text-align: center;
}

.set-row input[type="text"] { width: 120px; }

/* On/off settings: a styled checkbox, so applySetting reads it as before. */
.switch-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 8px 0 10px; }
.switch-row label { cursor: pointer; }
.sw-title { display: block; font-weight: 600; }
.sw-desc { display: block; color: var(--muted); font-size: 14px; }

.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: 999px;
  background: var(--line);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(30, 27, 46, 0.3);
  transition: transform 0.15s ease;
}

.switch::after { content: ""; position: absolute; inset: -6px -2px; } /* a 44 px tap area */
.switch:checked { background: var(--violet); box-shadow: none; }
.switch:checked::before { transform: translateX(20px); }

.set-card { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.set-card > .switch-row { padding: 0; }

.audio-note { display: flex; align-items: flex-start; gap: 12px; }
.audio-note p { margin: 0; color: var(--text-2); font-size: 15px; }

.audio-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
}

.audio-icon svg { width: 18px; height: 18px; }

/* Segmented choice (radio buttons): Theme here, Cards and Level in Make a deck. */
.seg-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.seg-field legend { margin-bottom: 8px; padding: 0; font-weight: 600; }

.seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}

.seg label { position: relative; display: block; min-width: 0; }
.seg input { position: absolute; inset: -2px 0; z-index: 1; width: 100%; height: calc(100% + 4px); margin: 0; opacity: 0; cursor: pointer; }

.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 6px;
  border-radius: 999px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.seg input:checked + span { background: var(--ink); color: var(--on-ink); font-weight: 800; }
.seg input:focus-visible + span { outline: 3px solid var(--violet); outline-offset: 2px; }

/* Scheduling: a card that opens. */
details.advanced { margin-top: 14px; }

.advanced summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 14px 16px;
  border-radius: 22px;
  list-style: none;
  cursor: pointer;
}

.advanced summary::-webkit-details-marker { display: none; }
.sum-text { display: flex; flex-direction: column; }
.sum-text span { color: var(--muted); font-size: 14px; }
.advanced .chev { flex: none; transition: transform 0.15s ease; }
.advanced[open] .chev { transform: rotate(180deg); }
.adv-body { padding: 0 16px 10px; border-top: 1px solid var(--line); }

.set-note { margin: 0; color: var(--text-2); font-size: 15px; }
.adv-body .set-note { margin: 12px 0 4px; color: var(--muted); font-size: 14px; }
.set-note a,
.sw-desc a { color: var(--text); font-weight: 700; }

.data-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.data-btns .btn,
.set-card > .btn.danger { min-height: 48px; font-size: 15px; }
.data-btns .btn { flex: 1 1 140px; }

/* Import is a label holding the (visually hidden, still focusable) file input. */
label.btn { position: relative; }
label.btn:focus-within { outline: 3px solid var(--violet); outline-offset: 2px; }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--on-ink);
  box-shadow: 0 10px 30px rgba(30, 27, 46, 0.3);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- cookie banner ---------- */

/* Asks about analytics cookies until the visitor chooses. Under the toast, so a
   "Saved" still shows. Reject and Accept look the same on purpose. */
.consent {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  width: min(560px, calc(100% - 32px));
  padding: 18px 20px 20px;
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line-strong), 0 24px 60px -20px rgba(30, 27, 46, 0.55);
  transform: translateX(-50%);
}

.consent p { margin: 0 0 14px; color: var(--text-2); font-size: 15px; line-height: 1.45; }
.consent p b,
.consent p a { color: var(--text); }
.consent p a { font-weight: 700; }
.consent-btns { display: flex; gap: 8px; }
.consent-btns .btn { flex: 1; }

/* ---------- confirmation dialog ---------- */

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(30, 27, 46, 0.5);
}

.modal {
  width: min(420px, 100%);
  padding: 22px;
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line), 0 24px 60px -20px rgba(30, 27, 46, 0.55);
}

.modal p { margin: 0 0 20px; font-size: 17px; font-weight: 600; line-height: 1.45; }
.modal .row { gap: 8px; }

/* ---------- account ---------- */

body[data-view="account"] #app { max-width: 440px; }

.auth-wrap { display: flex; flex-direction: column; gap: 18px; padding-top: 32px; }
.auth-wrap > h1 { margin: 0; }

/* The stamp logo on its own. */
.bubble-badge { align-self: flex-start; color: var(--violet); }

.auth-head { display: flex; flex-direction: column; gap: 6px; }
.auth-head h1 { margin: 0; }
.auth-head p { margin: 0; color: var(--text-2); }

.auth { display: flex; flex-direction: column; gap: 14px; }

.stack-field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; font-weight: 700; }
.stack-field input { width: 100%; min-height: 52px; padding: 0 16px; font-size: 17px; }

.auth-submit { min-height: 56px; font-size: 18px; }
.auth-switch { margin: 0; color: var(--text-2); font-size: 15px; }

.note-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 18px; }
.note-card .ico { flex: none; margin-top: 2px; color: var(--accent-text); }
.note-card p { margin: 0; color: var(--text-2); font-size: 14px; }

.acct-card { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 18px; }
.acct-card p { margin: 0; }
.acct-sync { color: var(--muted); font-size: 14px; }

/* ---------- privacy notice ---------- */

body[data-view="privacy"] #app { max-width: 640px; }
/* Room to scroll the last section clear of the cookie banner while it shows. */
body[data-view="privacy"]:has(> .consent) #app { padding-bottom: 300px; }

.pv { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.pv-sec { padding: 18px 20px; }
.pv-sec h2 { margin: 0 0 8px; font-size: 19px; }
.pv-sec p,
.pv-sec ul { margin: 0 0 10px; color: var(--text-2); }
.pv-sec ul { padding-left: 20px; }
.pv-sec li + li { margin-top: 4px; }
.pv-sec > :last-child { margin-bottom: 0; }
.pv-sec .btn { margin-top: 4px; }
.pv-sec a { color: var(--text); font-weight: 700; }

/* ---------- making a deck ---------- */

body[data-view="create"] #app { max-width: 640px; }

.maker { display: flex; flex-direction: column; gap: 16px; padding-top: 12px; }
.maker h1 { margin: 0; font-size: 28px; }

.back-link {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  min-height: 44px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover { color: var(--text); }

.maker-head { display: flex; flex-direction: column; gap: 8px; }
.maker-head p { margin: 0; color: var(--text-2); font-size: 15px; }

.maker-form { display: flex; flex-direction: column; gap: 16px; }
.maker .stack-field { font-weight: 800; }
#mk-topic { border-color: var(--text); }

/* Idea chips: the one matching the box is lit. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }

.chip {
  position: relative;
  min-height: 40px;
  padding: 0 13px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: 600 14px/1.2 var(--font);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip::after { content: ""; position: absolute; inset: -3px 0; } /* a 44 px tap area */
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip[aria-pressed="true"] { border-color: var(--violet); background: var(--violet-tint); color: var(--accent-text); font-weight: 700; }

.maker .seg-field legend { font-size: 15px; font-weight: 800; }
.maker .seg span { min-height: 42px; font-size: 15px; }
#mk-level span { font-size: clamp(12px, 3.6vw, 14px); }

.mk-big { min-height: 58px; font-size: 18px; }
.maker-form .mk-big { margin-top: 6px; }

/* The cards Claude wrote. */
.mk-head { display: flex; flex-direction: column; gap: 6px; }
.mk-head .kicker { letter-spacing: 0.12em; }

.mk-title-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 12px;
  border: 2px dashed var(--line-strong);
  border-radius: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mk-title-field .ico { flex: none; margin-right: 8px; color: var(--muted); }
.mk-title-field:focus-within { border-style: solid; border-color: var(--violet); box-shadow: 0 0 0 4px var(--violet-tint); }

input.mk-title {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 700 22px/1.25 var(--font);
}

input.mk-title:focus-visible { box-shadow: none; }

.mk-native { color: var(--muted); font-size: 16px; font-weight: 600; }
.mk-topic { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.mk-status { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--text-2); font-weight: 600; }
.mk-status.bad { display: block; color: var(--red-text); }
.mk-status .text-btn { margin-left: auto; }

.spinner {
  flex: none;
  width: 18px;
  height: 18px;
  border: 3px solid var(--violet-tint);
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.mk-cards {
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.mk-cards li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 12px 8px 12px 16px;
  border-bottom: 1px solid var(--surface-2);
}

.mk-cards li:last-child { border-bottom: 0; }
.mk-card { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mk-term { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.mk-front .rom { display: block; font-size: 14px; }
.mk-en { overflow-wrap: anywhere; }
.mk-note { color: var(--muted); font-size: 14px; }
.mk-drop:hover { background: var(--surface-2); }

.mk-help { margin: 0; color: var(--muted); font-size: 14px; }

.mk-actions { display: flex; flex-direction: column; gap: 8px; }
.mk-pair { display: flex; gap: 8px; }
.mk-pair .btn { flex: 1 1 0; min-height: 48px; font-size: 15px; }
.mk-edit { align-self: center; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- landing ---------- */
/* The home page for visitors who aren't signed in yet. It has its own nav and runs full
   width: paper, with the passport page as the picture, then oxblood to close. */

body[data-view="landing"] .top { display: none; }
body[data-view="landing"] #app { max-width: none; padding: 0; }

.ld { font-size: 17px; line-height: 1.55; overflow-x: clip; }
.ld-wrap { max-width: 1200px; margin: 0 auto; padding-left: clamp(16px, 4vw, 48px); padding-right: clamp(16px, 4vw, 48px); }
.ld [tabindex="-1"]:focus { outline: none; }

.ld h2 {
  margin: 0;
  font: 900 clamp(44px, 5.6vw, 80px)/0.92 var(--font-display);
  text-wrap: balance;
}

.ld h3 { margin: 0; font: 700 22px/1.25 var(--font); }

.btn.ld-big { min-height: 58px; padding: 0 30px; font-size: 18px; }

/* nav */

.ld-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-bottom: 16px;
}

.ld-nav .brand-name { font-size: 26px; }
.ld-nav nav { display: flex; align-items: center; gap: 4px 22px; font-weight: 600; font-size: 16px; }

.ld-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
}

.ld-link:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 4px; }

@media (max-width: 719px) {
  .ld-link.wide { display: none; }
  .ld-nav { padding-top: calc(10px + env(safe-area-inset-top, 0px)); padding-bottom: 10px; }
  .ld-nav nav { gap: 14px; }
  .ld-nav .btn { padding: 0 16px; }
  .ld-nav .brand-name { font-size: 22px; }
}

/* Keeps the nav on one row on 360px phones. */
@media (max-width: 400px) {
  .ld-nav { column-gap: 8px; }
  .ld-nav nav { gap: 10px; }
  .ld-nav .btn { padding: 0 12px; }
  .ld-nav .brand { gap: 6px; }
  .ld-nav .brand .brand-mark { width: 32px; height: auto; }
  .ld-nav .brand-name { font-size: 18px; }
}

@media (max-width: 359px) {
  .ld-nav .brand-name { display: none; }
}

/* hero */

/* The hero's spacing and type scale with the viewport height (svh: the height with the
   browser's bars showing) so "Start for free" sits above the fold. */
.ld-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 48px;
  align-items: center;
  padding-top: clamp(12px, min(5vw, 4svh), 56px);
  padding-bottom: clamp(64px, 9vw, 120px);
}

.ld-hero-copy { display: flex; flex-direction: column; gap: clamp(14px, 2.6svh, 28px); min-width: 0; }

.ld-hero h1 {
  margin: 0;
  font-size: clamp(64px, min(8.4vw, 15svh), 132px);
  line-height: 0.88;
}

.ld-lede { margin: 0; max-width: 44ch; font-size: clamp(17px, min(1.5vw, 2.6svh), 20px); line-height: 1.5; color: var(--text-2); text-wrap: pretty; }

.ld-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.ld-pick-label { font-size: 17px; font-weight: 600; }

/* A native select, with the app's chevron in place of the browser's arrow. */
.ld-select { position: relative; display: inline-flex; align-items: center; }
.ld-select .chev { position: absolute; right: 16px; color: var(--text); pointer-events: none; }

.ld-select select {
  appearance: none;
  min-height: 50px;
  padding: 0 46px 0 16px;
  border-color: var(--text);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 600 17px var(--font);
  cursor: pointer;
}

.ld-ctas { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; }

/* The passport page: card stock, turned a little, with Day 90's stamp landing on it. */
.ld-passport { position: relative; margin: 0 0 32px; min-width: 0; }

.ld-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 18px 24px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 3px 0 var(--line-strong);
  transform: rotate(1.5deg);
}

.ld-page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; color: var(--muted); font-size: 15px; }
.ld-page-head b { color: var(--text); }
.ld-slots { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px 4px; margin: 0; padding: 0; list-style: none; }
.ld-slots li { display: grid; place-items: center; min-width: 0; aspect-ratio: 8 / 7; }
.ld-slots .stamp { width: 100%; height: auto; }
.ld-slots .stamp.mile { width: 86%; }
.ld-last .stamp.slot { color: var(--red); }

.ld-final { position: absolute; right: -20px; bottom: -36px; width: min(46%, 250px); height: auto; }

@media (min-width: 1000px) {
  .ld-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; }
}

/* method strip */

.ld-method { background: var(--surface-2); }

.ld-method .ld-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 28px 48px;
  padding-top: 48px;
  padding-bottom: 48px;
}

.ld .ld-point h2 { font: 700 21px/1.3 var(--font); }
.ld-point p { margin: 6px 0 0; color: var(--text-2); }

/* why it works */

.ld-why {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr));
  gap: 18px;
  padding-top: clamp(64px, 9vw, 120px);
  padding-bottom: clamp(64px, 9vw, 120px);
}

.ld-why article {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: clamp(24px, 3vw, 36px);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.ld-why h3 { font-size: clamp(24px, 2.4vw, 30px); }
.ld-why p { margin: 0; color: var(--text-2); }

.ld-chart { width: 100%; height: auto; }
.ld-chart .axis { stroke: var(--line-strong); stroke-width: 2; }
.ld-chart .guide { stroke: var(--line-strong); stroke-width: 2; stroke-dasharray: 4 5; }
.ld-chart .area { fill: var(--violet-tint); }
.ld-chart .curve { fill: none; stroke: var(--violet); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.ld-chart .faded { fill: none; stroke: color-mix(in srgb, var(--muted) 55%, transparent); stroke-width: 3; stroke-dasharray: 6 6; stroke-linecap: round; }
.ld-chart .dot { fill: var(--text); }
.ld-chart text { font: 600 14px var(--font); fill: var(--text); }
.ld-chart text.small { font: 500 12px var(--font); fill: var(--muted); }

/* try a card: the first three Everyday phrases, played through on the page with the
   app's own card. The step being done is lifted onto card stock. */

.ld-day { background: var(--surface-2); }

.ld-day .ld-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 48px clamp(40px, 6vw, 80px);
  align-items: center;
  padding-top: clamp(64px, 8vw, 104px);
  padding-bottom: clamp(64px, 8vw, 104px);
}

.ld-day-intro { display: flex; flex-direction: column; gap: 22px; }
.ld-day-intro p { margin: 0; max-width: 40ch; font-size: 18px; color: var(--text-2); }

.ld-steps { margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.ld-steps li { display: flex; gap: 18px; align-items: center; padding: 16px 20px; border-radius: 18px; transition: background-color 0.2s, box-shadow 0.2s; }
.ld-steps li.on { background: var(--surface); box-shadow: var(--shadow-card); }
.ld-step-n { flex: none; width: 32px; font: 900 40px/1 var(--font-display); color: var(--muted); }
.ld-steps li.on .ld-step-n { color: var(--violet); }
.ld-steps b { display: block; font-size: 18px; }
.ld-steps li span:not(.ld-step-n) { color: var(--text-2); }

.ld-try-play { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 440px; min-width: 0; justify-self: center; }
.ld-try-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; color: var(--muted); font-size: 15px; }
.ld-try-head b { color: var(--text); }
.ld-try-msg { margin: 0; padding: 12px 16px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-card); font-size: 15px; line-height: 1.4; }
.ld-try-msg:empty { display: none; }
.ld-try-stage { display: flex; flex-direction: column; gap: 12px; }

/* The card sits on the deeper paper here, so its perforation's notches are cut in that. */
.ld-try .card:not(.revealed) .card-stub::before,
.ld-try .card:not(.revealed) .card-stub::after,
.ld-try .card.revealed .face.back::before,
.ld-try .card.revealed .face.back::after { background: var(--surface-2); }

.ld-try .ld-try-done { gap: 14px; padding: 26px 24px 24px; cursor: default; }
.ld-try-done .done-stamp .stamp { width: min(200px, 56vw); }
.ld .ld-try-done h3 { font: 900 clamp(40px, 4.4vw, 52px)/0.92 var(--font-display); text-wrap: balance; }
.ld-try-done h3:focus { outline: none; }
.ld-try-done p { margin: 0; max-width: 32ch; color: var(--text-2); }
.ld-try-list { align-self: stretch; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); text-align: left; }
.ld-try-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.ld-try-list .term { min-width: 0; font-weight: 600; }
.ld-try-list li > span:last-child { flex: none; color: var(--muted); }
.ld-try-ctas { display: flex; flex-wrap: wrap; gap: 10px; }
.ld-try-ctas .btn.primary { flex: 1 1 220px; }

@media (prefers-reduced-motion: reduce) {
  .ld-try .stamp.thump { animation: none; }
}

/* languages: a ruled list, each greeting in its own language */

.ld-langs .ld-wrap {
  display: flex;
  flex-direction: column;
  gap: 36px;
  padding-top: clamp(64px, 9vw, 120px);
  padding-bottom: clamp(64px, 9vw, 120px);
}

.ld-langs p { margin: 0; max-width: 56ch; color: var(--text-2); }

.ld-lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 0 28px; margin: 0; padding: 0; list-style: none; }
.ld-lang-grid li { border-top: 1.5px solid var(--text); }

.ld-lang {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 18px 0 24px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ld-lang:hover .ld-hello { color: var(--accent-text); }
.ld-hello { font: 600 40px/1.15 var(--font); }
.ld-hello[lang="ka"] { font: 600 36px/1.2 var(--font-ka); }
.ld-hello[lang="th"] { font: 600 38px/1.2 var(--font-th); }
.ld-lang-label { color: var(--muted); font-size: 16px; }

/* closing call to action, on the passport cover */

.ld-end { background: var(--oxblood); color: var(--on-oxblood); }

.ld-end .ld-wrap {
  display: flex;
  flex-direction: column;
  gap: 64px;
  padding-top: clamp(64px, 9vw, 112px);
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

.ld-end-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 28px; }
.ld-end-head { display: flex; flex-wrap: wrap; align-items: center; gap: 20px 28px; }
.ld-end-head .brand-mark { color: var(--gold); }
.ld-end h2 { max-width: 13ch; color: var(--gold); font-size: clamp(48px, 6vw, 84px); }
.btn.ld-paper { border-color: #E9EFE4; background: #E9EFE4; color: #1E1B2E; }
.btn.ld-paper:hover { background: #FBFCF8; border-color: #FBFCF8; }

.ld-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 24px;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--on-oxblood) 25%, transparent);
  font-size: 15px;
  color: var(--on-oxblood-muted);
}

.ld-foot nav { display: flex; flex-wrap: wrap; gap: 0 22px; }
.ld-foot a { display: inline-flex; align-items: center; min-height: 44px; color: inherit; }
.ld-foot button { min-height: 44px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .spinner { animation-duration: 2.4s; }
  .done-stamp .stamp.thump { animation: none; }
}
