/* ============================================================
   Slovníček — foundation
   Warm near-black, champagne gold, lamp-glow amber.
   Surfaces are frosted glass lit from behind.
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;

  /* --- theme helpers (overridden by the light theme) ------- */
  --ink: 255, 244, 228; /* tint colour for borders and hover fills */
  --well: 10, 9, 8; /* sunken surfaces: inputs, slots */
  --scrim: rgba(6, 5, 4, 0.8);
  --solid: #17130f; /* opaque surface: table head, select options */
  --scroll: rgba(230, 205, 163, 0.24);
  --on-select: #fff;
  --rose-text: #e58891;
  --sheen-a: rgba(255, 250, 240, 0.09);
  --sheen-b: rgba(255, 244, 228, 0.05);

  /* --- core ----------------------------------------------- */
  --night: #0a0908;
  --night-2: #100e0c;
  --champagne: #e6cda3;
  --champagne-deep: #c7a876;
  --amber: #ffb765;
  --cream: #f4efe7;
  --rose: #d4676f;
  --leaf: #93c08f;

  /* --- glass ---------------------------------------------- */
  --glass-bg: linear-gradient(
    158deg,
    rgba(255, 252, 246, 0.072) 0%,
    rgba(255, 250, 242, 0.032) 46%,
    rgba(255, 248, 238, 0.045) 100%
  );
  --glass-bg-soft: linear-gradient(
    158deg,
    rgba(255, 252, 246, 0.05) 0%,
    rgba(255, 250, 242, 0.022) 100%
  );
  --glass-blur: saturate(150%) blur(26px);
  --glass-edge: rgba(var(--ink), 0.11);
  --glass-edge-lit: rgba(255, 246, 230, 0.2);
  --glass-sheen: inset 0 1px 0 rgba(var(--ink), 0.16);
  --glass-drop: 0 18px 44px rgba(0, 0, 0, 0.5);

  --champagne-soft: rgba(230, 205, 163, 0.13);
  --champagne-line: rgba(230, 205, 163, 0.26);
  --leaf-soft: rgba(147, 192, 143, 0.16);
  --rose-soft: rgba(212, 103, 111, 0.16);

  --rule: rgba(var(--ink), 0.1);
  --rule-quiet: rgba(var(--ink), 0.06);

  /* --- text ----------------------------------------------- */
  --text: #f4efe7;
  --text-2: #cfc7bb;
  --text-3: #a69d91;
  --text-4: #7c7468;

  /* --- CEFR ramp ------------------------------------------ */
  --a1: #10b981;
  --a2: #3b82f6;
  --b1: #6366f1;
  --b2: #f59e0b;
  --c1: #ec4899;
  --c2: #8b5cf6;

  /* --- type ----------------------------------------------- */
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans:
    "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* --- metrics -------------------------------------------- */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 13px;
  --r-lg: 20px;
  --r-xl: 26px;
  --shell: 1180px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

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

button,
select,
input,
textarea {
  touch-action: manipulation;
}

body {
  background: var(--night);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}

/* The light the glass refracts. Fixed, so panels pick up a different
   part of the glow as the page scrolls. */
.ambience {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(
      52% 38% at 50% -4%,
      rgba(255, 183, 101, 0.16) 0%,
      rgba(255, 183, 101, 0) 70%
    ),
    radial-gradient(
      40% 34% at 92% 22%,
      rgba(230, 205, 163, 0.1) 0%,
      rgba(230, 205, 163, 0) 72%
    ),
    radial-gradient(
      46% 40% at 4% 74%,
      rgba(199, 168, 118, 0.085) 0%,
      rgba(199, 168, 118, 0) 74%
    ),
    radial-gradient(
      70% 50% at 50% 108%,
      rgba(255, 183, 101, 0.07) 0%,
      rgba(255, 183, 101, 0) 70%
    );
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.006em;
  margin: 0;
  color: var(--text);
}

h1 {
  font-size: 2.15rem;
  line-height: 1.16;
}

h2 {
  font-size: 1.72rem;
  line-height: 1.22;
}

h3 {
  font-size: 1.38rem;
  line-height: 1.3;
}

p {
  margin: 0;
}

a {
  color: var(--champagne);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  background: rgba(var(--ink), 0.07);
  border-radius: var(--r-xs);
  padding: 1px 5px;
}

input,
button,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

::selection {
  background: rgba(230, 205, 163, 0.3);
  color: var(--on-select);
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

.hidden {
  display: none !important;
}

/* ============================================================
   The glass primitive
   ============================================================ */

.glass {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-sheen), var(--glass-drop);
}

/* A specular sweep across the surface — the tell that it is glass
   and not merely a translucent box. */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    112deg,
    var(--sheen-a) 0%,
    transparent 24%,
    transparent 76%,
    var(--sheen-b) 100%
  );
}

/* Without backdrop-filter the glass would sit on bare black and lose
   contrast, so fall back to a solid warm surface. */
@supports not (
  (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))
) {
  .glass {
    background: var(--solid);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   Shell & navigation
   ============================================================ */

.app-shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 26px 110px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 16px;
  padding: 34px 0 18px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--rule-quiet);
}

.wordmark {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  flex-shrink: 0;
}

.wordmark-logo {
  width: 56px;
  height: auto;
  display: block;
}

