/* Astra Tarot — visual system.
 * Deep violet / ink black ground, antique gold structure, rose-gold accents.
 * Deliberately distinct from the Qimen build (deep blue + #d4a574).
 * All art is local; no external fonts, no framework.
 */

:root {
  --bg: #0b0810;
  --bg-2: #120d1c;
  --bg-3: #171021;
  --panel: #171021;
  --panel-2: #1d152b;
  --panel-3: #241a34;
  --ink: #f2ecdf;
  --ink-soft: #d8cdbb;
  --muted: #a99f92;
  --muted-2: #7d7468;
  --gold: #c9a86a;
  --gold-2: #e3c88f;
  --gold-dim: #8f7442;
  --rose: #b76e79;
  --rose-2: #d9a0a6;
  --line: rgba(201, 168, 106, 0.22);
  --line-strong: rgba(201, 168, 106, 0.45);
  --danger: #d98a8a;
  --ok: #9fbf9a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Songti SC", "Noto Serif SC", SimSun, serif;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --radius: 3px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 620px at 50% -14%, rgba(95, 55, 132, 0.38), transparent 62%),
    radial-gradient(900px 520px at 92% 104%, rgba(183, 110, 121, 0.13), transparent 60%),
    radial-gradient(700px 400px at 4% 84%, rgba(201, 168, 106, 0.045), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(1px 1px at 8% 12%, rgba(242, 236, 223, 0.55), transparent 100%),
    radial-gradient(1px 1px at 19% 38%, rgba(242, 236, 223, 0.35), transparent 100%),
    radial-gradient(1.5px 1.5px at 33% 8%, rgba(227, 200, 143, 0.5), transparent 100%),
    radial-gradient(1px 1px at 47% 27%, rgba(242, 236, 223, 0.28), transparent 100%),
    radial-gradient(1px 1px at 62% 14%, rgba(242, 236, 223, 0.4), transparent 100%),
    radial-gradient(1.5px 1.5px at 78% 33%, rgba(227, 200, 143, 0.38), transparent 100%),
    radial-gradient(1px 1px at 91% 9%, rgba(242, 236, 223, 0.32), transparent 100%),
    radial-gradient(1px 1px at 12% 72%, rgba(242, 236, 223, 0.3), transparent 100%),
    radial-gradient(1.4px 1.4px at 72% 78%, rgba(227, 200, 143, 0.3), transparent 100%),
    radial-gradient(1px 1px at 88% 62%, rgba(242, 236, 223, 0.26), transparent 100%),
    radial-gradient(1px 1px at 42% 91%, rgba(242, 236, 223, 0.22), transparent 100%);
  background-size: 100% 100%;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(4, 2, 7, 0.55) 100%);
}

header, main, footer, #modal-root, .toast { position: relative; z-index: 1; }

::selection { background: rgba(201, 168, 106, 0.35); color: #fff; }

a { color: var(--gold-2); text-decoration-thickness: 1px; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

img { max-width: 100%; display: block; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--gold-2);
  outline-offset: 3px;
  border-radius: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  background: var(--gold);
  color: #150f1e;
  padding: 12px 16px;
  border-radius: 2px;
  font-family: var(--sans);
  font-size: 14px;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, rgba(11, 8, 16, 0.98), rgba(11, 8, 16, 0.92));
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 10px clamp(16px, 4vw, 36px);
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--ink);
  min-height: 48px;
  flex: 0 0 auto;
}
.brand-mark { width: 38px; height: 38px; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.08; }
.brand-text strong {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.08em;
  color: var(--gold-2);
  font-weight: 600;
  white-space: nowrap;
}
.brand-text small {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.header-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.pi-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  max-width: 160px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(201, 168, 106, 0.05);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.pi-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}
.pi-chip.is-signed { border-color: rgba(183, 110, 121, 0.55); color: var(--rose-2); }
.pi-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted-2);
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(125, 116, 104, 0.12);
}
.pi-chip.is-signed .pi-dot { background: var(--rose); box-shadow: 0 0 0 3px rgba(183, 110, 121, 0.15); }

.nav-btn, .lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.03em;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.nav-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.nav-btn:hover, .lang-btn:hover { color: var(--gold-2); border-color: var(--line); background: rgba(201, 168, 106, 0.05); }
.lang-btn {
  border-color: var(--line);
  color: var(--gold);
  min-width: 52px;
  letter-spacing: 0.06em;
}

/* ---------- shared ---------- */

body.modal-open { overflow: hidden; }

