/* Cantami "Cartolina": warm paper, espresso ink, sealing-wax red, an editorial serif.
   This file: fonts, tokens, base, typography, app shell (top bar, tab bar) and shared components.
   Screen layouts live in screens.css. */

/* ── Fonts (self-hosted, OFL). Only the subsets a page actually uses are downloaded (unicode-range). ── */
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/fraunces-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/fraunces-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url(fonts/fraunces-italic-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url(fonts/fraunces-italic-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Instrument Sans'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(fonts/instrument-sans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Instrument Sans'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(fonts/instrument-sans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Caveat'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(fonts/caveat-latin.woff2) format('woff2'); }
@font-face { font-family: 'DM Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/dm-mono-500-latin.woff2) format('woff2'); }

:root {
  color-scheme: light;

  /* Paper and surfaces */
  --paper:      #F4EBDD;   /* app background (with grain) */
  --paper-2:    #EADCC6;   /* kraft: sunken wells, skeletons, sheet grabber, progress track */
  --card:       #FFFAF2;   /* cards, postcard, tiles, packs, tab bar, sheets */
  --card-sel:   #FFF8F1;   /* selected tile/pack fill */
  --stamp:      #FFFDF8;   /* stamp paper around cover photos */

  /* Ink */
  --ink:        #2A1C16;
  --ink-2:      #5C4A3F;
  --ink-3:      #7A6455;   /* only on paper, card, card-sel; never on paper-2 */

  /* Accent: sealing wax */
  --seal:       #BF3F27;   /* fills; as text only at >= 24px */
  --seal-deep:  #A3341F;   /* accent as text under 24px, pressed primary */
  --on-seal:    #FFF6EA;
  --seal-wash:  #F8E4DA;

  /* Secondary */
  --sea:        #2B5876;
  --sea-wash:   #DCE6EA;
  --olive:      #56652A;
  --olive-wash: #E6E7CF;
  --sun:        #E2A33C;   /* decoration only, never text */
  --danger:     #A3221B;
  --danger-wash:#F6DEDA;
  --seal-on-ink:#E0613F;

  /* Lines */
  --line:       #DCCBB0;
  --line-2:     #C9B391;
  --edge:       #9A836B;
  --focus:      #2B5876;

  /* Overlays */
  --scrim:      rgb(42 28 22 / 45%);
  --grain:      url(img/paper-grain.png);

  /* Type families */
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans:  'Instrument Sans', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
  --hand:  'Caveat', 'Bradley Hand', 'Segoe Print', cursive;
  --mono:  'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Fraunces axis presets */
  --fv-display: 'SOFT' 100, 'WONK' 1, 'opsz' 144;
  --fv-title:   'SOFT' 100, 'WONK' 1, 'opsz' 96;
  --fv-text:    'SOFT' 100, 'WONK' 0, 'opsz' 24;
  --fv-num:     'SOFT' 50,  'WONK' 0, 'opsz' 48;

  /* Spacing (4px base) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px;
  --gutter: 20px;

  /* Radii */
  --r-paper: 6px;
  --r-sheet: 18px;
  --r-tile:  12px;
  --r-pack:  10px;
  --r-btn:   14px;
  --r-pill:  999px;
  --r-badge: 6px;

  /* Shadows (warm brown, never grey or black) */
  --sh-1: 0 1px 2px rgb(74 44 20 / 8%);
  --sh-paper: 0 1px 0 rgb(255 255 255 / 70%) inset, 0 1px 2px rgb(74 44 20 / 10%), 0 14px 28px -16px rgb(74 44 20 / 32%);
  --sh-lift: 0 1px 1px rgb(74 44 20 / 18%), 0 10px 14px rgb(74 44 20 / 18%);
  --sh-btn: 0 1px 0 rgb(255 255 255 / 22%) inset, 0 8px 18px -8px rgb(163 52 31 / 60%);
  --sh-sel: 0 10px 22px -14px rgb(163 52 31 / 55%);
  --sh-bar: 0 -10px 24px -18px rgb(74 44 20 / 35%);
  --sh-sheet: 0 -18px 40px -20px rgb(42 28 22 / 45%);

  /* Motion */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --t-tap: 180ms;
  --t-screen: 320ms;
  --t-stamp: 240ms;

  /* Layout */
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --safe-top: var(--tg-content-safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --z-bar: 20; --z-tab: 30; --z-toast: 60; --z-sheet: 50; --z-wait: 70;
}

@media (max-width: 379px) { :root { --gutter: 16px; } }

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  background: var(--paper) var(--grain) repeat;
  background-size: 128px 128px;
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 120ms !important; } }

h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; text-wrap: balance; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
button:disabled { cursor: default; }
input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
svg.i { display: block; width: 100%; height: 100%; }
[hidden] { display: none !important; }
.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; }

/* ── Typography ── */
.t-display { font: 480 clamp(36px, 10.4vw, 42px)/1.05 var(--serif); font-variation-settings: var(--fv-display); letter-spacing: -0.025em; }
.t-h1 { font-size: 30px; line-height: 34px; font-weight: 500; font-variation-settings: var(--fv-title); letter-spacing: -0.01em; }
.t-h2 { font-size: 26px; line-height: 30px; font-weight: 500; font-variation-settings: var(--fv-title); }
@media (min-width: 390px) {
  .t-h1 { font-size: 32px; line-height: 36px; }
  .t-h2 { font-size: 28px; line-height: 32px; }
}
.t-question { display: block; font: italic 500 24px/30px var(--serif); font-variation-settings: var(--fv-title); letter-spacing: -0.01em; }
.t-h3 { font: 520 18px/22px var(--serif); font-variation-settings: var(--fv-text); }
.t-body { font: 400 16px/24px var(--sans); }
.t-body-2 { font: 400 15px/22px var(--sans); color: var(--ink-2); text-wrap: pretty; }
.t-meta { font: 500 13px/18px var(--sans); color: var(--ink-3); }
.t-kicker { font: 500 11px/14px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--sea); }
.t-mono { font: 500 12px/16px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.t-hand { font-family: var(--hand); font-weight: 600; }
.t-display em, .t-h1 em, .t-h2 em, .t-question em, .empty-title em { font-style: italic; color: var(--seal); font-weight: 520; }
.t-display em { padding-bottom: 6px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6.5c20-4 38 1.5 58-1.5s40-3 62-.5 26 2.2 36 0' fill='none' stroke='%23BF3F27' stroke-width='2.4' stroke-linecap='round' opacity='.75'/%3E%3C/svg%3E") 0 100% / 94% 9px no-repeat; }
.note-center { font: 500 13px/18px var(--sans); color: var(--ink-3); text-align: center; text-wrap: pretty; }

/* ── App shell: top bar ── */
.topbar {
  position: sticky; top: 0; z-index: var(--z-bar);
  display: flex; align-items: center; gap: 8px;
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) var(--gutter) 0 14px;
  background: var(--paper) var(--grain); background-size: 128px 128px;
  border-bottom: 1px solid var(--line);
}
.back-btn { display: none; width: 40px; height: 40px; margin-left: -6px; place-items: center; border-radius: 50%; color: var(--ink); flex: none; }
.back-btn svg { width: 22px; height: 22px; }
body.can-back:not(.in-telegram) .back-btn { display: grid; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; min-width: 0; border-radius: 6px; }
.brand-lockup { height: 28px; width: auto; }
.brand-mark { display: none; width: 28px; height: 28px; flex: none; }
.topbar-title { display: none; font: 500 13px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.inner .brand-lockup { display: none; }
body.inner .brand-mark, body.inner .topbar-title { display: block; }
.topbar-gap { flex: 1; }
.demo-badge {
  flex: none; padding: 4px 6px 3px; border: 1.5px solid currentColor; border-radius: 4px;
  font: 500 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--sea);
}
.credit-pill {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 8px;
  border: 1px dashed var(--line-2); border-radius: 8px; background: var(--card); position: relative;
}
.credit-pill::after { content: ''; position: absolute; inset: -6px -2px; } /* 44px tap target */
.credit-icon { width: 18px; height: 18px; color: var(--seal); }
.credit-icon svg { width: 100%; height: 100%; display: block; }
.credit-pill strong { font: 600 16px/1 var(--serif); font-variation-settings: var(--fv-num); font-variant-numeric: lining-nums tabular-nums; color: var(--ink); }
.credit-word { display: none; font: 500 12px/1 var(--mono); letter-spacing: .04em; color: var(--ink-2); }
@media (min-width: 390px) { .credit-word { display: inline; } }
.me-btn {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: var(--sea); color: var(--on-seal); font: italic 600 17px/1 var(--serif); overflow: visible;
}
.me-btn::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; }
.me-btn img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--card); }
body:not(.booted) .credit-pill, body:not(.booted) .me-btn, body:not(.booted) .tabbar { visibility: hidden; }

