/* Spark Deck: warm dark studio. Poppins only, upright, max weight 600. */
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/poppins-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/poppins-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/poppins-latin-600-normal.woff2') format('woff2'); }

:root {
  --bg: #1a1512;
  --bg-2: #211a16;
  --surface: #2a211c;
  --surface-2: #342a23;
  --line: rgba(243, 233, 220, 0.09);
  --ink: #f3e9dc;
  --muted: #b5a493;
  --faint: #7f7062;
  --accent: #f0a44b;
  --accent-ink: #2a1a08;
  --good: #9dbb8f;
  --bad: #e58f8f;
  --r-sm: 12px; --r-md: 16px; --r-lg: 24px; --r-xl: 32px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
*, *::before, *::after { font-style: normal; }
html, body { margin: 0; min-height: 100%; min-height: 100dvh; background: var(--bg); color: var(--ink); }
body {
  font-family: 'Poppins', system-ui, sans-serif; font-weight: 400; font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
body.in-deck, .app.in-deck {
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
}
/* Warm studio wall: faint grain via layered radial light, not a section gradient. */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(120% 60% at 15% -10%, rgba(240, 164, 75, 0.10), transparent 60%);
}
em, i, cite, address, dfn { font-style: normal; }
b, strong, h1, h2, h3, h4 { font-weight: 600; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

.app { position: relative; z-index: 1; min-height: 100%; max-width: 560px; margin: 0 auto; }
.view { padding: calc(var(--safe-t) + 24px) 0 calc(var(--safe-b) + 112px); }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.wordmark { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.wordmark-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.wordmark-mark svg { width: 16px; height: 16px; fill: var(--accent-ink); }
.streak { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 500; }
.streak svg { width: 16px; height: 16px; fill: var(--accent); }
.streak.cold svg { fill: var(--faint); }

.hello { padding: 32px 24px 0; }
.hello-kicker { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 0; }
.hello-title { font-size: 36px; line-height: 1.1; letter-spacing: -0.02em; margin: 8px 0 0; max-width: 14ch; }
.hello-title span { color: var(--accent); }

/* Featured pack: large, asymmetric */
.feature { display: block; margin: 24px 24px 0; border-radius: var(--r-xl); overflow: hidden; background: var(--surface); border: 1px solid var(--line); text-decoration: none; position: relative; transition: transform .4s var(--ease); }
.feature:active { transform: scale(0.98); }
.feature-art { aspect-ratio: 4 / 3; position: relative; }
.feature-art svg, .shelf-art svg, .card-art svg, .saved-art svg { display: block; width: 100%; height: 100%; }
.feature-body { padding: 16px 24px 24px; display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: end; }
.feature-label { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); font-weight: 500; grid-column: 1 / -1; }
.feature-title { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
.feature-meta { color: var(--muted); font-size: 14px; margin: 0; }
.feature-go { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; grid-row: 2 / span 2; grid-column: 2; }
.feature-go svg { width: 20px; height: 20px; stroke: var(--accent-ink); stroke-width: 2.4; fill: none; }
.progress-line { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); transform-origin: left; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 40px 24px 12px; }
.section-head h2 { font-size: 18px; margin: 0; }
.section-head p { margin: 0; color: var(--faint); font-size: 14px; }

/* Shelf: horizontal, staggered heights so it does not read as a uniform grid */
.shelf { display: flex; gap: 16px; overflow-x: auto; padding: 4px 24px 8px; scroll-snap-type: x mandatory; scroll-padding-inline: 24px; scrollbar-width: none; }
.shelf::-webkit-scrollbar { display: none; }
.shelf-item { flex: 0 0 64%; scroll-snap-align: start; text-decoration: none; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: transform .4s var(--ease); align-self: flex-start; }
.shelf-item:nth-child(even) { margin-top: 24px; }
.shelf-item:active { transform: scale(0.97); }
.shelf-art { aspect-ratio: 1 / 1; position: relative; }
.shelf-body { padding: 12px 16px 16px; }
.shelf-title { font-size: 16px; font-weight: 600; margin: 0; line-height: 1.3; }
.shelf-meta { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.badge { position: absolute; top: 12px; left: 12px; font-size: 12px; font-weight: 500; padding: 4px 8px; border-radius: 999px; background: rgba(26, 21, 18, 0.72); color: var(--ink); }
.badge.done { background: var(--good); color: #142012; }

.make-tile { margin: 32px 24px 0; padding: 24px; border-radius: var(--r-lg); border: 1px dashed rgba(240, 164, 75, 0.45); display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; background: transparent; width: calc(100% - 48px); text-align: left; cursor: pointer; transition: background .3s var(--ease); }
.make-tile:hover, .make-tile:active { background: rgba(240, 164, 75, 0.06); }
.make-tile-icon { width: 48px; height: 48px; border-radius: var(--r-md); background: var(--surface-2); display: grid; place-items: center; }
.make-tile-icon svg { width: 22px; height: 22px; stroke: var(--accent); stroke-width: 2.2; fill: none; stroke-linecap: round; }
.make-tile strong { display: block; font-size: 16px; }
.make-tile span { color: var(--muted); font-size: 14px; }

.empty { margin: 0 24px; padding: 24px; border-radius: var(--r-lg); background: var(--bg-2); color: var(--muted); font-size: 14px; border: 1px solid var(--line); }

/* Tab bar */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 12px); z-index: 20; display: flex; gap: 4px; padding: 6px; border-radius: 999px; background: rgba(42, 33, 28, 0.92); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35); }
.tab { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500; border: 0; background: none; cursor: pointer; transition: color .25s var(--ease), background .25s var(--ease); }
.tab svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tab.is-active { color: var(--ink); background: var(--surface-2); }
.tab-make { color: var(--accent-ink); background: var(--accent); }
.tab-make:active { transform: scale(0.96); }
.app.in-deck .tabbar { display: none; }

/* Deck */
.deck { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; height: 100%; height: 100dvh; max-height: 100dvh; padding: calc(var(--safe-t) + 8px) 16px calc(var(--safe-b) + 8px); max-width: 560px; margin: 0 auto; box-sizing: border-box; }
.deck-top { display: flex; align-items: center; gap: 12px; padding: 0 4px 12px; }
.icon-btn { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: transform .2s var(--ease), background .2s var(--ease); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.is-on { background: var(--accent); border-color: var(--accent); }
.icon-btn.is-on svg { stroke: var(--accent-ink); fill: var(--accent-ink); }
.segments { flex: 1; display: flex; gap: 4px; }
.segments i { flex: 1; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; position: relative; }
.segments i.on::after { content: ''; position: absolute; inset: 0; background: var(--accent); }

.stage { position: relative; flex: 1 1 auto; min-height: 0; user-select: none; -webkit-user-select: none; }
.card { position: absolute; inset: 0; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35); will-change: transform; }
.card.behind { transform: translateY(12px) scale(0.96); opacity: 0.55; }
.card-art { flex: 0 0 36%; max-height: 36%; min-height: 0; position: relative; }
.card-text { flex: 1 1 auto; min-height: 0; padding: 14px 20px 14px; display: flex; flex-direction: column; overflow: hidden; }
.card-kicker { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); font-weight: 500; margin: 0; }
.card-title { font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; margin: 6px 0 8px; }
.card-body { color: #e2d6c8; font-size: 15px; line-height: 1.45; margin: 0; }
.card-take { margin-top: 10px; padding-top: 0; display: flex; gap: 12px; align-items: flex-start; color: var(--ink); font-size: 14px; font-weight: 500; }
.card-take::before { content: ''; flex: 0 0 4px; align-self: stretch; border-radius: 4px; background: var(--accent); }
.card-count { position: absolute; top: 16px; right: 16px; font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 999px; background: rgba(26, 21, 18, 0.72); }

.deck-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 4px 0; }
.deck-hint { color: var(--faint); font-size: 12px; text-align: center; flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 24px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: none; transition: transform .2s var(--ease), background .2s var(--ease), opacity .2s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; }