main { display: block; }
main:focus { outline: none; }
#app { outline: none; }

.wrap {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 36px);
}
.wrap-narrow { max-width: 840px; }

.eyebrow {
  margin: 0 0 14px;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}
.eyebrow .zh { letter-spacing: 0.12em; }

.rule {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  margin: 22px 0;
}
.rule::before, .rule::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}
.rule span {
  width: 7px; height: 7px;
  transform: rotate(45deg);
  border: 1px solid var(--gold);
  display: inline-block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 2px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--gold-2);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background: rgba(201, 168, 106, 0.08); border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold-2), var(--gold) 58%, #a8874c);
  color: #181021;
  border-color: transparent;
  box-shadow: 0 10px 30px rgba(201, 168, 106, 0.18);
  font-weight: 700;
}
.btn-primary:hover { background: linear-gradient(135deg, #efd8a6, var(--gold-2) 58%, var(--gold)); color: #120c19; }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--gold-2); background: rgba(255, 255, 255, 0.03); }
.btn-small { min-height: 44px; padding: 0 14px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-danger { border-color: rgba(217, 138, 138, 0.5); color: var(--danger); }
.btn-danger:hover { background: rgba(217, 138, 138, 0.08); border-color: var(--danger); }

.note {
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted-2);
}
.error-text {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--danger);
  margin: 6px 0 0;
}
.is-hidden { display: none !important; }

/* ---------- home ---------- */

.home { padding: clamp(38px, 7vw, 76px) 0 80px; }

.hero { max-width: 820px; }
.hero-title {
  font-size: clamp(2.35rem, 7.4vw, 4.6rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0 0 20px;
}
.hero-title em {
  font-style: normal;
  color: var(--gold-2);
  position: relative;
  white-space: nowrap;
}
.lede {
  max-width: 640px;
  font-size: clamp(1rem, 2.4vw, 1.13rem);
  color: var(--ink-soft);
  line-height: 1.72;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 26px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted-2);
}
.hero-meta span { display: inline-flex; align-items: center; gap: 7px; }
.hero-meta span::before { content: "◆"; color: var(--gold-dim); font-size: 7px; }

.ask-panel {
  margin-top: clamp(36px, 6vw, 58px);
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--line);
  background:
    linear-gradient(160deg, rgba(201, 168, 106, 0.055), transparent 34%),
    var(--panel);
  box-shadow: var(--shadow);
  position: relative;
}
.ask-panel::before, .ask-panel::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border-color: var(--gold);
  border-style: solid;
  pointer-events: none;
}
.ask-panel::before { top: 8px; left: 8px; border-width: 1px 0 0 1px; }
.ask-panel::after { bottom: 8px; right: 8px; border-width: 0 1px 1px 0; }

.field { margin-bottom: 26px; }
.field:last-child { margin-bottom: 0; }
.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 9px;
}
.field label, .field-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.field .hint { font-family: var(--sans); font-size: 11px; color: var(--muted-2); }
.char-count {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

textarea, input[type="text"], input[type="password"], input[type="url"], input[type="number"] {
  width: 100%;
  min-height: 50px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(6, 4, 10, 0.55);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
  resize: vertical;
  transition: border-color 0.15s ease, background 0.15s ease;
}
textarea { min-height: 96px; }
textarea::placeholder, input::placeholder { color: var(--muted-2); opacity: 0.9; }
textarea:focus, input:focus { border-color: var(--gold); background: rgba(6, 4, 10, 0.8); }
input[type="number"] { font-family: var(--sans); }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.02em;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.chip:hover { border-color: var(--gold-dim); color: var(--gold-2); }
.chip.is-active {
  border-color: var(--gold);
  background: rgba(201, 168, 106, 0.12);
  color: var(--gold-2);
}

.spread-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  gap: 9px;
}
.spread-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-height: 104px;
  padding: 14px 13px 12px;
  border: 1px solid var(--line);
  background: rgba(6, 4, 10, 0.28);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.spread-option:hover { border-color: var(--gold-dim); background: rgba(201, 168, 106, 0.05); }