/* ── App shell: content and tab bar ── */
.view {
  max-width: 480px; margin-inline: auto;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 32px);
  /* The 12px slide-in of a new screen must not widen the page: on phones that zooms the layout out
     and pushes the tab bar labels below the fold. clip (not hidden) keeps sticky headers working. */
  overflow-x: clip;
}
.boot { min-height: 60vh; display: grid; place-items: center; }
.boot img { animation: breathe 1.6s var(--ease) infinite alternate; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tab);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 8px max(6px, calc((100% - 480px) / 2)) var(--safe-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: var(--card); border-top: 1px solid var(--line); box-shadow: var(--sh-bar);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px;
  min-height: 48px; padding-bottom: 6px; color: var(--ink-3); font: 500 12px/14px var(--sans);
  transition: color var(--t-tap) var(--ease);
}
.tab-icon { width: 24px; height: 24px; }
.tab.on { color: var(--seal-deep); font-weight: 700; }
.tab.on .f { fill: currentColor; }
.tab.on .d { stroke: var(--card); }
.create-btn { color: var(--seal-deep); font-weight: 700; }
.create-btn .seal {
  position: relative; width: 64px; height: 64px; margin-top: -34px; display: grid; place-items: center;
  filter: drop-shadow(0 8px 10px rgb(163 52 31 / 40%)); transition: transform var(--t-tap) var(--ease);
}
.seal-blob { position: absolute; inset: 0; width: 100%; height: 100%; }
.seal-plus { position: relative; width: 26px; height: 26px; color: var(--on-seal); }
.create-btn:active .seal { transform: scale(.94); }
.create-btn.stamped .seal { animation: stamp 90ms ease-out; }
body[data-screen='wizard'] .tabbar, body[data-screen='wizard'] .topbar { display: none; }
body[data-screen='wizard'] .view { padding-bottom: 0; }

