/* ==========================================================================
   Leitner Words — design tokens
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efeb;
  --surface-3: #e7e6e1;
  --border: #e5e3dd;
  --border-strong: #d6d4cc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #85847e;
  --accent: #2a78d6;
  --accent-strong: #1c5cab;
  --accent-soft: rgba(42, 120, 214, 0.1);
  --on-accent: #ffffff;
  --good: #0ca30c;
  --good-ink: #0a6e0a;
  --good-soft: rgba(12, 163, 12, 0.1);
  --bad: #d03b3b;
  --bad-ink: #b12f2f;
  --bad-soft: rgba(208, 59, 59, 0.09);
  --warn: #e39a00;
  /* Leitner boxes: one hue, light → dark as mastery grows (validated ordinal ramp) */
  --box-1: #86b6ef;
  --box-2: #5598e7;
  --box-3: #2a78d6;
  --box-4: #1c5cab;
  --box-5: #104281;
  --shadow-1: 0 1px 2px rgba(20, 20, 18, 0.04), 0 1px 1px rgba(20, 20, 18, 0.03);
  --shadow-2: 0 1px 2px rgba(20, 20, 18, 0.05), 0 8px 24px -8px rgba(20, 20, 18, 0.12);
  --shadow-3: 0 2px 6px rgba(20, 20, 18, 0.06), 0 24px 48px -16px rgba(20, 20, 18, 0.22);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-fa: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  --font-ipa: 'Segoe UI', 'Noto Sans', 'Lucida Sans Unicode', system-ui, sans-serif;

  --radius: 20px;
  --radius-sm: 12px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.5, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-3: #2d2d2a;
    --border: #2a2a28;
    --border-strong: #3a3a37;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #8d8c85;
    --accent: #3987e5;
    --accent-strong: #6da7ec;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --good: #0ca30c;
    --good-ink: #4fd04f;
    --good-soft: rgba(12, 163, 12, 0.16);
    --bad: #e25c5c;
    --bad-ink: #f08080;
    --bad-soft: rgba(226, 92, 92, 0.14);
    --warn: #fab219;
    --box-1: #184f95;
    --box-2: #256abf;
    --box-3: #3987e5;
    --box-4: #6da7ec;
    --box-5: #9ec5f4;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -8px rgba(0, 0, 0, 0.5);
    --shadow-3: 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 48px -16px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #111110;
  --surface: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2d2d2a;
  --border: #2a2a28;
  --border-strong: #3a3a37;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --text-3: #8d8c85;
  --accent: #3987e5;
  --accent-strong: #6da7ec;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --good: #0ca30c;
  --good-ink: #4fd04f;
  --good-soft: rgba(12, 163, 12, 0.16);
  --bad: #e25c5c;
  --bad-ink: #f08080;
  --bad-soft: rgba(226, 92, 92, 0.14);
  --warn: #fab219;
  --box-1: #184f95;
  --box-2: #256abf;
  --box-3: #3987e5;
  --box-4: #6da7ec;
  --box-5: #9ec5f4;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 48px -16px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

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