.wordmark-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.wordmark h1 {
  background: linear-gradient(
    94deg,
    var(--cream) 8%,
    var(--champagne) 48%,
    var(--champagne-deep) 96%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.wordmark-note {
  font-size: 0.8rem;
  color: var(--text-4);
  letter-spacing: 0.03em;
  text-transform: none;
}

.header-controls {
  display: grid;
  grid-template-columns: auto auto auto;
  justify-content: end;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
}

.header-controls > .main-nav {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: end;
  max-width: 100%;
}

/* Top row, left to right: theme toggle, language, account. */
.header-controls > .btn:nth-child(1) {
  grid-column: 2;
  grid-row: 1;
}

.header-controls > .btn:nth-child(2) {
  grid-column: 3;
  grid-row: 1;
}

.btn-theme {
  grid-column: 1;
  grid-row: 1;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
}

.btn-theme svg {
  display: block;
  width: 17px;
  height: 17px;
}

.main-nav {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
  padding: 4px;
  border-radius: 99px;
  background: var(--glass-bg-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.nav-tab-btn {
  background: none;
  border: 0;
  border-radius: 99px;
  color: var(--text-3);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 19px;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition:
    color 0.2s var(--ease),
    background 0.2s var(--ease);
}

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

.nav-tab-btn.active {
  color: #241b10;
  background: linear-gradient(150deg, #f3e0be, var(--champagne-deep));
  box-shadow: 0 3px 14px rgba(230, 205, 163, 0.25);
}

.nav-trigger {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--glass-bg-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  border-radius: 99px;
  color: var(--text);
  font-size: 0.87rem;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-trigger svg {
  flex-shrink: 0;
}

.nav-modal {
  width: min(360px, 100%);
}

.nav-modal-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-modal-item {
  background: rgba(var(--ink), 0.045);
  border: 1px solid var(--rule-quiet);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  padding: 14px 18px;
  cursor: pointer;
  transition:
    background 0.18s var(--ease),
    border-color 0.18s var(--ease),
    color 0.18s var(--ease);
}

.nav-modal-item:hover {
  border-color: var(--rule);
  color: var(--text);
}

.nav-modal-item.active {
  color: #241b10;
  background: linear-gradient(150deg, #f3e0be, var(--champagne-deep));
  border-color: transparent;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* ============================================================
   Panels
   ============================================================ */

.panel {
  border-radius: var(--r-xl);
  padding: 28px 30px;
  margin-bottom: 22px;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.panel-desc {
  color: var(--text-2);
  font-size: 0.97rem;
  max-width: 64ch;
  margin-bottom: 20px;
}

/* ============================================================
   Progress ledger
   ============================================================ */

.ledger {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 30px;
  border-radius: var(--r-xl);
  padding: 22px 30px;
  margin-bottom: 28px;
}

.ledger-figure {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-family: var(--serif);
}

.ledger-learned {
  font-size: 3rem;
  font-weight: 600;
  line-height: 1;
  color: var(--champagne);
  font-variant-numeric: lining-nums tabular-nums;
}

.ledger-total {
  font-size: 1.22rem;
  color: var(--text-4);
  font-variant-numeric: lining-nums tabular-nums;
}

.ledger-body {
  min-width: 0;
}

.ledger-caption {
  font-size: 0.92rem;
  color: var(--text-2);
  margin-bottom: 11px;
}

.ledger-caption strong {
  color: var(--text);
  font-weight: 600;
}

.track {
  height: 4px;
  background: rgba(var(--ink), 0.09);
  border-radius: 99px;
  overflow: hidden;
}

.track-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    var(--champagne-deep),
    var(--champagne) 55%,
    var(--amber)
  );
  box-shadow: 0 0 14px rgba(255, 183, 101, 0.3);
  transition: width 0.55s var(--ease);
}

.ledger-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.ledger-hint {
  font-size: 0.8rem;
  color: var(--text-4);
  text-align: right;
  max-width: 24ch;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  font-family: var(--sans);
  font-size: 0.93rem;
  font-weight: 600;
  letter-spacing: 0.008em;
  border-radius: 99px;
  padding: 11px 22px;
  cursor: pointer;
  transition:
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.btn-solid {
  background: linear-gradient(150deg, #f3e0be, var(--champagne-deep));
  border: 1px solid rgba(255, 246, 226, 0.4);
  color: #241b10;
  box-shadow: 0 4px 18px rgba(230, 205, 163, 0.22);
}

.btn-solid:hover:not(:disabled) {
  background: linear-gradient(150deg, #fbedd3, #d7b983);
  box-shadow: 0 6px 24px rgba(255, 183, 101, 0.32);
}

.btn-outline {
  background: var(--glass-bg-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--champagne-line);
  color: var(--champagne);
}

.btn-outline:hover:not(:disabled) {
  background: var(--champagne-soft);
  border-color: var(--champagne);
}

.btn-quiet {
  background: rgba(var(--ink), 0.045);
  border: 1px solid var(--rule-quiet);
  color: var(--text-2);
}

.btn-quiet:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--rule);
  background: rgba(var(--ink), 0.08);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-wide {
  display: block;
  width: 100%;
  margin-top: 16px;
}

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

.field {
  background-color: rgba(var(--well), 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 12px 15px;
  font-size: 0.97rem;
  transition:
    border-color 0.2s var(--ease),
    background 0.2s var(--ease);
  min-width: 0;
}

.field::placeholder {
  color: var(--text-4);
}

.field:hover {
  border-color: var(--rule);
  background-color: rgba(var(--well), 0.35);
}

.field:focus {
  outline: none;
}

input.field:focus,
textarea.field:focus,
select.field:focus-visible {
  border-color: var(--champagne);
}

select.field {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23a69d91' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 14px center;
  background-size: 12px 8px;
  background-repeat: no-repeat;
  padding-right: 38px;
  cursor: pointer;
  text-overflow: ellipsis;
}

select.field option {
  background: var(--solid);
  color: var(--text);
}

textarea.field {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86rem;
  line-height: 1.6;
}

/* ============================================================
   CEFR marks
   ============================================================ */

.lvl-a1 {
  --lvl: var(--a1);
}

.lvl-a2 {
  --lvl: var(--a2);
}

.lvl-b1 {
  --lvl: var(--b1);
}

.lvl-b2 {
  --lvl: var(--b2);
}

.lvl-c1 {
  --lvl: var(--c1);
}

.lvl-c2 {
  --lvl: var(--c2);
}

.level-mark {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

.level-mark::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lvl, var(--champagne));
  box-shadow: 0 0 9px var(--lvl, var(--champagne));
}

/* Level filter row */
.level-rail {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.level-chip {
  --lvl: var(--champagne);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 92px;
  border-radius: var(--r-md);
  padding: 11px 16px 10px;
  cursor: pointer;
  border: 1px solid var(--glass-edge);
  background: var(--glass-bg-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition:
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.level-chip-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--lvl, var(--champagne));
  opacity: 0.85;
  transition: width 0.3s var(--ease);
}

.level-chip:hover:not(:disabled) {
  border-color: var(--glass-edge-lit);
}

.level-chip.active {
  border-color: color-mix(in srgb, var(--lvl) 55%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--lvl) 28%, transparent),
    0 8px 22px rgba(0, 0, 0, 0.4);
  background: var(--glass-bg);
}

.level-chip:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.level-chip-name {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.level-chip.active .level-chip-name {
  color: var(--lvl);
}

.level-chip-count {
  font-size: 0.78rem;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Dictionary
   ============================================================ */

.filter-bar {
  display: flex;
  gap: 11px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filter-bar .field {
  flex: 1 1 210px;
}

.filter-bar .field-search {
  flex: 2 1 330px;
}

.result-line {
  font-size: 0.87rem;
  color: var(--text-4);
  margin-bottom: 14px;
  font-variant-numeric: tabular-nums;
}

.word-list {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl);
  overflow: hidden;
}

/* Base entry styles - desktop/tablet */
.entry {
  --lvl: var(--champagne);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  padding: 19px 24px 19px 22px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--rule-quiet);
  transition:
    background 0.18s var(--ease),
    border-left-color 0.18s var(--ease);
  position: relative;
}

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

.entry:hover {
  background: rgba(var(--ink), 0.045);
  border-left-color: var(--lvl);
}

.entry.is-learned {
  border-left-color: var(--lvl);
}

.entry-main {
  min-width: 0;
}

.entry-head {
  display: flex;
  align-items: baseline;
  gap: 11px;
  flex-wrap: wrap;
}

.entry-cz {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.75rem;
  line-height: 1.15;
  letter-spacing: 0.008em;
  color: var(--cream);
}

.btn-say {
  background: none;
  border: 0;
  color: var(--text-4);
  cursor: pointer;
  padding: 3px 5px;
  line-height: 1;
  border-radius: var(--r-xs);
  transition:
    color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-say:hover {
  color: var(--amber);
  transform: scale(1.08);
}

.btn-say.is-speaking {
  color: var(--amber);
  filter: drop-shadow(
    0 0 8px color-mix(in srgb, var(--amber) 60%, transparent)
  );
  animation: pulse-say 1.2s infinite ease-in-out;
}

@keyframes pulse-say {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

.btn-say svg {
  display: block;
  width: 17px;
  height: 17px;
}

.entry-phon {
  font-size: 0.88rem;
  color: var(--text-4);
  font-style: italic;
}

.entry-ua {
  font-size: 1.06rem;
  color: var(--text);
  margin-top: 2px;
}

.entry-usage {
  margin-top: 11px;
  padding: 9px 0 9px 15px;
  border-left: 2px solid var(--champagne-line);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text-2);
}

.entry-usage-translation {
  margin-top: 6px;
  padding-left: 15px;
  font-size: 0.93rem;
  line-height: 1.45;
  color: var(--text-3);
  font-style: italic;
  border-left: 2px solid transparent;
}

@keyframes pulse-text {
  0%,
  100% {
    opacity: 0.75;
  }
  50% {
    opacity: 1;
  }
}

.entry-usage-row {
  cursor: pointer;
  border-radius: var(--r-xs);
  transition:
    opacity 0.2s var(--ease),
    color 0.2s var(--ease);
}

.entry-usage-row:hover .entry-usage {
  color: var(--amber);
  border-left-color: var(--amber);
}

.entry-usage-row.is-speaking-usage .entry-usage {
  color: var(--amber);
  border-left-color: var(--amber);
  animation: pulse-text 1.2s infinite ease-in-out;
}

.entry-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.btn-learn {
  font-family: var(--sans);
  background: rgba(var(--ink), 0.05);
  border: 1px solid var(--rule-quiet);
  border-radius: 99px;
  color: var(--text-3);
  font-size: 0.83rem;
  font-weight: 600;
  padding: 6px 15px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s var(--ease);
}

.btn-learn:hover {
  border-color: var(--rule);
  color: var(--text);
}

.btn-learn.on {
  background: var(--leaf-soft);
  border-color: rgba(147, 192, 143, 0.45);
  color: var(--leaf);
}

/* Phones only (tablets keep the desktop layout): level badge
   pinned top-right of the card, learn button spans full width
   beneath the text. */
@media (max-width: 560px) {
  .entry {
    grid-template-columns: 1fr;
    padding: 17px 18px;
  }

  .entry-main {
    padding-right: 54px;
  }

  .entry-cz {
    font-size: 1.55rem;
  }

  .entry-side {
    display: contents;
  }

  .level-mark {
    position: absolute;
    top: 17px;
    right: 18px;
  }

  .btn-learn {
    display: block;
    width: 100%;
    margin-top: 14px;
    text-align: center;
  }
}

.empty-note strong {
  color: var(--text);
  font-weight: 600;
}

/* ============================================================
   Roadmap — colour-coded stage cards
   ============================================================ */

.roadmap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stage {
  --lvl: var(--champagne);
  position: relative;
  border-radius: var(--r-lg);
  padding: 24px 28px 22px;
  overflow: hidden;
}

/* The colour rail that identifies the level at a glance. */
.stage::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--lvl);
  box-shadow: 0 0 22px color-mix(in srgb, var(--lvl) 60%, transparent);
}

.stage.locked {
  opacity: 0.6;
}

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

.stage-level {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--lvl);
  margin-bottom: 2px;
}

.stage-title {
  font-family: var(--serif);
  font-size: 1.62rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--cream);
}

.stage-pill {
  flex: none;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-2);
  background: rgba(var(--ink), 0.07);
  border: 1px solid var(--rule-quiet);
  border-radius: 99px;
  padding: 5px 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stage.done .stage-pill {
  color: var(--lvl);
  border-color: color-mix(in srgb, var(--lvl) 45%, transparent);
  background: color-mix(in srgb, var(--lvl) 14%, transparent);
}

.stage-desc {
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--text-2);
  max-width: 70ch;
  margin-top: 10px;
}

.stage-rule {
  height: 1px;
  background: var(--rule-quiet);
  margin: 18px 0 16px;
}

.topic-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topic {
  font-size: 0.83rem;
  color: var(--text-2);
  background: rgba(var(--ink), 0.045);
  border: 1px solid var(--rule-quiet);
  border-radius: 99px;
  padding: 5px 13px;
  transition:
    border-color 0.18s var(--ease),
    color 0.18s var(--ease);
}

.topic:hover {
  border-color: color-mix(in srgb, var(--lvl) 50%, transparent);
  color: var(--text);
}

.topic-n {
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

.stage-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.stage-count {
  font-size: 0.85rem;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

.stage-actions {
  display: flex;
  gap: 9px;
}

.stage .btn {
  font-size: 0.86rem;
  padding: 8px 17px;
}

/* ============================================================
   Own words
   ============================================================ */

.form-row {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.6fr auto;
  gap: 11px;
}

.table-wrap {
  max-height: 480px;
  overflow: auto;
  border: 1px solid var(--rule-quiet);
  border-radius: var(--r-md);
}

table.db {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

table.db th {
  position: sticky;
  top: 0;
  background: var(--solid);
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-3);
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  z-index: 1;
}

table.db td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule-quiet);
  color: var(--text-2);
}

table.db tr:hover td {
  background: rgba(var(--ink), 0.04);
}

table.db td.cz-cell {
  font-family: var(--serif);
  font-size: 1.22rem;
  color: var(--text);
}

.btn-remove {
  background: none;
  border: 0;
  color: var(--text-4);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--r-xs);
}

.btn-remove:hover {
  color: var(--rose);
  background: var(--rose-soft);
}

.db-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ============================================================
   Level test overlay
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: grid;
  place-items: center;
  padding: 22px;
  z-index: 60;
}

.overlay-window {
  width: min(640px, 100%);
  max-height: 88vh;
  max-height: calc(100dvh - 44px);
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: var(--r-xl);
}

.overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 30px 18px;
}

.overlay-head p {
  font-size: 0.9rem;
  color: var(--text-3);
  margin-top: 4px;
}

.btn-close {
  background: none;
  border: 0;
  color: var(--text-3);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

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

.overlay-body {
  padding: 22px 30px 30px;
}

.exam-meta {
  font-size: 0.82rem;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
  margin-bottom: 14px;
}

.exam-word {
  font-family: var(--serif);
  font-size: 2.9rem;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  margin: 18px 0 6px;
  color: var(--cream);
}

.exam-phon {
  text-align: center;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-4);
  margin-bottom: 24px;
  min-height: 20px;
}

.result-pane {
  text-align: center;
  padding: 18px 0 6px;
}

.result-score {
  font-family: var(--serif);
  font-size: 4rem;
  font-weight: 600;
  line-height: 1;
  color: var(--champagne);
  font-variant-numeric: lining-nums tabular-nums;
}

.result-of {
  font-size: 0.97rem;
  color: var(--text-4);
  margin-bottom: 14px;
}

.result-pane h2 {
  margin-bottom: 9px;
}

.result-pane p {
  font-size: 0.97rem;
  color: var(--text-2);
  max-width: 46ch;
  margin: 0 auto 24px;
}

/* ============================================================
   Language selection modal
   ============================================================ */

.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.btn-lang-option {
  height: auto;
  text-align: center;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition:
    transform 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.btn-lang-option:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.btn-lang-option strong {
  display: block;
  font-size: 1.25rem;
  color: var(--cream);
}

.btn-lang-option span {
  display: block;
  font-size: 0.85rem;
  color: var(--text-4);
  font-weight: 400;
}

.btn-lang-option.active {
  border-color: var(--champagne);
  background: var(--champagne-soft);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 880px) {
  .app-shell {
    padding: 0 16px 90px;
  }

  .ledger {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .ledger-action {
    align-items: flex-start;
  }

  .ledger-hint {
    text-align: left;
    max-width: none;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 22px 18px;
  }

  .stage {
    padding: 20px 20px 18px;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .app-header {
    align-items: flex-start;
    padding-top: 24px;
  }

  h1 {
    font-size: 1.85rem;
  }

  .nav-tab-btn {
    padding: 7px 13px;
    font-size: 0.87rem;
  }

  .ledger-learned {
    font-size: 2.4rem;
  }

  .stage-top {
    flex-direction: column;
    gap: 10px;
  }
}

/* ============================================================
   Practice — one design language across all five drills.
   ============================================================ */

.practice-panel {
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

/* ---------- Setup ---------------------------------------- */

.setup-lead {
  margin-bottom: 22px;
}

.drill-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(226px, 1fr));
  gap: 11px;
  margin-bottom: 26px;
}

.drill-option {
  text-align: left;
  border-radius: var(--r-md);
  padding: 17px 19px 18px;
  cursor: pointer;
  border: 1px solid var(--glass-edge);
  background: var(--glass-bg-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition:
    border-color 0.2s var(--ease),
    background 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.drill-option:hover:not(:disabled) {
  border-color: var(--glass-edge-lit);
}

.drill-option.active {
  border-color: var(--champagne-line);
  background: var(--glass-bg);
  box-shadow:
    0 0 0 1px rgba(230, 205, 163, 0.16),
    0 10px 28px rgba(0, 0, 0, 0.42);
}

.drill-option:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.drill-option-name {
  display: block;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--cream);
}

.drill-option.active .drill-option-name {
  color: var(--champagne);
}

.drill-option-desc {
  display: block;
  font-size: 0.89rem;
  color: var(--text-3);
  line-height: 1.5;
}

.drill-option.active .drill-option-desc {
  color: var(--text-2);
}

.drill-option-avail {
  display: block;
  margin-top: 11px;
  font-size: 0.8rem;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

.drill-option.active .drill-option-avail {
  color: var(--champagne-deep);
}

.setup-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 11px;
  align-items: end;
  padding-top: 22px;
  border-top: 1px solid var(--rule-quiet);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 0.82rem;
  color: var(--text-3);
}

/* ---------- Shared session chrome ------------------------ */

.drill {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.drill-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 13px;
}

.drill-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-2);
}

.drill-stats {
  display: flex;
  align-items: baseline;
  gap: 20px;
  font-size: 0.87rem;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

.drill-stats b {
  color: var(--text);
  font-weight: 700;
}

.drill-stats .streak {
  color: var(--amber);
}

.drill-rule {
  height: 3px;
  background: rgba(var(--ink), 0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 34px;
}

.drill-rule-fill {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--champagne-deep),
    var(--champagne) 60%,
    var(--amber)
  );
  box-shadow: 0 0 12px rgba(255, 183, 101, 0.35);
  transition: width 0.4s var(--ease);
}

.drill-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.drill-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--rule-quiet);
}

.foot-right {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

/* ---------- The prompt ----------------------------------- */

.prompt {
  text-align: center;
  margin-bottom: 32px;
}

.prompt-kicker {
  font-size: 0.93rem;
  color: var(--text-3);
  margin-bottom: 14px;
}

.prompt-word {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.3rem, 6vw, 3.4rem);
  line-height: 1.12;
  letter-spacing: 0.006em;
  word-break: break-word;
  color: var(--cream);
}

/* Sentences and Ukrainian prompts are read word by word — sans, and
   never smaller than body text. */
.prompt-sentence {
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(1.28rem, 3vw, 1.7rem);
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--cream);
  max-width: 34ch;
  margin: 0 auto;
}

.prompt-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-top: 12px;
  font-size: 1rem;
  color: var(--text-3);
  min-height: 26px;
}