.spread-option.is-active {
  border-color: var(--gold);
  background: linear-gradient(155deg, rgba(201, 168, 106, 0.14), rgba(201, 168, 106, 0.03));
  box-shadow: inset 0 0 0 1px rgba(201, 168, 106, 0.18);
}
.spread-option input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.spread-option input:focus-visible + .spread-check {
  outline: 2px solid var(--gold-2);
  outline-offset: 3px;
}
.spread-count {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.spread-name {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.15;
  color: var(--ink);
}
.spread-best {
  font-family: var(--sans);
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.spread-check {
  position: absolute;
  top: 10px; right: 10px;
  width: 15px; height: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}
.spread-option.is-active .spread-check {
  border-color: var(--gold);
  background: var(--gold);
  box-shadow: inset 0 0 0 3px var(--panel);
}

.variant-area { margin-top: 12px; }
.variant-area:empty { display: none; }
.variant-label {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 0 0 8px;
}
.variant-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.variant-chip {
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.25;
  text-align: left;
}
.variant-chip:hover { border-color: var(--gold-dim); }
.variant-chip.is-active { border-color: var(--rose); color: var(--rose-2); background: rgba(183, 110, 121, 0.08); }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 30px;
}
.form-actions .btn-primary { flex: 1 1 220px; }
.form-actions .btn { flex: 0 0 auto; }
.form-note { margin-top: 14px; }

/* ---------- draw ---------- */

.draw-view { padding: clamp(28px, 5vw, 56px) 0 64px; }
.draw-head { max-width: 700px; }
.draw-head h1 { font-size: clamp(1.8rem, 5vw, 3rem); margin-bottom: 14px; color: var(--ink); }
.draw-instruction { color: var(--muted); font-size: 0.95rem; max-width: 600px; }

.draw-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 26px 0 22px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.progress-line {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.next-position {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
}
.shuffle-status {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted-2);
  letter-spacing: 0.04em;
}

.spread-stage { margin: 8px 0 26px; }
.tray-grid {
  display: grid;
  gap: 10px;
  align-items: start;
  width: 100%;
}
.layout-single { grid-template-columns: minmax(0, 236px); justify-content: center; }
.layout-row { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 600px; margin: 0 auto; gap: 14px; }
.layout-cross { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 580px; margin: 0 auto; }
.layout-horseshoe { grid-template-columns: repeat(7, minmax(0, 1fr)); max-width: 820px; margin: 0 auto; gap: 8px; }
.layout-celtic-cross { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 660px; margin: 0 auto; gap: 9px; }

.slot { position: relative; min-width: 0; text-align: center; }
.slot.is-crossing { z-index: 2; }
.slot-card {
  position: relative;
  width: 100%;
  aspect-ratio: 0.571;
  perspective: 900px;
  border-radius: 4px;
  transform-origin: 50% 50%;
  transition: transform 0.3s ease;
}
.slot.is-crossing .slot-card {
  transform: rotate(90deg) scale(0.82);
}
.card-flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.68s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.slot.is-revealed .card-flip { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
}
.card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-back img { filter: saturate(0.9) brightness(0.92); }
.card-front { transform: rotateY(180deg); }
.card-front img.is-reversed {
  transform: rotate(180deg);
  filter: saturate(0.82) brightness(0.94);
}
.card-front::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.07), transparent 32%);
}
.slot-index {
  display: block;
  margin-top: 8px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--gold-dim);
}
.slot-name {
  display: block;
  margin-top: 1px;
  font-family: var(--sans);
  font-size: 9.5px;
  line-height: 1.25;
  color: var(--muted-2);
  overflow-wrap: anywhere;
}
.draw-view .layout-celtic-cross .slot-name,
.draw-view .layout-horseshoe .slot-name,
.draw-view .layout-cross .slot-name {
  font-size: 9px;
}

.deck-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 10px 0 0;
}
.deck {
  position: relative;
  width: 132px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--gold-2);
  min-height: 44px;
  transition: transform 0.18s ease;
}
.deck:not([disabled]):hover { transform: translateY(-4px); }
.deck[disabled] { cursor: default; opacity: 0.5; }
.deck-stack {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 0.571;
}
.deck-stack img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.45);
}
.deck-stack img:nth-child(1) { transform: translate(4px, 5px) rotate(2.4deg); opacity: 0.55; }
.deck-stack img:nth-child(2) { transform: translate(-3px, 2px) rotate(-1.8deg); opacity: 0.75; }
.deck-stack img:nth-child(3) { transform: translate(0, 0); }
.deck-count {
  position: absolute;
  right: -8px;
  top: -8px;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--gold);
  color: #150f1e;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.deck-label {
  display: block;
  margin-top: 12px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.deck.is-ready { animation: deck-breathe 3.6s ease-in-out infinite; }
.draw-view.is-shuffling .deck-stack { animation: shuffle-stack 0.78s ease-in-out; }
.draw-view.is-shuffling .deck { pointer-events: none; }

