:root {
  --bg: #edf0eb;
  --bg-deep: #101923;
  --bg-muted: #e6dcc9;
  --surface: rgba(248, 243, 234, 0.74);
  --surface-strong: rgba(255, 251, 245, 0.84);
  --ink: #14202a;
  --ink-soft: rgba(20, 32, 42, 0.72);
  --ink-muted: rgba(20, 32, 42, 0.54);
  --verse-card-start: #132231;
  --verse-card-end: #223445;
  --verse-card-ink: #f4efe4;
  --reflection-card-start: #fbf7ef;
  --reflection-card-end: #efe4d2;
  --reflection-card-ink: #17212b;
  --accent-gold: #b38a4e;
  --accent-sage: #6a8370;
  --accent-indigo: #435a7a;
  --border-soft: rgba(255, 255, 255, 0.28);
  --border-dark: rgba(19, 34, 49, 0.08);
  --shadow-soft: 0 28px 60px rgba(16, 25, 35, 0.16);
  --shadow-strong: 0 36px 90px rgba(16, 25, 35, 0.18);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --font-serif: "Cormorant Garamond", "Times New Roman", serif;
  --font-sans: "Manrope", "Segoe UI", sans-serif;
  --focus-ring: 0 0 0 3px rgba(115, 152, 124, 0.28);
  --content-width: 1120px;
}

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

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(179, 138, 78, 0.12), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(92, 120, 149, 0.18), transparent 26%),
    linear-gradient(145deg, #f5f0e5 0%, #eef1eb 48%, #dbe4e7 100%);
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

button:focus-visible,
[tabindex="0"]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.page-glow,
.page-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.page-glow {
  filter: blur(72px);
  opacity: 0.7;
}

.glow-one {
  background: radial-gradient(circle at 20% 25%, rgba(197, 176, 125, 0.36), transparent 32%);
}

.glow-two {
  background: radial-gradient(circle at 78% 18%, rgba(83, 111, 136, 0.22), transparent 28%);
}

.page-grain {
  opacity: 0.035;
  background-image:
    linear-gradient(0deg, rgba(0, 0, 0, 0.6) 0, rgba(0, 0, 0, 0.6) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.35) 0, rgba(0, 0, 0, 0.35) 1px, transparent 1px);
  background-size: 4px 4px;
  mix-blend-mode: multiply;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 32px 20px 40px;
}

.hero {
  display: grid;
  gap: 24px;
  align-items: end;
}

.hero-copy,
.hero-status,
.controls-panel {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.hero-copy {
  padding: 8px 4px 0;
}

.eyebrow,
.status-kicker,
.card-overline {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.hero h1 {
  margin: 10px 0 6px;
  font-family: var(--font-serif);
  font-size: clamp(3rem, 9vw, 5.2rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  font-size: clamp(1rem, 2.2vw, 1.24rem);
  color: var(--accent-indigo);
  font-weight: 600;
}

.description {
  max-width: 38rem;
  margin: 16px 0 0;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink-soft);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.daily-draw-pill,
.sample-pill,
.mini-pill,
.storage-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 251, 245, 0.52);
  color: var(--ink-soft);
  font-size: 0.87rem;
}

.daily-draw-pill::before,
.mini-pill-daily::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f0dfb1 0%, #a9834c 100%);
  box-shadow: 0 0 12px rgba(179, 138, 78, 0.52);
}

.hero-status,
.controls-panel {
  border: 1px solid rgba(255, 255, 255, 0.42);
  background:
    linear-gradient(145deg, rgba(255, 251, 245, 0.82), rgba(236, 240, 235, 0.58));
  box-shadow: var(--shadow-soft);
}

.hero-status {
  padding: 22px;
  border-radius: var(--radius-lg);
}

.status-header,
.card-top,
.deck-footer,
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-count {
  margin: 18px 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3vw, 2rem);
  line-height: 1;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(20, 32, 42, 0.08);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-sage) 0%, var(--accent-gold) 100%);
  transition: width 520ms ease;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 0;
}

.status-grid div {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.36);
}

.status-grid dt {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-muted);
}

