:root {
  --bg: #0a0712;
  --bg-2: #140d24;
  --ink: #ece3ff;
  --muted: #a99fc9;
  --gold: #d9b25f;
  --gold-bright: #f4d488;
  --violet: #6d4ed6;
  --violet-glow: #9a78ff;
  --panel: rgba(28, 19, 48, 0.72);
  --panel-edge: rgba(217, 178, 95, 0.28);
  --danger: #e0607a;
  --ok: #5fd6a0;
  --card-ratio: 0.66;
  /* One source of truth for card width: the Celtic Cross grid sizes its columns
     from this too, so cards never overflow their own cells. The Celtic Cross is
     the constraint — ten cards, four columns wide, beside a 400px console. */
  --card-w: clamp(130px, 15vw, 205px);
}
@media (max-width: 1450px) {
  /* Only the Celtic Cross is short of room on a narrower screen — it is four
     columns wide. The one- and three-card spreads keep the full size. */
  .table[data-spread="celtic"] { --card-w: clamp(115px, 11.5vw, 165px); }
}
@media (max-width: 900px) {
  /* Console and table are stacked here, so the full width is the table's. */
  :root { --card-w: clamp(120px, 19vw, 200px); }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 800px at 50% -10%, #1d1338 0%, transparent 60%),
    radial-gradient(900px 700px at 90% 110%, #241a3f 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: "EB Garamond", Georgia, serif;
  /* Base size for the whole page — everything below is in rem, so raise this
     to scale the interface as a whole. */
  font-size: 21px;
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.masthead {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2.4rem 1rem 1rem;
}

.masthead h1 {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: 0.06em;
  margin: 0;
  color: var(--gold-bright);
  text-shadow: 0 0 24px rgba(217, 178, 95, 0.45), 0 2px 2px #000;
}

.subtitle {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-style: italic;
  letter-spacing: 0.04em;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
  padding: 0.3rem 0.9rem;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 8px currentColor;
}
.status--ok .status-dot { background: var(--ok); }
.status--ok { color: var(--ok); }
.status--down .status-dot { background: var(--danger); }
.status--down { color: var(--danger); }

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 400px 1fr;
  grid-template-areas:
    "console table"
    "reading reading";
  gap: 1.4rem;
  max-width: 1750px;
  margin: 0 auto;
  padding: 1.4rem clamp(1rem, 3vw, 2.5rem) 4rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  padding: 1.3rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 0 40px rgba(109, 78, 214, 0.07);
}

.table-wrap { grid-area: table; min-height: 60vh; position: relative; overflow-x: auto; }
.reading-wrap { grid-area: reading; }

@media (max-width: 900px) {
  /* Stacked: controls, cards, reading — wallet last, out of the way. The
     console wrapper dissolves (display: contents) so its two panels can be
     ordered independently among the grid's former children. */
  .layout { display: flex; flex-direction: column; }
  .layout > .console { display: contents; }
  .table-wrap { order: 2; }
  .reading-wrap { order: 3; }
  .wallet-panel { order: 4; }
}

/* ── Demo videos ─────────────────────────────────────────── */
.demos-wrap { grid-area: demos; }
.demos-title {
  font-family: "Cinzel", serif;
  color: var(--gold-bright);
  letter-spacing: 0.06em;
  margin: 0 0 0.9rem;
  font-size: 1.4rem;
}
.demos {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.2rem;
  align-items: start;
}
.demo { margin: 0; min-width: 0; }
.demo video {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--panel-edge);
  background: #000;
  display: block;
}
.demo-mobile video { width: min(300px, 100%); margin: 0 auto; }
.demo-wide { grid-column: 1 / -1; }
.demo figcaption {
  color: var(--muted);
  font-style: italic;
  font-size: 0.95rem;
  margin-top: 0.5rem;
  text-align: center;
}
@media (max-width: 900px) {
  .demos { grid-template-columns: 1fr; }
}

/* ── Controls ─────────────────────────────────────────────── */
.field { display: block; margin-bottom: 1rem; }
.field-label {
  display: block;
  font-family: "Cinzel", serif;
  font-size: 0.86rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.4rem;
}

.question-row { display: flex; gap: 0.5rem; align-items: stretch; }