/* ── Screen transitions ── */
.enter-forward { animation: enter-right var(--t-screen) var(--ease) both; }
.enter-back { animation: enter-left var(--t-screen) var(--ease) both; }
.enter-fade { animation: fade-in var(--t-screen) var(--ease) both; }

/* ── Buttons ── */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 54px; padding: 0 20px; border-radius: var(--r-btn);
  font: 600 17px/1 var(--sans); letter-spacing: .005em; text-align: center; white-space: nowrap;
  transition: background-color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease), box-shadow var(--t-tap) var(--ease);
}
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--seal); color: var(--on-seal); box-shadow: var(--sh-btn); }
.btn-primary:active:not(:disabled) { background: var(--seal-deep); transform: scale(.98); }
.btn-primary:disabled { background: var(--paper-2); color: var(--ink-2); box-shadow: none; }
.btn-secondary { background: var(--card); color: var(--ink); border: 1.5px solid var(--line-2); }
.btn-secondary:active:not(:disabled) { background: var(--card-sel); transform: scale(.98); }
.btn-secondary:disabled { opacity: .55; }
.btn-icon { width: 54px; padding: 0; }
.btn-icon svg { width: 22px; height: 22px; }
.btn-small { height: 40px; padding: 0 16px; border-radius: 12px; font-size: 15px; gap: 8px; }
.btn-icon-start, .btn-icon-end { width: 20px; height: 20px; flex: none; }
.btn-small .btn-icon-start { width: 18px; height: 18px; }
.btn.busy { pointer-events: none; }
.btn.busy > * { visibility: hidden; }
.btn-primary.busy { background: var(--seal); color: var(--on-seal); box-shadow: var(--sh-btn); }
.btn.busy::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite;
}
.link {
  display: inline-flex; align-items: center; gap: 5px; min-height: 32px;
  font: 600 15px/20px var(--sans); color: var(--seal-deep);
}
.link svg, .link .i { width: 15px; height: 15px; }
.link > span:has(svg) { width: 15px; height: 15px; }
.link-small { font-size: 14px; }
.link-sea {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
  font: 600 15px/20px var(--sans); color: var(--sea);
}
.link-sea > span:last-child { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-color: rgb(43 88 118 / 40%); }
.link-sea .star { width: 16px; height: 16px; color: var(--sun); flex: none; }
.link-sea.to-card .star { display: none; }
/* Invisible hit areas: links (32px), chips (38px), row play buttons (40px) and name tags reach 44px to tap. */
.link, .chip, .player-row .play-btn { position: relative; }
.link::after, .chip::after, .player-row .play-btn::after, .name-tag::after { content: ''; position: absolute; inset: -6px -2px; }
.chip::after, .player-row .play-btn::after, .name-tag::after { inset: -3px 0; border-radius: inherit; }
.btn-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
/* Long labels ("Scrivi un nuovo testo") wrap to two lines instead of pushing the pair off-screen. */
.btn-pair .btn { min-width: 0; height: auto; min-height: 54px; padding: 8px 12px; white-space: normal; line-height: 1.2; }