/* Quiz */
.quiz-card .card-text { padding-top: 14px; }
.quiz-q { font-size: 20px; line-height: 1.3; margin: 6px 0 12px; }
.choices { display: grid; gap: 12px; }
.choice { text-align: left; padding: 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2); font-size: 16px; font-weight: 500; cursor: pointer; transition: background .25s var(--ease), border-color .25s var(--ease), transform .2s var(--ease); }
.choice:active { transform: scale(0.98); }
.choice.right { background: rgba(157, 187, 143, 0.18); border-color: var(--good); }
.choice.wrong { background: rgba(229, 143, 143, 0.14); border-color: var(--bad); }
.choice:disabled { cursor: default; }
.why { margin: 16px 0 0; color: var(--muted); font-size: 14px; }
.quiz-card .card-art, .quiz-art { flex: 0 0 24%; max-height: 24%; }

.result { text-align: left; }
.result-score { font-size: 48px; line-height: 1; font-weight: 600; letter-spacing: -0.03em; margin: 8px 0; color: var(--accent); }
.result p { color: var(--muted); margin: 0 0 8px; }
.result-actions { display: grid; gap: 12px; margin-top: 24px; }

/* Saved */
.page-title { font-size: 32px; letter-spacing: -0.02em; margin: 24px 24px 4px; }
.page-sub { margin: 0 24px 24px; color: var(--muted); }
.saved-list { display: grid; gap: 12px; padding: 0 24px; }
.saved-item { display: grid; grid-template-columns: 72px 1fr; gap: 16px; align-items: center; padding: 12px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); text-align: left; cursor: pointer; width: 100%; }
.saved-art { width: 72px; height: 72px; border-radius: var(--r-md); overflow: hidden; }
.saved-item strong { display: block; font-size: 16px; line-height: 1.3; }
.saved-item span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.saved-open { margin: 0 24px; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(10, 8, 6, 0.6); }
.sheet-panel { position: relative; width: 100%; max-width: 560px; background: var(--bg-2); border-radius: var(--r-xl) var(--r-xl) 0 0; border: 1px solid var(--line); border-bottom: 0; padding: 12px 24px calc(var(--safe-b) + 24px); display: grid; gap: 16px; }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--surface-2); margin: 0 auto 8px; }
.sheet-title { font-size: 24px; margin: 0; }
.sheet-sub { margin: -8px 0 0; color: var(--muted); font-size: 14px; }
.field { display: grid; gap: 8px; }
.field-label { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.field input { min-height: 52px; padding: 0 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); font-size: 16px; }
.field input:focus { outline: none; border-color: var(--accent); }
.field input::placeholder { color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; color: var(--muted); cursor: pointer; }
.chip:active { background: var(--surface-2); }
.sheet-error { margin: 0; padding: 12px 16px; border-radius: var(--r-md); background: rgba(229, 143, 143, 0.12); color: #f2c3c3; font-size: 14px; }
.making { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 14px; }
.making[hidden] { display: none; }
.making p { margin: 0; }
.making-deck { position: relative; width: 40px; height: 48px; flex: 0 0 40px; }
.making-deck i { position: absolute; inset: 0; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.making-deck i:nth-child(3) { background: var(--accent); }

/* Card drawings sit over the built-in icon scene */
.saved-art { position: relative; }
.art-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.card-count, .badge, .feed-pack, .feed-save, .progress-line { z-index: 2; }

/* Today's goal */
.today { padding: 24px 24px 0; display: grid; gap: 8px; }
.today-bar { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.today-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform .8s var(--ease); }
.today p { margin: 0; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; color: var(--muted); }
.today.is-hit p { color: var(--good); }
.today.is-hit .today-bar i { background: var(--good); }

/* Review and feed tiles */
.tile { margin: 16px 24px 0; padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; text-decoration: none; transition: transform .3s var(--ease); }
.tile:active { transform: scale(0.98); }
.tile strong { display: block; font-size: 16px; }
.tile span span { display: block; color: var(--muted); font-size: 14px; }
.tile-num, .tile-icon { width: 48px; height: 48px; border-radius: var(--r-md); display: grid; place-items: center; font-size: 20px; font-weight: 600; }
.tile-num { background: var(--accent); color: var(--accent-ink); }
.tile-icon { background: var(--surface-2); }
.tile-icon svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tile-go svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2.2; display: block; }
.review-tile { border-color: rgba(240, 164, 75, 0.45); margin-top: 24px; }
.feed-tile { margin-top: 24px; }
.badge.new { background: var(--accent); color: var(--accent-ink); }

/* Long cards: smaller picture first, then scroll */
.card.tight .card-art { flex-basis: 22%; max-height: 22%; }
.card-text { overflow-y: auto; scrollbar-width: none; }
.card-text::-webkit-scrollbar { display: none; }
.stage { touch-action: pan-y; }

/* Review recall */
.recall-actions { display: grid; gap: 12px; margin-top: 16px; }
.recall-actions.two { grid-template-columns: 1fr 1fr; }
.btn-danger { color: var(--bad); border-color: rgba(229, 143, 143, 0.4); }

/* Feed */
body.in-feed { overflow: hidden; }
.feed { position: fixed; z-index: 10; top: calc(var(--safe-t) + 8px); bottom: calc(var(--safe-b) + 76px); left: 0; right: 0; max-width: 560px; margin: 0 auto; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; }
.feed::-webkit-scrollbar { display: none; }
.feed-item { height: 100%; padding: 8px 16px; scroll-snap-align: start; scroll-snap-stop: always; }
.feed-item .card { position: relative; inset: auto; height: 100%; box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3); }
.feed-pack { position: absolute; top: 16px; left: 16px; max-width: 62%; padding: 6px 12px; border-radius: 999px; background: rgba(26, 21, 18, 0.78); font-size: 12px; font-weight: 500; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-save { position: absolute; top: 12px; right: 12px; background: rgba(26, 21, 18, 0.78); }
.feed-again .card-text { justify-content: center; }
.tab-make { padding: 10px 14px; }

/* PIN page (public address only) */
.gate { position: relative; z-index: 1; max-width: 400px; margin: 0 auto; padding: calc(var(--safe-t) + 64px) 24px 24px; display: grid; gap: 24px; }
.gate .page-title { margin: 0; }
.gate-form { display: grid; gap: 16px; }

/* Skeleton */
.skel { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-lg); }
@keyframes shimmer { to { background-position: -200% 0; } }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 88px); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; white-space: nowrap; }

