/* =========================================================
   A Strange Morning — interactive English lesson
   Hand-written CSS · Rubik · cream & OLED themes
   ========================================================= */

:root {
  color-scheme: light;
  --bg: #fdfbf7;
  --bg-soft: #f8f2e9;
  --surface: #fffdf9;
  --surface-2: #f4ede2;
  --surface-3: #eae0d1;
  --text: #211c16;
  --text-soft: #3b342b;
  --muted: #6e6559;
  --faint: #72685c;
  --border: rgba(43, 34, 24, 0.11);
  --border-strong: rgba(43, 34, 24, 0.18);
  --accent: #a9562d;
  --accent-strong: #87401e;
  --accent-soft: #f3e2d1;
  --accent-ink: #fff9f2;
  --btn-bg: #a9562d;
  --btn-bg-hover: #974a25;
  --btn-ink: #fff9f2;
  --btn-shadow: rgba(169, 86, 45, 0.22);
  --green: #2f7d5a;
  --green-soft: #e7f3ec;
  --green-border: rgba(47, 125, 90, 0.24);
  --red: #a9443a;
  --red-soft: #fbeae7;
  --red-border: rgba(169, 68, 58, 0.24);
  --note-bg: #f6e8a8;
  --note-ink: #3c3216;
  --speak-bg: #f1d6b7;
  --speak-ink: #2c1e12;
  --saved-line: rgba(169, 86, 45, 0.55);
  --header-bg: rgba(253, 251, 247, 0.82);
  --glow-1: rgba(214, 154, 94, 0.15);
  --glow-2: rgba(137, 160, 196, 0.1);
  --dot: rgba(43, 34, 24, 0.07);
  --shimmer: #efe6d8;
  --shimmer-2: #f8f2e8;
  --shadow-soft: 0 26px 70px -44px rgba(72, 50, 28, 0.3);
  --shadow-card: 0 18px 45px -30px rgba(72, 50, 28, 0.35);
  --font: "Rubik", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  --shell: 1120px;
  --gutter: clamp(20px, 5vw, 40px);
  --radius: 14px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --header-height: 72px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-soft: #0f151d;
  --surface: #131a22;
  --surface-2: #18212b;
  --surface-3: #1e2833;
  --text: #f3ede3;
  --text-soft: #d9d2c6;
  --muted: #a6a093;
  --faint: #908a7f;
  --border: rgba(243, 237, 227, 0.09);
  --border-strong: rgba(243, 237, 227, 0.17);
  --accent: #efc6a0;
  --accent-strong: #f7d8b8;
  --accent-soft: rgba(239, 198, 160, 0.12);
  --accent-ink: #211810;
  --btn-bg: #efc6a0;
  --btn-bg-hover: #f7d8b8;
  --btn-ink: #211810;
  --btn-shadow: rgba(239, 198, 160, 0.2);
  --green: #87d6a9;
  --green-soft: rgba(66, 145, 101, 0.16);
  --green-border: rgba(135, 214, 169, 0.26);
  --red: #ffa196;
  --red-soft: rgba(175, 68, 59, 0.17);
  --red-border: rgba(255, 161, 150, 0.26);
  --note-bg: #e7d98f;
  --note-ink: #2f2811;
  --speak-bg: rgba(239, 198, 160, 0.27);
  --speak-ink: #ffe9d2;
  --saved-line: rgba(239, 198, 160, 0.65);
  --header-bg: rgba(13, 17, 23, 0.8);
  --glow-1: rgba(239, 198, 160, 0.09);
  --glow-2: rgba(110, 140, 190, 0.08);
  --dot: rgba(243, 237, 227, 0.045);
  --shimmer: #1b242e;
  --shimmer-2: #222d38;
  --shadow-soft: 0 26px 70px -42px rgba(0, 0, 0, 0.85);
  --shadow-card: 0 18px 45px -30px rgba(0, 0, 0, 0.8);
}

