:root {
  /* Palette drawn from the DarkPraxis emblem: near-black ground, parchment
     cream, antique gold, and an oxblood/brick ring. */
  --bg: #0d0b0f;
  --bg-2: #151016;
  --panel: #191420;
  --panel-2: #221b29;
  --ink: #ece0c4;          /* parchment cream (skull / linework) */
  --ink-dim: #c6b691;
  --muted: #8f8168;
  --gold: #cda15a;         /* antique gold */
  --gold-dim: #9a7d45;
  --oxblood: #7c2733;      /* emblem ring, deep brick */
  --oxblood-deep: #5a1b25;
  --ember: #c96140;        /* torch / ember accent */
  --line: #2a2230;
  --danger: #c25a5a;
  --radius: 10px;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --body: 'EB Garamond', Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(120% 90% at 50% -10%, #1a1411 0%, var(--bg) 60%) fixed;
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100%;
}

.hidden { display: none !important; }

/* ── Candlelight ambiance ── a persistent, GPU-cheap layer of warm glow, a
   slow flicker, and a vignette. Sits behind all content; brightest on Read
   and Mori. Honors prefers-reduced-motion. ── */
#ambient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  opacity: 0.7; transition: opacity 1.4s ease;
  box-shadow: inset 0 0 190px 44px rgba(0, 0, 0, 0.55);
  background: radial-gradient(130% 80% at 50% 118%, rgba(201, 97, 64, 0.10), transparent 60%);
}
#ambient::before, #ambient::after {
  content: ''; position: absolute; border-radius: 50%;
  filter: blur(64px); mix-blend-mode: screen; will-change: opacity, transform;
}
#ambient::before {
  width: 48vmax; height: 48vmax; left: -14vmax; bottom: -18vmax;
  background: radial-gradient(circle, rgba(201, 97, 64, 0.5), rgba(124, 39, 51, 0.16) 55%, transparent 70%);
  animation: candle-flicker 6s ease-in-out infinite;
}
#ambient::after {
  width: 42vmax; height: 42vmax; right: -14vmax; bottom: -20vmax;
  background: radial-gradient(circle, rgba(205, 161, 90, 0.4), rgba(124, 39, 51, 0.12) 55%, transparent 70%);
  animation: candle-flicker 7.5s ease-in-out infinite reverse;
}
@keyframes candle-flicker {
  0%, 100% { opacity: 0.42; transform: translateY(0) scale(1); }
  20% { opacity: 0.56; transform: translateY(-1.2%) scale(1.03); }
  45% { opacity: 0.36; transform: translateY(0.6%) scale(0.985); }
  68% { opacity: 0.52; transform: translateY(-0.6%) scale(1.02); }
  85% { opacity: 0.44; transform: translateY(0.3%) scale(1); }
}
body[data-view="read"] #ambient,
body[data-view="mori"] #ambient { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  #ambient::before, #ambient::after { animation: none; opacity: 0.46; }
}
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }
.dim { color: var(--ink-dim); }

button {
  font-family: var(--body);
  cursor: pointer;
}

/* subtle parchment texture via noise-ish overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(200, 161, 90, 0.03) 1px, transparent 1px);
  background-size: 3px 3px;
  z-index: 0;
}

/* ── Gate ── */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 100;
}
.gate-card {
  text-align: center;
  padding: 3rem 2.5rem;
  max-width: 360px;
}
.gate-card h1 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: 0.15em;
  font-size: 2.2rem;
  margin: 0.3rem 0 0.2rem;
}
.sigil {
  font-size: 2.4rem;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(205, 161, 90, 0.5);
}
.gate-icon {
  width: 132px;
  height: 132px;
  border-radius: 28px;
  object-fit: cover;
  box-shadow: 0 0 44px rgba(124, 39, 51, 0.35), 0 0 22px rgba(205, 161, 90, 0.22),
    0 10px 34px rgba(0, 0, 0, 0.6);
}
.gate-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.motto {
  margin-top: 1.6rem;
  font-family: var(--serif);
  font-size: 0.8rem;
  letter-spacing: 0.28em;
  text-transform: lowercase;
  color: var(--gold-dim);
  opacity: 0.75;
}