kbd {
  font: 500 11px/1 var(--font);
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  color: var(--text-2);
  background: var(--surface);
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.muted {
  color: var(--text-2);
}

.center {
  text-align: center;
  justify-content: center;
}

.spacer {
  width: 40px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

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

/* ==========================================================================
   Layout & view transitions
   ========================================================================== */

#app {
  position: relative;
  min-height: 100dvh;
  /* Cards and views slide past the screen edge while animating. Clip that overflow so it can't
     change the page's scroll width (in RTL it would otherwise make the page jump). */
  overflow-x: hidden;
  overflow-x: clip;
}

.view {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}

.view.entering.forward {
  animation: view-in-fwd 0.46s var(--ease-out) both;
}
.view.entering.back {
  animation: view-in-back 0.46s var(--ease-out) both;
}
.view.leaving {
  position: absolute;
  inset: 0 0 auto 0;
  pointer-events: none;
}
.view.leaving.forward {
  animation: view-out-fwd 0.3s var(--ease-in-out) both;
}
.view.leaving.back {
  animation: view-out-back 0.3s var(--ease-in-out) both;
}

@keyframes view-in-fwd {
  from { opacity: 0; transform: translateX(28px); }
}
@keyframes view-in-back {
  from { opacity: 0; transform: translateX(-28px); }
}
@keyframes view-out-fwd {
  to { opacity: 0; transform: translateX(-28px); }
}
@keyframes view-out-back {
  to { opacity: 0; transform: translateX(28px); }
}

/* Staggered entrance for home / summary sections */
.home > *,
.summary > *,
.settings > * {
  animation: rise 0.6s var(--ease-out) both;
}
.home > :nth-child(2), .summary > :nth-child(2), .settings > :nth-child(2) { animation-delay: 0.05s; }
.home > :nth-child(3), .summary > :nth-child(3), .settings > :nth-child(3) { animation-delay: 0.1s; }
.home > :nth-child(4), .summary > :nth-child(4), .settings > :nth-child(4) { animation-delay: 0.15s; }
.home > :nth-child(5), .summary > :nth-child(5), .settings > :nth-child(5) { animation-delay: 0.2s; }
.home > :nth-child(6), .settings > :nth-child(6) { animation-delay: 0.25s; }

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

/* ==========================================================================
   Top bar & brand
   ========================================================================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  margin-bottom: 8px;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand em {
  font-style: normal;
  font-weight: 500;
  color: var(--text-3);
}

.logo {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  width: 28px;
  height: 22px;
}
.logo i {
  flex: 1;
  border-radius: 2px 2px 1px 1px;
  background: var(--c);
  height: calc(var(--i) * 20%);
  transform-origin: bottom;
  animation: logo-grow 0.8s var(--ease-spring) both;
  animation-delay: calc(var(--i) * 60ms + 100ms);
}
.logo i:nth-child(1) { --c: var(--box-1); }
.logo i:nth-child(2) { --c: var(--box-2); }
.logo i:nth-child(3) { --c: var(--box-3); }
.logo i:nth-child(4) { --c: var(--box-4); }
.logo i:nth-child(5) { --c: var(--box-5); }

@keyframes logo-grow {
  from { transform: scaleY(0); }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--text-2);
  font-size: 22px;
  line-height: 1;
  transition: background-color 0.2s, color 0.2s, transform 0.15s var(--ease-out);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn.sm {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 18px;
}
.icon-btn.sm .icon {
  width: 18px;
  height: 18px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.18s var(--ease-out), opacity 0.2s;
  user-select: none;
}
.btn .icon {
  width: 18px;
  height: 18px;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 1px 2px rgba(20, 60, 120, 0.25), 0 6px 16px -6px rgba(42, 120, 214, 0.55);
}
.btn.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 90%, #000);
}
.btn.primary:disabled {
  opacity: 0.45;
}
.btn.ghost {
  background: var(--surface-2);
  color: var(--text);
}
.btn.ghost:hover {
  background: var(--surface-3);
}
.btn.danger {
  background: var(--bad);
  color: #fff;
}
.btn.danger-text {
  color: var(--bad-ink);
}
.btn.lg {
  height: 52px;
  padding: 0 24px;
  font-size: 16px;
  border-radius: 14px;
}
.btn.xl {
  height: 60px;
  padding: 0 28px;
  font-size: 17px;
  border-radius: 16px;
}
.btn.block {
  width: 100%;
}

/* ==========================================================================
   Cards
   ========================================================================== */

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

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}
.card-head h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-head p {
  font-size: 13px;
  margin-top: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
}
.pill .icon {
  width: 14px;
  height: 14px;
}
.pill.good {
  background: var(--good-soft);
  color: var(--good-ink);
}
.pill.streak {
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: color-mix(in srgb, var(--warn) 55%, var(--text));
  margin-top: 12px;
  animation: pop 0.5s var(--ease-spring) 1.4s both;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.6); }
}

/* ==========================================================================
   Home
   ========================================================================== */