/* ---------- Base ---------- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--border-strong) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--bg);
  background-image:
    radial-gradient(var(--dot) 1px, transparent 1px),
    radial-gradient(58rem 42rem at 88% -12%, var(--glow-1), transparent 64%),
    radial-gradient(46rem 36rem at -12% 34%, var(--glow-2), transparent 66%);
  background-size: 26px 26px, auto, auto;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  color: inherit;
  font: inherit;
}

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

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

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

.shell {
  width: min(calc(100% - (2 * var(--gutter))), var(--shell));
  margin-inline: auto;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.17em;
  line-height: 1.4;
  text-transform: uppercase;
}

.eyebrow-line {
  width: 24px;
  height: 1px;
  background: var(--accent);
  opacity: 0.7;
}

.step-number {
  display: inline-grid;
  min-width: 24px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 300;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 500;
  transform: translateY(-160%);
  transition: transform 0.2s var(--ease);
}

.skip-link:focus {
  transform: none;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 90;
  border-bottom: 1px solid transparent;
  transition: background-color 0.3s ease, border-color 0.3s ease, backdrop-filter 0.3s ease;
}

.site-header.is-scrolled {
  border-bottom-color: var(--border);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.header-inner {
  display: flex;
  height: var(--header-height);
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--accent);
  transition: transform 0.4s var(--ease), border-color 0.25s ease;
}

.brand-mark svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.brand:hover .brand-mark {
  border-color: var(--border-strong);
  transform: rotate(90deg);
}

.brand-name {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.035em;
}

.brand-name span {
  color: var(--accent);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-inline: auto;
  font-size: 12.5px;
  color: var(--muted);
}

.main-nav a {
  position: relative;
  padding: 6px 0;
  transition: color 0.2s ease;
}

.main-nav a::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: var(--accent);
  content: "";
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s var(--ease);
}

.main-nav a:hover,
.main-nav a.is-active {
  color: var(--text);
}

.main-nav a:hover::after,
.main-nav a.is-active::after {
  transform: scaleX(1);
  transform-origin: left;
}

.header-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 9px;
}

.level-badge {
  display: inline-grid;
  height: 28px;
  padding: 0 10px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.theme-toggle {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.3s var(--ease);
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transform: rotate(-12deg);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sun,
.icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="light"] .icon-moon {
  display: block;
}

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

.btn {
  display: inline-flex;
  height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.005em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    color 0.22s ease,
    transform 0.22s var(--ease);
}

.btn .icon {
  width: 15px;
  height: 15px;
}

.btn-primary {
  border-color: var(--btn-bg);
  background: var(--btn-bg);
  box-shadow: 0 10px 28px -16px var(--btn-shadow);
  color: var(--btn-ink);
}

.btn-primary:hover {
  border-color: var(--btn-bg-hover);
  background: var(--btn-bg-hover);
  box-shadow: 0 14px 34px -16px var(--btn-shadow);
  transform: translateY(-2px);
}

.btn-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}

.btn-small {
  height: 38px;
  padding-inline: 13px;
  border-radius: 9px;
  font-size: 11.5px;
}

.text-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.4;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.text-button:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.82fr);
  gap: clamp(30px, 6vw, 76px);
  align-items: center;
  padding-top: clamp(44px, 7vw, 82px);
  padding-bottom: clamp(54px, 8vw, 100px);
}

.hero-copy {
  animation: rise 0.8s var(--ease) both;
}

.hero-kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 12px;
}

.level-pill {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
}

.kicker-sep {
  color: var(--border-strong);
}

.hero h1 {
  margin: 20px 0 0;
  font-size: clamp(3.4rem, 7.2vw, 6.2rem);
  font-weight: 600;
  letter-spacing: -0.058em;
  line-height: 0.94;
  text-wrap: balance;
}

.title-accent {
  color: var(--accent);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.065em;
}

.title-dot {
  color: var(--accent);
}

.hero-lead {
  max-width: 480px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(0.96rem, 1.4vw, 1.04rem);
  line-height: 1.75;
  text-wrap: pretty;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 20px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 11.5px;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.meta-item .icon {
  width: 13px;
  height: 13px;
  color: var(--faint);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 30px;
}

.completion-chip {
  display: inline-flex;
  height: 38px;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  transition: border-color 0.3s ease, color 0.3s ease, background-color 0.3s ease;
}

.completion-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px var(--border);
}

.completion-chip.is-done {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green);
}

.completion-chip.is-done .completion-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

/* Hero illustration */

.hero-visual {
  position: relative;
  width: 100%;
  height: 430px;
  animation: rise 0.9s var(--ease) 0.12s both;
}