input, textarea, select {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-family: var(--body);
  font-size: 1rem;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--gold-dim);
}

button:not(.ghost):not(.nav-btn):not(.link):not(.brand):not(.door) {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  border-radius: var(--radius);
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  transition: all 0.15s ease;
}
button:not(.ghost):not(.nav-btn):not(.link):not(.brand):not(.door):hover {
  border-color: var(--gold);
  color: var(--ink);
  box-shadow: 0 0 18px rgba(200, 161, 90, 0.15);
}
button:disabled { opacity: 0.4; cursor: not-allowed; }

.ghost {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
}
.ghost:hover { color: var(--ink); }
.link {
  background: none;
  border: none;
  color: var(--gold);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: inherit;
}
.danger-btn { border-color: var(--danger) !important; color: var(--danger) !important; }

/* ── Top bar ── */
.app { position: relative; z-index: 1; }
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(13, 11, 15, 0.92);
  backdrop-filter: blur(8px);
  z-index: 10;
  max-width: 100%;
}
.brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--serif);
  letter-spacing: 0.18em;
  color: var(--gold);
  font-size: 1.15rem;
}
.brand:hover { color: var(--ink); }
.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  margin-right: 0.55rem;
  object-fit: cover;
  border: 1px solid var(--gold-dim);
}
.nav {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.4rem 0.9rem;
  font-size: 1rem;
  letter-spacing: 0.05em;
  border-bottom: 2px solid transparent;
}
.nav-btn.active { color: var(--gold); border-bottom-color: var(--gold-dim); }
.nav-btn:hover { color: var(--ink); }
#logout { margin-left: 0.5rem; }

/* ── Threshold (home hub) ── */
.threshold { max-width: 760px; margin: 0 auto; }
.threshold-head { text-align: center; margin: 1.5rem 0 2rem; }
.threshold-emblem {
  width: 92px; height: 92px; border-radius: 16px;
  object-fit: cover; border: 1px solid var(--gold-dim);
  box-shadow: 0 0 40px rgba(205, 161, 90, 0.15);
}
.threshold-head .view-title { margin: 0.8rem 0 0.3rem; }
.threshold-head .motto {
  color: var(--muted); font-style: italic; letter-spacing: 0.08em; font-size: 0.9rem;
}
.door-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.9rem;
}
.door {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem;
  text-align: left;
  background: linear-gradient(160deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.door:hover {
  border-color: var(--gold-dim);
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
}
.ask-card {
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  background: radial-gradient(120% 140% at 50% -20%, rgba(205, 161, 90, 0.12), var(--panel) 70%);
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.6rem;
  text-align: center;
}
.ask-label {
  color: var(--gold); font-size: 0.72rem; letter-spacing: 0.22em; text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.ask-question {
  font-family: var(--serif); font-size: 1.5rem; line-height: 1.35; color: var(--ink);
  margin: 0 0 0.7rem;
}
.door-glyph { font-size: 1.7rem; line-height: 1; color: var(--gold); }
.door-name {
  font-family: var(--serif); font-size: 1.35rem; color: var(--ink);
  letter-spacing: 0.04em;
}
.door-blurb { color: var(--muted); font-size: 0.92rem; }

/* ── Views ── */
.view {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
  position: relative;
  z-index: 1; /* above the candlelight ambiance */
}
.view.wide { max-width: 1100px; }

h2.view-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.8rem;
  letter-spacing: 0.04em;
  margin: 0 0 1.2rem;
}

/* ── Unload ── */
.unload-box textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  font-size: 1.15rem;
  line-height: 1.6;
  background: var(--bg-2);
}
.unload-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
}
.unload-actions input[type='text'] { flex: 1; }

