/*
 * Aegean redesign — a fixed limestone/sea-blue/gold palette (light only).
 * The app deliberately does NOT follow the Telegram theme: it owns its look.
 * Legacy semantic vars (--text, --button, …) are kept as aliases onto the
 * brand tokens so the component rules below stay compact.
 */
:root {
  /*
   * The palette is light-only, so say so: without this a WebView running under a
   * dark system theme paints the controls it owns — caret, selection, scrollbars
   * — for a dark UI, and a white caret on the white input is invisible.
   */
  color-scheme: light;

  /* Brand tokens */
  --limestone: #f0ebdc; /* page background */
  --paper: #fffdf8; /* elevated card / panel */
  --surface: #ffffff; /* inner card, tile, option */
  --ink: #1f2e3d; /* primary text */
  --ink-soft: #7c8288; /* secondary text */
  --ink-faint: #a9aeb3; /* captions, placeholders */
  --sea: #2c6a93; /* primary / brand accent */
  --sea-strong: #245779;
  --gold: #a38a4d; /* eyebrow */
  --gold-accent: #d79b3f; /* success badge */
  --sand: #f1ede2; /* soft control background */
  --sand-2: #f6f3ea; /* chip background */
  --line: #ece6d6; /* hairline borders */
  --ok: #4f9d7c;
  --bad: #c1603f;

  --font-serif: "Lora", Georgia, "Times New Roman", serif;
  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Legacy aliases (referenced by shared component rules) */
  --bg: var(--limestone);
  --text: var(--ink);
  --hint: var(--ink-soft);
  --link: var(--sea);
  --button: var(--sea);
  --button-text: #ffffff;
  --secondary-bg: var(--sand);
  --card: var(--paper);

  --radius: 18px;
  --radius-lg: 22px;
  --app-max-width: 460px;
  --screen-pad: clamp(14px, 4vw, 22px);
  --shadow-card: 0 1px 3px rgba(31, 46, 61, 0.06);
  --shadow-lift: 0 14px 34px rgba(31, 46, 61, 0.1), 0 2px 8px rgba(31, 46, 61, 0.05);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  /*
   * The app is a single vertical column: sideways panning and pinch-zoom only
   * ever drag the layout off-centre on a phone, so both are locked down here.
   * `overflow-x`/`overscroll-behavior-x` kill the sideways drag and the viewport
   * meta kills pinch-zoom; `manipulation` is left to kill double-tap zoom only.
   * It must not be narrowed to `pan-y`: touch-action intersects down the whole
   * ancestor chain, so a pan-only body also denies the touch gestures that place
   * the caret and drag a selection inside an input.
   * `text-size-adjust` stops iOS from inflating text in landscape, which is what
   * made rows overflow to begin with.
   */
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--limestone);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: min(100%, var(--app-max-width));
  margin: 0 auto;
  padding: var(--screen-pad) var(--screen-pad) calc(28px + env(safe-area-inset-bottom));
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fade 0.18s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/*
 * The UA default highlight is picked for the UA's own scheme, not for this
 * fixed light palette, so it can come out unreadable inside the Telegram
 * WebView. Own it, in the brand blue.
 */
::selection {
  background: color-mix(in srgb, var(--sea) 26%, transparent);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.center {
  text-align: center;
}

h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  margin: 4px 0 0;
}

.muted {
  color: var(--ink-faint);
  font-size: 13.5px;
  line-height: 1.55;
}

code {
  font-size: 12px;
  word-break: break-all;
  color: var(--ink-soft);
}

/* Cards */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius);
  padding: 15px 16px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s ease, background 0.15s ease;
  min-width: 0;
  overflow-wrap: anywhere;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
}

.btn-primary {
  background: var(--sea);
  color: #fff;
  box-shadow: 0 10px 20px rgba(44, 106, 147, 0.26);
}

.btn-secondary {
  background: var(--sand);
  color: var(--ink);
}

.btn-success {
  background: var(--ok);
  color: #fff;
}

.btn-danger-outline {
  background: var(--surface);
  color: var(--bad);
  border: 1.5px solid var(--bad);
}

.btn-block {
  width: 100%;
}

/* Text link — secondary, low-weight action (e.g. "На главную", "Назад") */
.link-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--sea);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  padding: 10px;
  cursor: pointer;
  text-align: center;
}