.status-grid dd {
  margin: 8px 0 0;
  font-size: 1rem;
  color: var(--ink);
  font-weight: 600;
}

.status-copy,
.deck-note,
.deck-hint,
.feedback-text,
.card-caption,
.illustration-caption {
  margin: 14px 0 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.deck-section {
  margin-top: 28px;
}

.deck-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 560px;
  perspective: 1800px;
  isolation: isolate;
}

.stack-card {
  position: absolute;
  inset: 28px 0 0;
  margin: 0 auto;
  width: min(100%, 560px);
  height: clamp(420px, 72vw, 540px);
  padding: 28px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.42);
  background:
    linear-gradient(180deg, rgba(255, 250, 244, 0.74), rgba(239, 229, 211, 0.48));
  box-shadow: 0 18px 44px rgba(16, 25, 35, 0.09);
  color: rgba(20, 32, 42, 0.45);
  transition: transform 480ms ease, opacity 480ms ease;
}

.stack-card .stack-reference {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.2rem;
}

.stack-card .stack-label {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.depth-one {
  transform: translateY(18px) scale(0.974);
  opacity: 0.76;
}

.depth-two {
  transform: translateY(38px) scale(0.946);
  opacity: 0.52;
}

.depth-three {
  transform: translateY(58px) scale(0.918);
  opacity: 0.34;
}

.active-card {
  position: relative;
  z-index: 5;
  width: min(100%, 560px);
  height: clamp(420px, 72vw, 540px);
  border-radius: var(--radius-xl);
  touch-action: pan-y;
  transform: translateX(var(--drag-offset, 0)) rotate(var(--drag-rotate, 0deg));
  transition: transform 200ms ease;
}

.active-card.is-mastered {
  filter: drop-shadow(0 18px 48px rgba(179, 138, 78, 0.14));
}

.active-card.is-pulsing {
  animation: hapticPulse 280ms ease;
}

.card-rotator {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 620ms cubic-bezier(0.22, 1, 0.36, 1);
}

.active-card.is-flipped .card-rotator {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(24px, 4vw, 34px);
  border-radius: inherit;
  backface-visibility: hidden;
  overflow: hidden;
  box-shadow: var(--shadow-strong);
}

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

.card-face::before {
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 34%),
    radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.08), transparent 34%);
}

.card-face::after {
  inset: 12px;
  border-radius: calc(var(--radius-xl) - 8px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.card-face-front {
  color: var(--verse-card-ink);
  background:
    radial-gradient(circle at 88% 12%, rgba(198, 169, 120, 0.18), transparent 24%),
    linear-gradient(160deg, var(--verse-card-start) 0%, var(--verse-card-end) 100%);
}

.card-face-back {
  color: var(--reflection-card-ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(179, 138, 78, 0.12), transparent 22%),
    linear-gradient(180deg, var(--reflection-card-start) 0%, var(--reflection-card-end) 100%);
  transform: rotateY(180deg);
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.mini-pill {
  min-height: 32px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mini-pill-mastered,
.mini-pill-back {
  border-color: rgba(255, 255, 255, 0.12);
}

.card-face-back .mini-pill,
.card-face-back .reflection-reference {
  color: rgba(23, 33, 43, 0.72);
}

.card-reference,
.reflection-reference {
  margin: 6px 0 0;
  font-size: 1.18rem;
  font-weight: 600;
}

.card-meta {
  margin: 6px 0 0;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(244, 239, 228, 0.68);
}

.reflection-meta {
  color: rgba(23, 33, 43, 0.56);
}

.verse-wrap,
.reflection-wrap {
  display: flex;
  flex: 1;
  align-items: center;
}

.verse-text {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.16;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.reflection-text {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.08rem);
  line-height: 1.85;
  color: rgba(23, 33, 43, 0.82);
}

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

.ornament span {
  display: block;
  width: 44px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 249, 238, 0.72) 45%, transparent 100%);
}

.ornament span:nth-child(2) {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 249, 238, 0.82);
  box-shadow: 0 0 16px rgba(255, 249, 238, 0.4);
}

.card-caption {
  font-size: 0.9rem;
  color: rgba(244, 239, 228, 0.72);
}

.illustration-panel {
  display: grid;
  gap: 14px;
}

.illustration-frame {
  min-height: 120px;
  border-radius: 22px;
  border: 1px solid rgba(67, 90, 122, 0.14);
  background:
    radial-gradient(circle at 50% 0%, rgba(179, 138, 78, 0.1), transparent 40%),
    rgba(255, 255, 255, 0.36);
  display: grid;
  place-items: center;
  color: var(--accent-indigo);
}

.illustration-frame svg {
  width: min(100%, 220px);
  height: auto;
}

.illustration-caption {
  margin-top: 0;
  font-size: 0.9rem;
}

.deck-footer {
  margin-top: 18px;
  flex-wrap: wrap;
}

.deck-note,
.deck-hint {
  margin: 0;
  font-size: 0.92rem;
}

.controls-panel {
  margin-top: 22px;
  padding: 18px;
  border-radius: var(--radius-lg);
}

.control-row {
  flex-wrap: wrap;
}

.control-row + .control-row {
  margin-top: 12px;
}

.control-button {
  flex: 1 1 140px;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 18px;
  border: 1px solid rgba(20, 32, 42, 0.08);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 20px rgba(16, 25, 35, 0.06);
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.control-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.78);
}

