:root {
  --bg: #04050b;
  --ink: #efe6d2;
  --ink-2: #b9b09c;
  --ink-3: #7d7668;
  --line: rgba(239, 230, 210, 0.14);
  --panel: #0b0d15;
  --panel-2: #12141e;
  --gold: #d9b46c;
  --accent: #d9b46c;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans);
  font-variant-numeric: lining-nums;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, a { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

#sky {
  position: fixed; inset: 0; width: 100%; height: 100%;
  touch-action: none; cursor: grab;
}
#sky.dragging { cursor: grabbing; }
#sky.pointing { cursor: pointer; }

/* top bar */
.top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.mark {
  display: flex; align-items: center; gap: 9px;
  color: var(--ink); padding: 6px 8px 6px 2px;
}
.mark svg { width: 24px; height: 24px; color: var(--gold); }
.mark span {
  font-family: var(--serif); font-weight: 500; font-size: 22px; letter-spacing: 0.06em;
}
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ink-2); background: rgba(4, 5, 11, 0.55);
  border: 1px solid var(--line);
  transition: color .2s, border-color .2s;
}
.icon-btn:hover { color: var(--ink); border-color: rgba(239,230,210,.3); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .snd-on { display: none; }
.icon-btn[aria-pressed="true"] .snd-on { display: block; color: var(--gold); }
.icon-btn[aria-pressed="true"] .snd-off { display: none; }
.badge {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--gold); color: #1a1408;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}

/* where am I */
.region {
  position: fixed; top: calc(64px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: baseline; gap: 8px; white-space: nowrap;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(4, 5, 11, 0.6); border: 1px solid var(--line);
  pointer-events: none; transition: opacity .5s;
}
.region .dot { width: 7px; height: 7px; border-radius: 50%; align-self: center; background: var(--c, #fff); box-shadow: 0 0 10px var(--c, #fff); }
.region .name { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: .04em; }
.region .alt { font-size: 12px; color: var(--ink-3); }

/* intro */
.intro {
  position: fixed; left: 0; right: 0; bottom: calc(118px + var(--safe-b));
  text-align: center; padding: 0 24px; pointer-events: none;
  transition: opacity 1.4s ease, transform 1.4s ease;
}
.intro.gone { opacity: 0; transform: translateY(8px); }
.intro h1 {
  font-family: var(--serif); font-weight: 400; font-size: clamp(44px, 11vw, 76px);
  letter-spacing: .14em; margin: 0 0 6px; padding-left: .14em;
  text-shadow: 0 0 30px rgba(217, 180, 108, .35);
}
.intro .lead { font-family: var(--serif); font-size: clamp(18px, 4.6vw, 22px); color: var(--ink); margin: 0 auto; max-width: 30ch; line-height: 1.35; text-wrap: balance; }
.intro .whisper { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--gold); margin: 10px 0 0; min-height: 1em; }
.intro .hint { font-size: 12px; color: var(--ink-3); margin: 14px 0 0; letter-spacing: .03em; }

/* minimap */
#minimap {
  position: fixed; left: 14px; bottom: calc(14px + var(--safe-b));
  width: 96px; height: 96px; border-radius: 50%;
  cursor: pointer; touch-action: none;
}

/* saying card */
.card {
  position: fixed; z-index: 5;
  left: 0; right: 0; bottom: 0;
  max-height: 72vh; overflow-y: auto;
  padding: 22px 22px calc(18px + var(--safe-b));
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -20px 60px rgba(0,0,0,.55);
  animation: rise .45s cubic-bezier(.2,.8,.2,1);
}
.card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--c, var(--gold)), transparent);
  opacity: .8; border-radius: 20px 20px 0 0;
}
@keyframes rise { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.card .close, .sheet .close {
  position: absolute; top: 12px; right: 12px; width: 38px; height: 38px;
  display: grid; place-items: center; color: var(--ink-3); border-radius: 50%;
}
.card .close:hover, .sheet .close:hover { color: var(--ink); }
.card .close svg, .sheet .close svg { width: 20px; height: 20px; }
.card-nebula {
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--c, var(--gold)); font-weight: 600; margin-bottom: 14px;
}
.card-text {
  margin: 0; font-family: var(--serif); font-weight: 500;
  font-size: clamp(21px, 5.6vw, 27px); line-height: 1.36; color: var(--ink);
  white-space: pre-line; text-wrap: pretty;
}
.card-source { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.card-source .who { font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--ink); }
.card-source .where { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.card-more { margin-top: 10px; font-size: 13px; color: var(--ink-3); }
.card-more summary { cursor: pointer; list-style: none; display: inline-block; padding: 2px 0; }
.card-more summary::-webkit-details-marker { display: none; }
.card-more summary::after { content: " +"; }
.card-more[open] summary::after { content: " −"; }
.card-more div { margin-top: 6px; line-height: 1.5; color: var(--ink-2); }
.card-more div p { margin: 0 0 6px; }
.card-more .orig { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--ink-2); }