.link-btn:active {
  opacity: 0.6;
}

.link-btn-muted {
  color: var(--ink-soft);
}

/* Home header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

.app-subtitle {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 3px;
}

.app-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.icon-btn {
  appearance: none;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--sand);
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn:disabled {
  opacity: 0.6;
}

.divider-dashed {
  height: 3px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--sea) 0 12px, transparent 12px 24px);
  opacity: 0.45;
}

/* Home hero — progress ring around the due count */
.due-hero {
  display: flex;
  justify-content: center;
  padding: 6px 0 2px;
}

.due-ring {
  position: relative;
  width: 136px;
  height: 136px;
}

.due-ring svg {
  width: 100%;
  height: 100%;
}

.due-ring-track {
  fill: none;
  stroke: var(--line);
  stroke-width: 10;
}

.due-ring-arc {
  fill: none;
  stroke: var(--sea);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 339.29;
  stroke-dashoffset: 339.29; /* empty until app.js sets it */
  transition: stroke-dashoffset 0.5s ease;
}

.due-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.due-count {
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.due-caption {
  font-size: 11px;
  color: var(--ink-faint);
  text-align: center;
  max-width: 92px;
}

/* Home tiles — "Мои слова" / "Словарь" */
.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tile {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.06s ease, border-color 0.15s ease;
}

.tile:active {
  transform: scale(0.98);
}

.tile-emoji {
  font-size: 22px;
  line-height: 1;
}

.tile-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

/* Stats — a card wrapping a grid of chips */
.stats-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.chip-stat {
  background: var(--sand-2);
  border-radius: 14px;
  padding: 11px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chip-stat b {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.chip-stat span {
  font-size: 10.5px;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.chip-stat.good b {
  color: var(--ok);
}

.chip-stat.bad b {
  color: var(--bad);
}

.chip-stat.total {
  background: #efe6cf;
}

/* Training — stage ladder */
.stage-ladder {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.stage-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--line);
  flex: none;
  transition: background 0.2s ease;
}

.stage-dot.done {
  background: var(--sea);
  opacity: 0.35;
}

.stage-dot.active {
  width: 26px;
  height: 26px;
  background: var(--sea);
  opacity: 1;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

/* Progress bar */
.progress {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--sea);
  border-radius: 99px;
  transition: width 0.25s ease;
}

/* Question */
.question {
  text-align: center;
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 96px;
  justify-content: center;
  background: var(--surface);
}

.q-kind {
  font-size: 13px;
  color: var(--ink-faint);
}

.q-prompt {
  font-family: var(--font-serif);
  font-size: clamp(28px, 8vw, 36px);
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.q-translation {
  font-family: var(--font-serif);
  font-size: clamp(18px, 6vw, 22px);
  font-weight: 500;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--sand);
  color: var(--ink);
  border: none;
  border-radius: 99px;
  padding: 10px 20px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.audio-btn.big {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  font-size: 34px;
  padding: 0;
}

.audio-btn:active {
  transform: scale(0.96);
}

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

.option {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 16px 12px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  min-height: 60px;
  cursor: pointer;
  transition: transform 0.06s ease, border-color 0.15s ease, background 0.15s ease;
  overflow-wrap: anywhere;
}

.option:active {
  transform: scale(0.98);
}

.option.correct {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
}

.option.wrong {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 14%, transparent);
}

.option.dim {
  opacity: 0.5;
}

/* Stage 3 matching */
.match-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.match-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.match-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 54px;
  padding: 10px 8px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.match-item.selected {
  border-color: var(--sea);
  background: color-mix(in srgb, var(--sea) 10%, transparent);
}

.match-item.paired {
  border-color: var(--sea);
}

.match-item.correct {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
}

.match-item.wrong {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 14%, transparent);
}

.match-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sea);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

/* Train actions (secondary controls) */
.train-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

/* Feedback */
.feedback {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  padding: 4px 0;
  color: var(--ok);
}

.feedback .answer {
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 15px;
  margin-top: 3px;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

/* Results */
.results-badge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gold-accent);
  color: #fff;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px auto 0;
  box-shadow: 0 12px 24px rgba(215, 155, 63, 0.3);
}

