/* ═══════════════════════════════════════════════════
   MUCHA — Nature curves. Botanical frames. Living ornament.
   Art Nouveau design system for Hapa Study Companion
═══════════════════════════════════════════════════ */

:root {
  --parch:  #f3e8cc;
  --ivory:  #fdf6e4;
  --deep:   #e8d8b0;
  --ink:    #221408;
  --br:     #6a4020;
  --gold:   #b88820;
  --gold2:  #7a5c10;
  --sage:   #5a7a48;
  --sage2:  #3a5228;
  --rose:   #b87060;
  --rose2:  #885040;
  --teal:   #3a7068;
  --mauv:   #806880;
  --line:   rgba(106, 64, 32, 0.15);
  --line-strong: rgba(106, 64, 32, 0.28);
  --shadow-sm: 0 2px 8px rgba(106, 64, 32, 0.08);
  --shadow:    0 8px 28px rgba(106, 64, 32, 0.12);
  --shadow-lg: 0 16px 48px rgba(106, 64, 32, 0.16);
  --font-display: "Libre Baskerville", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-body:    "Cormorant Garamond", "Hiragino Mincho ProN", "Yu Mincho", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  background-color: #ede0bc;
  background-image:
    radial-gradient(ellipse at 12%  8%,  rgba(184, 136,  32, 0.18) 0%, transparent 38%),
    radial-gradient(ellipse at 88% 92%,  rgba( 90, 122,  72, 0.16) 0%, transparent 35%),
    radial-gradient(ellipse at 50% 50%,  rgba(184, 112,  96, 0.08) 0%, transparent 55%),
    repeating-linear-gradient( 45deg, rgba(106, 64, 32, 0.04) 0px, rgba(106, 64, 32, 0.04) 1px, transparent 1px, transparent 14px),
    repeating-linear-gradient(-45deg, rgba(106, 64, 32, 0.04) 0px, rgba(106, 64, 32, 0.04) 1px, transparent 1px, transparent 14px),
    linear-gradient(170deg, #ede4c0 0%, #f3e8cc 45%, #ead8a8 100%);
}

button, input, textarea, select {
  font: inherit;
  font-size: 16px;
}

button {
  border: 0;
  background: none;
}

[hidden] {
  display: none !important;
}

/* ── APP SHELL ── */
.app-shell {
  position: relative;
  width: min(100% - 20px, 880px);
  margin: 0 auto;
  padding: 18px 0 calc(190px + env(safe-area-inset-bottom));
}

/* ── HERO ── */
.hero {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 40px 28px 28px;
  border-radius: 50% 50% 16px 16px / 12% 12% 16px 16px;
  background: linear-gradient(170deg, var(--ivory) 0%, rgba(252, 242, 220, 0.88) 100%);
  border: 1.5px solid rgba(184, 136, 32, 0.32);
  box-shadow: var(--shadow-lg), inset 0 0 0 6px rgba(184, 136, 32, 0.05);
  overflow: hidden;
  animation: mUp 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* golden radial halo */
.hero::after {
  content: '';
  position: absolute;
  top: -40%; left: 50%; transform: translateX(-50%);
  width: 140%; padding-top: 70%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(184, 136, 32, 0.14) 0%, transparent 65%);
  pointer-events: none;
}

/* botanical dots along the arched top */
.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 36px;
  background:
    radial-gradient(circle 3px   at 15% 60%, var(--sage)  0%, transparent 100%),
    radial-gradient(circle 4px   at 22% 35%, var(--sage2) 0%, transparent 100%),
    radial-gradient(circle 2px   at 30% 68%, var(--gold)  0%, transparent 100%),
    radial-gradient(circle 3px   at 38% 25%, var(--sage)  0%, transparent 100%),
    radial-gradient(circle 4px   at 50% 15%, var(--rose)  0%, transparent 100%),
    radial-gradient(circle 3px   at 62% 25%, var(--sage)  0%, transparent 100%),
    radial-gradient(circle 2px   at 70% 68%, var(--gold)  0%, transparent 100%),
    radial-gradient(circle 4px   at 78% 35%, var(--sage2) 0%, transparent 100%),
    radial-gradient(circle 3px   at 85% 60%, var(--sage)  0%, transparent 100%);
  pointer-events: none;
  opacity: 0.7;
}

.hero__copy {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  text-align: center;
}