.hero {
  position: relative;
  overflow: hidden;
  padding: 22px 22px 18px;
}
.hero::before {
  content: '';
  position: absolute;
  inset: -40% -20% auto auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent);
  pointer-events: none;
  animation: drift 12s ease-in-out infinite alternate;
}
@keyframes drift {
  to { transform: translate(-40px, 30px) scale(1.15); }
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 26px;
}

.hero-main {
  margin: 14px 0 22px;
}
.hero-figure {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.hero-num {
  font-family: var(--font-display);
  font-size: 68px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'opsz' 144;
}
.hero-unit {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-2);
}
.hero-sub {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 15px;
}

.start {
  position: relative;
  width: 100%;
  overflow: hidden;
}
.start .icon {
  transition: transform 0.3s var(--ease-out);
}
.start:hover:not(:disabled) .icon {
  transform: translateX(4px);
}
.start::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.28) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: shine 3.6s var(--ease-in-out) 1.2s infinite;
}
@keyframes shine {
  0%, 60% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.hero-keys {
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

/* ---- Box chart ---- */

.chart {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  align-items: end;
}

.col {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  border-radius: 12px;
  outline-offset: 4px;
}
.col-count {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
  color: var(--text);
}
.col-track {
  position: relative;
  width: 100%;
  height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 1px solid var(--border-strong);
}
.col-bar {
  width: min(100%, 52px);
  height: 0;
  border-radius: 4px 4px 0 0;
  background: var(--c);
  transition: height 0.9s var(--ease-out);
}
.col-empty {
  position: absolute;
  bottom: 0;
  width: min(100%, 52px);
  height: 2px;
  background: var(--border-strong);
  border-radius: 2px;
}
.col-label {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
}
.col-sub {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}
.col-due {
  color: var(--accent);
  font-weight: 600;
}

.col-tip {
  position: absolute;
  bottom: calc(100% - 10px);
  left: 50%;
  z-index: 5;
  display: grid;
  gap: 1px;
  min-width: 132px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  box-shadow: var(--shadow-3);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity 0.18s, transform 0.18s var(--ease-out);
}
.col-tip strong {
  font-size: 13px;
}
.col-tip .muted {
  color: color-mix(in srgb, var(--bg) 65%, var(--text));
}
.col:first-child .col-tip { left: 0; transform: translate(0, 6px); }
.col:last-child .col-tip { left: auto; right: 0; transform: translate(0, 6px); }
.col:hover .col-tip,
.col:focus-visible .col-tip {
  opacity: 1;
  transform: translate(-50%, 0);
}
.col:first-child:hover .col-tip, .col:first-child:focus-visible .col-tip,
.col:last-child:hover .col-tip, .col:last-child:focus-visible .col-tip {
  transform: translate(0, 0);
}
.col:hover .col-bar {
  filter: brightness(1.06);
}

.box-chart {
  position: relative;
}
.chart-empty {
  white-space: pre-line;
  position: absolute;
  left: 0;
  right: 0;
  top: 64px;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
  pointer-events: none;
  animation: rise 0.6s var(--ease-out) 0.4s both;
}
.is-empty .col-count {
  color: var(--text-3);
}

.chart-note {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.55;
}

/* ---- Stats ---- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.stat b {
  display: block;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat span:not(.stat-icon) {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
}
.stat-icon .icon {
  width: 18px;
  height: 18px;
}
.stat.streak .stat-icon {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}
.stat.acc .stat-icon {
  color: var(--accent);
  background: var(--accent-soft);
}
.stat.master .stat-icon {
  color: var(--box-5);
  background: color-mix(in srgb, var(--box-5) 14%, transparent);
}

.privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}
.privacy .icon {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   Session
   ========================================================================== */

.session {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.session-top {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
}
.progress {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--ease-out);
}
.progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: right;
}
.score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 10px;
  border-radius: 99px;
  background: var(--good-soft);
  color: var(--good-ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.score .icon {
  width: 14px;
  height: 14px;
}

.stage {
  position: relative;
  flex: 1;
  display: grid;
  align-items: center;
  padding: 8px 0 4vh;
}
.stage > * {
  grid-area: 1 / 1;
  min-width: 0;
}

.qcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-2);
  padding: 18px 18px 16px;
  animation: card-in 0.5s var(--ease-out) both;
}
.qcard.leaving {
  animation: card-out 0.38s var(--ease-in-out) both;
  pointer-events: none;
}
@keyframes card-in {
  from { opacity: 0; transform: translateX(48px) rotate(1.5deg) scale(0.98); }
}
@keyframes card-out {
  to { opacity: 0; transform: translateX(-56px) rotate(-2deg) scale(0.97); }
}