.hero-visual::before {
  position: absolute;
  top: -42px;
  left: -30px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 68%);
  content: "";
  filter: blur(6px);
  pointer-events: none;
}

.clock-card {
  position: absolute;
  top: 0;
  right: 0;
  width: min(100%, 352px);
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(155deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow-card);
  transform: rotate(1.5deg);
}

.clock-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 3px;
}

.clock-day {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.clock-mood {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.clock-mood i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7fc99c;
  box-shadow: 0 0 0 3px rgba(127, 201, 156, 0.12);
}

.clock-face {
  position: relative;
  width: min(100%, 238px);
  aspect-ratio: 1;
  margin: 13px auto 9px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, var(--surface), var(--surface-2) 72%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 10px 30px -20px rgba(0, 0, 0, 0.45);
}

.clock-face::before {
  position: absolute;
  inset: 12px;
  border: 1px solid var(--border);
  border-radius: 50%;
  content: "";
  opacity: 0.65;
}

.clock-ticks {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from -0.5deg,
    var(--border-strong) 0deg 0.9deg,
    transparent 0.9deg 30deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
}

.clock-hand {
  position: absolute;
  bottom: 50%;
  left: 50%;
  border-radius: 999px;
  transform-origin: 50% 100%;
}

.clock-hand-hour {
  width: 5px;
  height: 51px;
  background: var(--text-soft);
  transform: translateX(-50%) rotate(210deg);
}

.clock-hand-minute {
  width: 3px;
  height: 72px;
  background: var(--accent);
  transform: translateX(-50%) rotate(0deg);
}

.clock-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

.clock-digital {
  position: absolute;
  right: 0;
  bottom: 34px;
  left: 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-align: center;
}

.clock-caption {
  margin: 0 0 2px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.02em;
  text-align: center;
}

.note-card {
  position: absolute;
  bottom: 2px;
  left: 0;
  width: min(76%, 292px);
  padding: 22px 22px 18px;
  border-radius: 10px;
  background: var(--note-bg);
  box-shadow: 0 18px 35px -20px rgba(61, 44, 20, 0.4);
  color: var(--note-ink);
  transform: rotate(-4deg);
}

.note-tape {
  position: absolute;
  top: -11px;
  left: 50%;
  width: 72px;
  height: 20px;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 0 1px 3px rgba(70, 50, 20, 0.08);
  content: "";
  transform: translateX(-50%) rotate(-3deg);
}

.note-quote {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.22rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.45;
}

.note-caption {
  margin: 12px 0 0;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  opacity: 0.65;
  text-transform: uppercase;
}

.hero-sticker {
  position: absolute;
  top: 18px;
  left: -8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  transform: rotate(-3deg);
}

.hero-sticker svg {
  width: 12px;
  height: 12px;
  color: var(--accent);
  fill: currentColor;
}

/* ---------- Sections ---------- */

.section {
  padding-top: clamp(42px, 6vw, 74px);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.section-heading {
  max-width: 680px;
}

.section-head h2 {
  margin: 0 0 9px;
  font-size: clamp(1.9rem, 3.8vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.042em;
  line-height: 1.08;
  text-wrap: balance;
}

.section-desc {
  max-width: 610px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
  text-wrap: pretty;
}

.section-side {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 7px;
  padding-bottom: 3px;
}

.soft-badge {
  display: inline-flex;
  height: 25px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ---------- Reader ---------- */

.reader-card {
  padding: clamp(18px, 3.2vw, 30px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.reader-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  color: var(--faint);
  font-size: 10.5px;
}

.reader-tip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.reader-tip .icon {
  width: 12px;
  height: 12px;
  color: var(--accent);
}

.saved-count {
  white-space: nowrap;
}

.saved-count b {
  color: var(--text-soft);
  font-weight: 500;
}

/* TTS player */

.tts-player {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(120deg, var(--surface-2), var(--bg-soft));
  transition: border-color 0.25s ease;
}

.tts-player.is-playing {
  border-color: var(--green-border);
}

.player-play {
  display: grid;
  width: 48px;
  height: 48px;
  flex: none;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--btn-bg);
  box-shadow: 0 8px 24px -14px var(--btn-shadow);
  color: var(--btn-ink);
  cursor: pointer;
  transition: transform 0.2s var(--ease), background-color 0.2s ease;
}

.player-play:hover {
  background: var(--btn-bg-hover);
  transform: scale(1.045);
}

.player-play:active {
  transform: scale(0.97);
}

.player-play:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.player-play .icon {
  width: 19px;
  height: 19px;
}

.player-play .icon-pause {
  display: none;
}

.tts-player.is-playing .player-play .icon-play {
  display: none;
}

.tts-player.is-playing .player-play .icon-pause {
  display: block;
}

.tts-player.is-paused .player-play .icon-play {
  display: block;
}

.player-info {
  flex: 1;
  min-width: 0;
}

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

.player-title {
  overflow: hidden;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-position {
  flex: none;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.player-track {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.player-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.18s linear;
}

.player-speed {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.speed-label {
  color: var(--faint);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.speed-pills {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.speed-pills button {
  padding: 5px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.speed-pills button:hover {
  color: var(--text);
}

.speed-pills button.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.speed-pills button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.player-wave {
  display: flex;
  height: 25px;
  flex: none;
  align-items: center;
  gap: 3px;
}

.player-wave span {
  width: 3px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.35;
  transition: height 0.2s ease, opacity 0.2s ease;
}

.player-wave span:nth-child(2) {
  height: 13px;
}

.player-wave span:nth-child(3) {
  height: 19px;
}

.player-wave span:nth-child(4) {
  height: 11px;
}

.tts-player.is-playing .player-wave span {
  opacity: 0.8;
  animation: wave 0.9s ease-in-out infinite alternate;
}

.tts-player.is-playing .player-wave span:nth-child(2) {
  animation-delay: 0.12s;
}

.tts-player.is-playing .player-wave span:nth-child(3) {
  animation-delay: 0.24s;
}

.tts-player.is-playing .player-wave span:nth-child(4) {
  animation-delay: 0.36s;
}

.tts-player.is-playing .player-wave span:nth-child(5) {
  animation-delay: 0.48s;
}

@keyframes wave {
  from {
    transform: scaleY(0.55);
  }
  to {
    transform: scaleY(1.35);
  }
}

/* Story */

.story-title-row {
  display: flex;
  max-width: 720px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 30px auto 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.story-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.story-title-row h3 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.story {
  max-width: 720px;
  margin: 0 auto;
  color: var(--text-soft);
  font-size: clamp(1.04rem, 1.35vw, 1.15rem);
  line-height: 1.8;
  letter-spacing: 0.001em;
}

.story p {
  margin: 0 0 1.1em;
}

.story p:last-child {
  margin-bottom: 0;
}

.story-loading {
  display: grid;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 0 12px;
}

.story-loading span,
.section-loading span {
  display: block;
  height: 13px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--shimmer) 25%, var(--shimmer-2) 50%, var(--shimmer) 75%);
  background-size: 220% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.story-loading span:nth-child(2) {
  width: 94%;
}

.story-loading span:nth-child(3) {
  width: 98%;
}

.story-loading span:nth-child(4) {
  width: 88%;
}

.story-loading span:nth-child(5) {
  width: 61%;
}

.word {
  padding: 1px 0;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.word:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.word:focus {
  outline: none;
}

.word.is-selected {
  background: var(--accent-soft);
  color: var(--text);
}

.word.is-speaking {
  background: var(--speak-bg);
  box-shadow: 0 0 0 2px var(--speak-bg);
  color: var(--speak-ink);
}

.word.is-saved {
  text-decoration: underline;
  text-decoration-color: var(--saved-line);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.reader-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.reader-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.5;
}

.reader-note .icon {
  width: 12px;
  height: 12px;
  flex: none;
  color: var(--accent);
}

.saved-words {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
}

.saved-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.saved-head > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.saved-head .icon {
  width: 12px;
  height: 12px;
  color: var(--accent);
}

.saved-head-count {
  display: inline-grid;
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0;
}

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

.saved-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 11.5px;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.saved-chip span {
  color: var(--faint);
  font-size: 10px;
}

.saved-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Quiz ---------- */

.quiz-panel {
  padding: clamp(18px, 3.2vw, 30px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.quiz-summary {
  display: flex;
  align-items: center;
  gap: 18px;
}

.score-dial {
  position: relative;
  display: grid;
  width: 70px;
  height: 70px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 3.6deg), var(--surface-2) 0);
  transition: background 0.4s ease;
}

.score-dial::before {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--surface);
  content: "";
}

.score-dial span {
  position: relative;
  z-index: 1;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
}

.quiz-summary-copy {
  flex: 1;
  min-width: 0;
}

.quiz-summary-copy h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.quiz-summary-copy p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.quiz-status-badge {
  margin-left: auto;
}

.quiz-status-badge.is-done {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green);
}

.quiz-progress {
  height: 4px;
  margin: 18px 0 22px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.quiz-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.35s var(--ease);
}

.quiz-list {
  display: grid;
  gap: 12px;
}

.section-loading {
  display: grid;
  gap: 10px;
  padding: 10px 0;
}

.section-loading span:nth-child(2) {
  width: 82%;
}

.section-loading span:nth-child(3) {
  width: 66%;
}

.quiz-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

.quiz-card.is-correct {
  border-color: var(--green-border);
}

.quiz-card.is-wrong {
  border-color: var(--red-border);
}

.quiz-question {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 14px;
}

.quiz-number {
  display: grid;
  width: 25px;
  height: 25px;
  flex: none;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.quiz-question h3 {
  margin: 1px 0 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.012em;
  line-height: 1.5;
}

.quiz-options {
  display: grid;
  gap: 7px;
}

.quiz-option {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease,
    opacity 0.18s ease;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quiz-option:disabled {
  cursor: default;
}

.option-letter {
  display: grid;
  width: 21px;
  height: 21px;
  flex: none;
  place-items: center;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
}

.option-text {
  flex: 1;
  min-width: 0;
}

.option-mark {
  display: grid;
  width: 17px;
  height: 17px;
  flex: none;
  margin-left: auto;
  place-items: center;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.option-mark .icon {
  width: 13px;
  height: 13px;
}

.quiz-option.is-correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.quiz-option.is-correct .option-letter {
  background: var(--green);
  color: var(--surface);
}

.quiz-option.is-correct .option-mark {
  opacity: 1;
}

.quiz-option.is-wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.quiz-option.is-wrong .option-letter {
  background: var(--red);
  color: var(--surface);
}

.quiz-option.is-wrong .option-mark {
  opacity: 1;
}

.quiz-option.is-muted {
  opacity: 0.58;
}

.quiz-feedback {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 10px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.quiz-feedback.is-correct {
  border-color: var(--green-border);
  background: var(--green-soft);
}

.quiz-feedback.is-wrong {
  border-color: var(--red-border);
  background: var(--red-soft);
}

.feedback-icon {
  display: grid;
  width: 20px;
  height: 20px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
}

.quiz-feedback.is-wrong .feedback-icon {
  color: var(--red);
}

.feedback-icon .icon {
  width: 15px;
  height: 15px;
}

.feedback-copy {
  min-width: 0;
}

.feedback-copy strong {
  display: block;
  margin-bottom: 2px;
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
}

.quiz-feedback.is-wrong .feedback-copy strong {
  color: var(--red);
}

.feedback-copy p {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.6;
}

.quiz-result {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--green-border);
  border-radius: 11px;
  background: var(--green-soft);
}

.result-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--green);
}

.result-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.quiz-result > div:nth-child(2) {
  flex: 1;
  min-width: 0;
}

.quiz-result h3 {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 600;
}

.quiz-result p {
  margin: 0;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.55;
}

.quiz-result .btn {
  flex: none;
}

/* ---------- Flashcards ---------- */

.cards-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(270px, 0.68fr);
  gap: 18px;
  align-items: start;
}

.deck {
  padding: clamp(16px, 2.6vw, 24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

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

.deck-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.deck-label {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.deck-meta strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
}

.deck-due {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--faint);
  font-size: 9.5px;
}

.due-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.deck-stage {
  position: relative;
}

.flashcard {
  position: relative;
  height: clamp(285px, 42vh, 355px);
  perspective: 1200px;
  cursor: pointer;
  outline: none;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.62s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.flashcard.is-flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 34px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.flashcard-front {
  background:
    radial-gradient(100% 100% at 50% 0%, var(--accent-soft), transparent 65%),
    var(--surface-2);
}

.flashcard-front::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 250px;
  height: 250px;
  border: 1px solid var(--border);
  border-radius: 50%;
  content: "";
  opacity: 0.55;
  transform: translate(-50%, -50%);
}

.flashcard-front::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 310px;
  height: 310px;
  border: 1px dashed var(--border);
  border-radius: 50%;
  content: "";
  opacity: 0.5;
  transform: translate(-50%, -50%);
}

.flashcard-back {
  border-color: var(--border-strong);
  background:
    radial-gradient(100% 100% at 50% 100%, var(--accent-soft), transparent 65%),
    var(--surface-2);
  transform: rotateY(180deg);
}

.face-kicker {
  position: absolute;
  top: 16px;
  left: 18px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.word-main {
  position: relative;
  z-index: 1;
  max-width: 100%;
  color: var(--text);
  font-size: clamp(2.6rem, 5.1vw, 3.9rem);
  font-weight: 600;
  letter-spacing: -0.055em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.word-ipa {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.word-pos {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.03em;
}

.flip-hint {
  position: absolute;
  right: 16px;
  bottom: 14px;
  left: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.4;
}

.flip-hint .icon {
  width: 12px;
  height: 12px;
}

.card-translation {
  position: relative;
  z-index: 1;
  max-width: 100%;
  color: var(--text);
  font-size: clamp(1.55rem, 3.2vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.2;
  text-wrap: balance;
}

.card-example {
  position: relative;
  z-index: 1;
  max-width: 430px;
  margin: 14px 0 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.5;
}

.card-example::before {
  content: "“";
}

.card-example::after {
  content: "”";
}

.card-example-ru {
  position: relative;
  z-index: 1;
  max-width: 430px;
  margin: 5px 0 0;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.5;
}

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

.deck-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.deck-btn {
  height: 43px;
  font-size: 12px;
}

.deck-btn:disabled {
  border-color: var(--border);
  background: var(--surface-2);
  box-shadow: none;
  color: var(--faint);
  cursor: not-allowed;
  opacity: 1;
}

.deck-btn-forgot {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--muted);
}

.deck-btn-forgot:hover:not(:disabled) {
  border-color: var(--red-border);
  background: var(--red-soft);
  color: var(--red);
  transform: translateY(-2px);
}

.deck-btn-remember {
  border-color: var(--btn-bg);
  background: var(--btn-bg);
  color: var(--btn-ink);
}

.deck-btn-remember:hover:not(:disabled) {
  border-color: var(--btn-bg-hover);
  background: var(--btn-bg-hover);
  transform: translateY(-2px);
}

.deck-hint {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 9.5px;
  line-height: 1.5;
  text-align: center;
}

.deck-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 12px;
}

.deck-dots span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  transition: width 0.2s ease, background-color 0.2s ease;
}

.deck-dots span.is-current {
  width: 16px;
  background: var(--accent);
}

.deck-dots span.is-forgotten {
  background: var(--red);
}

.deck-dots span.is-done {
  background: var(--green);
}

.deck-state {
  display: flex;
  min-height: clamp(285px, 42vh, 355px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
}

.state-icon {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 13px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
}

.state-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.deck-state h3 {
  margin: 0 0 5px;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.deck-state p {
  max-width: 370px;
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.65;
}

.deck-state .btn {
  margin-top: 17px;
}

.cards-aside {
  display: grid;
  gap: 14px;
}

.aside-card {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.aside-card .eyebrow {
  margin-bottom: 9px;
  font-size: 9px;
}

.aside-card h3 {
  margin: 0 0 7px;
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.aside-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

.interval-list {
  display: grid;
  gap: 0;
  margin-top: 15px;
}

.interval-row {
  display: grid;
  grid-template-columns: 21px 1fr auto auto;
  gap: 7px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 10.5px;
}

.interval-badge {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 8.5px;
}

.interval-arrow {
  color: var(--faint);
}

.interval-row span:last-child {
  color: var(--text-soft);
}

.interval-note {
  margin: 9px 0 0;
  color: var(--faint);
  font-size: 9.5px;
  line-height: 1.55;
}

.aside-progress-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.privacy-dot {
  width: 7px;
  height: 7px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.mini-stats > div {
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}

.mini-stats strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.mini-stats span {
  color: var(--faint);
  font-size: 9px;
  line-height: 1.4;
}

.privacy-note {
  margin-top: 12px !important;
  color: var(--faint) !important;
  font-size: 9.5px !important;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: clamp(58px, 9vw, 108px);
  padding: 25px 0 36px;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--faint);
  font-size: 10.5px;
}

.footer-inner p {
  margin: 0;
}

.footer-brand {
  color: var(--text-soft);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.footer-mid {
  margin-inline: auto !important;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 17px;
}

.footer-top {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  transition: color 0.2s ease;
}

.footer-top .icon {
  width: 12px;
  height: 12px;
}

.footer-top:hover {
  color: var(--accent);
}

/* ---------- Popover ---------- */

.popover-scrim {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(24, 18, 12, 0.42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.popover-scrim.is-visible {
  opacity: 1;
}

.word-popover {
  position: fixed;
  z-index: 200;
  width: min(356px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 21px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 30px 80px -34px rgba(0, 0, 0, 0.5);
  outline: none;
  animation: pop-in 0.18s var(--ease);
}

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

.popover-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.popover-meta {
  margin: 5px 0 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.5;
}

.popover-level {
  flex: none;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 8.5px;
}

.popover-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--faint);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.popover-close:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.popover-close svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.popover-block {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.popover-label {
  display: block;
  margin-bottom: 6px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.popover-translation {
  margin: 0;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.45;
}

.popover-base {
  margin: 3px 0 0;
  color: var(--faint);
  font-size: 10px;
}

.popover-context-block {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.popover-context-block .popover-label {
  margin-bottom: 5px;
}

.popover-context {
  margin: 0;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.65;
}

.popover-context mark {
  padding: 1px 2px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.popover-note {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.65;
}

.popover-save {
  width: 100%;
  height: 40px;
  margin-top: 17px;
  font-size: 11.5px;
}

.popover-save.is-saved {
  border-color: var(--green-border);
  background: var(--green-soft);
  box-shadow: none;
  color: var(--green);
}

.popover-save.is-saved:hover {
  background: var(--green-soft);
  transform: none;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Toast & messages ---------- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  z-index: 300;
  max-width: calc(100vw - 32px);
  padding: 10px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--text);
  box-shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.5);
  color: var(--bg);
  font-size: 11.5px;
  line-height: 1.4;
  text-align: center;
  transform: translate(-50%, 10px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s var(--ease);
}

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

.app-error {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-top: 22px;
  padding: 15px;
  border: 1px solid var(--red-border);
  border-radius: var(--radius);
  background: var(--red-soft);
}

.app-error-icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--red);
}

.app-error-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-error h2 {
  margin: 3px 0 3px;
  font-size: 13px;
  font-weight: 600;
}

.app-error p {
  margin: 0;
  color: var(--text-soft);
  font-size: 11.5px;
  line-height: 1.6;
}

.app-error code {
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.92em;
}

.noscript-message {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 400;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--text);
  font-size: 12px;
  text-align: center;
}

/* ---------- Theme transition ---------- */

html.is-theme-changing *,
html.is-theme-changing *::before,
html.is-theme-changing *::after {
  transition:
    background-color 0.28s ease,
    border-color 0.28s ease,
    color 0.28s ease,
    box-shadow 0.28s ease !important;
}

/* ---------- Motion ---------- */

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

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -20% 0;
  }
}

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

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 20px;
    padding-top: 38px;
  }

  .hero-copy {
    max-width: 720px;
  }

  .hero-visual {
    width: min(100%, 520px);
    height: 405px;
    margin: 16px auto 0;
  }

  .cards-layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(250px, 0.75fr);
  }
}

@media (max-width: 820px) {
  .main-nav {
    display: none;
  }

  .header-inner {
    justify-content: space-between;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .section-side {
    padding-bottom: 0;
  }

  .cards-layout {
    grid-template-columns: 1fr;
  }

  .cards-aside {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px) {
  html {
    scroll-padding-top: 82px;
  }

  body {
    background-attachment: scroll;
  }

  :root {
    --header-height: 64px;
  }

  .hero {
    padding-top: 28px;
    padding-bottom: 58px;
  }

  .hero h1 {
    font-size: clamp(3rem, 14vw, 4.5rem);
  }

  .hero-visual {
    height: 370px;
  }

  .clock-card {
    width: min(100%, 315px);
    padding: 14px;
  }

  .clock-face {
    width: min(100%, 214px);
  }

  .clock-hand-hour {
    height: 45px;
  }

  .clock-hand-minute {
    height: 63px;
  }

  .clock-caption {
    display: none;
  }

  .note-card {
    width: min(73%, 255px);
    padding: 18px 18px 15px;
  }

  .hero-sticker {
    left: 0;
  }

  .reader-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .tts-player {
    flex-wrap: wrap;
    gap: 11px;
    padding: 12px;
  }

  .player-info {
    flex: 1 1 calc(100% - 64px);
  }

  .player-speed {
    flex: 1 1 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-top: 2px;
  }

  .player-wave {
    display: none;
  }

  .story {
    font-size: 1.02rem;
  }

  .story-title-row {
    margin-top: 24px;
  }

  .reader-bottom {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .quiz-summary {
    flex-wrap: wrap;
    gap: 13px;
  }

  .quiz-summary-copy {
    flex-basis: calc(100% - 85px);
  }

  .quiz-status-badge {
    display: none;
  }

  .quiz-result {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .quiz-result .btn {
    width: 100%;
  }

  .cards-aside {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 11px;
  }

  .footer-mid {
    display: none;
  }

  .footer-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .brand-name {
    font-size: 15px;
  }

  .level-badge {
    height: 26px;
    padding-inline: 8px;
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
  }

  .hero-meta {
    gap: 8px 15px;
  }

  .hero-actions {
    align-items: stretch;
  }

  .hero-actions .btn {
    flex: 1 1 auto;
  }

  .completion-chip {
    height: 36px;
  }

  .reader-card,
  .quiz-panel {
    padding: 14px;
  }

  .tts-player {
    padding: 11px;
  }

  .player-play {
    width: 44px;
    height: 44px;
  }

  .story {
    font-size: 1rem;
    line-height: 1.8;
  }

  .section-head h2 {
    font-size: clamp(1.8rem, 8vw, 2.25rem);
  }

  .section-desc {
    font-size: 0.86rem;
  }

  .quiz-card {
    padding: 14px;
  }

  .quiz-summary-copy {
    flex-basis: calc(100% - 76px);
  }

  .score-dial {
    width: 62px;
    height: 62px;
  }

  .flashcard {
    height: clamp(278px, 40vh, 330px);
  }

  .deck-state {
    min-height: clamp(278px, 40vh, 330px);
  }

  .flashcard-face {
    padding: 32px 20px;
  }

  .word-main {
    font-size: clamp(2.25rem, 11vw, 3rem);
  }

  .card-translation {
    font-size: 1.5rem;
  }

  .card-example {
    font-size: 11px;
  }

  .card-example-ru {
    font-size: 9.5px;
  }

  .deck {
    padding: 13px;
  }

  .deck-actions {
    position: relative;
  }

  .saved-words {
    padding: 12px;
  }
}

@media (max-width: 400px) {
  .brand {
    gap: 8px;
  }

  .brand-name {
    font-size: 14px;
  }

  .header-actions {
    gap: 6px;
  }

  .hero h1 {
    font-size: clamp(2.75rem, 14.5vw, 3.5rem);
  }

  .hero-visual {
    height: 345px;
  }

  .clock-card {
    width: min(100%, 292px);
  }

  .clock-face {
    width: min(100%, 196px);
  }

  .note-card {
    width: min(75%, 236px);
    padding: 16px;
  }

  .hero-sticker {
    font-size: 8.5px;
  }

  .section-head h2 {
    font-size: 1.8rem;
  }

  .quiz-summary-copy {
    flex-basis: 100%;
  }

  .quiz-option {
    font-size: 11.5px;
  }

  .flashcard {
    height: 285px;
  }

  .deck-state {
    min-height: 285px;
  }

  .player-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .player-position {
    font-size: 9px;
  }
}

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

  .hero-actions .btn {
    flex-basis: 100%;
  }

  .completion-chip {
    width: 100%;
    justify-content: center;
  }

  .speed-pills button {
    padding-inline: 5px;
  }
}

/* Mobile popover becomes a bottom sheet */

@media (max-width: 640px) {
  .word-popover.is-sheet {
    top: auto !important;
    right: 10px !important;
    bottom: 10px !important;
    left: 10px !important;
    width: auto;
    max-height: calc(100vh - 20px);
    border-radius: 16px;
    animation: sheet-in 0.22s var(--ease);
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .flashcard-inner {
    transition: none !important;
  }
}