.entry {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-top: 1rem;
  background: var(--panel);
}
.entry .meta {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.entry .body { white-space: pre-wrap; }
.entry .reflection {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line);
  color: var(--ink-dim);
  font-style: italic;
  white-space: pre-wrap;
}
.entry .entry-actions { margin-top: 0.7rem; display: flex; gap: 0.75rem; }
.section-divider {
  display: flex; align-items: center; gap: 1rem;
  margin: 2rem 0 0.5rem; color: var(--muted);
}
.section-divider::before, .section-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

/* ── Spirits ── */
.spirit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.spirit-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.2rem;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.spirit-card:hover { border-color: var(--gold-dim); box-shadow: 0 0 22px rgba(0,0,0,0.4); }
.monogram {
  width: 64px; height: 64px; margin: 0 auto 0.8rem;
  display: grid; place-items: center;
  border: 1px solid var(--gold-dim);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 1.8rem;
  color: var(--gold);
  background: radial-gradient(circle, rgba(200,161,90,0.08), transparent);
}
.spirit-card .name { font-family: var(--serif); font-size: 1.3rem; }
.spirit-card .domain { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }
.spirit-card .last { color: var(--gold-dim); font-size: 0.78rem; margin-top: 0.5rem; }

/* summon */
.summon-card {
  border: 1px dashed var(--gold-dim);
  display: grid; place-items: center;
  min-height: 160px; color: var(--gold);
  font-family: var(--serif); font-size: 1.1rem;
}

/* ── Chat ── */
.chat-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem;
  flex-wrap: wrap;
}
.chat-header .name { font-family: var(--serif); font-size: 1.5rem; }
.chat-header .domain { color: var(--muted); font-size: 0.9rem; }
.chat-header .spacer { flex: 1; }
.toggle {
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--ink-dim); font-size: 0.85rem;
}
.messages {
  display: flex; flex-direction: column; gap: 0.9rem;
  margin-bottom: 1rem;
}
.msg { max-width: 85%; padding: 0.7rem 1rem; border-radius: var(--radius); white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--oxblood); color: #f2e7e0; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg .speak { margin-top: 0.4rem; font-size: 0.75rem; }
.chat-input { display: flex; gap: 0.6rem; }
.chat-input textarea { flex: 1; min-height: 52px; resize: vertical; }
.session-note {
  color: var(--muted); font-style: italic; font-size: 0.9rem;
  margin-bottom: 1rem; border-left: 2px solid var(--gold-dim); padding-left: 0.8rem;
}

/* ── Decks ── */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.2rem;
}
.deck-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--panel);
  transition: all 0.15s ease;
}
.deck-tile:hover { border-color: var(--gold-dim); }
.deck-tile .thumb {
  aspect-ratio: 3 / 4; background: var(--bg-2);
  display: grid; place-items: center; color: var(--muted);
  background-size: cover; background-position: center;
}
.deck-tile .info { padding: 0.7rem 0.9rem; }
.deck-tile .info .t { font-family: var(--serif); font-size: 1.15rem; }
.deck-tile .info .s { font-size: 0.8rem; color: var(--muted); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.9rem;
}
.tarot {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.tarot .art {
  aspect-ratio: 3 / 4;
  background: var(--bg-2);
  display: grid; place-items: center;
  color: var(--muted); font-size: 0.8rem;
  background-size: cover; background-position: center;
  position: relative;
}
.tarot .art.pending::after {
  content: '· conjuring ·';
  color: var(--gold-dim);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:0.3} 50%{opacity:0.9} }
.tarot .cap { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.tarot .cap .nm { font-family: var(--serif); }
.tarot .reroll { font-size: 0.72rem; padding: 0.2rem 0.4rem; margin-top:0.3rem; }

.progress {
  height: 6px; background: var(--panel); border-radius: 3px; overflow: hidden;
  margin: 0.5rem 0 1.5rem;
}
.progress > div { height: 100%; background: linear-gradient(90deg, var(--oxblood), var(--gold)); transition: width 0.4s ease; }

.status-badge { font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--line); }
.status-badge.generating { color: var(--ember); border-color: var(--ember); }
.status-badge.complete { color: var(--gold); border-color: var(--gold-dim); }
.status-badge.partial { color: var(--danger); border-color: var(--danger); }