.qcard-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}
.meta-tags {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.box-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: color-mix(in srgb, var(--c) 18%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent);
  transition: background-color 0.4s, box-shadow 0.4s;
  white-space: nowrap;
}
.box-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
  transition: background-color 0.4s;
}
.box-badge > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.box-badge .icon {
  width: 13px;
  height: 13px;
}
.box-badge.moved > span {
  animation: badge-swap 0.45s var(--ease-spring) both;
}
@keyframes badge-swap {
  from { opacity: 0; transform: translateY(8px); }
}

/* Timer ring */
.timer {
  position: relative;
  width: 44px;
  height: 44px;
  flex: none;
  --ring: var(--accent);
}
.timer svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.timer circle {
  fill: none;
  stroke-width: 3.5;
}
.ring-bg {
  stroke: var(--surface-3);
}
.timer .ring-fg {
  stroke: var(--ring);
  stroke-linecap: round;
  transition: stroke 0.3s;
}
.timer-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
.timer.urgent {
  --ring: var(--bad);
}
.timer.urgent .timer-num {
  color: var(--bad-ink);
}
.timer.expired .ring-fg {
  opacity: 0;
}
.qcard.answered .timer:not(.expired) {
  opacity: 0.45;
  transition: opacity 0.3s;
}

/* Word */
.word-block {
  text-align: center;
  padding: 18px 0 22px;
}
.word-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.word {
  font-family: var(--font-display);
  font-size: clamp(40px, 11vw, 56px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 144;
  overflow-wrap: anywhere;
  animation: word-in 0.6s var(--ease-out) 0.08s both;
}
.word.long {
  font-size: clamp(32px, 9vw, 46px);
}
.word.xlong {
  font-size: clamp(26px, 7.4vw, 38px);
}
@keyframes word-in {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
}
.ipa {
  margin-top: 6px;
  font-family: var(--font-ipa);
  font-size: 17px;
  color: var(--text-2);
  letter-spacing: 0.01em;
  animation: word-in 0.6s var(--ease-out) 0.16s both;
}

.speak {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
  transition: transform 0.2s var(--ease-out), background-color 0.2s;
}
.speak:hover {
  transform: scale(1.06);
}
.speak:active {
  transform: scale(0.94);
}
.speak .icon {
  width: 21px;
  height: 21px;
}
.speaking .wave {
  animation: wave 0.9s ease-in-out infinite;
}
.speaking .w2 {
  animation-delay: 0.15s;
}
@keyframes wave {
  50% { opacity: 0.2; }
}

/* Options */
.options {
  display: grid;
  gap: 8px;
}
.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  font-family: var(--font-fa);
  font-size: 17px;
  font-weight: 500;
  text-align: right;
  line-height: 1.5;
  animation: opt-in 0.45s var(--ease-out) both;
  animation-delay: calc(0.14s + var(--i) * 45ms);
  transition: background-color 0.2s, border-color 0.2s, transform 0.16s var(--ease-out), opacity 0.3s, color 0.2s;
}
@keyframes opt-in {
  from { opacity: 0; transform: translateY(10px); }
}
.option:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.option:active:not(:disabled) {
  transform: scale(0.985);
}
.opt-key {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font: 600 12px/1 var(--font);
  color: var(--text-3);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.opt-text {
  flex: 1;
}
.opt-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
}
.opt-mark .icon {
  width: 20px;
  height: 20px;
}
.opt-mark .icon path {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: draw 0.4s var(--ease-out) 0.05s forwards;
}
@keyframes draw {
  to { stroke-dashoffset: 0; }
}

