:root {
  color-scheme: dark;
  --ink: #f6f1e5;
  --muted: #b9ac94;
  --line: rgba(246, 241, 229, 0.18);
  --panel: rgba(20, 22, 30, 0.82);
  --gold: #d9b86f;
  --violet: #8d7bd8;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 16%, rgba(217, 184, 111, 0.18), transparent 26%),
    radial-gradient(circle at 86% 12%, rgba(107, 183, 169, 0.15), transparent 28%),
    linear-gradient(145deg, #11131c 0%, #0c0e14 48%, #17121a 100%);
}
button, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 410px);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}
.workspace, .side-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.workspace { display: grid; grid-template-rows: auto auto minmax(360px, 1fr); min-width: 0; overflow: hidden; }
.topbar { display: flex; justify-content: space-between; gap: 16px; padding: 22px 24px 14px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: 12px; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(26px, 4vw, 44px); line-height: 1.05; }
h2 { font-size: 18px; }
.reading-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 13px; }
.reading-meta span { min-height: 30px; padding: 6px 10px; border: 1px solid var(--line); background: rgba(255,255,255,0.04); }

.control-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(320px, 1fr);
  grid-template-areas:
    "question assist"
    "spreads spreads"
    "actions actions";
  gap: 10px 12px;
  align-items: stretch;
  padding: 12px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.question-field { grid-area: question; display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.question-field textarea {
  min-height: 72px;
  max-height: 112px;
  resize: vertical;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255,255,255,0.06);
  outline: none;
}
.question-field textarea:focus { border-color: rgba(217,184,111,0.62); box-shadow: 0 0 0 3px rgba(217,184,111,0.12); }
.question-assist { grid-area: assist; display: grid; gap: 8px; align-self: stretch; align-content: start; min-width: 0; }
.template-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(142px, 1fr)); gap: 6px; overflow: visible; }
.template-chip {
  display: flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(246,241,229,0.14);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.045);
  font-size: 12px;
  text-align: left;
}
.template-chip:hover { color: var(--ink); border-color: rgba(217,184,111,0.42); background: rgba(217,184,111,0.08); }
.spread-recommendation {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  min-height: 30px;
  color: var(--muted);
  font-size: 12px;
}
.spread-recommendation button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(217,184,111,0.24);
  border-radius: 999px;
  color: #f1d894;
  background: rgba(217,184,111,0.075);
}
.spread-recommendation button:hover { border-color: rgba(217,184,111,0.58); background: rgba(217,184,111,0.14); }
.spread-row {
  grid-area: spreads;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  overflow: visible;
  padding: 0;
}
.spread-option, .primary-action, .secondary-action, .icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,0.06);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.spread-option {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  min-height: 54px;
  gap: 7px;
  align-items: center;
  padding: 7px;
  text-align: left;
  overflow: hidden;
  isolation: isolate;
}
.spread-option::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  border-radius: 7px;
  background:
    radial-gradient(circle at 20% 18%, rgba(217,184,111,0.24), transparent 18%),
    radial-gradient(circle at 82% 26%, rgba(107,183,169,0.14), transparent 22%),
    linear-gradient(145deg, rgba(255,255,255,0.075), rgba(255,255,255,0.025));
  opacity: 0.8;
}
.spread-option::after {
  content: "☾";
  position: absolute;
  right: 6px;
  top: 4px;
  color: rgba(217,184,111,0.38);
  font-size: 12px;
}
.spread-copy { display: grid; gap: 2px; min-width: 0; }
.spread-copy > span { font-size: 13px; line-height: 1.18; overflow-wrap: anywhere; }
.spread-copy > small { color: var(--muted); font-size: 10px; line-height: 1.25; overflow-wrap: anywhere; }
.spread-diagram {
  display: grid;
  grid-template-columns: repeat(var(--mini-cols), 1fr);
  grid-template-rows: repeat(var(--mini-rows), 1fr);
  gap: 2px;
  width: 40px;
  height: 40px;
  padding: 4px;
  border: 1px solid rgba(217,184,111,0.26);
  border-radius: 8px;
  background:
    linear-gradient(rgba(246,241,229,0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(246,241,229,0.055) 1px, transparent 1px),
    rgba(5,7,12,0.28);
  background-size: 12px 12px;
  box-shadow: inset 0 0 18px rgba(217,184,111,0.06);
}
.spread-diagram i {
  display: block;
  min-width: 3px;
  min-height: 5px;
  border: 1px solid rgba(240,215,144,0.78);
  border-radius: 2px;
  background: linear-gradient(145deg, rgba(240,215,144,0.36), rgba(141,123,216,0.16));
  box-shadow: 0 0 8px rgba(217,184,111,0.18);
  animation: glimmer 1200ms ease both;
}
.spread-option.active {
  border-color: rgba(217,184,111,0.84);
  background: linear-gradient(135deg, rgba(217,184,111,0.18), rgba(107,183,169,0.08));
  box-shadow: 0 0 0 2px rgba(217,184,111,0.09), inset 0 0 24px rgba(217,184,111,0.05);
}
.spread-option.active .spread-diagram { border-color: rgba(240,215,144,0.62); background-color: rgba(217,184,111,0.07); }
.spread-option.active .spread-diagram i { border-color: rgba(255,236,176,0.94); background: linear-gradient(145deg, rgba(255,236,176,0.54), rgba(107,183,169,0.24)); }
.spread-option[data-spread="one"] { color: #f2d68c; }
.spread-option[data-spread="freeThree"] { color: #b9d8ff; }
.spread-option[data-spread="three"] { color: #d8c4ff; }
.spread-option[data-spread="situationAdvice"] { color: #bfe7d4; }
.spread-option[data-spread="choice"] { color: #ffcfb4; }
.spread-option[data-spread="fourElements"] { color: #f2d68c; }
.spread-option[data-spread="fiveCross"] { color: #cde0ff; }
.spread-option[data-spread="loveCross"] { color: #ffc7dc; }
.spread-option[data-spread="hexagram"] { color: #b8efe7; }
.spread-option[data-spread="cross"] { color: #ead0ff; }
.spread-option[data-spread="treeOfLife"] { color: #d4edba; }
.actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(92px, 0.45fr));
  gap: 7px;
  width: 100%;
  max-width: none;
  justify-self: stretch;
  align-self: end;
}
.actions .primary-action { min-height: 42px; }
.primary-action, .secondary-action, .icon-button { min-height: 36px; padding: 0 12px; }
.primary-action { color: #16120a; border-color: transparent; background: linear-gradient(135deg, #f0d790, #cba052); font-weight: 700; }
.secondary-action:hover, .icon-button:hover, .spread-option:hover { transform: translateY(-1px); border-color: rgba(246,241,229,0.34); background: rgba(255,255,255,0.09); }

.table-area { min-height: 360px; padding: 16px; overflow: auto; }
.card-table {
  position: relative;
  display: grid;
  gap: 16px;
  min-height: 360px;
  align-content: center;
  justify-content: center;
  padding: 18px;
  border: 1px solid rgba(246,241,229,0.12);
  background:
    linear-gradient(rgba(246,241,229,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(246,241,229,0.035) 1px, transparent 1px),
    rgba(255,255,255,0.03);
  background-size: 34px 34px;
}
.card-table.empty { place-items: center; }
.card-table.shuffling { place-items: center; border-color: rgba(217,184,111,0.28); animation: table-breath 850ms ease both; }
.shuffle-stage { display: grid; justify-items: center; gap: 14px; color: var(--muted); text-align: center; }
.shuffle-stage p { margin: 0; }
.shuffle-deck { position: relative; width: 132px; height: 184px; }
.shuffle-deck span {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(217,184,111,0.58);
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 34%, transparent 0 22%, rgba(217,184,111,0.2) 23% 25%, transparent 26%),
    linear-gradient(145deg, #2b2438, #11131c 58%, #273033);
  transform: rotate(calc((var(--i) - 4) * 6deg)) translateX(calc((var(--i) - 4) * 4px));
  animation: shuffle-card 850ms ease both;
}
.spread-one { grid-template-columns: minmax(180px, 250px); }
.spread-freeThree, .spread-three, .spread-situationAdvice { grid-template-columns: repeat(3, minmax(150px, 210px)); }
.spread-fourElements { grid-template-columns: repeat(2, minmax(150px, 210px)); }
.spread-choice { grid-template-columns: repeat(5, minmax(130px, 180px)); grid-template-rows: repeat(3, auto); }
.spread-fiveCross { grid-template-columns: repeat(3, minmax(150px, 205px)); grid-template-rows: repeat(3, auto); }
.spread-loveCross { grid-template-columns: repeat(3, minmax(150px, 205px)); grid-template-rows: repeat(2, auto); }
.spread-hexagram { grid-template-columns: repeat(3, minmax(150px, 205px)); grid-template-rows: repeat(3, auto); }
.spread-cross { grid-template-columns: repeat(5, minmax(132px, 176px)); grid-template-rows: repeat(4, auto); }
.spread-treeOfLife { grid-template-columns: repeat(4, minmax(132px, 176px)); grid-template-rows: repeat(4, auto); }

.spread-choice .card-slot-0 { grid-column: 3; grid-row: 2; }
.spread-choice .card-slot-1 { grid-column: 1; grid-row: 1; }
.spread-choice .card-slot-2 { grid-column: 1; grid-row: 2; }
.spread-choice .card-slot-3 { grid-column: 1; grid-row: 3; }
.spread-choice .card-slot-4 { grid-column: 5; grid-row: 1; }
.spread-choice .card-slot-5 { grid-column: 5; grid-row: 2; }
.spread-choice .card-slot-6 { grid-column: 5; grid-row: 3; }

.spread-fiveCross .card-slot-0 { grid-column: 2; grid-row: 2; }
.spread-fiveCross .card-slot-1 { grid-column: 1; grid-row: 2; }
.spread-fiveCross .card-slot-2 { grid-column: 2; grid-row: 3; }
.spread-fiveCross .card-slot-3 { grid-column: 2; grid-row: 1; }
.spread-fiveCross .card-slot-4 { grid-column: 3; grid-row: 2; }

.spread-loveCross .card-slot-0 { grid-column: 1; grid-row: 1; }
.spread-loveCross .card-slot-1 { grid-column: 3; grid-row: 1; }
.spread-loveCross .card-slot-2 { grid-column: 2; grid-row: 1; }
.spread-loveCross .card-slot-3 { grid-column: 1; grid-row: 2; }
.spread-loveCross .card-slot-4 { grid-column: 3; grid-row: 2; }
.spread-loveCross .card-slot-5 { grid-column: 2; grid-row: 2; }

.spread-hexagram .card-slot-0 { grid-column: 1; grid-row: 2; }
.spread-hexagram .card-slot-1 { grid-column: 2; grid-row: 1; }
.spread-hexagram .card-slot-2 { grid-column: 3; grid-row: 2; }
.spread-hexagram .card-slot-3 { grid-column: 1; grid-row: 3; }
.spread-hexagram .card-slot-4 { grid-column: 3; grid-row: 3; }
.spread-hexagram .card-slot-5 { grid-column: 2; grid-row: 3; }
.spread-hexagram .card-slot-6 { grid-column: 2; grid-row: 2; }

.spread-cross .card-slot-0 { grid-column: 3; grid-row: 2; }
.spread-cross .card-slot-1 { grid-column: 2; grid-row: 2; }
.spread-cross .card-slot-2 { grid-column: 3; grid-row: 3; }
.spread-cross .card-slot-3 { grid-column: 3; grid-row: 1; }
.spread-cross .card-slot-4 { grid-column: 1; grid-row: 2; }
.spread-cross .card-slot-5 { grid-column: 4; grid-row: 2; }
.spread-cross .card-slot-6 { grid-column: 5; grid-row: 4; }
.spread-cross .card-slot-7 { grid-column: 5; grid-row: 3; }
.spread-cross .card-slot-8 { grid-column: 5; grid-row: 2; }
.spread-cross .card-slot-9 { grid-column: 5; grid-row: 1; }

.spread-treeOfLife .card-slot-0 { grid-column: 2 / span 2; grid-row: 1; justify-self: center; }
.spread-treeOfLife .card-slot-1 { grid-column: 1; grid-row: 2; }
.spread-treeOfLife .card-slot-2 { grid-column: 4; grid-row: 2; }
.spread-treeOfLife .card-slot-3 { grid-column: 1; grid-row: 3; }
.spread-treeOfLife .card-slot-4 { grid-column: 4; grid-row: 3; }
.spread-treeOfLife .card-slot-5 { grid-column: 2 / span 2; grid-row: 3; justify-self: center; }
.spread-treeOfLife .card-slot-6 { grid-column: 1; grid-row: 4; }
.spread-treeOfLife .card-slot-7 { grid-column: 4; grid-row: 4; }
.spread-treeOfLife .card-slot-8 { grid-column: 2; grid-row: 4; }
.spread-treeOfLife .card-slot-9 { grid-column: 3; grid-row: 4; }

.empty-state { display: grid; justify-items: center; gap: 18px; color: var(--muted); text-align: center; }
.deck-preview { position: relative; width: 132px; height: 188px; }
.deck-preview span {
  position: absolute; inset: 0; border: 1px solid rgba(217,184,111,0.55); border-radius: 12px;
  background: radial-gradient(circle, transparent 0 26%, rgba(217,184,111,0.18) 27% 28%, transparent 29%), linear-gradient(135deg, #242839, #11131c 55%, #2b2131);
}
.deck-preview span:nth-child(1) { transform: rotate(-8deg) translateX(-12px); }
.deck-preview span:nth-child(2) { transform: rotate(2deg); }
.deck-preview span:nth-child(3) { transform: rotate(9deg) translateX(12px); }

.tarot-card {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 318px;
  aspect-ratio: 0.68;
  padding: 8px;
  border: 1px solid rgba(217,184,111,0.5);
  border-radius: 12px;
  overflow: hidden;
  color: #f3ead8;
  background: linear-gradient(160deg, #2a2130, #141722 56%, #0d0f16);
  box-shadow: 0 20px 36px rgba(0,0,0,0.32);
  animation: flip-in 520ms ease both;
  transition: transform 220ms ease, opacity 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}
.tarot-card:hover, .tarot-card:focus-visible, .tarot-card.selected {
  border-color: rgba(240,215,144,0.9);
  box-shadow: 0 0 0 3px rgba(217,184,111,0.14), 0 22px 42px rgba(0,0,0,0.36);
  outline: none;
}
.tarot-card.reversed { border-color: rgba(141,123,216,0.72); }
.card-position { min-height: 30px; color: rgba(246,241,229,0.72); font-size: 12px; line-height: 1.3; }
.card-art { display: grid; place-items: center; min-height: 0; margin: 8px 0; border: 1px solid rgba(246,241,229,0.14); border-radius: 8px; overflow: hidden; background: #0b0d12; }
.card-art img { display: block; width: 100%; height: 100%; min-height: 210px; object-fit: cover; object-position: center; }
.tarot-card.reversed .card-art img { transform: rotate(180deg); }
.card-symbol { color: var(--gold); font-size: clamp(42px, 7vw, 70px); }
.card-title { display: grid; gap: 3px; }
.card-title strong { font-size: 16px; line-height: 1.2; }
.card-title span { font-size: 12px; color: rgba(246,241,229,0.66); }

.side-panel { display: grid; grid-template-rows: minmax(430px, 1fr) minmax(190px, 0.5fr); min-height: 0; overflow: hidden; }
.interpretation, .history { min-height: 0; padding: 20px; }
.interpretation { border-bottom: 1px solid var(--line); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-actions { display: flex; gap: 8px; align-items: center; }
.icon-button { min-width: 54px; color: var(--muted); font-size: 13px; }
.icon-button.is-loading { color: var(--gold); border-color: rgba(217,184,111,0.5); }
.reading-output, .history-list { overflow: auto; padding-right: 4px; }
.reading-output { max-height: calc(100vh - 340px); color: #e9dfca; line-height: 1.72; }
.reading-output p { margin: 0 0 14px; }
.reading-output h3 { margin: 18px 0 8px; color: var(--gold); font-size: 15px; }
.reading-output ul { margin: 0 0 14px; padding-left: 18px; }
.reading-output li { margin: 6px 0; }
.reading-section { margin: 0 0 13px; padding: 12px; border: 1px solid rgba(246,241,229,0.11); border-radius: 8px; background: rgba(255,255,255,0.035); }
.reading-section h3 { margin-top: 0; }
.followup-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(217,184,111,0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(217,184,111,0.08), rgba(107,183,169,0.045));
}
.followup-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.followup-heading h3 { margin: 0; color: var(--gold); font-size: 15px; }
.followup-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.followup-heading span { flex: none; padding: 4px 8px; border: 1px solid rgba(217,184,111,0.24); border-radius: 999px; color: var(--muted); font-size: 12px; background: rgba(0,0,0,0.16); }
.followup-thread {
  display: grid;
  max-height: 220px;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}
.followup-message {
  display: grid;
  gap: 5px;
  max-width: 92%;
  padding: 10px 12px;
  border: 1px solid rgba(246,241,229,0.13);
  border-radius: 8px;
  background: rgba(255,255,255,0.045);
}
.followup-message.user {
  justify-self: end;
  border-color: rgba(217,184,111,0.34);
  background: rgba(217,184,111,0.1);
}
.followup-message.assistant { justify-self: start; }
.followup-message.error { border-color: rgba(232,126,126,0.42); color: #ffd6d6; }
.followup-message span { color: var(--muted); font-size: 12px; }
.followup-message p { margin: 0; line-height: 1.62; }
.followup-compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.followup-compose textarea {
  min-height: 46px;
  max-height: 110px;
  resize: vertical;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255,255,255,0.055);
  outline: none;
}
.followup-compose textarea:focus { border-color: rgba(217,184,111,0.62); box-shadow: 0 0 0 3px rgba(217,184,111,0.12); }
.followup-button { width: 68px; min-height: 46px; padding: 0 10px; }
.followup-panel.locked { opacity: 0.72; }
.followup-panel.locked textarea, .followup-panel.locked button { cursor: not-allowed; }
.card-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(5,7,12,0.68);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.card-zoom-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.zoom-card {
  width: min(74vw, 360px);
  max-height: min(86vh, 620px);
  min-height: 0;
  transform: translateY(12px) scale(0.92);
  opacity: 0;
  animation: none;
  cursor: zoom-out;
}
.zoom-card .card-art img { min-height: min(62vh, 460px); }
.zoom-card .card-position { font-size: 13px; }
.zoom-card .card-title strong { font-size: 18px; }
.zoom-card .card-title span { display: block; font-size: 12px; }
.card-zoom-overlay.open .zoom-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.zoom-open { overflow: hidden; }
.detail-card-title { display: grid; gap: 4px; margin-bottom: 12px; padding: 12px; border: 1px solid rgba(217,184,111,0.26); border-radius: 8px; background: rgba(217,184,111,0.08); }
.detail-card-title span, .history-item span { color: var(--muted); font-size: 12px; }
.detail-card-title strong { font-size: 17px; }
.history-list { display: grid; max-height: calc(100vh - 620px); min-height: 170px; gap: 10px; }
.history-item { display: grid; gap: 6px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-align: left; background: rgba(255,255,255,0.045); }
.history-item:hover { border-color: rgba(217,184,111,0.48); }
.history-item em { color: var(--gold); font-size: 12px; font-style: normal; }
.muted { margin: 0; color: var(--muted); font-size: 14px; }
.ai-note { padding: 12px; border: 1px solid rgba(217,184,111,0.25); border-radius: 8px; color: var(--muted); background: rgba(217,184,111,0.07); }
.ai-waiting {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid rgba(217,184,111,0.26);
  border-radius: 8px;
  color: #eadfcb;
  background: linear-gradient(135deg, rgba(217,184,111,0.09), rgba(107,183,169,0.045));
}
.ai-waiting span {
  display: block;
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(217,184,111,0.1), rgba(217,184,111,0.72), rgba(107,183,169,0.18));
  background-size: 220% 100%;
  animation: reading-flow 1100ms ease infinite;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5,7,12,0.72);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.spread-info-card {
  display: grid;
  gap: 14px;
  width: min(92vw, 620px);
  max-height: 82vh;
  padding: 18px;
  border: 1px solid rgba(217,184,111,0.34);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(20,22,30,0.96);
  box-shadow: var(--shadow);
  transform: translateY(10px);
  transition: transform 200ms ease;
}
.modal-overlay.open .spread-info-card { transform: translateY(0); }
.modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.spread-info-content {
  display: grid;
  gap: 12px;
  max-height: 62vh;
  overflow: auto;
  color: #e9dfca;
  line-height: 1.68;
}
.spread-info-content p { margin: 0; }
.spread-info-content ul { margin: 0; padding-left: 18px; }
.spread-info-content li { margin: 6px 0; }

@keyframes flip-in { from { opacity: 0; transform: translateY(14px) rotateY(78deg); } to { opacity: 1; transform: translateY(0) rotateY(0); } }
@keyframes glimmer { from { opacity: 0; transform: translateY(2px) scale(0.86); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes shuffle-card {
  0% { opacity: 0; transform: rotate(-22deg) translate(-24px, 18px) scale(0.92); }
  55% { opacity: 1; transform: rotate(calc((var(--i) - 4) * -8deg)) translateX(calc((var(--i) - 4) * -7px)); }
  100% { opacity: 1; transform: rotate(calc((var(--i) - 4) * 6deg)) translateX(calc((var(--i) - 4) * 4px)); }
}
@keyframes table-breath {
  0% { box-shadow: inset 0 0 0 rgba(217,184,111,0); }
  50% { box-shadow: inset 0 0 42px rgba(217,184,111,0.12); }
  100% { box-shadow: inset 0 0 0 rgba(217,184,111,0); }
}
@keyframes reading-flow {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 1fr; }
  .side-panel { grid-template-rows: auto auto auto; }
  .reading-output, .history-list { max-height: none; }
  .control-panel { grid-template-columns: 1fr; grid-template-areas: "question" "assist" "spreads" "actions"; align-items: stretch; }
  .spread-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .actions { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .app-shell { padding: 10px; }
  .topbar, .control-panel, .table-area, .interpretation, .history { padding-left: 14px; padding-right: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .control-panel { grid-template-columns: 1fr; gap: 9px; }
  .question-field textarea { min-height: 68px; }
  .question-assist { align-content: start; }
  .template-row { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: none; }
  .template-chip { border-radius: 8px; line-height: 1.25; padding: 6px 8px; }
  .spread-row { grid-template-columns: repeat(3, minmax(0, 1fr)); overflow-x: visible; }
  .spread-option { grid-template-columns: 34px minmax(0, 1fr); min-height: 52px; padding: 6px; gap: 6px; }
  .spread-diagram { width: 32px; height: 32px; padding: 3px; }
  .spread-copy > span { font-size: 12px; }
  .spread-copy > small { font-size: 9px; }
  .actions { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions .primary-action { grid-column: 1 / -1; }
  .table-area { min-height: 330px; overflow: auto; }
  .card-table { gap: 7px; min-height: 318px; padding: 8px; align-content: center; justify-content: center; }
  .spread-one { grid-template-columns: minmax(124px, 168px); }
  .spread-freeThree, .spread-three, .spread-situationAdvice { grid-template-columns: repeat(3, minmax(82px, 30vw)); }
  .spread-fourElements { grid-template-columns: repeat(2, minmax(112px, 36vw)); }
  .spread-choice { grid-template-columns: repeat(3, minmax(76px, 29vw)); grid-template-rows: repeat(3, auto); }
  .spread-fiveCross, .spread-loveCross, .spread-hexagram { grid-template-columns: repeat(3, minmax(76px, 29vw)); }
  .spread-cross { grid-template-columns: repeat(5, minmax(54px, 18vw)); grid-template-rows: repeat(4, auto); }
  .spread-treeOfLife { grid-template-columns: repeat(4, minmax(58px, 22vw)); grid-template-rows: repeat(4, auto); }
  .spread-choice .card-slot-0 { grid-column: 2; grid-row: 2; }
  .spread-choice .card-slot-1 { grid-column: 1; grid-row: 1; }
  .spread-choice .card-slot-2 { grid-column: 1; grid-row: 2; }
  .spread-choice .card-slot-3 { grid-column: 1; grid-row: 3; }
  .spread-choice .card-slot-4 { grid-column: 3; grid-row: 1; }
  .spread-choice .card-slot-5 { grid-column: 3; grid-row: 2; }
  .spread-choice .card-slot-6 { grid-column: 3; grid-row: 3; }
  .tarot-card { min-height: 0; padding: 5px; border-radius: 8px; justify-self: stretch; box-shadow: 0 10px 22px rgba(0,0,0,0.3); }
  .card-position { min-height: 24px; font-size: 9px; overflow-wrap: anywhere; }
  .card-art { margin: 4px 0; border-radius: 6px; }
  .card-art img { min-height: 82px; }
  .card-title { gap: 1px; }
  .card-title strong { font-size: 10px; overflow-wrap: anywhere; }
  .card-title span { font-size: 8px; overflow-wrap: anywhere; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .panel-actions { width: 100%; }
  .panel-actions .icon-button { flex: 1; }
  .followup-panel { padding: 12px; }
  .followup-compose { grid-template-columns: 1fr; }
  .followup-button { width: 100%; }
}
@media (max-width: 520px) {
  .spread-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .spread-option { grid-template-columns: 1fr; min-height: 58px; justify-items: center; text-align: center; }
  .spread-diagram { width: 30px; height: 30px; }
  .spread-copy > span { font-size: 11px; }
  .spread-copy > small { display: none; }
  .spread-recommendation button { flex: 1 1 auto; }
  .table-area { padding-left: 8px; padding-right: 8px; }
  .card-table { gap: 5px; padding: 7px; min-height: 300px; }
  .spread-freeThree, .spread-three, .spread-situationAdvice { grid-template-columns: repeat(3, minmax(72px, 30vw)); }
  .spread-choice, .spread-fiveCross, .spread-loveCross, .spread-hexagram { grid-template-columns: repeat(3, minmax(66px, 29vw)); }
  .spread-cross { grid-template-columns: repeat(5, minmax(48px, 18vw)); }
  .spread-treeOfLife { grid-template-columns: repeat(4, minmax(54px, 22vw)); }
  .card-position { min-height: 21px; font-size: 8px; }
  .card-art img { min-height: 68px; }
  .card-title strong { font-size: 9px; }
  .card-title span { display: none; }
  .zoom-card { width: min(82vw, 320px); }
  .spread-info-card { padding: 14px; }
}