@keyframes deck-breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes shuffle-stack {
  0% { transform: translateY(0) rotate(0); }
  20% { transform: translate(-5px, -3px) rotate(-2deg); }
  40% { transform: translate(5px, 2px) rotate(2.2deg); }
  60% { transform: translate(-3px, 1px) rotate(-1.2deg); }
  80% { transform: translate(3px, -1px) rotate(1.2deg); }
  100% { transform: translateY(0) rotate(0); }
}

.draw-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 34px;
}
.draw-actions .btn { min-width: 170px; }

/* ---------- reading ---------- */

.reading-view { padding: clamp(30px, 5vw, 58px) 0 72px; }
.reading-head { max-width: 800px; margin-bottom: 30px; }
.reading-head h1 { font-size: clamp(1.85rem, 4.6vw, 3.1rem); margin-bottom: 18px; }
.question-quote {
  margin: 0 0 20px;
  padding: 4px 0 4px 18px;
  border-left: 2px solid var(--rose);
  color: var(--ink-soft);
  font-size: clamp(1rem, 2.4vw, 1.12rem);
  line-height: 1.62;
  font-style: italic;
}
.question-quote .q-label {
  display: block;
  font-family: var(--sans);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 5px;
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.meta-row .tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
}
.meta-row .tag-gold { color: var(--gold); border-color: var(--line-strong); }
.meta-row .saved { color: var(--muted-2); }
.meta-row .saved::before { content: "✓"; color: var(--ok); margin-right: 5px; }

.reading-body { max-width: 820px; }

.position {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 24px;
  padding: 30px 0;
  border-top: 1px solid var(--line);
}
.position:first-of-type { border-top: 1px solid var(--line-strong); }
.position-media { position: relative; }
.position-media img {
  width: 100%;
  aspect-ratio: 0.571;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  background: var(--bg-2);
}
.position-media img.is-reversed {
  transform: rotate(180deg);
  filter: saturate(0.84) brightness(0.95);
}
.position-media .rev-mark {
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--rose);
  color: var(--rose-2);
  font-family: var(--sans);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.position-content { min-width: 0; }
.position-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 6px;
}
.pos-number {
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--gold-dim);
  font-variant-numeric: tabular-nums;
}
.position h2 {
  font-size: clamp(1.12rem, 2.8vw, 1.38rem);
  color: var(--gold-2);
  margin: 0;
  flex: 1 1 auto;
}
.orientation {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.orientation.is-reversed { border-color: rgba(183, 110, 121, 0.5); color: var(--rose-2); }
.card-title {
  font-family: var(--serif);
  font-size: 1.02rem;
  color: var(--ink);
  margin: 0 0 3px;
}
.card-alt {
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--muted-2);
  margin-left: 7px;
  letter-spacing: 0.02em;
}
.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 9px 0 10px;
}
.keyword {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 7px;
  border: 1px solid rgba(201, 168, 106, 0.18);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.02em;
}
.pos-guidance {
  font-style: italic;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted-2);
  margin: 0 0 10px;
}
.pos-text {
  font-size: 1.01rem;
  line-height: 1.78;
  color: var(--ink-soft);
  margin: 0;
}
.position.is-pivot .position-media img { border-color: var(--gold); }

.panel {
  margin-top: 30px;
  padding: clamp(20px, 3.5vw, 30px);
  border: 1px solid var(--line);
  background: linear-gradient(155deg, rgba(201, 168, 106, 0.055), transparent 40%), var(--panel);
  position: relative;
}
.panel h2 {
  font-size: 1.16rem;
  color: var(--gold-2);
  margin-bottom: 10px;
}
.panel p { color: var(--ink-soft); }
.panel-synthesis { border-left: 2px solid var(--gold); }
.panel-advice { border-left: 2px solid var(--rose); }
.panel-advice h2 { color: var(--rose-2); }
.panel-disclaimer {
  margin-top: 28px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted-2);
}

.yesno {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
}
.yesno strong { color: var(--gold-2); font-weight: 600; }