.option.correct,
.option.reveal {
  background: var(--good-soft);
  border-color: var(--good);
  color: var(--good-ink);
}
.option.correct {
  animation: opt-correct 0.5s var(--ease-spring) both;
}
@keyframes opt-correct {
  40% { transform: scale(1.025); }
}
.option.correct .opt-key,
.option.reveal .opt-key {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}
.option.reveal {
  animation: opt-reveal 0.6s var(--ease-out) 0.25s both;
}
@keyframes opt-reveal {
  from { background: var(--surface-2); border-color: transparent; color: var(--text); }
}
.option.wrong {
  background: var(--bad-soft);
  border-color: var(--bad);
  color: var(--bad-ink);
}
.option.wrong .opt-key {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
.option.dim {
  opacity: 0.4;
}
.option:disabled {
  cursor: default;
}

.feedback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  margin-top: 12px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s, transform 0.3s var(--ease-out);
}
.feedback.in {
  opacity: 1;
  transform: none;
}
.fb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 15px;
}
.fb .icon {
  width: 18px;
  height: 18px;
}
.fb.good {
  color: var(--good-ink);
}
.fb.bad {
  color: var(--bad-ink);
}
.btn.continue {
  background: var(--surface-2);
  height: 40px;
}
.btn.continue:hover {
  background: var(--surface-3);
}

.session-keys {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  padding: 18px 0 4px;
  font-size: 12px;
  color: var(--text-3);
}
.session-keys span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

@media (hover: none) {
  .session-keys,
  .hero-keys,
  .opt-key {
    display: none;
  }
}

/* ==========================================================================
   Summary
   ========================================================================== */

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

.result {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 24px;
}
.result-ring {
  position: relative;
  flex: none;
  width: 120px;
  height: 120px;
}
.result-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.result-ring circle {
  fill: none;
  stroke-width: 9;
}
.result-ring .ring-fg {
  stroke: var(--accent);
  stroke-linecap: round;
}
.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ring-num {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'opsz' 144;
}
.ring-label small {
  font-size: 16px;
  color: var(--text-2);
  margin: 10px 0 0 1px;
}
.result-text h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 4px 0 6px;
  font-variation-settings: 'opsz' 144;
}

/* Flow chart */
.flow-chart {
  position: relative;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding-top: 28px;
}
.flow-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.flow-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
}
.flow-dot.up {
  background: var(--good);
}
.flow-dot.down {
  background: var(--bad);
}
.flow-chart .col-bar {
  transition: height 0.24s var(--ease-out);
}
.col-delta {
  direction: ltr;
  unicode-bidi: isolate;
  position: absolute;
  top: -26px;
  height: 20px;
  padding: 0 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transform: translateY(6px) scale(0.8);
  transition: opacity 0.3s, transform 0.4s var(--ease-spring);
}
.col-delta.in {
  opacity: 1;
  transform: none;
}
.col-delta.pos {
  background: var(--good-soft);
  color: var(--good-ink);
}
.col-delta.neg {
  background: var(--bad-soft);
  color: var(--bad-ink);
}

.deck {
  position: relative;
  width: min(100%, 46px);
  height: 58px;
}
.deck i {
  position: absolute;
  inset: 0;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
}
.deck i:nth-child(1) { transform: translate(-4px, -8px) rotate(-6deg); }
.deck i:nth-child(2) { transform: translate(3px, -4px) rotate(5deg); }
.deck i:nth-child(3) { background: var(--surface); }

.flow-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-2);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s, transform 0.4s var(--ease-out);
}
.flow-legend.in {
  opacity: 1;
  transform: none;
}
.leg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.leg b {
  color: var(--text);
}
.leg .icon {
  width: 15px;
  height: 15px;
}
.leg.up .icon {
  color: var(--good);
}
.leg.down .icon {
  color: var(--bad);
}
.leg .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--box-5);
}