.card-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.act {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; border-radius: 12px; text-decoration: none;
  border: 1px solid var(--line); background: rgba(255,255,255,.03);
  color: var(--ink); font-size: 15px;
  transition: background .2s, border-color .2s, color .2s, transform .1s;
}
.act:hover { background: rgba(255,255,255,.06); border-color: rgba(239,230,210,.28); }
.act:active { transform: scale(.97); }
.act svg { width: 20px; height: 20px; }
#likeBtn[aria-pressed="true"] { color: var(--c, var(--gold)); border-color: var(--c, var(--gold)); --heart-fill: currentColor; }
.next {
  display: block; width: 100%; margin-top: 10px; padding: 10px;
  font-size: 14px; color: var(--ink-2); text-align: center;
}
.next:hover { color: var(--ink); }

/* liked sheet */
.sheet {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; max-height: 80vh; overflow-y: auto;
  padding: 20px 20px calc(20px + var(--safe-b));
  background: var(--panel); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
  box-shadow: 0 -20px 60px rgba(0,0,0,.6);
  animation: rise .4s cubic-bezier(.2,.8,.2,1);
}
.sheet h2 { font-family: var(--serif); font-weight: 500; font-size: 26px; margin: 0 0 14px; }
.portrait { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.portrait .p {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 0; border-radius: 10px; background: rgba(255,255,255,.025);
  font-size: 12px; color: var(--ink-2);
}
.portrait .p i { display: block; border-radius: 50%; background: var(--c); box-shadow: 0 0 12px var(--c); }
.portrait .p b { font-weight: 600; color: var(--ink); font-size: 13px; }
.liked-list { list-style: none; margin: 0; padding: 0; }
.liked-list li { border-top: 1px solid var(--line); }
.liked-list button { display: block; width: 100%; text-align: left; padding: 12px 2px; }
.liked-list .t { font-family: var(--serif); font-size: 18px; line-height: 1.3; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.liked-list .s { font-size: 12px; color: var(--ink-3); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.liked-list .s i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.empty { color: var(--ink-2); font-family: var(--serif); font-size: 18px; line-height: 1.4; }

/* share image preview */
.preview {
  position: fixed; inset: 0; z-index: 8; background: rgba(2, 3, 7, .9);
  display: grid; place-items: center; padding: 20px 16px calc(20px + var(--safe-b));
  animation: fade .3s ease;
}
@keyframes fade { from { opacity: 0; } }
.preview-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; max-height: 100%; }
.preview img {
  max-width: min(420px, 100%); max-height: calc(100vh - 140px); height: auto;
  border-radius: 10px; box-shadow: 0 20px 80px rgba(0,0,0,.7);
}
.preview-actions { display: flex; gap: 8px; }
.preview-actions .act { padding: 0 16px; }

.toast {
  position: fixed; left: 50%; top: calc(70px + var(--safe-t)); transform: translate(-50%, -10px);
  padding: 9px 16px; border-radius: 999px; background: var(--ink); color: #14110a;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; z-index: 9;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.fail {
  position: fixed; inset: auto 16px 40% 16px; text-align: center; font-family: var(--serif);
  font-size: 19px; color: var(--ink); line-height: 1.4;
}
.fail code { font-family: ui-monospace, Menlo, monospace; font-size: 14px; color: var(--gold); }

/* wider screens: the card becomes a side panel so the sky stays visible */
@media (min-width: 760px) {
  .card {
    left: auto; right: 24px; top: 50%; bottom: auto; width: 420px;
    transform: translateY(-50%); max-height: calc(100vh - 120px);
    border: 1px solid var(--line); border-radius: 18px;
    padding: 26px 26px 20px;
    animation: slide .45s cubic-bezier(.2,.8,.2,1);
  }
  .card::before { border-radius: 18px 18px 0 0; }
  @keyframes slide { from { transform: translate(24px, -50%); opacity: 0; } to { transform: translateY(-50%); opacity: 1; } }
  .sheet {
    left: auto; right: 24px; top: 80px; bottom: 24px; width: 420px; max-height: none;
    border: 1px solid var(--line); border-radius: 18px;
  }
  #minimap { width: 120px; height: 120px; left: 20px; bottom: 20px; }
  .intro { bottom: 34px; }
  .intro h1 { font-size: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .sheet, .preview { animation: none; }
}

/* review fixes (2026-10-16) */
.card-actions { grid-template-columns: repeat(2, 1fr); }
.card-source .tr { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.card-source .tr:empty { display: none; }
#minimap { opacity: 0; pointer-events: none; transition: opacity .6s; }
#minimap.on { opacity: 1; pointer-events: auto; }
.mark span { transition: opacity .8s; }
body.intro-on .mark span { opacity: 0; }
.preview-close {
  position: fixed; top: calc(14px + var(--safe-t)); right: 14px; width: 42px; height: 42px;
  display: grid; place-items: center; border-radius: 50%; color: var(--ink-2);
  border: 1px solid var(--line); background: rgba(4,5,11,.6);
}
.preview-close svg { width: 20px; height: 20px; }
.preview-actions { flex-wrap: wrap; justify-content: center; }