/* ── Chips and tags ── */
.chips { display: flex; gap: 8px; }
.chips-wrap { flex-wrap: wrap; }
.chips-scroll {
  overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--gutter)); padding: 2px var(--gutter);
  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.chips-scroll::-webkit-scrollbar { display: none; }
.chips-scroll .chip { flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px 0 12px;
  border-radius: var(--r-pill); background: var(--card); border: 1px solid var(--line);
  font: 500 15px/1 var(--sans); color: var(--ink); white-space: nowrap;
  transition: background-color var(--t-tap) var(--ease), border-color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease);
}
.chip:active { transform: scale(.97); }
.chip.on { border: 1.5px solid var(--seal); background: var(--card-sel); color: var(--seal-deep); padding: 0 13.5px 0 11.5px; }
.chip-small { height: 32px; padding: 0 12px; font-size: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--seal)); flex: none; display: inline-block; }

/* ── Cards, paper, notices ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-tile); box-shadow: var(--sh-1); }
.paper { background: var(--card); border-radius: var(--r-paper); box-shadow: var(--sh-paper); }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  font: 400 15px/22px var(--sans); color: var(--ink); background: var(--sea-wash);
}
.notice-icon { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--sea); }
.notice-success { background: var(--olive-wash); }
.notice-success .notice-icon { color: var(--olive); }
.notice-error { background: var(--danger-wash); }
.notice-error .notice-icon { color: var(--danger); }
.notice-error strong { color: var(--danger); font-weight: 600; }

/* ── Postal motifs ── */
.postmark {
  position: absolute; width: 92px; aspect-ratio: 120 / 64; z-index: 2;
  background: url(img/brand/postmark.svg) center / contain no-repeat;
  opacity: .85; mix-blend-mode: multiply; pointer-events: none; transform: rotate(-12deg);
}
.postmark > span {
  position: absolute; left: 70%; top: 50%; translate: -50% -50%;
  width: min-content; text-align: center; /* two-word labels ("Per te", "23 nov") stack inside the ring */
  font: 500 9px/1.1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--sea);
}
.stamp {
  --hole: 10px; --rad: 3px; --edge-in: 12px;
  display: flex; flex-direction: column; background: var(--stamp);
  -webkit-mask:
    radial-gradient(circle, transparent var(--rad), #000 calc(var(--rad) + .5px)) calc(var(--hole) / -2) calc(var(--hole) / -2) / var(--hole) var(--hole),
    linear-gradient(#000 0 0) center / calc(100% - var(--edge-in)) calc(100% - var(--edge-in)) no-repeat;
          mask:
    radial-gradient(circle, transparent var(--rad), #000 calc(var(--rad) + .5px)) calc(var(--hole) / -2) calc(var(--hole) / -2) / var(--hole) var(--hole),
    linear-gradient(#000 0 0) center / calc(100% - var(--edge-in)) calc(100% - var(--edge-in)) no-repeat;
}
.stamp .ph { flex: 1; min-height: 0; overflow: hidden; background: var(--paper-2); }
.stamp .ph img { width: 100%; height: 100%; object-fit: cover; }
.stamp .denom {
  height: 30px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 2px;
  font: 500 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
}
.stamp .denom span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stamp .denom b { font: italic 600 15px/1 var(--serif); letter-spacing: 0; color: var(--seal-deep); font-variant-numeric: lining-nums tabular-nums; }
.wave-wrap { margin: 32px 0; color: var(--line-2); }
.wave-rule { display: block; width: 100%; height: 12px; }

/* ── Inputs ── */
.field-label { font: 600 14px/20px var(--sans); color: var(--ink-2); margin-bottom: 8px; }
.field-hint { font: 500 13px/18px var(--sans); color: var(--ink-3); margin: -4px 0 10px; text-wrap: pretty; }
.input {
  display: block; width: 100%; height: 52px; padding: 0 14px; border-radius: var(--r-tile);
  background: var(--card); border: 1px solid var(--line); font: 400 16px/1.4 var(--sans); color: var(--ink);
  transition: border-color var(--t-tap) var(--ease), box-shadow var(--t-tap) var(--ease);
}
.input::placeholder, .other-input::placeholder { color: var(--ink-3); opacity: 1; }
.input:focus { outline: none; border-color: var(--edge); box-shadow: 0 0 0 3px rgb(43 88 118 / 18%); }
.input.error { border-color: var(--danger); }
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
.input-mono { font: 500 13px/1 var(--mono); letter-spacing: .02em; color: var(--ink-2); }
.search { position: relative; display: block; }
.search > svg { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; translate: 0 -50%; color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 44px; }
.search .input::-webkit-search-cancel-button { filter: sepia(1) saturate(.4); }

.switch-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; }
.switch-text { flex: 1; display: grid; gap: 2px; }
.switch-text strong { font: 600 16px/22px var(--sans); }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch {
  position: relative; flex: none; width: 44px; height: 26px; border-radius: 13px;
  background: var(--paper-2); border: 1px solid var(--edge); transition: background-color var(--t-tap) var(--ease);
}
.switch::after {
  content: ''; position: absolute; left: 2px; top: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--card); box-shadow: var(--sh-1); transition: transform var(--t-tap) var(--ease);
}
.switch-input:checked + .switch { background: var(--seal); border-color: var(--seal); }
.switch-input:checked + .switch::after { transform: translateX(18px); }
.switch-input:focus-visible + .switch { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch-input:disabled + .switch { opacity: .5; }

.segmented { display: flex; height: 40px; padding: 3px; border-radius: 12px; background: var(--paper-2); }
.segmented button {
  flex: 1; min-width: 44px; display: grid; place-items: center; text-align: center; border-radius: 9px; font: 500 13px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
  transition: background-color var(--t-tap) var(--ease);
}
.segmented button.on { background: var(--card); color: var(--ink); font-weight: 500; box-shadow: var(--sh-1); }

/* ── Status pills ── */
.status {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: var(--r-pill);
  font: 500 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  background: var(--paper-2); color: var(--ink-2);
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.status-icon { width: 13px; height: 13px; flex: none; }
.status-generating { background: var(--sea-wash); color: var(--sea); }
.status-generating .status-dot { animation: pulse 1.2s ease-in-out infinite alternate; }
.status-ready { background: var(--seal-wash); color: var(--seal-deep); }
.status-unlocked { background: var(--olive-wash); color: var(--olive); }
.status-failed { background: var(--danger-wash); color: var(--danger); }

/* ── Player ── */
.play-btn { position: relative; display: grid; place-items: center; border-radius: 50%; flex: none; }
.play-btn > span { grid-area: 1 / 1; display: grid; place-items: center; }
.play-btn .play-icon svg { margin-left: 2px; }
.play-btn .pause-icon, .play-btn .spinner { display: none; }
.player.playing .play-icon { display: none; }
.player.playing .pause-icon { display: grid; }
.player.loading .play-icon, .player.loading .pause-icon { display: none; }
.player.loading .spinner { display: block; width: 18px; height: 18px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.player-button .play-btn {
  width: 44px; height: 44px; background: var(--card); color: var(--seal); box-shadow: 0 6px 14px -6px rgb(42 28 22 / 55%);
}
.player-button .play-btn svg, .player-row .play-btn svg { width: 18px; height: 18px; }
.player-row .play-btn {
  width: 40px; height: 40px; background: var(--card); color: var(--seal); border: 1.5px solid var(--line-2);
  transition: background-color var(--t-tap) var(--ease);
}
.player-row.playing .play-btn, .player-row.loading .play-btn { background: var(--seal); border-color: var(--seal); color: var(--on-seal); }
.player.paper { display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: center; padding: 14px 16px; }
.player.paper .play-btn { width: 56px; height: 56px; background: var(--seal); color: var(--on-seal); box-shadow: var(--sh-btn); transition: transform var(--t-tap) var(--ease); }
.player.paper .play-btn:active { transform: scale(.96); }
.player.paper .play-btn svg { width: 22px; height: 22px; }
.player-main { min-width: 0; }
.player-head { font: 600 15px/20px var(--sans); color: var(--ink); }
.wave { position: relative; height: 44px; cursor: pointer; touch-action: manipulation; }
.wave svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave-base { color: var(--line-2); }
.wave-played { color: var(--sea); clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0); }
.player-meta { display: flex; align-items: center; gap: 10px; min-height: 22px; font: 500 12px/16px var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.badge-preview { padding: 4px 7px 3px; border-radius: var(--r-badge); background: var(--sea-wash); color: var(--sea); font: 500 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.player-error { display: inline-flex; align-items: center; gap: 6px; font: 600 13px/18px var(--sans); color: var(--danger); }
.player-error > span { width: 16px; height: 16px; flex: none; }

/* ── Toasts ── */
.toasts {
  position: fixed; z-index: var(--z-toast); left: var(--gutter); right: var(--gutter);
  /* 12px above the create seal, which rises 34px over the tab bar. */
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 46px);
  display: grid; justify-items: center; pointer-events: none;
}
body[data-screen='wizard'] .toasts { bottom: calc(118px + var(--safe-bottom)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; max-width: 440px; width: 100%;
  padding: 12px 14px; border-radius: 10px; background: var(--ink); color: var(--paper);
  font: 500 15px/20px var(--sans); box-shadow: 0 12px 24px -12px rgb(42 28 22 / 60%);
  opacity: 0; transform: translateY(12px); transition: opacity var(--t-stamp) var(--ease), transform var(--t-stamp) var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--sun); }
.toast-success .toast-dot { background: var(--olive-wash); box-shadow: 0 0 0 2px var(--olive); }
.toast-error .toast-dot { background: var(--seal-on-ink); }

/* ── Bottom sheet ── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: var(--z-sheet); display: flex; align-items: flex-end; justify-content: center;
  background: var(--scrim); opacity: 0; transition: opacity 200ms var(--ease);
}
.sheet-backdrop.in { opacity: 1; }
.sheet {
  width: 100%; max-width: 480px; max-height: 88dvh; overflow: auto; overscroll-behavior: contain;
  padding: 10px var(--gutter) calc(20px + var(--safe-bottom));
  background: var(--card); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--sh-sheet);
  transform: translateY(100%); transition: transform var(--t-stamp) var(--ease);
}
.sheet-backdrop.in .sheet { transform: none; transition-duration: var(--t-screen); }
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--paper-2); margin: 0 auto 14px; }
.sheet-title { outline: none; }
.sheet-text { margin-top: 6px; font: 400 15px/22px var(--sans); color: var(--ink-2); }
.sheet-body > .btn { margin-top: 18px; }
.sheet-body > .btn + .btn { margin-top: 10px; }
.sheet-body .pack-picker { margin-top: 18px; }
.sheet .pack .stub::before, .sheet .pack .stub::after { background: var(--card); }

/* ── Skeletons, empty states ── */
.sk, .skeleton-row, .skeleton-block, .skeleton-cover {
  display: block; background: linear-gradient(100deg, transparent 30%, rgb(255 250 242 / 55%) 50%, transparent 70%) var(--paper-2);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.skeleton-row { height: 72px; border-top: 1px solid var(--line); }
.skeleton-row:first-child { border-top: 0; }
.skeleton-block { height: 220px; border-radius: var(--r-tile); margin-top: 20px; }
.skeleton-cover { width: 300px; height: 340px; margin: 24px auto 0; border-radius: 2px; }
.empty { display: grid; justify-items: center; gap: 8px; padding: 28px 20px; text-align: center; }
.empty-art { position: relative; width: 72px; height: 72px; color: var(--line-2); margin-bottom: 6px; }
.empty-art svg { width: 72px; height: 72px; display: block; }
.empty-seal { position: absolute; left: 24px; top: 28px; width: 24px; height: 24px; }
.empty-art-stamp .empty-seal { left: 36px; top: 40px; }
.boot-error .empty-art { color: var(--danger); }
.empty-title { font: 520 20px/24px var(--serif); font-variation-settings: var(--fv-text); }
.empty-text { font: 400 15px/22px var(--sans); color: var(--ink-2); max-width: 300px; text-wrap: pretty; }
.empty .btn { margin-top: 10px; }
.boot-error { margin: 24px var(--gutter); }

/* ── Keyframes ── */
@keyframes enter-right { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes enter-left { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes pulse { from { opacity: .4; } to { opacity: 1; } }
@keyframes breathe { from { transform: scale(.96); } to { transform: scale(1.04); } }
@keyframes stamp { 0% { transform: scaleY(.94); } 100% { transform: none; } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes ring { to { stroke-dashoffset: -20; } }
@keyframes bar { 0%, 100% { transform: scaleY(.45); } 50% { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) {
  .sk, .skeleton-row, .skeleton-block, .skeleton-cover { animation: none; }
}