.eyebrow {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.22em;
  color: var(--gold2);
  text-align: center;
}

.hero__copy h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 0 2px 8px rgba(106, 64, 32, 0.10);
}

/* vine separator in hero */
.hero-vine {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-vine svg {
  width: 100%;
  max-width: 340px;
  height: 28px;
}

.support-copy {
  margin: 0;
  font-style: italic;
  color: var(--br);
  opacity: 0.72;
  font-size: 0.9rem;
}

.hero__stats {
  position: relative;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.hero__stats .stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.hero__stats .stat-card__label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.7em;
  line-height: 1.25;
  letter-spacing: 0.08em;
}

.hero__stats .stat-card__value {
  margin-top: 0;
}

/* ── STAT / SUMMARY / SESSION CARDS ── */
.stat-card,
.summary-card,
.session-card {
  padding: 12px 10px;
  border-radius: 50% 50% 8px 8px / 18% 18% 8px 8px;
  border: 1px solid rgba(184, 136, 32, 0.22);
  background: rgba(253, 246, 228, 0.72);
  text-align: center;
}

.stat-card__label,
.summary-card__label,
.session-card__label,
.answer-block__label,
.flashcard__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mauv);
}

.stat-card__value,
.summary-card__value,
.session-card__value {
  display: block;
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  color: var(--br);
}

/* ── SCREENS ── */
.screens {
  margin-top: 16px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: mUp 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ── PANEL ── */
.panel {
  padding: 22px;
  border-radius: 8px 8px 40px 40px / 8px 8px 20px 20px;
  background: var(--ivory);
  border: 1.5px solid rgba(184, 136, 32, 0.24);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: mUp 700ms 80ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* coloured botanical stripe on left edge */
.panel::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 5px;
  background: repeating-linear-gradient(
    180deg,
    var(--sage)  0px,  var(--sage)  4px,
    transparent  4px,  transparent 12px,
    var(--gold)  12px, var(--gold) 16px,
    transparent 16px, transparent 24px,
    var(--rose)  24px, var(--rose) 28px,
    transparent 28px, transparent 36px
  );
  opacity: 0.4;
  border-radius: 4px 0 0 4px;
}

.panel__header,
.panel__header--split {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.panel__header--split {
  justify-content: space-between;
}

.panel__header h2,
.panel__header--split h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  font-style: italic;
  color: var(--br);
}

/* ── FILTER GROUPS ── */
.setup-groups {
  display: grid;
  gap: 14px;
}

.filter-group {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 4px 36px 4px 36px;
  background: rgba(243, 232, 204, 0.48);
}

.filter-group:nth-child(even) {
  border-radius: 36px 4px 36px 4px;
}

.filter-group > span {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold2);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── CHIPS ── */
.chip {
  min-height: 40px;
  padding: 9px 18px;
  border: 1px solid rgba(184, 136, 32, 0.26);
  border-radius: 36px 8px 36px 8px;
  background: var(--ivory);
  color: var(--br);
  font-family: var(--font-body);
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.chip:nth-child(even) {
  border-radius: 8px 36px 8px 36px;
}

.chip.is-active {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  border-color: transparent;
  color: #fff8e4;
  box-shadow: 0 4px 14px rgba(184, 136, 32, 0.32);
  transform: translateY(-2px) scale(1.03);
}

.chip:hover:not(.is-active) {
  transform: translateY(-1px);
  border-color: rgba(184, 136, 32, 0.5);
}

.chip:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

/* ── NUMBER INPUT ── */
.range-fields {
  display: grid;
  gap: 10px;
}

.number-field {
  display: grid;
  gap: 6px;
}

.number-field span {
  font-style: italic;
  color: var(--br);
  font-size: 0.86rem;
  opacity: 0.8;
}

.number-field input {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 4px 24px 4px 24px;
  background: rgba(253, 246, 228, 0.97);
  color: var(--ink);
  box-shadow: inset 0 1px 3px rgba(106, 64, 32, 0.06);
}

.number-field input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 136, 32, 0.14),
              inset 0 1px 3px rgba(106, 64, 32, 0.06);
}