.control-button:active {
  transform: translateY(1px) scale(0.992);
}

.control-button-accent,
.control-button.is-active {
  color: #faf5ea;
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(120deg, var(--accent-indigo) 0%, #334c63 100%);
}

.control-button-mastered {
  color: #fffaf2;
  border-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(120deg, var(--accent-sage) 0%, #7f6a4f 100%);
}

.control-button-quiet {
  color: var(--ink-soft);
}

.control-button-wide {
  flex-basis: 200px;
}

.feedback-text {
  margin: 14px 2px 0;
  min-height: 1.4em;
  font-size: 0.93rem;
}

.deck-frame.is-exiting-left .active-card {
  animation: cardExitLeft 180ms both;
}

.deck-frame.is-exiting-right .active-card {
  animation: cardExitRight 180ms both;
}

.deck-frame.is-entering-left .active-card {
  animation: cardEnterLeft 420ms both;
}

.deck-frame.is-entering-right .active-card {
  animation: cardEnterRight 420ms both;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes cardExitLeft {
  from {
    opacity: 1;
    transform: translateX(0) rotate(0deg) scale(1);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateX(-46px) rotate(-3deg) scale(0.984);
    filter: blur(2px);
  }
}

@keyframes cardExitRight {
  from {
    opacity: 1;
    transform: translateX(0) rotate(0deg) scale(1);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateX(46px) rotate(3deg) scale(0.984);
    filter: blur(2px);
  }
}

@keyframes cardEnterLeft {
  from {
    opacity: 0;
    transform: translateX(-54px) rotate(-4deg) scale(0.976);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotate(0deg) scale(1);
    filter: blur(0);
  }
}

@keyframes cardEnterRight {
  from {
    opacity: 0;
    transform: translateX(54px) rotate(4deg) scale(0.976);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotate(0deg) scale(1);
    filter: blur(0);
  }
}

@keyframes hapticPulse {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.012);
  }
  100% {
    transform: scale(1);
  }
}

@media (min-width: 860px) {
  .hero {
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, 360px);
  }

  .controls-panel {
    padding: 20px;
  }
}

@media (max-width: 859px) {
  .deck-frame {
    min-height: 520px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 22px 14px 32px;
  }

  .hero h1 {
    font-size: clamp(2.65rem, 15vw, 3.6rem);
  }

  .hero-status,
  .controls-panel {
    padding: 16px;
  }

  .deck-frame {
    min-height: 460px;
  }

  .stack-card {
    padding: 18px;
  }

  .card-face {
    padding: 22px;
  }

  .verse-text {
    font-size: clamp(1.78rem, 9vw, 2.3rem);
  }

  .reflection-text {
    font-size: 0.98rem;
    line-height: 1.72;
  }

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

  .control-button,
  .control-button-wide {
    flex-basis: calc(50% - 8px);
  }

  .control-button-quiet {
    flex-basis: 100%;
  }
}

@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;
  }
}