/* draw mode */
.draw-controls { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.5rem; }
.spread-cards { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; margin: 1.5rem 0; }
.flip { perspective: 1000px; width: 150px; }
.flip .inner {
  position: relative; width: 100%; aspect-ratio: 3/4;
  transform-style: preserve-3d; transition: transform 0.7s;
}
.flip.revealed .inner { transform: rotateY(180deg); }
.flip .face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--gold-dim);
  display: grid; place-items: center; background-size: cover; background-position: center;
}
.flip .back { background: linear-gradient(135deg, #241a2e, #120e18); color: var(--gold); font-size: 1.6rem; }
.flip .front { transform: rotateY(180deg); background: var(--bg-2); }
.flip .front.reversed { transform: rotateY(180deg) rotate(180deg); }
.flip-caption { text-align: center; font-size: 0.8rem; margin-top: 0.4rem; color: var(--ink-dim); }
.interpretation {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; background: var(--panel); white-space: pre-wrap;
  margin-top: 1rem; line-height: 1.7;
}

/* ── Modal ── */
.modal-back {
  position: fixed; inset: 0; background: rgba(5,4,7,0.7);
  display: grid; place-items: center; z-index: 200; padding: 1rem;
}
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.8rem; max-width: 460px; width: 100%;
}
.modal h3 { font-family: var(--serif); font-weight: 500; margin-top: 0; }
.modal .row { display: flex; gap: 0.75rem; margin-top: 1.2rem; justify-content: flex-end; }
.modal textarea, .modal input { width: 100%; margin-top: 0.5rem; }
.field { margin-top: 0.9rem; }
.field label { display: block; color: var(--ink-dim); font-size: 0.9rem; margin-bottom: 0.2rem; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--gold-dim); color: var(--ink);
  padding: 0.7rem 1.2rem; border-radius: var(--radius); z-index: 300;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.toast.err { border-color: var(--danger); color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; font-style: italic; }
.spinner { color: var(--gold-dim); }
.warn-banner {
  background: rgba(110,34,51,0.25); border: 1px solid var(--oxblood);
  color: var(--ink-dim); padding: 0.6rem 1rem; border-radius: var(--radius);
  font-size: 0.9rem; margin-bottom: 1.2rem;
}

/* ── Grimoire / lore spirits ── */
.spirit-card.lore { border-color: var(--oxblood); }
.spirit-card.lore:hover { border-color: var(--ember); }
.bound {
  color: var(--oxblood); font-size: 0.72rem; letter-spacing: 0.08em; margin-top: 0.35rem;
}
#grimoire-list { max-height: 58vh; overflow-y: auto; margin: 0.5rem 0; padding-right: 0.4rem; }
.grim-entry { border-top: 1px solid var(--line); padding: 0.8rem 0; }
.grim-entry:first-child { border-top: none; }
.grim-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; }
.grim-name { font-family: var(--serif); font-size: 1.2rem; color: var(--gold); }
.grim-rank {
  font-size: 0.7rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap;
}
.grim-domain { font-style: italic; color: var(--ink-dim); font-size: 0.9rem; }
.grim-lore { font-size: 0.88rem; color: var(--ink-dim); margin-top: 0.3rem; }
.grim-actions { margin-top: 0.45rem; }
.ritual-box {
  border: 1px solid var(--oxblood);
  background: rgba(124, 39, 51, 0.12);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 0.7rem 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink);
}
input[type='file'] { color: var(--ink-dim); font-size: 0.85rem; }

/* ── Read: card rows ── */
.card-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; align-items: center; }
.card-row .card-name { flex: 1; min-width: 0; }
.orient {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim);
  border-radius: var(--radius); padding: 0.55rem 0.7rem; font-size: 0.82rem; white-space: nowrap;
}
.orient.reversed { border-color: var(--oxblood); color: var(--ember); }
.rm-row { font-size: 1rem; padding: 0.2rem 0.45rem; }