/* ── SETUP SUMMARY ── */
.setup-summary {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ── ACTION ROW ── */
.action-row {
  display: flex;
  justify-content: flex-start;
}

.action-row--bottom {
  margin-top: 20px;
}

/* ── BUTTONS ── */
.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 13px 36px;
  border-radius: 36px 8px 36px 8px;
  border: 1.5px solid var(--gold2);
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #fff8e4;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 0 rgba(34, 20, 8, 0.18);
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  box-shadow: 0 5px 18px rgba(184, 136, 32, 0.30);
  transition:
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 220ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 220ms ease;
}

.button::before,
.button::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.button::before {
  inset: -18%;
  background: linear-gradient(
    120deg,
    transparent 16%,
    rgba(255, 248, 228, 0.05) 34%,
    rgba(255, 248, 228, 0.28) 48%,
    transparent 66%
  );
  opacity: 0.72;
  transform: translateX(-145%) skewX(-22deg);
  transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease;
}

.button::after {
  inset: 1px;
  border-radius: inherit;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 248, 228, 0.22) 0%, transparent 34%),
    radial-gradient(circle at 80% 82%, rgba(255, 248, 228, 0.12) 0%, transparent 38%);
  opacity: 0.7;
}

.button:hover {
  transform: translateY(-2px) scale(1.012);
  box-shadow: 0 8px 24px rgba(184, 136, 32, 0.36);
  filter: saturate(1.06);
}

.button:hover::before,
.button:focus-visible::before {
  transform: translateX(145%) skewX(-22deg);
}

.button:active {
  transform: translateY(1px) scale(0.988);
  box-shadow: 0 3px 12px rgba(106, 64, 32, 0.22);
}

.button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(184, 136, 32, 0.18),
    0 8px 24px rgba(184, 136, 32, 0.22);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
  filter: none;
}

.button:disabled::before,
.button:disabled::after {
  opacity: 0;
}

.button--ghost {
  background: var(--ivory);
  color: var(--br);
  border-color: var(--line);
  box-shadow: none;
}

.button--ghost:hover {
  box-shadow: var(--shadow-sm);
}

.button--again {
  background: linear-gradient(135deg, var(--rose), var(--rose2));
  border-color: transparent;
  color: #fff0ec;
  box-shadow: 0 5px 18px rgba(184, 112, 96, 0.30);
}

.button--again:hover {
  box-shadow: 0 8px 24px rgba(184, 112, 96, 0.38);
}

.button--good {
  background: linear-gradient(135deg, var(--sage), var(--sage2));
  border-color: transparent;
  color: #e4f0dc;
  box-shadow: 0 5px 18px rgba(90, 122, 72, 0.28);
}

.button--good:hover {
  box-shadow: 0 8px 24px rgba(90, 122, 72, 0.36);
}

.button.is-outcome-active {
  animation: buttonRespond 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.button--again.is-outcome-active {
  box-shadow: 0 0 0 1px rgba(184, 112, 96, 0.18), 0 10px 28px rgba(184, 112, 96, 0.34);
}

.button--good.is-outcome-active {
  box-shadow: 0 0 0 1px rgba(90, 122, 72, 0.18), 0 10px 28px rgba(90, 122, 72, 0.34);
}

/* ── SESSION STRIP ── */
.session-strip {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

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

.session-progress,
.flashcard__progress {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(184, 136, 32, 0.08), rgba(184, 136, 32, 0.18));
  box-shadow: inset 0 1px 2px rgba(106, 64, 32, 0.08);
}

.session-progress::before,
.flashcard__progress::before {
  content: "";
  position: absolute;
  inset: 1px 10px;
  border-radius: inherit;
  background:
    radial-gradient(circle at 14% 55%, rgba(90, 122, 72, 0.2) 0%, transparent 18%),
    radial-gradient(circle at 32% 36%, rgba(184, 136, 32, 0.18) 0%, transparent 18%),
    radial-gradient(circle at 57% 62%, rgba(184, 112, 96, 0.18) 0%, transparent 18%),
    radial-gradient(circle at 84% 40%, rgba(58, 112, 104, 0.2) 0%, transparent 18%);
  opacity: 0.5;
  pointer-events: none;
}

.session-progress span,
.flashcard__progress span {
  display: block;
  position: relative;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 13px 7px at 18% 62%, rgba(90, 122, 72, 0.92) 0%, transparent 56%),
    radial-gradient(ellipse 11px 6px at 39% 34%, rgba(58, 112, 104, 0.82) 0%, transparent 58%),
    radial-gradient(ellipse 10px 6px at 61% 68%, rgba(184, 136, 32, 0.88) 0%, transparent 58%),
    radial-gradient(circle 10px at 88% 48%, rgba(255, 248, 228, 0.34) 0%, transparent 42%),
    linear-gradient(90deg, var(--sage) 0%, var(--gold) 56%, var(--rose) 100%);
  box-shadow: 0 0 14px rgba(184, 136, 32, 0.22);
  transition: width 260ms ease, box-shadow 220ms ease, filter 220ms ease;
}