.results-grid {
  margin-top: 2px;
}

.results-grid .chip-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 13px 6px;
}

.results-grid .chip-stat b {
  font-size: 20px;
}

/* Inputs */
.input,
textarea.mnemonic-input {
  /*
   * `caret-color: auto` lets the UA decide, and the Telegram WebView decides for
   * its own chrome rather than for this always-light field. Pin it to the text
   * colour. The user-select reset is the same story: the WebView suppresses
   * selection to make Mini Apps feel native, which also takes the caret with it.
   */
  caret-color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}

.input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
}

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

.input:focus {
  outline: none;
  border-color: var(--sea);
}

.note {
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 14px;
  text-align: center;
}

.note.ok {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ink);
}

.note.err {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  color: var(--ink);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(31, 46, 61, 0.9);
  color: #fff;
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 14px;
  z-index: 30;
  max-width: 90%;
  text-align: center;
}

/* Dictionary search */
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.search-row .btn {
  padding: 14px 18px;
}

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

/* Filter bar ("Мои слова") — one chip group per facet. The groups wrap rather
 * than scroll sideways: the body deliberately locks horizontal panning (see the
 * html/body rule), so a chip parked off the right edge would be unreachable. */
/* A wrapped group spans two lines, so the gap between facets has to read as
 * bigger than the gap between chips of one facet. */
.filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

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