/* Missed words */
.word-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.word-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  animation: rise 0.5s var(--ease-out) both;
  animation-delay: calc(0.5s + var(--i) * 50ms);
}
.word-list li:first-child {
  border-top: 0;
  padding-top: 0;
}
.wl-en {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.wl-en b {
  font-size: 16px;
  font-weight: 600;
}
.wl-en .ipa {
  margin: 0;
  font-size: 13px;
  animation: none;
}
.wl-fa {
  font-family: var(--font-fa);
  font-size: 15px;
  color: var(--text-2);
  text-align: right;
  flex: 1;
}

.summary-actions {
  display: flex;
  justify-content: center;
  padding: 8px 0 12px;
}
.summary-actions .btn {
  min-width: 200px;
}

/* ==========================================================================
   Onboarding
   ========================================================================== */

.onboarding {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.onb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.steps {
  display: flex;
  gap: 6px;
}
.steps i {
  width: 22px;
  height: 4px;
  border-radius: 99px;
  background: var(--surface-3);
  transition: background-color 0.4s, width 0.4s var(--ease-out);
}
.steps i.on {
  background: var(--accent);
}
.onb-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 4px 20px;
}
.onb-panel > * {
  animation: rise 0.55s var(--ease-out) both;
}
.onb-panel > :nth-child(2) { animation-delay: 0.05s; }
.onb-panel > :nth-child(3) { animation-delay: 0.1s; }
.onb-panel > :nth-child(4) { animation-delay: 0.15s; }
.onb-panel > :nth-child(5) { animation-delay: 0.2s; }
.onb-panel > :nth-child(6) { animation-delay: 0.25s; }
.onb-panel > :nth-child(7) { animation-delay: 0.3s; }
.onb-panel.bwd > * {
  animation-name: rise-back;
}
@keyframes rise-back {
  from { opacity: 0; transform: translateY(-12px); }
}

.onb-hero {
  display: flex;
  margin-bottom: 28px;
}
.onb-hero .logo {
  width: 72px;
  height: 56px;
  gap: 5px;
}
.onb-hero .logo i {
  border-radius: 5px 5px 2px 2px;
  animation-duration: 1.1s;
}
.onb-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 9vw, 46px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-variation-settings: 'opsz' 144;
}
.onb-title.sm {
  font-size: clamp(28px, 7.5vw, 36px);
  margin-top: 8px;
}
.onb-lead {
  margin: 14px 0 26px;
  font-size: 16px;
  color: var(--text-2);
  max-width: 480px;
}
.onb-points {
  list-style: none;
  padding: 0;
  margin: 0 0 30px;
  display: grid;
  gap: 14px;
}
.onb-points li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14.5px;
  color: var(--text-2);
}
.onb-points .icon {
  flex: none;
  color: var(--accent);
  margin-top: 1px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 14px;
  background: var(--surface-2);
}
.stepper-value {
  min-width: 44px;
  text-align: center;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.stepper.big {
  display: flex;
  justify-content: space-between;
  max-width: 280px;
  margin: 0 auto 10px;
  padding: 6px;
  border-radius: 20px;
}
.stepper.big .icon-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 28px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.stepper.big .stepper-value {
  font-family: var(--font-display);
  font-size: 52px;
  font-weight: 500;
  font-variation-settings: 'opsz' 144;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 30px;
}
.chip {
  height: 36px;
  min-width: 56px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-2);
  transition: all 0.2s var(--ease-out);
}
.chip:hover {
  border-color: var(--text-3);
}
.chip[aria-pressed='true'] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.level-list {
  display: grid;
  gap: 8px;
  margin-bottom: 26px;
}
.level-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.2s, background-color 0.2s, transform 0.15s var(--ease-out);
}
.level-opt:hover {
  border-color: var(--border-strong);
}
.level-opt:active {
  transform: scale(0.99);
}
.level-opt[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.lvl-tag {
  display: grid;
  place-items: center;
  width: 38px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
}
.level-opt[aria-pressed='true'] .lvl-tag {
  background: var(--accent);
  color: var(--on-accent);
}
.lvl-name {
  flex: 1;
  font-weight: 600;
}
.lvl-count {
  font-size: 13px;
  color: var(--text-3);
}

.sound-test {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 4px auto 22px;
  color: var(--text-2);
  font-weight: 600;
  font-size: 14px;
}
.sound-test .icon {
  box-sizing: content-box;
  width: 34px;
  height: 34px;
  padding: 26px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
  transition: transform 0.25s var(--ease-spring);
}
.sound-test:hover .icon {
  transform: scale(1.06);
}
.sound-test.speaking .icon {
  animation: pulse-ring 1.2s var(--ease-out) infinite;
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); }
  100% { box-shadow: 0 0 0 22px transparent; }
}
.sound-test:disabled {
  opacity: 0.5;
}

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