textarea, select {
  width: 100%;
  background: rgba(10, 7, 18, 0.7);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
  resize: vertical;
}
textarea:focus, select:focus {
  outline: none;
  border-color: var(--violet-glow);
  box-shadow: 0 0 0 3px rgba(154, 120, 255, 0.18);
}
select { cursor: pointer; }
option { background: #140d24; }


.mic {
  flex: 0 0 auto;
  width: 56px;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  background: rgba(10, 7, 18, 0.7);
  color: var(--gold);
  cursor: pointer;
  transition: all 0.2s ease;
}
.mic svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mic:hover { color: var(--gold-bright); border-color: var(--gold); }
.mic.listening {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  animation: pulse 1.1s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 96, 122, 0.6); }
  50% { box-shadow: 0 0 0 10px rgba(224, 96, 122, 0); }
}

.cast {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: "Cinzel", serif;
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: #1a1024;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(217, 178, 95, 0.3);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.cast:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(217, 178, 95, 0.45); }
.cast:active { transform: translateY(0); }
.cast:disabled { filter: grayscale(0.6) brightness(0.7); cursor: wait; transform: none; }

.spread-hint { color: var(--muted); font-size: 1rem; font-style: italic; margin: 0.9rem 0 0; min-height: 1.2em; }

/* ── The table & cards ────────────────────────────────────── */
.table {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 2.4rem 1.6rem;
  min-height: 60vh;
  padding: 1.6rem 1rem 1rem;
}
.table-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-style: italic;
  pointer-events: none;
  text-align: center;
  padding: 2rem;
}

.card {
  width: var(--card-w);
  aspect-ratio: var(--card-ratio);
  perspective: 1000px;
  cursor: pointer;
  position: relative;
}
.card-pos-label {
  position: absolute;
  /* Anchored to the card's top edge and grown upward, so a long position name
     ("This is Beneath Him") can wrap without shifting onto the card. */
  bottom: 100%;
  margin-bottom: 0.35rem;
  left: -0.5rem; right: -0.5rem;
  text-align: center;
  font-family: "Cinzel", serif;
  font-size: 0.78rem;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.9;
}
.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.card.flipped .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 9px;
  overflow: hidden;
  border: 1.5px solid var(--gold);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
}
.card-back {
  background:
    radial-gradient(circle at 50% 35%, rgba(244, 212, 136, 0.22), transparent 60%),
    repeating-linear-gradient(45deg, #221643 0 7px, #1a1133 7px 14px);
  display: flex; align-items: center; justify-content: center;
}
.card-back::after {
  content: "✶";
  font-size: 3rem;
  color: var(--gold-bright);
  text-shadow: 0 0 14px rgba(244, 212, 136, 0.6);
}
.card-front {
  transform: rotateY(180deg);
  background: #1a1133;
  display: flex; align-items: center; justify-content: center;
}
.card-front img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.reversed .card-front img,
.card.reversed .card-front .fallback {
  transform: rotate(180deg);
}
/* A name plate across the foot of the card, in the gold-on-parchment idiom of
   the card art itself. Sits outside the img, so it stays upright and readable
   when a reversed card turns its art upside down. */
.card-name-banner {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0.32em 0.3em 0.36em;
  background:
    linear-gradient(180deg, rgba(252, 244, 222, 0.96), rgba(232, 213, 168, 0.96));
  border-top: 1.5px solid var(--gold);
  box-shadow: 0 -4px 10px rgba(26, 17, 51, 0.35);
  color: #3a2708;
  font-family: "Cinzel", serif;
  font-size: clamp(0.56rem, 0.85vw, 0.76rem);
  line-height: 1.18;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 250, 235, 0.8);
}

.card-front .fallback {
  padding: 0.4rem 0.4rem 2.2rem;
  text-align: center;
  font-family: "Cinzel", serif;
  font-size: 0.9rem;
  color: var(--gold-bright);
  letter-spacing: 0.04em;
}

.card:hover .card-face { box-shadow: 0 0 22px rgba(154, 120, 255, 0.5); }

/* Celtic Cross layout */
.table[data-spread="celtic"] {
  flex-wrap: nowrap;
  gap: 0;
  align-items: center;
  justify-content: center;
}
.celtic-cross {
  display: grid;
  grid-template-columns: repeat(3, var(--card-w));
  grid-template-rows: repeat(3, auto);
  /* The column gap must clear the crossing card, which is rotated 90° and so
     sticks out sideways by half the difference between its height and width —
     about 0.26 × the card width. */
  gap: 3.4rem 3.1rem;
  place-items: center;
  margin-right: clamp(1rem, 3vw, 2.5rem);
}
.celtic-staff {
  display: grid;
  grid-template-rows: repeat(4, auto);
  gap: 2.4rem;
}
.celtic-pos-0 { grid-column: 2; grid-row: 2; position: relative; z-index: 1; }
.celtic-pos-1 { grid-column: 2; grid-row: 2; z-index: 2; align-self: center; justify-self: center; }
/* This card shares its cell with the one it crosses, so its label stacks a line
   above that card's label instead of printing on top of it. */