.chip-filter {
  background: var(--sand-2);
  color: var(--ink-soft);
  font-size: 12.5px;
  padding: 6px 12px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.chip-filter.is-on {
  background: var(--sea);
  color: #ffffff;
}

.result {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  width: 100%;
  min-width: 0;
}

.result:active {
  transform: scale(0.99);
}

.result-lemma {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.result-tr {
  color: var(--ink);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.result-pos {
  color: var(--ink-faint);
  font-size: 12px;
}

.result-base {
  color: var(--ink-faint);
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* Keep the study-level pill compact instead of stretching to row width. */
.result-stage {
  align-self: flex-start;
}

/* Word row header: the word on the left, its frequency ring pinned right. */
.result-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/*
 * Frequency indicator for word rows (ADR-0020): a ring of five dashed ticks
 * with `band` of them lit (app.js builds the dash pattern).
 *
 * Gold, never --sea: frequency is a property of the word, while the sea-blue in
 * the same row (level steps, stage ladder) means study progress. Sharing the
 * colour would read as a second progress bar.
 *
 * `margin-left: auto` parks it against the card's right edge, away from the
 * word itself — at the old inline size it read as a smudge on the accent.
 */
.freq-ring {
  width: 20px;
  height: 20px;
  flex: none;
  margin-left: auto;
  opacity: 0.9;
}

.freq-ring circle {
  fill: none;
  stroke-width: 3;
}

.freq-ring-track {
  stroke: var(--line);
}

.freq-ring-value {
  stroke: var(--gold);
}

/* Dictionary rows get a circular Greek-initial avatar (design screen 05). */
.result.has-avatar {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.result-avatar {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--sand);
  color: var(--sea);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Per-word level indicator + "raise one level" button (ADR-0019). */
.level-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.level-steps {
  display: flex;
  gap: 3px;
  flex: none;
}

.level-step {
  width: 14px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
}

.level-step.active {
  background: var(--sea);
}

.level-up-btn {
  margin-left: auto;
  flex: none;
  border: none;
  background: var(--sand);
  color: var(--ink);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.level-up-btn:active {
  transform: scale(0.95);
}

.level-up-btn:disabled {
  opacity: 0.5;
}

/* A word row with a mnemonic thumbnail lays out as picture + text column. */
.result.has-thumb {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

/* Fills the row so the right-pinned frequency ring reaches the card edge even
 * when a thumbnail sits beside the text. */
.result-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.result-thumb {
  width: 52px;
  height: 52px;
  flex: none;
  object-fit: cover;
  border-radius: 12px;
  background: var(--sand);
}

/* Word-card overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--screen-pad);
  background: rgba(31, 46, 61, 0.42);
  animation: fade 0.15s ease;
}

.overlay-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 2 * var(--screen-pad) - env(safe-area-inset-bottom));
  overflow-y: auto;
  box-shadow: var(--shadow-lift);
}

.overlay-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}

/*
 * Headline row: the word with its frequency bar (ADR-0020) beside it. The bar
 * sits by the word, not in the meta row below, so it reads as a fact about the
 * word rather than as another badge. The 28px right padding keeps the row clear
 * of the close button; it lives here rather than on .card-head so the bar stops
 * short of the × too.
 */
.card-head-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 28px;
  min-width: 0;
}

.card-head {
  font-family: var(--font-serif);
  font-size: clamp(26px, 8vw, 34px);
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.word-card-subtitle {
  color: var(--ink-soft);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-block;
  background: var(--sand);
  color: var(--ink);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 12.5px;
  font-weight: 600;
}

.badge-soft {
  color: var(--ink-soft);
  font-weight: 500;
}

.freq {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 3px;
  padding: 3px 4px;
}

.freq-dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--line);
}

.freq-dot.on {
  background: var(--sea);
}

.card-tr {
  font-size: 17px;
  margin-top: 12px;
  overflow-wrap: anywhere;
}

.word-card-block {
  margin-top: 12px;
}

.word-card-line {
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.word-card-actions {
  justify-content: flex-start;
}

.word-card-image {
  display: block;
  max-width: 100%;
  margin-bottom: 8px;
}

.card-section-title {
  margin-top: 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
}

.card-senses {
  margin: 6px 0 0;
  padding-left: 20px;
}

.card-senses li {
  margin: 3px 0;
}

.sense-note {
  color: var(--ink-soft);
  font-size: 14px;
}

.forms {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.form-row:last-child {
  border-bottom: none;
}

/* Full Russian feature label ("именительный", "1-е лицо") on the left. */
.form-label {
  color: var(--ink-soft);
  font-size: 14px;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.form-word {
  font-weight: 600;
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

/* The study form (or the headword) stands out inside the paradigm. */
.form-word.study {
  color: var(--sea);
}

/* The card overlay reuses .audio-btn; give it some breathing room. */
#card-body .audio-btn {
  margin-top: 12px;
}

/* Keyword mnemonic (ADR-0015) — progressive block on the Stage 0 encode card */
.mnemonic {
  width: 100%;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mnemonic-title {
  font-size: 13px;
}

.mnemonic-keyword {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.mnemonic-story {
  font-size: 15px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.mnemonic-image {
  width: 100%;
  max-width: 320px;
  border-radius: var(--radius);
  margin-top: 6px;
}

.mnemonic-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.chip {
  background: var(--sand);
  color: var(--ink);
  border: none;
  border-radius: 99px;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.chip:active {
  transform: scale(0.97);
}

.chip:disabled {
  opacity: 0.5;
}

.mnemonic-input {
  width: 100%;
  margin-top: 6px;
}

textarea.mnemonic-input {
  min-height: 64px;
  resize: vertical;
  font-family: inherit;
}

/* ---- Import review (ADR-0017) ---- */
.import-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}

.import-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 10px;
}

.import-row .input {
  min-width: 0;
  border-color: transparent;
  background: transparent;
  padding: 6px 6px;
}

.import-row .input:focus {
  border-color: var(--sea);
}

.import-badges {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.import-toggle {
  background: var(--sand);
  color: var(--ink);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 14px;
  cursor: pointer;
}

.import-toggle:active {
  transform: scale(0.95);
}

.import-row.excluded .input,
.import-row.excluded .import-badges {
  opacity: 0.45;
}

@media (max-width: 360px) {
  :root {
    --screen-pad: 12px;
  }

  .screen {
    gap: 14px;
  }

  .card {
    padding: 14px;
  }

  .btn,
  .input,
  .option {
    font-size: 15px;
  }

  .options,
  .train-actions .btn-row,
  .import-row {
    grid-template-columns: 1fr;
  }

  .import-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .search-row .btn {
    padding-inline: 0;
  }

  .result.has-thumb {
    align-items: flex-start;
  }

  .result-thumb {
    width: 44px;
    height: 44px;
  }
}

@media (min-width: 700px) {
  :root {
    --app-max-width: 520px;
  }

  #app {
    padding-top: 28px;
  }

  .options {
    gap: 12px;
  }

  .option {
    min-height: 68px;
  }

  .overlay-card {
    max-width: 560px;
  }
}