.settings-group {
  padding: 6px 20px;
}
.settings-group h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 0 6px;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.settings-group h2 + .row {
  border-top: 0;
}
.row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.row-title {
  font-weight: 500;
}
.row-desc {
  font-size: 12.5px;
  color: var(--text-3);
}
.group-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--text-2);
  padding: 4px 0 14px;
  line-height: 1.55;
}
.group-note .icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--text-3);
}
.settings .card:last-child .group-note {
  padding-bottom: 16px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
  flex: none;
}
.segmented.center {
  display: flex;
  width: max-content;
  margin: 0 auto 28px;
}
.seg {
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}
.seg[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
}

.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 99px;
  background: var(--surface-3);
  transition: background-color 0.25s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s var(--ease-spring);
}
.switch[aria-checked='true'] {
  background: var(--accent);
}
.switch[aria-checked='true']::after {
  transform: translateX(18px);
}

.select {
  max-width: 55%;
  height: 38px;
  padding: 0 32px 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2385847e' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: var(--text);
  font: 500 13px var(--font);
  appearance: none;
  text-overflow: ellipsis;
}

.range {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.range input {
  width: 130px;
  height: 22px;
  margin: 0;
  appearance: none;
  background: transparent;
  --p: 50%;
}
.range input::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--p), var(--surface-3) var(--p));
}
.range input::-moz-range-track {
  height: 5px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--p), var(--surface-3) var(--p));
}
.range input::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.04);
}
.range input::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.range-value {
  min-width: 42px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ==========================================================================
   Overlays: dialog, toast, sparks
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 10, 9, 0.4);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s;
}
.overlay.in {
  opacity: 1;
}
.dialog {
  width: min(400px, 100%);
  padding: 22px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-3);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.35s var(--ease-spring);
}
.overlay.in .dialog {
  transform: none;
}
.dialog h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}
.dialog p {
  color: var(--text-2);
  font-size: 14px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 60;
  padding: 11px 18px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-3);
  transform: translate(-50%, 20px);
  opacity: 0;
  transition: transform 0.4s var(--ease-spring), opacity 0.3s;
  max-width: calc(100% - 32px);
}
.toast.in {
  transform: translate(-50%, 0);
  opacity: 1;
}
.toast.bad {
  background: var(--bad);
  color: #fff;
}

#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}
.spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 2px;
}

/* ==========================================================================
   Word lists
   ========================================================================== */

.list-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.list-controls .switch {
  margin-inline-start: 6px;
}
.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 18px;
  border-top: 1px solid var(--border);
}
.row-title {
  overflow-wrap: anywhere;
}

.dialog.wide {
  width: min(560px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}
.field {
  display: grid;
  gap: 6px;
  margin: 16px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.text-input,
.text-area {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: 400 15px/1.6 var(--font);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.text-area {
  resize: vertical;
  min-height: 150px;
  font-family: var(--font), var(--font-fa);
  unicode-bidi: plaintext;
}
.text-input:focus,
.text-area:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.dialog-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}
.link-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.link-btn:hover {
  text-decoration: underline;
}
.import-summary {
  display: grid;
  gap: 4px;
  min-height: 22px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-2);
}
.import-summary span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.import-summary .icon {
  width: 15px;
  height: 15px;
}
.import-summary .ok {
  color: var(--good-ink);
  font-weight: 600;
}
.import-summary .warn {
  color: var(--bad-ink);
}

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

@media (max-width: 420px) {
  .card {
    padding: 16px;
  }
  .hero-num {
    font-size: 58px;
  }
  .chart {
    gap: 6px;
  }
  .flow-chart {
    gap: 4px;
  }
  .col-sub {
    font-size: 10px;
  }
  .stats {
    gap: 8px;
  }
  .stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
  }
  .result {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }
  .row {
    flex-wrap: wrap;
  }
  .select {
    max-width: 100%;
  }
  .range input {
    width: 110px;
  }
  .option {
    min-height: 50px;
    font-size: 16px;
  }
}