.celtic-pos-1 .card-pos-label { margin-bottom: 1.75rem; }
.celtic-pos-1 .card-inner { transform: rotate(90deg); }
/* Only the rotated art should take clicks. The element's own box is upright and
   covers the whole card beneath it, which would otherwise make that card — the
   one it crosses — impossible to open. */
.celtic-pos-1 { pointer-events: none; }
.celtic-pos-1 .card-inner { pointer-events: auto; }
.celtic-pos-1.flipped .card-inner { transform: rotate(90deg) rotateY(180deg); }
.celtic-pos-2 { grid-column: 2; grid-row: 1; }
.celtic-pos-3 { grid-column: 2; grid-row: 3; }
.celtic-pos-4 { grid-column: 1; grid-row: 2; }
.celtic-pos-5 { grid-column: 3; grid-row: 2; }

@media (max-width: 760px) {
  .table[data-spread="celtic"] { flex-wrap: wrap; }
  .celtic-cross { margin-right: 0; margin-bottom: 1.5rem; }
  .celtic-staff { grid-template-rows: none; grid-template-columns: repeat(4, var(--card-w)); }
}

/* ── Phones ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  html, body { font-size: 18px; }

  .masthead { padding-top: 1.4rem; }
  .layout { gap: 1rem; padding: 1rem 0.7rem 3rem; }
  .panel { padding: 1rem; border-radius: 12px; }
  .table { min-height: 0; padding: 1.4rem 0.3rem 0.6rem; gap: 2rem 1rem; }
  /* Enough height that the bare-cloth message sits comfortably, uncut. */
  .table-wrap { min-height: 11rem; }

  /* Ten cards must fit a hand-held screen: the cross is three columns wide,
     so the card size follows from the viewport. */
  .table[data-spread="celtic"] { --card-w: clamp(74px, 23vw, 104px); }
  /* Row gap must clear two stacked labels over the centre cell. */
  .celtic-cross { gap: 3rem 1rem; }
  /* The staff reads better as a 2×2 block than a row of four slivers; its own
     top margin keeps its labels off the cross above. */
  .celtic-staff {
    grid-template-columns: repeat(2, var(--card-w));
    gap: 2.6rem 1.2rem;
    margin-top: 1.2rem;
  }

  .card-pos-label { font-size: 0.6rem; letter-spacing: 0.05em; }
  .celtic-pos-1 .card-pos-label { margin-bottom: 1.4rem; }

  /* The detail panel becomes a scrollable sheet. */
  .card-detail { padding: 0.8rem; }
  .card-detail-inner {
    max-height: 92vh;
    overflow-y: auto;
    padding: 1.1rem;
    gap: 0.9rem;
  }
  .card-detail-inner img { width: min(48vw, 200px); }
}

/* ── Reading panel ────────────────────────────────────────── */
.reading-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.reading-head h2 {
  font-family: "Cinzel", serif;
  color: var(--gold-bright);
  letter-spacing: 0.06em;
  margin: 0;
  font-size: 1.6rem;
}
.reading {
  line-height: 1.75;
  font-size: 1.2rem;
  white-space: pre-wrap;
  min-height: 4rem;
  color: #efe9ff;
}
.reading-placeholder, .reading-error { color: var(--muted); font-style: italic; }
.reading-error { color: var(--danger); }
.reading.streaming::after {
  content: "▌";
  color: var(--gold-bright);
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.ghost {
  background: transparent;
  border: 1px solid var(--panel-edge);
  color: var(--muted);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-family: inherit;
}
.ghost:hover { color: var(--ink); border-color: var(--violet-glow); }

/* ── Login page ───────────────────────────────────────────── */
.login-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  padding: 3rem 1rem;
}
.login-panel { width: min(420px, 100%); }
input[type="text"], input[type="password"], input[type="email"], input[type="number"] {
  width: 100%;
  background: rgba(10, 7, 18, 0.7);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
}
input:focus {
  outline: none;
  border-color: var(--violet-glow);
  box-shadow: 0 0 0 3px rgba(154, 120, 255, 0.18);
}
.login-note { color: var(--muted); }
.login-code {
  background: rgba(10, 7, 18, 0.7);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 0.8rem;
  overflow-x: auto;
}
#login-error { min-height: 1.3em; margin: 0.8rem 0 0; }
/* Add-to-home-screen prompt */
.a2hs-inner { max-width: 460px; align-items: center; }
.card-detail-inner img.a2hs-icon {
  width: 84px; height: 84px;
  border-radius: 18px; border: 1px solid var(--gold); flex: 0 0 auto;
}
.a2hs-glyph { color: var(--gold-bright); }
.a2hs-buttons { display: flex; gap: 0.7rem; margin-top: 1rem; }
.a2hs-buttons .cast { width: auto; padding: 0.6rem 1.2rem; }

