/* Entrecartas · Crepúsculo. Dark only: a dusk sky behind glass surfaces.
   Layout: an app column (top bar, one screen at a time, bottom tab bar). */

@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/fraunces-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
}

@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/fraunces-italic-latin.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Figtree";
  src: url("/assets/fonts/figtree-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --night: #1b1230;
  --plum: #3b1f4f;
  --rose: #6e3558;
  --ember: #a2545f;
  --ink: #fbf3ee;
  --muted: rgb(251 243 238 / 72%);
  --faint: rgb(251 243 238 / 50%);
  --accent: #ffd6a3;
  --cream: #fff3e6;
  --on-cream: #2a1838;
  --glass: rgb(255 255 255 / 9%);
  --glass-hi: rgb(255 255 255 / 15%);
  --glass-line: rgb(255 255 255 / 17%);
  --veil: rgb(30 15 42 / 62%);
  --veil-strong: rgb(30 15 42 / 86%);
  --danger: #ffb0a3;
  --danger-bg: #7c2c3a;
  --font-ui: "Figtree", "Segoe UI", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --column: 34rem;
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --tabbar-h: calc(64px + env(safe-area-inset-bottom, 0px));
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.sprite { position: absolute; }

html { background: var(--night); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background: transparent; /* html paints the night; the fixed .sky sits between them */
  font: 400 1rem/1.5 var(--font-ui);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* The sky is fixed behind everything; iOS ignores background-attachment: fixed. */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(90% 40% at 50% 110%, rgb(226 140 112 / 55%) 0%, rgb(226 140 112 / 0) 70%),
    linear-gradient(180deg, var(--night) 0%, var(--plum) 45%, var(--rose) 80%, var(--ember) 100%);
}
.sky::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1px 1px at 12% 9%, rgb(255 255 255 / 70%) 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 16%, rgb(255 255 255 / 45%) 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 61% 6%, rgb(255 255 255 / 60%) 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 19%, rgb(255 255 255 / 40%) 50%, transparent 51%),
    radial-gradient(1px 1px at 90% 33%, rgb(255 255 255 / 35%) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 30%, rgb(255 255 255 / 30%) 50%, transparent 51%);
}
.moon {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 76px);
  right: max(28px, calc(50% - 15rem));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  box-shadow: inset -10px 4px 0 0 #ffe7c7;
  filter: drop-shadow(0 0 16px rgb(255 214 163 / 50%));
  transition: opacity .4s var(--ease);
}
.has-reading .moon { opacity: 0; }
.is-history .moon { opacity: .3; }

/* ---------- Icons, buttons ---------- */
.ico { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .55; }
button:not(:disabled):not(.card-frame):active { transform: scale(.97); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; } /* headings focused by script for screen readers */

.primary, .secondary, .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 48px;
  padding: .7rem 1.3rem;
  border-radius: 999px;
  font-weight: 600;
  transition: transform .15s var(--ease), background-color .2s;
}
.primary { border: 0; background: var(--cream); color: var(--on-cream); box-shadow: 0 8px 24px rgb(20 6 30 / 35%); }
.secondary { border: 1px solid var(--glass-line); background: var(--glass); color: var(--ink); }
.danger { border: 0; background: var(--danger-bg); color: #fff0ec; }
.text-button { display: inline-flex; align-items: center; min-height: 44px; padding: .5rem 0; border: 0; background: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.danger-text { color: var(--danger); }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink); }
.icon-button:hover { background: var(--glass); }

a { color: var(--accent); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: var(--gutter);
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: linear-gradient(var(--night) 0%, rgb(27 18 48 / 0%) 100%);
}
.has-reading .topbar, .is-history .topbar {
  background: rgb(27 18 48 / 72%);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border-bottom: 1px solid var(--glass-line);
}
.topbar-inner { display: flex; align-items: center; gap: .6rem; max-width: var(--column); min-height: 56px; margin: 0 auto; }
.brand { flex: 1; margin: 0; font: 600 1.35rem/1 var(--font-display); letter-spacing: -.01em; }
.has-reading .brand { display: none; }
.reader-current { flex: 1; min-width: 0; display: flex; align-items: center; gap: .65rem; }
.reader-current p { margin: 0; min-width: 0; line-height: 1.15; }
.reader-current p > span { display: block; font: 600 1.05rem/1.1 var(--font-display); }
.reader-current small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .78rem; }
.avatar { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; object-position: 50% 16%; border: 1.5px solid var(--accent); background: var(--plum); }
.has-reading .badge { display: none; }
.badge { padding: .2rem .6rem; border: 1px solid var(--glass-line); border-radius: 999px; color: var(--muted); font-size: .72rem; letter-spacing: .04em; }