@media (min-width: 720px) {
  .view {
    padding-top: 28px;
  }
  .session {
    max-width: 580px;
  }
}

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

/* ==========================================================================
   Italian words, and Farsi / right-to-left interface
   ========================================================================== */

:root {
  --font-word: 'Fraunces', Georgia, 'Times New Roman', serif;
  /* Article colours: masculine / feminine */
  --masc: #2a6fc4;
  --fem: #c73a3a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --masc: #6da7ec;
    --fem: #f08080;
  }
}
:root[data-theme='dark'] {
  --masc: #6da7ec;
  --fem: #f08080;
}

.word {
  font-family: var(--font-word);
}
.article {
  font-weight: 500;
}
.art-m { color: var(--masc); }
.art-f { color: var(--fem); }

.forms {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-3);
  animation: word-in 0.6s var(--ease-out) 0.22s both;
}
.forms [lang='it'] {
  color: var(--text-2);
  font-weight: 500;
}
.wl-en .it-word {
  font-size: 16px;
  font-weight: 600;
}

.lang-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color 0.2s, color 0.2s;
}
.lang-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.lang-btn[lang='fa'] {
  font-family: 'Vazirmatn', sans-serif;
}

/* Farsi typography: Vazirmatn everywhere except Italian words and phonetics.
   Letter-spacing breaks the joins of Persian script, so it is removed. */
html[lang='fa'] {
  --font: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  --font-display: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}
html[lang='fa'] body {
  line-height: 1.7;
}
html[lang='fa'] *:not(.it-word):not(.it-word *):not(.ipa) {
  letter-spacing: 0 !important;
}
html[lang='fa'] .eyebrow {
  text-transform: none;
  font-size: 13px;
}
html[lang='fa'] .hero-num,
html[lang='fa'] .ring-num,
html[lang='fa'] .stepper.big .stepper-value {
  font-weight: 600;
}
html[lang='fa'] .onb-title,
html[lang='fa'] .result-text h1 {
  font-weight: 700;
  line-height: 1.35;
}
html[lang='fa'] .onb-title {
  font-size: clamp(30px, 8vw, 40px);
}
html[lang='fa'] .onb-title.sm {
  font-size: clamp(24px, 6.5vw, 32px);
}
html[lang='fa'] .result-text h1 {
  font-size: 25px;
}

/* Mirror what depends on reading direction */
[dir='rtl'] .flip-rtl {
  transform: scaleX(-1);
}
[dir='rtl'] .start:hover:not(:disabled) .icon {
  transform: scaleX(-1) translateX(4px);
}
[dir='rtl'] .progress-fill {
  transform-origin: right;
}
.progress-text {
  text-align: end;
}
.level-opt {
  text-align: start;
}
[dir='rtl'] .col:first-child .col-tip {
  left: auto;
  right: 0;
}
[dir='rtl'] .col:last-child .col-tip {
  right: auto;
  left: 0;
}
[dir='rtl'] .select {
  padding: 0 12px 0 32px;
  background-position: left 11px center;
}
[dir='rtl'] .range input::-webkit-slider-runnable-track {
  background: linear-gradient(to left, var(--accent) var(--p), var(--surface-3) var(--p));
}
[dir='rtl'] .range input::-moz-range-track {
  background: linear-gradient(to left, var(--accent) var(--p), var(--surface-3) var(--p));
}
[dir='rtl'] .switch::after {
  left: auto;
  right: 3px;
}
[dir='rtl'] .switch[aria-checked='true']::after {
  transform: translateX(-18px);
}
[dir='rtl'] .wl-fa {
  text-align: left;
}