.session-progress span::after,
.flashcard__progress span::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -5px;
  width: 18px;
  height: 14px;
  border-radius: 70% 35% 70% 35%;
  background: linear-gradient(135deg, rgba(90, 122, 72, 0.96), rgba(184, 136, 32, 0.84));
  box-shadow: 0 0 8px rgba(184, 136, 32, 0.26);
  transform: translateY(-50%) rotate(-18deg);
}

.session-progress span[data-active="false"],
.flashcard__progress span[data-active="false"] {
  box-shadow: none;
}

.session-progress span[data-active="false"]::after,
.flashcard__progress span[data-active="false"]::after {
  opacity: 0;
}

/* ── FLASHCARD OUTER (corner ornament wrapper) ── */
.flashcard-outer {
  position: relative;
  isolation: isolate;
  animation: mUp 700ms 160ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard-outer::before,
.flashcard-outer::after {
  content: "";
  position: absolute;
  inset: 4% 8%;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

.flashcard-outer::before {
  background: radial-gradient(
    circle,
    rgba(184, 136, 32, 0.22) 0%,
    rgba(184, 136, 32, 0.08) 38%,
    transparent 72%
  );
  filter: blur(4px);
  transform: scale(0.78);
}

.flashcard-outer::after {
  background:
    radial-gradient(circle at 20% 42%, rgba(184, 112, 96, 0.22) 0 3px, transparent 4px),
    radial-gradient(circle at 36% 22%, rgba(184, 136, 32, 0.24) 0 2.5px, transparent 3.5px),
    radial-gradient(circle at 48% 72%, rgba(90, 122, 72, 0.24) 0 3px, transparent 4px),
    radial-gradient(circle at 68% 26%, rgba(58, 112, 104, 0.24) 0 3px, transparent 4px),
    radial-gradient(circle at 82% 58%, rgba(184, 136, 32, 0.24) 0 2.5px, transparent 3.5px);
  transform: scale(1.06);
}

.flashcard-outer.is-stage-entering::before {
  animation: stageHalo 820ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard-outer.is-stage-entering::after {
  animation: stageDust 860ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard-outer.is-stage-entering .flashcard {
  animation: cardStageEntrance 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.flashcard-outer.is-stage-entering .card-corner {
  animation: cornerBloom 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card-corner {
  position: absolute;
  width: 70px;
  height: 70px;
  pointer-events: none;
  z-index: 2;
}

.card-corner--tl { top: -8px; left: -8px; }
.card-corner--tr { top: -8px; right: -8px; transform: scaleX(-1); }
.card-corner--bl { bottom: -8px; left: -8px; transform: scaleY(-1); }
.card-corner--br { bottom: -8px; right: -8px; transform: scale(-1); }

/* ── FLASHCARD ── */
.flashcard {
  position: relative;
  padding: 40px 24px 24px;
  border-radius: 50% 50% 16px 16px / 14% 14% 16px 16px;
  background: linear-gradient(170deg, var(--ivory) 0%, rgba(248, 238, 215, 0.92) 100%);
  border: 1.5px solid rgba(184, 136, 32, 0.34);
  box-shadow: var(--shadow-lg), inset 0 0 0 7px rgba(184, 136, 32, 0.05);
  overflow: hidden;
  transform-origin: center top;
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 240ms ease;
}

.flashcard.is-revealable {
  cursor: pointer;
}

.flashcard.is-card-advancing {
  animation: cardAdvance 440ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard.is-resolving {
  pointer-events: none;
}

.flashcard.is-outcome-good {
  animation: flashcardGood 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard.is-outcome-again {
  animation: flashcardAgain 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard.is-outcome-good::after,
.flashcard.is-outcome-again::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
}

.flashcard.is-outcome-good::after {
  background: radial-gradient(circle, rgba(255, 244, 196, 0.26) 0%, transparent 70%);
  animation: outcomeGlow 320ms ease-out both;
}

.flashcard.is-outcome-again::after {
  background: radial-gradient(circle, rgba(184, 112, 96, 0.18) 0%, transparent 70%);
  animation: outcomeGlow 320ms ease-out both;
}

/* botanical dots along arched top */
.flashcard::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 44px;
  background:
    radial-gradient(circle 2px    at 18% 55%, var(--sage)  0%, transparent 100%),
    radial-gradient(circle 3px    at 25% 28%, var(--sage2) 0%, transparent 100%),
    radial-gradient(circle 2px    at 32% 65%, var(--gold)  0%, transparent 100%),
    radial-gradient(circle 3.5px  at 40% 20%, var(--rose)  0%, transparent 100%),
    radial-gradient(circle 4px    at 50% 14%, var(--gold)  0%, transparent 100%),
    radial-gradient(circle 3.5px  at 60% 20%, var(--sage)  0%, transparent 100%),
    radial-gradient(circle 2px    at 68% 65%, var(--rose)  0%, transparent 100%),
    radial-gradient(circle 3px    at 75% 28%, var(--gold)  0%, transparent 100%),
    radial-gradient(circle 2px    at 82% 55%, var(--sage2) 0%, transparent 100%);
  pointer-events: none;
  opacity: 0.75;
}

/* golden halo */
.flashcard-halo {
  position: absolute;
  top: 10%; left: 50%; transform: translateX(-50%);
  width: 80%; padding-top: 50%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse,
    rgba(184, 136, 32, 0.10) 0%,
    rgba(184, 136, 32, 0.04) 40%,
    transparent 70%
  );
  pointer-events: none;
}

.flashcard-bloom {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.flashcard-bloom span {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 65% 35% 65% 35%;
  background: linear-gradient(135deg, rgba(184, 136, 32, 0.94), rgba(255, 248, 228, 0.72));
  box-shadow: 0 0 10px rgba(184, 136, 32, 0.18);
  opacity: 0;
}

.flashcard-bloom span:nth-child(1) {
  top: 20%;
  left: 18%;
}

.flashcard-bloom span:nth-child(2) {
  top: 14%;
  left: 34%;
}

.flashcard-bloom span:nth-child(3) {
  top: 16%;
  right: 26%;
}

.flashcard-bloom span:nth-child(4) {
  top: 28%;
  right: 16%;
}

.flashcard-bloom span:nth-child(5) {
  bottom: 22%;
  left: 24%;
}

.flashcard-bloom span:nth-child(6) {
  bottom: 18%;
  right: 22%;
}

.flashcard-outer.is-stage-entering .flashcard-bloom span {
  animation: bloomFloat 720ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard.is-outcome-good .flashcard-bloom span {
  animation: bloomFloat 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard.is-outcome-again .flashcard-bloom span {
  background: linear-gradient(135deg, rgba(184, 112, 96, 0.88), rgba(255, 240, 236, 0.74));
  animation: inkFloat 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard__meta {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 30px;
  padding: 5px 14px;
  border-radius: 36px 4px 36px 4px;
  border: 1px solid rgba(184, 136, 32, 0.30);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.3;
  flex-wrap: wrap;
}

#card-progress {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--mauv);
  white-space: nowrap;
  font-weight: 600;
}

.flashcard__progress {
  position: relative;
  z-index: 1;
  margin-top: 6px;
}

.card-badge--neutral {
  color: var(--gold2);
  background: rgba(184, 136, 32, 0.09);
}

.card-badge--phrase {
  background: rgba(184, 112, 96, 0.14);
  color: var(--rose2);
}

.card-badge--vocabulary {
  background: rgba(58, 112, 104, 0.12);
  color: var(--teal);
}

.card-badge--expression {
  background: rgba(90, 122, 72, 0.12);
  color: var(--sage2);
}

.flashcard__eyebrow {
  position: relative;
  z-index: 1;
  margin: 14px 0 8px;
  font-size: 0.76rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sage);
}

.flashcard__front {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 8.5vw, 3.5rem);
  font-weight: 700;
  font-style: italic;
  line-height: 1.12;
  color: var(--ink);
  text-align: center;
  text-shadow: 0 2px 10px rgba(106, 64, 32, 0.08);
}

.flashcard__tap-hint {
  position: relative;
  z-index: 1;
  margin: 16px 0 0;
  font-style: italic;
  color: var(--gold2);
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
}

/* vine divider between question and answer */
.flashcard-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px 0 0;
}

.flashcard-divider svg {
  width: 100%;
  max-width: 300px;
  height: 22px;
}

.flashcard__answer {
  position: relative;
  z-index: 1;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  animation: revealAnswer 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard.is-revealing-answer {
  animation: cardRevealBend 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard.is-revealing-answer .flashcard__front {
  animation: questionLift 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard.is-revealing-answer .flashcard__tap-hint {
  animation: hintFade 240ms ease-out both;
}

.flashcard.is-revealing-answer .flashcard-divider svg {
  animation: dividerBloom 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard.is-revealing-answer .flashcard__answer {
  animation: answerFanOpen 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.flashcard__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold2);
  margin-bottom: 10px;
  text-align: center;
}

.answer-stack {
  display: grid;
  gap: 8px;
}

.answer-block {
  padding: 13px 16px;
  border-radius: 4px 28px 4px 28px;
  border: 1px solid var(--line);
  background: rgba(243, 232, 204, 0.55);
}

.answer-block:nth-child(even) {
  border-radius: 28px 4px 28px 4px;
}

.answer-block__label {
  font-size: 0.68rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mauv);
}

.answer-block p {
  margin: 5px 0 0;
  font-style: italic;
  color: var(--br);
  font-size: 0.96rem;
  line-height: 1.6;
}

.flashcard__controls {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.flashcard__action-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.flashcard__action-row .button {
  width: 100%;
  min-height: 58px;
  font-size: 1rem;
  justify-content: center;
}

.flashcard__action-row .button--again {
  border-radius: 8px 36px 8px 36px;
}

.flashcard__action-row .button--good {
  border-radius: 36px 8px 36px 8px;
}

.flashcard__swipe-hint {
  display: flex;
  justify-content: space-between;
  font-style: italic;
  color: var(--mauv);
  font-size: 0.82rem;
  opacity: 0.8;
}

/* ── SESSION ACTIONS ── */
.session-actions {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.session-actions__copy {
  margin: 0;
}

.session-actions__buttons {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* ── MOBILE ACTION BAR ── */
.mobile-action-bar {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  left:  max(10px, env(safe-area-inset-left));
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1.5px solid rgba(184, 136, 32, 0.26);
  border-radius: 8px 8px 28px 28px / 8px 8px 14px 14px;
  background: rgba(253, 246, 228, 0.94);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.mobile-action-bar__meta {
  margin: 0;
  font-style: italic;
  color: var(--br);
  font-size: 0.84rem;
  font-weight: 600;
  opacity: 0.8;
}

.mobile-action-bar__actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mobile-action-bar .button {
  width: 100%;
  min-height: 56px;
}

.app-shell[data-active-screen="setup"] .mobile-action-bar--study,
.app-shell[data-active-screen="study"] .mobile-action-bar--setup {
  display: none;
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  left:  max(10px, env(safe-area-inset-left));
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 8px;
  border-radius: 50% 50% 16px 16px / 18% 18% 16px 16px;
  background: rgba(253, 246, 228, 0.92);
  border: 1.5px solid rgba(184, 136, 32, 0.26);
  box-shadow: 0 10px 36px rgba(106, 64, 32, 0.20);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.bottom-nav__button {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-height: 56px;
  padding: 8px 10px;
  border-radius: 50% 50% 12px 12px / 22% 22% 12px 12px;
  color: var(--mauv);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  transition: all 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bottom-nav__button:hover {
  transform: translateY(-1px);
}

.bottom-nav__button.is-active {
  background: linear-gradient(160deg, var(--gold), var(--gold2));
  color: #fff8e4;
  box-shadow: 0 4px 14px rgba(184, 136, 32, 0.30);
}

.bottom-nav__button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── ANIMATIONS ── */
@keyframes mUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

@keyframes buttonRespond {
  0%   { transform: translateY(0) scale(1); }
  40%  { transform: translateY(-2px) scale(1.04); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes stageHalo {
  0%   { opacity: 0; transform: scale(0.72); }
  35%  { opacity: 0.9; }
  100% { opacity: 0; transform: scale(1.18); }
}

@keyframes stageDust {
  0%   { opacity: 0; transform: scale(0.96) translateY(12px); }
  35%  { opacity: 0.85; }
  100% { opacity: 0; transform: scale(1.18) translateY(-16px); }
}

@keyframes cardStageEntrance {
  0%   { opacity: 0; transform: translateY(28px) scale(0.96) rotateX(-10deg); }
  55%  { opacity: 1; transform: translateY(-4px) scale(1.01) rotateX(1deg); }
  100% { opacity: 1; transform: none; }
}

@keyframes cornerBloom {
  0%   { opacity: 0; filter: blur(4px); }
  55%  { opacity: 1; filter: blur(0); }
  100% { opacity: 1; filter: none; }
}

@keyframes cardAdvance {
  0%   { opacity: 0.3; transform: translateY(16px) scale(0.985); }
  60%  { opacity: 1; transform: translateY(-2px) scale(1.003); }
  100% { opacity: 1; transform: none; }
}

@keyframes flashcardGood {
  0%   { transform: scale(1); box-shadow: var(--shadow-lg), inset 0 0 0 7px rgba(184, 136, 32, 0.05); }
  40%  { transform: scale(1.012); box-shadow: 0 18px 50px rgba(184, 136, 32, 0.26), inset 0 0 0 7px rgba(184, 136, 32, 0.08); }
  100% { transform: scale(1); box-shadow: var(--shadow-lg), inset 0 0 0 7px rgba(184, 136, 32, 0.05); }
}

@keyframes flashcardAgain {
  0%   { transform: translateX(0); }
  28%  { transform: translateX(-5px) rotate(-0.45deg); }
  60%  { transform: translateX(3px) rotate(0.25deg); }
  100% { transform: translateX(0); }
}

@keyframes outcomeGlow {
  0%   { opacity: 0; transform: scale(0.92); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.06); }
}

@keyframes bloomFloat {
  0%   { opacity: 0; transform: translateY(12px) scale(0.7) rotate(0deg); }
  35%  { opacity: 0.85; }
  100% { opacity: 0; transform: translateY(-26px) scale(1.12) rotate(26deg); }
}

@keyframes inkFloat {
  0%   { opacity: 0; transform: translateY(4px) scale(0.76) rotate(0deg); }
  35%  { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(18px) scale(1.06) rotate(-18deg); }
}

@keyframes revealAnswer {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cardRevealBend {
  0%   { transform: perspective(1100px) rotateX(0deg); }
  30%  { transform: perspective(1100px) rotateX(-7deg) translateY(-2px); }
  100% { transform: perspective(1100px) rotateX(0deg); }
}

@keyframes questionLift {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  45%  { opacity: 0.4; transform: translateY(-8px) scale(0.985); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes hintFade {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-6px); }
}

@keyframes dividerBloom {
  0%   { opacity: 0; transform: scaleX(0.84); }
  100% { opacity: 1; transform: scaleX(1); }
}

@keyframes answerFanOpen {
  0%   { opacity: 0; transform: translateY(18px) scale(0.985) rotateX(-8deg); }
  50%  { opacity: 1; transform: translateY(-2px) scale(1.005) rotateX(1deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotateX(0deg); }
}

/* ── RESPONSIVE — wider layout ── */
@media (min-width: 720px) {
  .app-shell {
    padding: 18px 0 calc(108px + env(safe-area-inset-bottom));
  }

  .hero {
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
    align-items: end;
  }

  .hero__copy {
    align-items: flex-start;
    text-align: left;
  }

  .eyebrow,
  .hero__copy h1 {
    text-align: left;
  }

  .hero__stats,
  .setup-summary,
  .session-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hero__stats .stat-card {
    padding: 12px 14px;
  }

  .hero__stats .stat-card__label {
    font-size: 0.68rem;
  }

  .hero__stats .stat-card__value {
    font-size: 1.7rem;
  }

  .setup-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .range-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flashcard {
    padding: 44px 28px 28px;
  }

  .mobile-action-bar {
    display: none;
  }
}

@media (max-width: 719px) {
  .app-shell[data-active-screen="study"] .hero {
    display: none;
  }

  .hero__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-shell[data-active-screen="study"] .screens {
    margin-top: 0;
  }

  .action-row--bottom,
  .flashcard__controls {
    display: none;
  }

  .panel__header--split .button--ghost {
    min-height: 46px;
    padding: 10px 16px;
  }

  .session-strip .support-copy {
    font-size: 0.86rem;
  }
}

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