/* ---------- Main column ---------- */
main {
  max-width: calc(var(--column) + 2 * 16px);
  margin: 0 auto;
  padding: .5rem max(16px, env(safe-area-inset-right, 0px)) calc(var(--tabbar-h) + 1.5rem) var(--gutter);
}
.screen { animation: screen-in .35s var(--ease) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

.status { margin: .75rem 0; color: var(--muted); font-size: .92rem; }
.status:empty, .hint:empty { display: none; }
.banner { padding: .7rem .9rem; border: 1px solid var(--glass-line); border-radius: 14px; background: var(--veil); }
.hint { color: var(--muted); font-size: .92rem; }
.reading-error { color: var(--danger); }

.panel { padding: 1rem; border: 1px solid var(--glass-line); border-radius: 22px; background: var(--glass); }

textarea, select, input[type="email"] {
  display: block;
  width: 100%;
  min-width: 0;
  padding: .8rem .95rem;
  border: 1px solid var(--glass-line);
  border-radius: 16px;
  background: rgb(20 10 30 / 28%);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
textarea { resize: none; field-sizing: content; min-height: 5.5rem; max-height: 12rem; }
textarea::placeholder, input::placeholder { color: var(--faint); }
select { min-height: 48px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.5rem; }
select option { background: var(--plum); color: var(--ink); }
.field { display: block; }
.field > span:not(.visually-hidden) { display: block; margin-bottom: .4rem; color: var(--muted); font-size: .85rem; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }

/* Segmented control built from radio chips. */
.segmented { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; padding: 3px; border-radius: 999px; background: rgb(0 0 0 / 22%); }
.chip { position: relative; display: block; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: .4rem .9rem; border-radius: 999px; color: var(--muted); font-size: .92rem; cursor: pointer; transition: background-color .2s, color .2s; white-space: nowrap; }
.segmented .chip input:checked + span { background: rgb(255 255 255 / 92%); color: var(--on-cream); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip input:disabled + span { opacity: .4; cursor: default; }
.positions { margin: .5rem 0 0; text-align: center; color: var(--muted); font-size: .85rem; letter-spacing: .02em; }

/* ---------- Home ---------- */
.home { display: grid; gap: 1.1rem; padding-top: 1.5rem; }
.greeting { margin: 0; color: var(--muted); font-size: .95rem; }
.home-title { margin: -.6rem 0 .2rem; max-width: 15ch; font: 400 2.35rem/1.05 var(--font-display); letter-spacing: -.015em; text-wrap: balance; }
.home-title em { font-style: italic; color: var(--accent); }
.readers-field legend { margin-bottom: .6rem; color: var(--muted); font-size: .85rem; }
.reader-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.reader-choice {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: .4rem;
  padding: .85rem .4rem .8rem;
  border: 1px solid var(--glass-line);
  border-radius: 20px;
  background: var(--glass);
  color: var(--ink);
  text-align: center;
  transition: background-color .2s, border-color .2s, transform .15s var(--ease);
}
.reader-choice img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; object-position: 50% 16%; border: 2px solid rgb(255 255 255 / 30%); transition: border-color .2s; }
.reader-choice-name { font: 600 1.1rem/1.1 var(--font-display); }
.reader-choice-style { color: var(--muted); font-size: .76rem; line-height: 1.25; }
.reader-choice[aria-pressed="true"] { background: rgb(255 214 163 / 16%); border-color: rgb(255 214 163 / 65%); }
.reader-choice[aria-pressed="true"] img { border-color: var(--accent); }
.reader-description { min-height: 1.4em; margin: .7rem 0 0; color: var(--muted); font-size: .92rem; text-align: center; text-wrap: balance; }
.reader-description:empty { visibility: hidden; }
.ask { display: grid; gap: .8rem; }
.ideas { display: flex; gap: .45rem; overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; scrollbar-width: none; scroll-snap-type: x proximity; }
.ideas::-webkit-scrollbar { display: none; }
.example { flex: 0 0 auto; min-height: 36px; padding: .35rem .8rem; border: 1px solid var(--glass-line); border-radius: 999px; background: transparent; color: var(--muted); font-size: .85rem; scroll-snap-align: start; }
.ask .positions { margin-top: -.3rem; }
.ask .status { margin: 0; text-align: center; }
#draw { width: 100%; }
.welcome-copy { margin: 0; text-align: center; font-size: .82rem; }
.resume { display: flex; align-items: center; gap: .8rem; width: 100%; padding: .85rem 1rem; border-color: rgb(255 214 163 / 45%); background: rgb(255 214 163 / 10%); color: var(--ink); text-align: left; font: inherit; }
.resume .avatar { width: 54px; height: 54px; }
.resume-copy { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.resume-copy small { color: var(--accent); font-size: .72rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.resume-copy strong { overflow: hidden; font: 400 1.08rem/1.25 var(--font-display); text-overflow: ellipsis; white-space: nowrap; }
.resume-copy span { color: var(--muted); font-size: .82rem; }
.resume-chevron { color: var(--accent); }

/* ---------- Reading ---------- */
.table { display: flex; flex-direction: column; }
.question-title { margin: 1.1rem 0 .6rem; font: 400 1.6rem/1.15 var(--font-display); text-align: center; text-wrap: balance; overflow-wrap: anywhere; }
.timeline { display: grid; gap: .25rem; }
.turn { scroll-margin-top: 72px; }
.turn-summary { display: flex; align-items: center; gap: .6rem; padding: .7rem 0; list-style: none; cursor: pointer; }
.turn-summary::-webkit-details-marker { display: none; }
.turn-summary::before, .turn-summary::after { content: ""; flex: 1; height: 1px; background: var(--glass-line); }
.turn-summary h3 { flex: 0 1 auto; min-width: 0; margin: 0; padding: .3rem .8rem; border: 1px solid var(--glass-line); border-radius: 999px; background: var(--veil); font-size: .78rem; font-weight: 600; letter-spacing: .03em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn[open] > .turn-summary h3 { color: var(--accent); border-color: rgb(255 214 163 / 40%); }
.turn-preview { display: none; }
.turn:not([open]) > .turn-summary { flex-wrap: wrap; }
.turn:not([open]) .turn-preview { display: block; order: 3; flex-basis: 100%; overflow: hidden; color: var(--faint); font-size: .82rem; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.turn-content { display: grid; gap: 1rem; padding: .25rem 0 1rem; }

.user-message { justify-self: end; max-width: 85%; margin: 0; padding: .7rem .95rem; border-radius: 20px 20px 6px 20px; background: var(--cream); color: var(--on-cream); overflow-wrap: anywhere; }
.turn-content > .hint { margin: -.4rem 0 0; text-align: center; font-size: .85rem; }

/* Cards: three open like a fan; captions stay level. */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 7.5rem)); justify-content: center; gap: .1rem .4rem; padding-top: .5rem; }
.cards:has(> .card:only-child) { grid-template-columns: minmax(0, 9.5rem); }
.card { display: grid; grid-template-rows: auto auto auto; justify-items: center; min-width: 0; margin: 0; }
.card-position { order: 2; margin: .95rem 0 .1rem; color: var(--accent); font-size: .7rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; text-align: center; }
/* Each card is a button: a face and a back on a 3D-flipping layer. The fan tilt lives on the button. */
.card-frame { order: 1; position: relative; display: block; width: 100%; aspect-ratio: 296 / 526; padding: 0; border: 0; border-radius: 10px; background: none; perspective: 900px; cursor: zoom-in; }
.card-frame.face-down { cursor: pointer; }
.cards > .card:nth-child(1):not(:only-child) .card-frame { transform: rotate(-6deg) translate(8px, 8px); }
.cards > .card:nth-child(2) .card-frame { z-index: 1; }
.cards > .card:nth-child(3) .card-frame { transform: rotate(6deg) translate(-8px, 8px); }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .75s var(--ease); }
.card-frame.face-down .card-inner { transform: rotateY(180deg); }
.card-face, .card-back { position: absolute; inset: 0; overflow: hidden; border: 2px solid rgb(255 255 255 / 85%); border-radius: 10px; background: var(--plum); box-shadow: 0 14px 28px rgb(20 6 30 / 55%); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-back { transform: rotateY(180deg); border-color: rgb(255 214 163 / 65%); }
.card-back svg { display: block; width: 100%; height: 100%; }
.card-frame.face-down .card-back { animation: beckon 2.6s ease-in-out infinite; }
.card-frame.face-down:active .card-inner { transform: rotateY(180deg) scale(.97); }
.card.is-hidden .card-caption { visibility: hidden; }
.cards.deal .card-frame { animation: deal .55s var(--ease) both; }
.cards.deal > .card:nth-child(2) .card-frame { animation-delay: .1s; }
.cards.deal > .card:nth-child(3) .card-frame { animation-delay: .2s; }
@keyframes beckon { 50% { box-shadow: 0 14px 28px rgb(20 6 30 / 55%), 0 0 22px rgb(255 214 163 / 35%); } }
.reveal-prompt { display: grid; justify-items: center; gap: .1rem; margin-top: -.2rem; text-align: center; }
.reveal-prompt p { margin: 0; font: italic 400 1.15rem/1.3 var(--font-display); color: var(--ink); }
.reveal-prompt .text-button { font-size: .85rem; }
.card-art, .card-placeholder { display: block; width: 100%; height: 100%; }
.card-art { object-fit: cover; }
.card-art.is-reversed { transform: rotate(180deg); }
.card-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; background: linear-gradient(180deg, color-mix(in srgb, var(--suit, #6a5a4a) 78%, white), var(--suit, #6a5a4a)); color: #f7f1e6; }
.card-numeral { font: 500 .9rem var(--font-display); letter-spacing: .08em; }
.card-emoji { font-size: 2rem; line-height: 1; }
.card-caption { order: 3; display: grid; gap: .05rem; margin: 0; text-align: center; }
.card-name { font-weight: 600; font-size: .86rem; line-height: 1.2; overflow-wrap: anywhere; }
.card-orientation { color: var(--muted); font-size: .76rem; }
@keyframes deal { from { opacity: 0; transform: translateY(-36px) rotate(-4deg) scale(.92); } }

.reading { display: grid; gap: .8rem; margin: 0; padding: .95rem 1.05rem; border: 1px solid var(--glass-line); border-radius: 6px 22px 22px 22px; background: var(--veil); }
.reading:empty { display: none; }
.reading-author { display: flex; align-items: center; gap: .5rem; color: var(--accent); font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.reading-author img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; object-position: 50% 16%; }
.reading p { margin: 0; font-size: 1.06rem; line-height: 1.62; overflow-wrap: anywhere; }
.reading .reading-error { font-size: .95rem; }
.typing { display: inline-flex; gap: 5px; padding: .3rem 0; }
.stream-caret { display: inline-block; width: 7px; height: 7px; margin-left: .2rem; border-radius: 50%; background: var(--accent); vertical-align: middle; animation: typing 1.2s infinite ease-in-out; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: typing 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.flow-status, .budget { margin: .5rem 0; text-align: center; font-size: .88rem; }
#retry { align-self: center; margin: .5rem 0 1rem; }
.closing { display: grid; gap: .9rem; margin: 1rem 0; }
.closing h3 { margin: 0; font: 400 1.6rem/1.15 var(--font-display); }
.closing .closing-actions { margin: 0; }
.closing-status:empty { display: none; }

/* Composer: sticks above the tab bar while the reading scrolls. */
.composer {
  position: sticky;
  bottom: calc(var(--tabbar-h) + .5rem);
  z-index: 10;
  margin-top: .75rem;
  padding: .5rem;
  border: 1px solid var(--glass-line);
  border-radius: 26px;
  background: #261334; /* opaque: reading text scrolls right behind it */
  box-shadow: 0 -6px 30px rgb(20 6 30 / 30%);
}
#follow { display: grid; gap: .45rem; }
/* Four equal actions: three ways to go on, and Terminar (pause or close). */
.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; }
.actions .chip span, .action-end { flex-direction: column; justify-content: center; gap: .15rem; min-height: 50px; padding: .35rem .15rem; border: 1px solid var(--glass-line); border-radius: 16px; background: var(--glass); color: var(--ink); font-size: .74rem; line-height: 1.1; white-space: normal; text-align: center; }
.actions .chip .ico, .action-end .ico { width: 18px; height: 18px; }
.chip-count { display: block; color: inherit; font-size: .64rem; font-weight: 500; opacity: .75; }
.actions .chip input:checked + span { background: var(--cream); border-color: var(--cream); color: var(--on-cream); font-weight: 600; }
.action-end { display: flex; align-items: center; font: inherit; font-size: .74rem; border-style: dashed; border-color: rgb(255 214 163 / 45%); background: transparent; }
.action-end .ico { color: var(--accent); }
.action-help { margin: 0 .3rem; color: var(--muted); font-size: .8rem; }
.action-help:empty { display: none; }
.compact > span:not(.visually-hidden) { font-size: .8rem; margin: 0 .3rem .3rem; }
.compose-row { display: flex; align-items: flex-end; gap: .45rem; }
.compose-row .field { flex: 1; min-width: 0; }
#follow-question { min-height: 44px; padding: .62rem 1rem; border-radius: 22px; }
.send { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--cream); color: var(--on-cream); }

/* ---------- History ---------- */
.history-screen { padding-top: 1rem; }
.screen-title { margin: .5rem 0 .3rem; font: 400 2rem/1.1 var(--font-display); }
.history-actions, .dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: 1rem 0; }
.history-actions > .primary, .history-actions > .secondary, .dialog-actions > button { flex: 1 1 auto; white-space: nowrap; }
.history-list { display: grid; gap: .6rem; }
.history-row { display: grid; gap: .2rem; padding: .35rem .9rem .5rem; border: 1px solid var(--glass-line); border-radius: 20px; background: var(--glass); }
.history-open { display: grid; gap: .25rem; min-width: 0; padding: .6rem 0 .2rem; border: 0; background: transparent; color: var(--ink); text-align: left; }
.history-open:active { transform: none; }
.history-question { font: 400 1.15rem/1.2 var(--font-display); overflow-wrap: anywhere; }
.history-open .hint { font-size: .8rem; }
.history-operations { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.history-operations .text-button { min-height: 36px; font-size: .85rem; }
#delete-all { margin-top: 1rem; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(26rem, calc(100% - 2 * var(--gutter)));
  padding: 5px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgb(30 15 42 / 86%);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 10px 30px rgb(10 3 16 / 40%);
  transform: translateX(-50%);
}
.tab { display: grid; justify-items: center; gap: 2px; min-height: 44px; padding: .3rem .2rem; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: .7rem; font-weight: 500; }
.tab[aria-current="page"] { color: var(--accent); background: rgb(255 214 163 / 10%); }
.tab .ico { width: 21px; height: 21px; }
/* While typing, give the keyboard the room. */
body:has(#follow-question:focus) .tabbar { display: none; }
body:has(#follow-question:focus) .composer { bottom: calc(env(safe-area-inset-bottom, 0px) + .5rem); }

/* ---------- Sheets (dialogs rise from the bottom on phones) ---------- */
.sheet {
  width: min(30rem, 100%);
  max-width: none;
  max-height: calc(100dvh - 2rem);
  margin: auto auto 0;
  padding: .6rem 1.4rem calc(1.4rem + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--glass-line);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  background: linear-gradient(180deg, #3a2150, #2a173b);
  color: var(--ink);
  box-shadow: 0 -20px 60px rgb(10 3 16 / 45%);
}
.sheet[open] { animation: sheet-in .32s var(--ease) both; }
.sheet::backdrop { background: rgb(14 6 22 / 60%); backdrop-filter: blur(2px); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
.sheet-grip { width: 40px; height: 4px; margin: 0 auto 1rem; border-radius: 2px; background: var(--glass-line); }
.sheet h2 { margin: 0 0 .8rem; font: 400 1.65rem/1.15 var(--font-display); }
.sheet p { line-height: 1.55; }
.sheet .primary, .sheet > .secondary { width: 100%; }
@media (min-width: 640px) {
  .sheet { margin: auto; border-bottom: 1px solid var(--glass-line); border-radius: 28px; padding-bottom: 1.4rem; }
  .sheet-grip { display: none; }
}
.finish-summary { color: var(--muted); }
#finish-dialog .primary { margin-top: .4rem; }
.finish-close { display: grid; gap: .35rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--glass-line); }
.finish-close .secondary { width: 100%; }
.finish-close .hint { margin: 0; text-align: center; font-size: .82rem; }
.finish-cancel { width: 100%; justify-content: center; margin-top: .4rem; }
.menu-list { display: grid; margin-bottom: 1rem; border: 1px solid var(--glass-line); border-radius: 18px; background: var(--glass); overflow: hidden; }
.menu-item { display: flex; align-items: center; gap: .8rem; min-height: 54px; padding: .8rem 1rem; border: 0; background: transparent; text-align: left; font-size: 1rem; }
.menu-item + .menu-item { border-top: 1px solid var(--glass-line); }
.menu-item:not(:disabled):active { transform: none; background: var(--glass); }
.menu-item:not(.danger-text) .ico { color: var(--accent); }

/* Card viewer: the card large, with its keywords. */
.viewer { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: calc(env(safe-area-inset-top, 0px) + 3.5rem) 1.25rem calc(env(safe-area-inset-bottom, 0px) + 1.5rem); border: 0; background: radial-gradient(80% 50% at 50% 40%, #2c1740, #120a1c); color: var(--ink); text-align: center; overscroll-behavior: contain; }
.viewer[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.1rem; }
.viewer::backdrop { background: transparent; }
.viewer-close { position: fixed; top: calc(env(safe-area-inset-top, 0px) + .75rem); right: max(1rem, env(safe-area-inset-right, 0px)); background: var(--glass); }
.viewer-card { margin: 0; cursor: zoom-out; }
.viewer-card img { display: block; height: min(60dvh, 32rem); width: auto; max-width: 100%; aspect-ratio: 296 / 526; object-fit: cover; border: 2px solid rgb(255 255 255 / 85%); border-radius: 16px; box-shadow: 0 24px 60px rgb(0 0 0 / 55%); }
.viewer-card img.is-reversed { transform: rotate(180deg); }
.viewer[open] .viewer-card { animation: zoom-in .35s var(--ease) both; }
@keyframes zoom-in { from { opacity: 0; transform: scale(.9); } }
.viewer-copy { display: grid; gap: .25rem; max-width: 26rem; }
.viewer-position { margin: 0; color: var(--accent); font-size: .72rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.viewer h2 { margin: 0; font: 400 1.7rem/1.15 var(--font-display); }
.viewer-orientation { margin: 0; color: var(--muted); font-size: .9rem; }
.viewer-meaning { margin: .5rem 0 0; color: var(--ink); font-size: .98rem; line-height: 1.5; }
.viewer-meaning:empty { display: none; }

/* Account */
.account-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.account-heading > div { min-width: 0; }
.account-heading h2 { margin: .35rem 0 0; }
.account-heading .icon-button { margin: -.4rem -.6rem 0 0; color: var(--muted); }
.account-eyebrow { display: flex; align-items: center; gap: .4rem; margin: 0; color: var(--accent); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.account-eyebrow .ico { width: 15px; height: 15px; }
.account-description { margin: .6rem 0 1.3rem; color: var(--muted); }
#account-dialog .primary, #account-dialog .secondary { width: 100%; }
.account-google span { color: var(--accent); }
.account-divider { display: flex; align-items: center; gap: .9rem; margin: 1.2rem 0; color: var(--muted); font-size: .85rem; }
.account-divider::before, .account-divider::after { content: ""; flex: 1; height: 1px; background: var(--glass-line); }
#email-signin { display: grid; gap: .7rem; }
.account-help { margin: .5rem 0 0; color: var(--muted); font-size: .86rem; }
#email-signin .account-help { margin: 0; text-align: center; }
.account-guest { width: 100%; justify-content: center; margin-top: .8rem; }
.account-email { margin: 0; padding: .8rem 1rem; border: 1px solid var(--glass-line); border-radius: 14px; background: var(--glass); overflow-wrap: anywhere; }
#account-signout { margin-top: 1rem; }
.credits { margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--glass-line); }
.credits-head { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; }
.credits-head h3 { margin: 0; font: 400 1.15rem/1.2 var(--font-display); }
.credits-balance { margin: 0; color: var(--accent); font-size: .92rem; font-weight: 600; white-space: nowrap; }
.packs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .8rem; }
.pack { position: relative; display: grid; justify-items: center; gap: .15rem; min-height: 76px; padding: .6rem .3rem; border: 1px solid var(--glass-line); border-radius: 16px; background: var(--glass); color: var(--ink); text-align: center; cursor: pointer; transition: background-color .2s, border-color .2s; }
.pack input { position: absolute; opacity: 0; pointer-events: none; }
.pack:hover { background: var(--glass-hi); }
.pack:has(input:checked) { border-color: var(--accent); background: rgb(255 214 163 / 14%); box-shadow: inset 0 0 0 1px var(--accent); }
.pack:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pack:has(input:disabled) { opacity: .55; cursor: default; }
#account-dialog .buy { margin-top: .9rem; }
.pack strong { font: 400 1.5rem/1 var(--font-display); }
.pack span { color: var(--muted); font-size: .76rem; }
.pack em { margin-top: .15rem; color: var(--accent); font-size: .9rem; font-style: normal; font-weight: 600; }
.credits-signin { margin-top: .9rem; text-align: center; }
#account-dialog .status { margin: 1rem 0 0; overflow-wrap: anywhere; }
.account-footer { margin: 1.2rem 0 0; padding-top: 1rem; border-top: 1px solid var(--glass-line); text-align: center; font-size: .9rem; }
.account-contact { margin: .7rem 0 0; color: var(--muted); font-size: .84rem; text-align: center; }
.account-contact a { color: var(--accent); overflow-wrap: anywhere; }
.support-open { min-height: auto; padding: 0; color: var(--accent); font-size: inherit; }
.support-card { margin-top: .4rem; padding: .85rem .95rem; border: 1px solid rgb(255 214 163 / 40%); border-radius: 16px; background: rgb(255 214 163 / 8%); }
.support-card p { margin: 0 0 .6rem; }
.support-title { color: var(--accent); font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.support-lines { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.support-lines a { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .2rem .7rem; min-height: 44px; padding: .45rem .7rem; border: 1px solid var(--glass-line); border-radius: 12px; background: var(--glass); color: var(--ink); text-decoration: none; }
.support-lines strong { font-size: 1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.support-lines span { color: var(--muted); font-size: .82rem; line-height: 1.25; }
#support-directory { margin: .8rem 0 1rem; }

/* Archive */
.archive-choice { display: flex; gap: .65rem; align-items: flex-start; margin: .8rem 0; }
.archive-choice input { margin-top: .3rem; flex: 0 0 auto; accent-color: var(--accent); }
#archive-existing legend { margin-bottom: .3rem; color: var(--muted); font-size: .85rem; }
#archive-choices { max-height: 14rem; overflow-y: auto; }

/* ---------- Aviso page ---------- */
.prose-page main { padding-top: 1rem; }
.prose { padding-bottom: 3rem; }
.prose h1 { margin: .5rem 0 .3rem; font: 400 2rem/1.1 var(--font-display); }
.prose h2 { margin: 1.6rem 0 .5rem; font: 400 1.3rem/1.2 var(--font-display); color: var(--accent); }
.prose .updated { margin-bottom: 1.4rem; color: var(--muted); font-size: .85rem; }
.prose .lead { padding: .9rem 1rem; border: 1px solid rgb(255 214 163 / 40%); border-radius: 16px; background: rgb(255 214 163 / 8%); }
.prose .small { color: var(--muted); font-size: .82rem; }
.prose .legal-nav { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--glass-line); font-size: .9rem; }
.legal-button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: .6rem 1.2rem; border-radius: 999px; text-decoration: none; font-weight: 600; }
.intro-legal { color: var(--muted); font-size: .88rem; }
.home-legal { margin: .9rem 0 0; color: var(--muted); font-size: .76rem; line-height: 1.6; text-align: center; }
.home-legal a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.prose p { margin: 0 0 1rem; color: var(--ink); font-size: 1.02rem; line-height: 1.65; }
.prose p:last-child { margin-top: 1.5rem; }
.back-link { display: inline-flex; align-items: center; gap: .3rem; min-height: 44px; color: var(--ink); text-decoration: none; }

.noscript { max-width: var(--column); margin: 1rem auto; padding: 0 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