@media (min-width: 720px) {
  .shelf-item { flex-basis: 40%; }
  .hello-title { font-size: 48px; }
}

@media (max-height: 740px) {
  .card-art { flex-basis: 32%; max-height: 32%; }
  .quiz-card .card-art, .quiz-art { flex-basis: 20%; max-height: 20%; }
  .card-title, .quiz-q { font-size: 18px; margin: 4px 0 6px; }
  .card-body { font-size: 14px; line-height: 1.4; }
  .card-text { padding: 10px 16px 10px; }
  .card-take { font-size: 13px; margin-top: 8px; }
  .deck-top { padding: 0 4px 8px; }
  .deck-nav { padding: 8px 4px 0; }
  .icon-btn { width: 40px; height: 40px; flex-basis: 40px; }
  .choice { padding: 12px; font-size: 15px; }
  .result-score { font-size: 40px; }
  .result-actions { margin-top: 12px; }
  .btn { min-height: 44px; }
}
@media (max-height: 620px) {
  .card-art { flex-basis: 26%; max-height: 26%; }
  .quiz-card .card-art, .quiz-art { flex-basis: 16%; max-height: 16%; }
  .card-title, .quiz-q { font-size: 17px; }
  .card-body { font-size: 13px; line-height: 1.35; }
  .card-kicker { font-size: 11px; }
  .why { margin-top: 8px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