.panel-ai { border-style: dashed; }
.ai-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.ai-head h2 { margin: 0; }
.ai-status {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.ai-status.is-busy { color: var(--gold); }
.ai-status.is-error { color: var(--danger); }
.ai-intro { font-size: 0.94rem; color: var(--muted); }
.ai-notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 2px solid var(--danger);
  background: rgba(217, 138, 138, 0.06);
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.ai-output {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.ai-output:empty { display: none; }
.ai-output h3 {
  font-size: 1rem;
  color: var(--gold-2);
  margin: 18px 0 7px;
  letter-spacing: 0.01em;
}
.ai-output h3:first-child { margin-top: 0; }
.ai-output p {
  font-size: 0.98rem;
  line-height: 1.78;
  color: var(--ink-soft);
  margin-bottom: 0.85em;
}
.ai-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }

.reading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.reading-actions .btn { flex: 1 1 45%; }

/* ---------- history ---------- */

.history-view { padding: clamp(30px, 5vw, 58px) 0 72px; }
.history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-strong);
}
.history-head h1 { font-size: clamp(1.8rem, 4.4vw, 2.6rem); }
.history-count {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.history-main { min-width: 0; }
.history-date {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  text-transform: uppercase;
}
.history-question {
  font-family: var(--serif);
  font-size: 1.06rem;
  color: var(--ink);
  margin: 3px 0 7px;
  overflow-wrap: anywhere;
}
.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--muted);
}
.history-thumbs {
  display: flex;
  gap: 5px;
  margin-top: 11px;
  flex-wrap: wrap;
}
.history-thumb {
  width: 34px;
  aspect-ratio: 0.571;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}
.history-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.history-actions .btn { min-height: 44px; min-width: 92px; }

.empty-state {
  padding: 56px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  background: rgba(201, 168, 106, 0.025);
}
.empty-state .empty-mark {
  width: 44px; height: 44px;
  margin: 0 auto 16px;
  border: 1px solid var(--gold-dim);
  transform: rotate(45deg);
  position: relative;
}
.empty-state .empty-mark::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid var(--line);
}
.empty-state p { color: var(--muted); max-width: 380px; margin: 0 auto; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(8, 5, 12, 0.6);
  padding: 30px 0 calc(26px + var(--safe-bottom));
  margin-top: 20px;
}
.footer-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 36px);
}
.footer-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.footer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tip-btn {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: transparent;
  color: var(--gold-2);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.03em;
}
.tip-btn:hover:not([disabled]) { background: rgba(201, 168, 106, 0.08); }
.tip-btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.footer-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
}
.footer-link:hover { color: var(--gold-2); }
[hidden] { display: none !important; }
.footer-disclaimer {
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted-2);
  max-width: 760px;
  margin-bottom: 8px;
}
.footer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 9px;
  font-family: var(--sans);
  font-size: 10px;
  color: var(--muted-2);
  margin: 0;
}
.footer-demo {
  margin-top: 10px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--gold-dim);
}

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 2, 7, 0.82);
  overflow-y: auto;
  animation: fade-in 0.16s ease;
}
.modal {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(165deg, rgba(201, 168, 106, 0.06), transparent 30%),
    var(--panel);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  padding: 22px;
  position: relative;
}
.modal::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(201, 168, 106, 0.1);
  pointer-events: none;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}
.modal-title {
  font-size: 1.4rem;
  color: var(--gold-2);
  margin: 0;
}
.modal-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -8px -8px 0 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}
.modal-close:hover { color: var(--gold-2); border-color: var(--line); }
.modal-body { position: relative; z-index: 1; }
.modal-body p { font-size: 0.95rem; color: var(--ink-soft); }
.modal-body .note { margin-top: 10px; }
.modal-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
.modal-section:first-child { border-top: 0; padding-top: 0; }
.modal-section h3 {
  font-size: 1rem;
  color: var(--gold);
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}
.modal-section .muted { color: var(--muted); font-size: 0.9rem; }
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}
.modal-actions .btn { flex: 1 1 140px; }
.modal-field { margin-bottom: 14px; }
.modal-field:last-child { margin-bottom: 0; }
.modal-field label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.modal-field input { min-height: 46px; font-size: 15px; }
.modal-field .hint { display: block; margin-top: 5px; }
.modal-field .field-error { display: block; margin-top: 5px; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
}
.checkbox-row input { width: 20px; height: 20px; accent-color: var(--gold); }
.status-line {
  margin-top: 8px;
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}
.status-line.is-ok { color: var(--ok); }
.status-line.is-bad { color: var(--danger); }

.share-preview-wrap {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}
.share-preview {
  width: 100%;
  height: auto;
  max-height: 58vh;
  object-fit: contain;
  border: 1px solid var(--line);
}
.share-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.tip-panel { text-align: left; }
.tip-amount {
  font-family: var(--serif);
  font-size: 2rem;
  color: var(--gold-2);
  margin: 6px 0 2px;
}
.tip-demo-mark {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--rose);
  border-radius: 999px;
  color: var(--rose-2);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  z-index: 150;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: var(--gold-2);
  color: #171021;
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  border-radius: 2px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #3a1d24; color: #f0c9c9; border: 1px solid var(--danger); }