.deck-tile.owned .thumb { font-size: 1.6rem; cursor: pointer; }

/* Spread tiles (named cards, physical mode) */
.tcard {
  width: 96px; border: 1px solid var(--gold-dim); border-radius: 8px;
  background: linear-gradient(160deg, #241a2e, #140f1c); overflow: hidden;
}
.tcard-inner { aspect-ratio: 3 / 4; display: grid; place-items: center; padding: 0.4rem; text-align: center; }
.tcard-name { font-family: var(--serif); font-size: 0.85rem; color: var(--ink); }
.tcard.rev .tcard-inner { transform: rotate(180deg); }
.tcard-cap { font-size: 0.62rem; text-align: center; color: var(--muted); padding: 0.2rem; letter-spacing: 0.04em; }
.tcard.rev .tcard-cap { color: var(--ember); }
.tcard.drawn-new { border-color: var(--ember); box-shadow: 0 0 14px rgba(201, 97, 64, 0.4); }

/* Arranged spread (geometric layout) */
.spread-grid {
  display: grid; gap: 0.5rem 0.4rem; justify-items: center; align-items: start;
  margin: 0.6rem auto; max-width: 100%;
}
.gcell { display: flex; flex-direction: column; align-items: center; width: 100%; }
.tcard.mini { width: 100%; max-width: 72px; }
.tcard.mini .tcard-name { font-size: 0.66rem; }
.gpos { font-size: 0.58rem; color: var(--muted); text-align: center; margin-top: 0.2rem; line-height: 1.15; }
.tcard.cross { transform: rotate(90deg); }
.tcard.cross.rev { transform: rotate(270deg); }
.spread-grid.flips .flip { width: 100%; max-width: 96px; }
.spread-grid.flips .flip-caption { max-width: 100px; }
.extras-label {
  text-align: center; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: lowercase; margin: 0.9rem 0 0.3rem;
}

/* Long content wraps — never push the page sideways. */
.msg, .interpretation, .body, .reflection, .grim-lore, .entry, .session-note {
  overflow-wrap: anywhere;
}
img, canvas, video { max-width: 100%; }

/* ── Mori floating button (app-logo FAB) ── */
#mori-fab {
  position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 50;
  width: 60px; height: 60px; border-radius: 50%; padding: 0; overflow: hidden;
  border: 1px solid var(--gold-dim); background: var(--panel); cursor: pointer;
  box-shadow: 0 0 22px rgba(124, 39, 51, 0.35), 0 6px 20px rgba(0, 0, 0, 0.55);
}
#mori-fab img { width: 100%; height: 100%; object-fit: cover; display: block; }
#mori-fab:hover { border-color: var(--gold); box-shadow: 0 0 28px rgba(205, 161, 90, 0.3); }

@media (max-width: 600px) {
  body { font-size: 17px; }
  .view { padding: 1.2rem 1rem 5.5rem; } /* bottom room for the FAB */
  .topbar {
    padding: 0.7rem 0.7rem;
    padding-top: calc(0.7rem + env(safe-area-inset-top));
    padding-left: max(0.7rem, env(safe-area-inset-left));
    padding-right: max(0.7rem, env(safe-area-inset-right));
    gap: 0.4rem;
  }
  .brand { font-size: 0; } /* hide the wordmark, keep the emblem */
  .brand-icon { margin-right: 0; width: 30px; height: 30px; }
  .nav {
    flex: 1; min-width: 0; overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-btn { padding: 0.4rem 0.55rem; font-size: 0.95rem; white-space: nowrap; }
  .modal { padding: 1.2rem; }
  .flip { width: 116px; }
  .spread-cards { gap: 0.6rem; }
  #mori-fab { width: 54px; height: 54px; }
  .chat-header { gap: 0.5rem; }
}