.notify-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0.2rem 0 1rem;
  cursor: pointer;
}
.notify-row input[type="checkbox"] {
  width: auto;
  margin-top: 0.25rem;
  accent-color: var(--violet-glow);
  transform: scale(1.25);
}
.login-link { color: var(--gold-bright); }
.login-demos { width: min(980px, 100%); margin-top: 1.2rem; }
.login-wrap { flex-direction: column; align-items: center; }

/* ── Admin ────────────────────────────────────────────────── */
.admin-wrap {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 1.2rem;
  max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 4rem;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.98rem; }
.admin-table th {
  font-family: "Cinzel", serif; font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--gold);
  text-align: left; padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--panel-edge);
}
.admin-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid rgba(217,178,95,0.12); }
.admin-table .mono { font-family: monospace; font-size: 0.85rem; }
.admin-table .neg { color: var(--danger); }
.admin-table .pos { color: var(--ok); }
.admin-sub { font-family: "Cinzel", serif; color: var(--gold); font-size: 0.95rem; margin: 1.2rem 0 0.4rem; }
.adj-cell { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.adj-cell input {
  background: rgba(10,7,18,0.7); border: 1px solid var(--panel-edge);
  border-radius: 8px; color: var(--ink); font-family: inherit; padding: 0.3rem 0.45rem;
}
.adj-amt { width: 5.2rem; }
.adj-note { width: 8rem; }
#admin-link, #deck-link { color: var(--muted); text-decoration: none; }
#deck-link:hover { color: var(--ink); }
#seeker-name { color: inherit; text-decoration: none; }
#seeker-name:hover { color: var(--gold-bright); }
#facts td { padding: 0.35rem 0.6rem; }
input[type="date"], input[type="time"] {
  width: 100%;
  background: rgba(10, 7, 18, 0.7);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.55rem 0.7rem;
  color-scheme: dark;
}
#admin-link:hover { color: var(--ink); }

/* Seeker chip in the masthead: credits + sign out. */
.seeker {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.9rem 0 0 0.6rem;
  padding: 0.3rem 0.9rem;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.95rem;
  color: var(--muted);
}
.seeker .credits { color: var(--gold-bright); }
.seeker button {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.seeker button:hover { color: var(--ink); }

/* ── Wallet panel (left column, below the console) ────────── */
.console {
  grid-area: console;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.wallet-panel {
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.wallet-panel.wallet-hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  visibility: hidden;
}
.wallet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.wallet-balance {
  font-family: "Cinzel", serif;
  font-size: 1.3rem;
  color: var(--gold-bright);
}
.wallet-row { display: flex; gap: 0.8rem; }
.wallet-row .field { flex: 1; min-width: 0; margin-bottom: 0.6rem; }
.qr-tile {
  background: #fdfaf2;
  border-radius: 12px;
  border: 1.5px solid var(--gold);
  padding: 0.55rem;
  margin: 0.4rem auto 0.8rem;
  width: min(210px, 80%);
}
.qr-tile svg { display: block; width: 100%; height: auto; }
.wallet-note { color: var(--muted); font-size: 0.92rem; margin: 0.5rem 0 0; }
.wallet-arm { width: 100%; margin: 0.2rem 0 0.4rem; }
.wallet-amount {
  font-family: "Cinzel", serif;
  font-size: 1.3rem;
  color: var(--gold-bright);
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
}
.wallet-address {
  font-family: monospace;
  font-size: 0.92rem;
  word-break: break-all;
  background: rgba(10, 7, 18, 0.7);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
}
#wallet-usd {
  width: 100%;
  background: rgba(10, 7, 18, 0.7);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
}

/* ── Deck gallery ─────────────────────────────────────────── */
.gallery-deck-pick { display: inline-flex; align-items: center; gap: 0.6rem; margin-top: 0.9rem; }
.gallery-deck-pick select {
  width: auto;
  background: rgba(10, 7, 18, 0.7);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.4rem 0.6rem;
}
.gallery-wrap {
  position: relative; z-index: 1;
  max-width: 1500px; margin: 0 auto; padding: 1rem 1rem 4rem;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.1rem;
}
.g-card { margin: 0; position: relative; cursor: pointer; border-radius: 9px; overflow: hidden;
  border: 1.5px solid var(--gold); box-shadow: 0 8px 22px rgba(0,0,0,0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease; background: #1a1133; }
.g-card:hover { transform: translateY(-3px); box-shadow: 0 0 22px rgba(154,120,255,0.5); }
.g-card img { display: block; width: 100%; aspect-ratio: var(--card-ratio); object-fit: cover; }

/* Single-card viewer */
.viewer-inner { max-width: 900px; align-items: flex-start; }
.viewer-inner img#viewer-img { width: min(300px, 38vw); border-radius: 10px; border: 1.5px solid var(--gold); }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; }
.viewer-head h3 { margin: 0 0 0.3rem; }
.viewer-deck select {
  background: rgba(10, 7, 18, 0.7);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.45rem;
  max-width: 11rem;
}
.viewer-label { font-family: "Cinzel", serif; color: var(--gold); font-size: 0.8rem; letter-spacing: 0.08em; }
.viewer-count { color: var(--muted); font-size: 0.85rem; margin: 0.8rem 0 0; }
.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(28, 19, 48, 0.85);
  border: 1px solid var(--panel-edge);
  color: var(--gold-bright);
  font-size: 2rem;
  line-height: 1;
  width: 46px; height: 64px;
  border-radius: 12px;
  cursor: pointer;
}
.viewer-nav:hover { border-color: var(--gold); }
.viewer-prev { left: -60px; }
.viewer-next { right: -60px; }
@media (max-width: 1050px) {
  .viewer-prev { left: 6px; }
  .viewer-next { right: 6px; }
}
@media (max-width: 600px) {
  .viewer-inner { flex-direction: column; align-items: center; }
  .viewer-inner img#viewer-img { width: min(52vw, 240px); }
}

/* ── Card detail modal ────────────────────────────────────── */
.card-detail {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  background: rgba(6, 4, 12, 0.8);
  backdrop-filter: blur(4px);
  padding: 1.5rem;
}
.card-detail.is-open {
  display: flex;
}
.card-detail[hidden] {
  display: none !important;
}
.card-detail-inner {
  position: relative;
  display: flex;
  gap: 1.4rem;
  max-width: 780px;
  /* Never taller than the display: the card itself scrolls, and that scroll
     stays inside it instead of chaining to the page behind. */
  max-height: 92vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-2);
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* While a card view is open, the page behind it must not scroll. */
body.no-scroll { overflow: hidden; }
.card-detail-inner img { width: 240px; border-radius: 10px; border: 1.5px solid var(--gold); align-self: flex-start; }
.card-detail-body h3 { font-family: "Cinzel", serif; color: var(--gold-bright); margin: 0 0 0.3rem; font-size: 1.4rem; }
.detail-position { color: var(--gold); font-style: italic; margin: 0 0 0.8rem; font-size: 1rem; }
.detail-keywords {
  color: var(--violet-glow);
  font-family: "Cinzel", serif;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 0.8rem;
}
.detail-scene { color: var(--muted); font-style: italic; margin-top: 0.8rem; font-size: 1.05rem; }
/* Lines that have a recorded narration behind them. */
.speakable {
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.speakable:hover {
  background: rgba(154, 120, 255, 0.13);
  box-shadow: 0 0 0 6px rgba(154, 120, 255, 0.13);
}
.speakable:active { background: rgba(154, 120, 255, 0.22); }

/* Lines of the reading — click one to hear it again. */
.reading-line { cursor: pointer; border-radius: 6px; transition: background 0.15s ease; }
.reading-line:hover { background: rgba(154, 120, 255, 0.13); }
.reading-line.line-loading { opacity: 0.65; }

.card-detail-close {
  position: absolute; top: 0.5rem; right: 0.7rem;
  background: none; border: none; color: var(--muted);
  font-size: 1.6rem; cursor: pointer; line-height: 1;
}
.card-detail-close:hover { color: var(--ink); }
@media (max-width: 560px) {
  .card-detail-inner { flex-direction: column; align-items: center; text-align: center; }
}