.noscript {
  max-width: 640px;
  margin: 40px auto;
  padding: 24px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-family: var(--sans);
  font-size: 14px;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- legal / privacy ---------- */

.legal-page {
  padding-top: clamp(34px, 6vw, 64px);
  padding-bottom: 72px;
  max-width: 780px;
}
.legal-page h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--ink);
  margin-bottom: 8px;
}
.legal-updated {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted-2);
  margin-bottom: 24px;
}
.legal-page h2 {
  font-size: 1.25rem;
  color: var(--gold-2);
  margin: 34px 0 10px;
}
.legal-page h3 {
  font-size: 1.04rem;
  color: var(--rose-2);
  margin: 22px 0 8px;
}
.legal-page p, .legal-page li {
  font-size: 0.98rem;
  line-height: 1.75;
  color: var(--ink-soft);
}
.legal-page ul {
  margin: 0 0 1em;
  padding-left: 22px;
}
.legal-page li { margin-bottom: 7px; }
.legal-page code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.86em;
  padding: 1px 4px;
  border: 1px solid var(--line);
  background: rgba(6, 4, 10, 0.5);
  color: var(--gold-2);
}
.legal-callout {
  margin: 0 0 26px;
  padding: 16px 18px;
  border-left: 2px solid var(--gold);
  background: rgba(201, 168, 106, 0.055);
  font-size: 0.96rem;
  line-height: 1.7;
  color: var(--ink-soft);
}
.legal-callout strong { color: var(--gold-2); }
.legal-footer { margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--line); }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .header-inner { flex-wrap: wrap; gap: 4px 12px; }
  .brand { flex: 1 1 auto; }
  .brand-text small { display: none; }
  .header-nav { margin-left: 0; flex: 1 1 100%; justify-content: flex-end; gap: 4px; }
  .pi-chip { margin-right: auto; max-width: 140px; }
  .nav-btn span { display: none; }
  .nav-btn { padding: 0; width: 44px; }
  .layout-horseshoe { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 440px; }
  .layout-horseshoe .slot { grid-column: auto !important; grid-row: auto !important; }
  .layout-cross { max-width: 480px; }
  .layout-celtic-cross { max-width: 480px; }
  .reading-actions .btn { flex: 1 1 100%; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .home { padding-top: 30px; }
  .hero-title { font-size: clamp(2rem, 9.6vw, 2.7rem); }
  .ask-panel { padding: 20px 16px; }
  .spread-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .spread-option { min-height: 108px; padding: 12px 11px 10px; }
  .spread-name { font-size: 15.5px; }
  .form-actions .btn-primary { flex: 1 1 100%; }
  .form-actions .btn-ghost { flex: 1 1 100%; }
  .layout-row { gap: 8px; }
  .layout-row .slot-name { font-size: 8.5px; }
  .draw-status { align-items: flex-start; flex-direction: column; gap: 4px; }
  .next-position { text-align: left; }
  .position {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 16px;
    padding: 24px 0;
  }
  .position h2 { font-size: 1.1rem; }
  .card-title { font-size: 0.95rem; }
  .pos-text { font-size: 0.96rem; line-height: 1.72; }
  .keywords { margin: 7px 0 9px; }
  .panel { padding: 18px 16px; }
  .history-item { grid-template-columns: minmax(0, 1fr); }
  .history-actions { flex-direction: row; }
  .history-actions .btn { flex: 1 1 0; }
  .modal { padding: 18px; }
  .modal-actions .btn { flex: 1 1 100%; }
  .draw-actions .btn { min-width: 100%; }
  .footer-top { align-items: flex-start; }
}

@media (max-width: 380px) {
  .header-inner { padding-left: 12px; padding-right: 12px; }
  .pi-chip { max-width: 112px; font-size: 10px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-text strong { font-size: 17px; }
  .position { grid-template-columns: 82px minmax(0, 1fr); gap: 12px; }
  .position h2 { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .card-flip { transition: none; }
}

@media print {
  body { background: #fff; color: #111; }
  .site-header, .site-footer, .reading-actions, .panel-ai, .toast, .modal-overlay { display: none !important; }
  .position { break-inside: avoid; }
}