.prompt-sub em {
  font-style: italic;
  color: var(--text-4);
}

/* ---------- Cloze gap ------------------------------------ */

.gap {
  display: inline-block;
  min-width: 5ch;
  border-bottom: 2px solid var(--champagne);
  box-shadow: 0 6px 16px -8px var(--amber);
  vertical-align: baseline;
}

/* ---------- Options grid --------------------------------- */

.opt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.opt {
  position: relative;
  text-align: left;
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 1.04rem;
  padding: 16px 19px;
  cursor: pointer;
  border: 1px solid var(--glass-edge);
  background: var(--glass-bg-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition:
    border-color 0.16s var(--ease),
    background 0.16s var(--ease),
    opacity 0.22s var(--ease);
}

.opt:hover:not(:disabled) {
  border-color: var(--champagne-line);
  background: var(--glass-bg);
}

.opt:disabled {
  cursor: default;
}

.opt.right {
  border-color: rgba(147, 192, 143, 0.6);
  background: var(--leaf-soft);
  color: var(--cream);
}

.opt.wrong {
  border-color: rgba(212, 103, 111, 0.6);
  background: var(--rose-soft);
}

.opt.faded {
  opacity: 0.32;
}

.opt-cz {
  font-family: var(--serif);
  font-size: 1.42rem;
  font-weight: 600;
}

/* ---------- Verdict -------------------------------------- */

.verdict {
  text-align: center;
  margin-top: 24px;
  min-height: 54px;
}

.verdict-line {
  font-size: 1.04rem;
  font-weight: 600;
}

.verdict-line.ok {
  color: var(--leaf);
}

.verdict-line.bad {
  color: var(--rose-text);
}

.verdict-usage {
  font-size: 1.04rem;
  line-height: 1.5;
  color: var(--text-2);
  margin-top: 8px;
  max-width: 52ch;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Typing --------------------------------------- */

.answer-row {
  display: flex;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.answer-field {
  flex: 1;
  background: rgba(var(--well), 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  padding: 14px 18px;
  font-size: 1.32rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  transition: border-color 0.2s var(--ease);
}

.answer-field::placeholder {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-4);
}

.answer-field:focus {
  outline: none;
  border-color: var(--champagne);
}

.answer-field.right {
  border-color: var(--leaf);
  color: var(--leaf);
}

.answer-field.wrong {
  border-color: var(--rose);
}

.answer-field:disabled {
  opacity: 1;
}

/* ---------- Pairs ---------------------------------------- */

.pairs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

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

.tile {
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 15px 17px;
  text-align: left;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1.35;
  border: 1px solid var(--glass-edge);
  background: var(--glass-bg-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition:
    border-color 0.16s var(--ease),
    background 0.16s var(--ease),
    opacity 0.28s var(--ease);
}

.tile.cz {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
}

.tile:hover:not(.locked) {
  border-color: var(--champagne-line);
  background: var(--glass-bg);
}

.tile.picked {
  border-color: var(--champagne);
  background: var(--champagne-soft);
  box-shadow: 0 0 0 1px rgba(230, 205, 163, 0.25);
}

.tile.locked {
  border-color: transparent;
  background: var(--leaf-soft);
  color: var(--text-4);
  cursor: default;
  opacity: 0.4;
}

.tile.miss {
  border-color: var(--rose);
  background: var(--rose-soft);
}

/* ---------- Builder -------------------------------------- */

.build-area {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

.slot {
  min-height: 86px;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  gap: 8px;
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin-bottom: 20px;
  border: 1px dashed var(--champagne-line);
  background: rgba(var(--well), 0.4);
  transition:
    border-color 0.24s var(--ease),
    background 0.24s var(--ease);
}

.slot.right {
  border-style: solid;
  border-color: var(--leaf);
  background: var(--leaf-soft);
}

.slot.wrong {
  border-style: solid;
  border-color: var(--rose);
  background: var(--rose-soft);
}

.slot:empty::before {
  content: attr(data-empty);
  font-size: 0.95rem;
  color: var(--text-4);
}

.chip-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 48px;
}

.chip {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 9px 17px;
  cursor: pointer;
  border: 1px solid var(--glass-edge);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition:
    border-color 0.16s var(--ease),
    transform 0.16s var(--ease);
}

.chip:hover:not(:disabled) {
  border-color: var(--champagne);
}

.chip:active:not(:disabled) {
  transform: translateY(1px);
}

.chip:disabled {
  cursor: default;
  opacity: 0.85;
}

/* ---------- Results -------------------------------------- */

.drill-result {
  text-align: center;
  padding: 32px 0;
  animation: rise 0.5s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.drill-result .result-score {
  font-family: var(--serif);
  font-size: 4.4rem;
  font-weight: 600;
  line-height: 1;
  color: var(--champagne);
  font-variant-numeric: lining-nums tabular-nums;
}

.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 26px;
}

.review-list {
  max-width: 560px;
  margin: 28px auto 0;
  text-align: left;
  border-top: 1px solid var(--rule-quiet);
}

.review-head {
  font-size: 0.85rem;
  color: var(--text-4);
  padding: 14px 2px 8px;
}

.review-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--rule-quiet);
}

.review-cz {
  font-family: var(--serif);
  font-size: 1.28rem;
  font-weight: 600;
  color: var(--cream);
}

.review-ua {
  font-size: 0.95rem;
  color: var(--text-2);
  text-align: right;
}

/* ---------- Responsive ----------------------------------- */

@media (max-width: 660px) {
  .pairs {
    gap: 8px;
  }

  .tile {
    padding: 12px 13px;
    font-size: 0.95rem;
  }

  .tile.cz {
    font-size: 1.16rem;
  }

  .opt-grid {
    grid-template-columns: 1fr;
  }

  .drill-rule {
    margin-bottom: 26px;
  }

  .drill-stats {
    gap: 14px;
    font-size: 0.82rem;
  }
}

/* ============================================================
   Mobile refinements
   Everything below only applies on small screens and overrides
   the desktop rules above.
   ============================================================ */

/* Touch devices have no hover, so hover states would stick after a tap. */
@media (hover: none) {
  .entry:hover {
    background: none;
    border-left-color: transparent;
  }

  .entry.is-learned:hover {
    border-left-color: var(--lvl);
  }
}

/* iOS Safari zooms the page when a focused field is under 16px. */
@media (max-width: 880px) {
  .field,
  textarea.field,
  .answer-field {
    font-size: 16px;
  }

  .app-shell {
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- Header ----------
   Row one: logo + account button.
   Row two: language icon + swipeable tab strip (no popup menu). */
@media (max-width: 760px) {
  .app-header {
    flex-wrap: wrap;
    align-items: center;
    gap: 0 8px;
    padding: 16px 0 14px;
    margin-bottom: 18px;
  }

  /* Invisible full-width item that forces a line break after the account button. */
  .app-header::after {
    content: "";
    order: 4;
    flex: 0 0 100%;
    height: 0;
  }

  .wordmark {
    order: 1;
    margin-right: auto;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 10px;
    min-width: 0;
  }

  .wordmark-logo {
    width: 38px;
  }

  .wordmark-details {
    align-items: flex-start;
    gap: 0;
  }

  .wordmark h1 {
    font-size: 1.5rem;
  }

  .wordmark-note {
    font-size: 0.72rem;
  }

  /* The controls become direct children of the header so they can be
     ordered independently of the logo. */
  .header-controls {
    display: contents;
  }

  .header-controls > .btn {
    min-width: 0;
    padding: 9px 14px;
    font-size: 0.85rem;
    /* Inline styles in the markup set display:flex; block lets long
       e-mail addresses truncate with an ellipsis instead of wrapping. */
    display: block !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-controls > .btn svg {
    display: inline-block;
    vertical-align: -2px;
    margin-right: 6px;
  }

  /* Theme toggle: round icon button, first row between logo and account. */
  .header-controls > .btn.btn-theme {
    order: 2;
    flex: 0 0 auto;
    display: inline-grid !important;
    padding: 0;
  }

  .header-controls > .btn.btn-theme svg {
    margin: 0;
    vertical-align: 0;
  }

  /* Account / sign-in: first row, right of the logo. */
  .header-controls > .btn:nth-child(2) {
    order: 3;
    flex: 0 1 auto;
  }

  /* Language: second row, icon + short code. */
  .header-controls > .btn:nth-child(1) {
    order: 5;
    flex: 0 0 auto;
    margin-top: 10px;
  }

  /* Tabs: second row, fill the rest of the width and scroll sideways. */
  .main-nav {
    order: 6;
    flex: 1 1 0;
    min-width: 0;
    margin-top: 10px;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------- Tablet and phone ---------- */
@media (max-width: 560px) {
  .panel {
    padding: 20px 16px;
    border-radius: var(--r-lg);
  }

  h2 {
    font-size: 1.5rem;
  }

  .panel-desc {
    font-size: 0.93rem;
    margin-bottom: 16px;
  }

  /* Progress ledger */
  .ledger {
    padding: 18px 16px;
    margin-bottom: 20px;
    border-radius: var(--r-lg);
  }

  .ledger-action .btn {
    width: 100%;
  }

  .ledger-action {
    align-items: stretch;
  }

  /* Level chips scroll sideways instead of wrapping into a tall block. */
  .level-rail {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -16px 16px;
    padding: 0 16px 6px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .level-rail::-webkit-scrollbar {
    display: none;
  }

  .level-chip {
    flex: 0 0 auto;
    min-width: 76px;
    padding: 9px 13px;
  }

  /* Filters: search on top, topic below, the rest side by side. */
  .filter-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
  }

  .filter-bar .field,
  .filter-bar .field-search {
    flex: none;
    width: 100%;
  }

  .filter-bar .field-search {
    grid-column: 1 / -1;
    order: -2;
  }

  .filter-bar .field:nth-child(3) {
    grid-column: 1 / -1;
    order: -1;
  }

  /* Dictionary cards */
  .word-list {
    border-radius: var(--r-lg);
  }

  .entry-head {
    gap: 6px 10px;
  }

  .entry-cz,
  .entry-ua,
  .entry-usage,
  .entry-usage-translation {
    overflow-wrap: break-word;
  }

  .btn-say {
    padding: 8px;
    margin: -5px -4px;
  }

  .btn-learn {
    padding: 10px 15px;
    font-size: 0.88rem;
  }

  /* Overlays */
  .overlay {
    padding: 12px;
  }

  .overlay-window {
    max-height: calc(100dvh - 24px);
    border-radius: var(--r-lg);
  }

  .overlay-head {
    padding: 20px 20px 12px;
  }

  .overlay-body {
    padding: 14px 20px 22px;
  }

  .exam-word {
    font-size: 2.2rem;
    overflow-wrap: break-word;
  }

  .result-score {
    font-size: 3.2rem;
  }

  .lang-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .btn-lang-option {
    padding: 16px;
  }

  /* Roadmap */
  .stage {
    padding: 18px 16px 16px;
  }

  .stage-title {
    font-size: 1.4rem;
  }

  .stage-pill {
    align-self: flex-start;
  }

  .stage-foot {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .stage-actions {
    width: 100%;
  }

  .stage-actions .btn {
    flex: 1;
  }

  /* My words: the table turns into a list of cards. */
  .db-head .field {
    max-width: none !important;
    width: 100%;
  }

  .table-wrap {
    max-height: 60vh;
    max-height: 60dvh;
  }

  table.db,
  table.db tbody {
    display: block;
  }

  table.db thead {
    display: none;
  }

  table.db tr {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 2px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--rule-quiet);
  }

  table.db td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
    overflow-wrap: break-word;
  }

  table.db td:first-child {
    display: none;
  }

  table.db td:nth-child(2) {
    grid-column: 1;
    grid-row: 1;
  }

  table.db td:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
    font-size: 0.92rem;
  }

  table.db td:nth-child(4) {
    grid-column: 2;
    grid-row: 1;
  }

  table.db td:nth-child(5) {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }

  table.db tr:hover td {
    background: none;
  }

  /* Practice */
  .practice-panel {
    min-height: 0;
  }

  .drill-menu {
    grid-template-columns: 1fr;
  }

  .drill-option {
    padding: 14px 16px;
  }

  .setup-controls {
    grid-template-columns: 1fr 1fr;
  }

  .setup-controls .btn-solid {
    grid-column: 1 / -1;
    padding: 13px 22px;
  }

  .drill-bar {
    gap: 6px 12px;
  }

  .drill-foot {
    margin-top: 22px;
    padding-top: 16px;
  }

  .drill-foot .btn {
    padding: 10px 16px;
  }

  .prompt {
    margin-bottom: 24px;
  }

  .answer-row {
    flex-direction: column;
  }

  .answer-field {
    font-size: 1.15rem;
    padding: 12px 14px;
  }

  .chip {
    font-size: 1.15rem;
    padding: 8px 13px;
  }

  .slot {
    min-height: 72px;
    padding: 12px;
  }

  .review-row {
    gap: 12px;
  }

  .drill-result .result-score {
    font-size: 3.4rem;
  }
}

/* Very narrow phones (320px class). */
@media (max-width: 360px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .level-rail {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .entry {
    padding: 15px 14px;
  }

  .entry-main {
    padding-right: 48px;
  }

  .level-mark {
    right: 14px;
  }

  .setup-controls {
    grid-template-columns: 1fr;
  }
}

/* Centered modal header (level test): title and subtitle centered,
   close button pinned to the corner. */
.overlay-head-center {
  position: relative;
  justify-content: center;
  text-align: center;
}

.overlay-head-center > div {
  flex: 1 1 auto;
  padding: 0 32px;
  text-align: center;
}

.overlay-head-center h2,
.overlay-head-center h3,
.overlay-head-center p {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

.overlay-head-center .btn-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

@media (max-width: 560px) {
  .overlay-head-center .btn-close {
    top: 12px;
    right: 12px;
  }
}

/* ============================================================
   Light theme
   Warm paper and champagne, taken from the e-mail look:
   cream page, beige cards, brown-gold accents.
   Activated by <html data-theme="light">.
   ============================================================ */

:root[data-theme="light"] {
  color-scheme: light;

  --ink: 92, 72, 40;
  --well: 255, 253, 249;
  --scrim: rgba(48, 40, 30, 0.5);
  --solid: #f3ede4;
  --scroll: rgba(122, 95, 46, 0.34);
  --on-select: #2e261b;
  --rose-text: #a3363f;
  --sheen-a: rgba(255, 255, 255, 0.16);
  --sheen-b: rgba(255, 255, 255, 0.06);

  --night: #f6f4f1;
  --night-2: #f0ece6;
  --champagne: #6a4d1a;
  --champagne-deep: #9a7230;
  --amber: #a8650f;
  --cream: #2a2218;
  --rose: #b4444d;
  --leaf: #3f7a45;

  --glass-bg: linear-gradient(
    158deg,
    rgba(246, 240, 233, 0.94) 0%,
    rgba(240, 233, 225, 0.88) 46%,
    rgba(243, 236, 228, 0.92) 100%
  );
  --glass-bg-soft: linear-gradient(
    158deg,
    rgba(246, 241, 234, 0.8) 0%,
    rgba(241, 234, 226, 0.72) 100%
  );
  --glass-edge: rgba(120, 94, 52, 0.32);
  --glass-edge-lit: rgba(120, 94, 52, 0.4);
  --glass-sheen: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --glass-drop: 0 10px 30px rgba(96, 72, 36, 0.12);

  --champagne-soft: rgba(184, 149, 90, 0.16);
  --champagne-line: rgba(122, 95, 46, 0.36);
  --leaf-soft: rgba(63, 122, 69, 0.12);
  --rose-soft: rgba(180, 68, 77, 0.1);

  --rule: rgba(92, 72, 40, 0.18);
  --rule-quiet: rgba(92, 72, 40, 0.1);

  --text: #2a2218;
  --text-2: #372e22;
  --text-3: #4a3f31;
  --text-4: #5c503f;

  /* CEFR colours darkened so the level labels stay readable on paper. */
  --a1: #0b8a64;
  --a2: #2563eb;
  --b1: #4f46e5;
  --b2: #b45309;
  --c1: #be185d;
  --c2: #6d28d9;
}

:root[data-theme="light"] .ambience {
  background:
    radial-gradient(
      52% 38% at 50% -4%,
      rgba(230, 205, 163, 0.38) 0%,
      rgba(230, 205, 163, 0) 70%
    ),
    radial-gradient(
      40% 34% at 92% 22%,
      rgba(230, 205, 163, 0.22) 0%,
      rgba(230, 205, 163, 0) 72%
    ),
    radial-gradient(
      46% 40% at 4% 74%,
      rgba(199, 168, 118, 0.16) 0%,
      rgba(199, 168, 118, 0) 74%
    ),
    radial-gradient(
      70% 50% at 50% 108%,
      rgba(255, 183, 101, 0.12) 0%,
      rgba(255, 183, 101, 0) 70%
    );
}

:root[data-theme="light"] select.field {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%2365594a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

:root[data-theme="light"] .btn-outline {
  background: rgba(255, 255, 255, 0.35);
}

:root[data-theme="light"] .tile.locked {
  color: var(--text-3);
}

/* ============================================================
   Slide switches (language UA / EN, theme Sun / Night)
   ============================================================ */

.header-switches {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 2;
  grid-row: 1;
}

.slide-switch {
  --thumb-a: #efd9ae;
  --thumb-b: #c9a56a;
  --thumb-ink: #1c150d;
  --thumb-glow: rgba(230, 205, 163, 0.35);

  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  padding: 3px;
  border-radius: 99px;
  background: var(--glass-bg-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-sheen);
  isolation: isolate;
}

.slide-switch-thumb {
  position: absolute;
  z-index: -1;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 99px;
  background: linear-gradient(135deg, var(--thumb-a), var(--thumb-b));
  box-shadow:
    0 2px 10px var(--thumb-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.28s cubic-bezier(0.4, 0.1, 0.2, 1);
}

.slide-switch[data-pos="1"] .slide-switch-thumb {
  transform: translateX(100%);
}

.slide-switch-opt {
  appearance: none;
  background: none;
  border: 0;
  min-width: 40px;
  height: 30px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  border-radius: 99px;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-3);
  transition: color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.slide-switch-opt.on {
  color: var(--thumb-ink);
}

.slide-switch-opt svg {
  display: block;
  width: 16px;
  height: 16px;
}

.slide-switch-opt:focus-visible {
  outline: 2px solid var(--champagne);
  outline-offset: 1px;
}

:root[data-theme="light"] .slide-switch {
  --thumb-a: #f6e3bb;
  --thumb-b: #d3ae6c;
  --thumb-ink: #3a2c14;
  --thumb-glow: rgba(168, 125, 52, 0.32);
}

@media (prefers-reduced-motion: reduce) {
  .slide-switch-thumb,
  .slide-switch-opt {
    transition: none;
  }
}

@media (max-width: 760px) {
  .header-controls > .header-switches {
    order: 5;
    margin-top: 10px;
    margin-right: auto;
  }

  .header-controls > .main-nav {
    order: 6;
    flex: 0 0 100%;
  }
}

/* ---- Light theme: contrast and gold pass ---- */
:root[data-theme="light"] .wordmark h1 {
  background: linear-gradient(94deg, #2a2218 6%, #6a4d1a 50%, #a97c32 98%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

:root[data-theme="light"] .wordmark-note,
:root[data-theme="light"] .nav-tab-btn,
:root[data-theme="light"] .panel-desc {
  color: var(--text-2);
}

:root[data-theme="light"] .nav-tab-btn.active {
  color: #2a1d08;
}

:root[data-theme="light"] .slide-switch {
  --thumb-a: #f2cf86;
  --thumb-b: #b8863a;
  --thumb-ink: #20160a;
  --thumb-glow: rgba(150, 103, 30, 0.5);
  background: linear-gradient(158deg, #efe3d0 0%, #e4d3b8 100%);
  border-color: rgba(106, 77, 26, 0.45);
  box-shadow:
    inset 0 1px 2px rgba(96, 72, 36, 0.18),
    0 1px 0 rgba(255, 255, 255, 0.6);
}

:root[data-theme="light"] .slide-switch-opt {
  color: #4a3f31;
}

:root[data-theme="light"] .slide-switch-opt.on {
  color: #20160a;
}

:root[data-theme="light"] .slide-switch-thumb {
  box-shadow:
    0 3px 12px rgba(150, 103, 30, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(106, 70, 14, 0.35);
}

/* ============================================================
   Pass 3: wordmark, level chips (no black glow), light sliders
   ============================================================ */

/* ---- Wordmark ---- */
.wordmark h1 {
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.05;
  background: linear-gradient(
    100deg,
    #fff6e0 0%,
    #f1d9a6 28%,
    #e6bb6a 52%,
    #f6e2b4 76%,
    #d9a955 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 14px rgba(230, 190, 110, 0.38));
  animation: wordmark-shine 9s ease-in-out infinite alternate;
}

:root[data-theme="light"] .wordmark h1 {
  background: linear-gradient(
    100deg,
    #3d2a0b 0%,
    #6b4710 26%,
    #a8741f 50%,
    #7a5214 74%,
    #3d2a0b 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 10px rgba(168, 116, 31, 0.28));
}

@keyframes wordmark-shine {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 100% 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark h1 {
    animation: none;
  }
}

@media (max-width: 760px) {
  .wordmark h1 {
    font-size: 1.95rem;
  }
}

/* ---- Level chips: tinted glow instead of black shadow ---- */
.level-chip.active {
  background:
    linear-gradient(
      145deg,
      color-mix(in srgb, var(--lvl) 20%, transparent) 0%,
      color-mix(in srgb, var(--lvl) 6%, transparent) 100%
    ),
    var(--glass-bg);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--lvl) 34%, transparent),
    0 6px 20px color-mix(in srgb, var(--lvl) 24%, transparent);
}

.drill-option.active {
  box-shadow:
    0 0 0 1px rgba(230, 205, 163, 0.2),
    0 6px 22px rgba(230, 190, 110, 0.18);
}

.btn-lang-option:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(230, 190, 110, 0.18);
}

:root[data-theme="light"] .drill-option.active,
:root[data-theme="light"] .btn-lang-option:hover:not(:disabled) {
  box-shadow:
    0 0 0 1px rgba(168, 116, 31, 0.3),
    0 6px 20px rgba(168, 116, 31, 0.2);
}

/* ---- Light-theme sliders: ivory glass + glossy gold thumb ---- */
:root[data-theme="light"] .slide-switch {
  --thumb-a: #fbeac0;
  --thumb-b: #d9a950;
  --thumb-ink: #3a2808;
  --thumb-glow: rgba(190, 135, 40, 0.42);
  background: linear-gradient(
    160deg,
    rgba(255, 252, 245, 0.95) 0%,
    rgba(247, 238, 222, 0.9) 100%
  );
  border: 1px solid rgba(168, 116, 31, 0.38);
  box-shadow:
    inset 0 1px 0 #fff,
    0 2px 10px rgba(150, 105, 30, 0.14);
}

:root[data-theme="light"] .slide-switch-thumb {
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.55) 0%,
      rgba(255, 255, 255, 0) 55%
    ),
    linear-gradient(135deg, #fbeac0 0%, #e8c370 48%, #c9963f 100%);
  box-shadow:
    0 3px 12px rgba(190, 135, 40, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -1px 0 rgba(150, 100, 20, 0.3);
}

:root[data-theme="light"] .slide-switch-opt {
  color: #7a5a22;
}

:root[data-theme="light"] .slide-switch-opt.on {
  color: #3a2808;
}

/* ---- Light theme: gold buttons, tabs, auth modal (no muddy brown) ---- */
:root[data-theme="light"] {
  --champagne-deep: #d6a74f;
}

:root[data-theme="light"] .nav-tab-btn.active,
:root[data-theme="light"] .nav-modal-item.active,
:root[data-theme="light"] .btn-solid {
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.5) 0%,
      rgba(255, 255, 255, 0) 55%
    ),
    linear-gradient(135deg, #fbeac0 0%, #e8c370 48%, #cf9d44 100%);
  color: #3a2808;
  border-color: rgba(168, 116, 31, 0.35);
  box-shadow:
    0 3px 12px rgba(190, 135, 40, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

:root[data-theme="light"] .btn-solid:hover:not(:disabled) {
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.6) 0%,
      rgba(255, 255, 255, 0) 55%
    ),
    linear-gradient(135deg, #fff3d2 0%, #efcc82 48%, #d9a84d 100%);
  box-shadow:
    0 5px 18px rgba(190, 135, 40, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

:root[data-theme="light"] .main-nav {
  background: linear-gradient(
    160deg,
    rgba(255, 252, 245, 0.95),
    rgba(247, 238, 222, 0.9)
  );
  border-color: rgba(168, 116, 31, 0.32);
}

:root[data-theme="light"] .btn-quiet {
  background: rgba(255, 252, 245, 0.7);
  border-color: rgba(168, 116, 31, 0.28);
  color: var(--text-2);
}

:root[data-theme="light"] .btn-outline {
  background: linear-gradient(
    160deg,
    rgba(255, 252, 245, 0.95),
    rgba(247, 238, 222, 0.9)
  );
  border-color: rgba(168, 116, 31, 0.5);
  color: #6a4d1a;
}

:root[data-theme="light"] .drill-option.active .drill-option-avail {
  color: var(--champagne);
}

/* ---- Light theme wordmark: rich amber gold ---- */
:root[data-theme="light"] .wordmark h1 {
  background: linear-gradient(
    100deg,
    #8a5508 0%,
    #c4851a 28%,
    #e0a82f 50%,
    #b87414 74%,
    #8a5508 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.7))
    drop-shadow(0 3px 10px rgba(196, 133, 26, 0.3));
}

/* ---- Level chips: always one row, swipe sideways ---- */
.level-rail {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 4px 10px;
  margin-left: -4px;
  margin-right: -4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}

.level-rail::-webkit-scrollbar {
  display: none;
}

.level-rail > .level-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

/* ---- Mobile header: switches sit under the sign-in button ---- */
@media (max-width: 760px) {
  .header-controls > .header-switches {
    order: 5;
    margin: 10px 0 0 auto;
    justify-content: flex-end;
  }

  .header-controls > .main-nav {
    order: 6;
    flex: 0 0 100%;
    margin-top: 10px;
  }
}

/* ---- Practice setup: controls must never push past the panel ---- */
.control {
  min-width: 0;
}

.control select.field {
  width: 100%;
  max-width: 100%;
}

.practice-panel {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 760px) {
  .setup-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px 10px;
  }

  /* Topic is the longest label: full row, first. */
  .setup-controls > .control:nth-child(2) {
    grid-column: 1 / -1;
    order: -1;
  }

  /* Level + length sit side by side. */
  .setup-controls > .control:nth-child(1),
  .setup-controls > .control:nth-child(3) {
    grid-column: auto;
  }

  /* Direction: full row. */
  .setup-controls > .control:nth-child(4) {
    grid-column: 1 / -1;
  }

  .setup-controls > .control.hidden {
    display: none;
  }

  .setup-controls .field {
    padding: 11px 36px 11px 13px;
    font-size: 16px; /* stops iOS zoom on focus */
  }
}

/* ---- Mobile pass: roadmap, my words ---- */
@media (max-width: 760px) {
  /* My words: the level badge belongs to its row, not the panel. */
  table.db .level-mark {
    position: static;
    justify-self: end;
  }

  /* Roadmap: topics become one swipeable row of compact chips. */
  .topic-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    margin: 0 -16px;
    padding: 2px 16px 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    -webkit-mask-image: linear-gradient(
      90deg,
      transparent 0,
      #000 14px,
      #000 calc(100% - 28px),
      transparent 100%
    );
    mask-image: linear-gradient(
      90deg,
      transparent 0,
      #000 14px,
      #000 calc(100% - 28px),
      transparent 100%
    );
  }

  .topic-row::-webkit-scrollbar {
    display: none;
  }

  .topic {
    flex: 0 0 auto;
    font-size: 0.76rem;
    padding: 4px 10px;
    white-space: nowrap;
  }

  .stage-desc {
    font-size: 0.92rem;
    margin-top: 8px;
  }

  .stage-rule {
    margin: 14px 0 12px;
  }

  .stage-foot {
    margin-top: 6px;
  }

  .stage-actions .btn {
    padding: 10px 12px;
    font-size: 0.86rem;
  }
}

/* ---- Mobile header v2: logo + sign-in on row 1, switches under it ---- */
@media (max-width: 760px) {
  .wordmark h1 {
    font-size: 1.7rem;
  }

  .wordmark-logo {
    width: 34px;
  }

  .wordmark {
    gap: 8px;
  }

  .header-controls > .btn:nth-child(2) {
    padding: 8px 12px;
    font-size: 0.8rem;
    max-width: 52vw;
  }

  .header-controls > .btn:nth-child(2) svg {
    margin-right: 4px;
  }
}

@media (max-width: 400px) {
  .wordmark h1 {
    font-size: 1.5rem;
  }

  .wordmark-note {
    font-size: 0.66rem;
  }
}

/* ---- Roadmap mobile: percent pill in the top-right corner ---- */
@media (max-width: 560px) {
  .stage-top {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
  }

  .stage-top > div {
    min-width: 0;
  }

  .stage-pill {
    align-self: flex-start;
    flex: 0 0 auto;
    margin-top: 2px;
    padding: 4px 11px;
    font-size: 0.78rem;
  }
}

/* ============================================================
   Mobile v3 — header never reflows, roadmap pill pinned right
   ============================================================ */
@media (max-width: 760px) {
  /* Row 1 is always: [logo + title (shrinks)] [sign-in (fixed)]. */
  .wordmark {
    flex: 1 1 0;
    min-width: 0;
    margin-right: 0;
  }

  .wordmark-details {
    min-width: 0;
  }

  .wordmark h1 {
    font-size: clamp(1.3rem, 6.4vw, 1.7rem);
    white-space: nowrap;
  }

  .wordmark-note {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .header-controls > .btn:nth-child(2) {
    flex: 0 0 auto;
    max-width: 60vw;
    white-space: nowrap;
  }
}

/* Very small phones (SE, 320–360px) */
@media (max-width: 360px) {
  .wordmark-logo {
    width: 28px;
  }

  .wordmark-note {
    display: none;
  }

  .header-controls > .btn:nth-child(2) {
    padding: 7px 10px;
    font-size: 0.74rem;
  }

  .header-controls > .btn:nth-child(2) svg {
    display: none;
  }

  .slide-switch-opt {
    min-width: 34px;
    padding: 0 8px;
  }
}

@media (max-width: 560px) {
  .stage .stage-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
  }

  .stage .stage-pill {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    justify-self: end;
    margin: 2px 0 0;
  }
}

@media (max-width: 760px) {
  .wordmark-details {
    overflow: hidden;
  }

  .wordmark h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
}

@media (max-width: 360px) {
  .wordmark h1 {
    font-size: clamp(1.1rem, 5.6vw, 1.4rem);
  }
}
