/* ===== 13 Tarot — Custom Mystical Theme ===== */
:root {
  --bg-deep: #120a24;
  --bg-card: #1e1238;
  --bg-soft: #2a1b4e;
  --accent-gold: #d4a843;
  --accent-purple: #9b59b6;
  --accent-purple-soft: #7e3ca3;
  --text-light: #f0e6d2;
  --text-muted: #a89bb8;
  --border: #4a3561;
  --danger: #e74c3c;
  --success: #2ecc71;
  --chat-user: #3d2566;
  --chat-ai: #231543;
  --font-body: "EB Garamond", Georgia, serif;
  --font-display: "Cinzel", serif;
  --font-brand: "Cinzel", serif;
}

/* Korean UI: Pretendard for body + headings; brand title stays Cinzel */
html[lang="ko"] {
  --font-body: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --font-display: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}

body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(155, 89, 182, 0.14) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(212, 168, 67, 0.08) 0%, transparent 45%),
    var(--bg-deep);
  color: var(--text-light);
  font-family: var(--font-body);
  min-height: 100vh;
  font-size: 17px;
}

html[lang="ko"] body {
  font-size: 16px;
  letter-spacing: -0.01em;
  word-break: keep-all;
}

.font-display {
  font-family: var(--font-display);
}

.brand-title,
.brand-title.font-display {
  font-family: var(--font-brand);
}

html, body {
  scroll-behavior: smooth;
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100%;
  overscroll-behavior-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

/* ---------- Card slots ---------- */
.card-slot {
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 16px;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  cursor: default;
  position: relative;
}
.card-slot:hover {
  border-color: var(--accent-purple);
}
.card-slot.filled {
  border-style: solid;
  border-color: var(--accent-gold);
  background: linear-gradient(135deg, var(--bg-card) 0%, #3d2566 100%);
  padding-top: 40px;
}
.card-slot.selected-for-scan {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px rgba(155,89,182,0.5), 0 0 24px rgba(155,89,182,0.25);
}

.slot-actions {
  display: flex !important;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 10px;
  justify-content: stretch;
  align-items: stretch;
  width: 100%;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(74, 53, 97, 0.55);
  box-sizing: border-box;
}

button.slot-action-btn {
  appearance: none;
  -webkit-appearance: none;
  flex: 1 1 0;
  min-width: 0;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 2px solid transparent;
  display: flex !important;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.03em;
  line-height: 1.15;
  cursor: pointer;
  box-sizing: border-box;
  transition: filter 0.2s, transform 0.15s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
button.slot-action-btn .slot-action-icon {
  display: block;
  font-size: 16px;
  line-height: 1;
}
button.slot-action-btn .slot-action-label {
  display: block;
  font-size: 15px;
  font-weight: 700;
}
button.slot-action-btn:active:not(:disabled) {
  transform: translateY(1px);
}
button.slot-action-btn.pick {
  background: linear-gradient(135deg, #9b59b6, #7e3ca3) !important;
  background-image: linear-gradient(135deg, #9b59b6, #7e3ca3) !important;
  color: #ffffff !important;
  box-shadow: 0 8px 22px rgba(155, 89, 182, 0.4);
}
button.slot-action-btn.pick:hover { filter: brightness(1.12); }
button.slot-action-btn.scan {
  background: linear-gradient(135deg, #d4a843, #b8892f) !important;
  background-image: linear-gradient(135deg, #d4a843, #b8892f) !important;
  color: #120a24 !important;
  box-shadow: 0 8px 22px rgba(212, 168, 67, 0.38);
}
button.slot-action-btn.scan:hover { filter: brightness(1.1); }
button.slot-action-btn.clear {
  background: #2a1b4e !important;
  background-image: none !important;
  border-color: #4a3561 !important;
  color: #f0e6d2 !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
}
button.slot-action-btn.clear:hover:not(:disabled) {
  border-color: rgba(231, 76, 60, 0.65) !important;
  color: #f1948a !important;
  background: rgba(231, 76, 60, 0.16) !important;
}
button.slot-action-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
  transform: none;
}

.slot-position-badge {
  position: absolute;
  top: 8px;
  left: 10px;
  background: rgba(212,168,67,0.16);
  color: var(--accent-gold);
  border: 1px solid rgba(212,168,67,0.4);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  text-transform: uppercase;
}

.mini-card-img {
  height: 72px;
  width: auto;
  max-width: 52px;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  border: 1px solid rgba(212,168,67,0.35);
}
.mini-card-img.reversed,
img.reversed {
  transform: rotate(180deg);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

/* ---------- Keywords ---------- */
.keyword-pill {
  background: rgba(212,168,67,0.14);
  color: var(--accent-gold);
  border: 1px solid rgba(212,168,67,0.22);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.3px;
}

/* ---------- Spread buttons ---------- */
.spread-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.spread-btn:hover {
  border-color: var(--accent-purple);
  color: var(--text-light);
}
.spread-btn.active {
  background: linear-gradient(135deg, var(--accent-gold), #b8892f);
  color: var(--bg-deep);
  border-color: var(--accent-gold);
  font-weight: 700;
}
.spread-btn-clear {
  color: var(--text-muted);
}
.spread-btn-clear:hover {
  border-color: rgba(231, 76, 60, 0.55);
  color: #f1948a;
}

/* ---------- Buttons ---------- */
.btn-gold {
  background: linear-gradient(135deg, var(--accent-gold), #b8892f);
  color: var(--bg-deep);
}
.btn-gold:hover {
  filter: brightness(1.1);
}
.btn-purple {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-purple-soft));
  color: #fff;
}
.btn-purple:hover { filter: brightness(1.12); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--accent-purple); color: var(--text-light); }
.btn-danger-ghost {
  background: transparent;
  border: 1px solid rgba(231,76,60,0.4);
  color: #f1948a;
}
.btn-danger-ghost:hover { background: rgba(231,76,60,0.12); }

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.share-btn:hover {
  border-color: var(--accent-purple);
  color: var(--text-light);
}
.share-btn .share-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.share-btn .share-btn-label {
  line-height: 1;
}

.footer-link {
  color: #a89bb8;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}
.footer-link:hover {
  color: var(--accent-gold);
}

.lang-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 11px;
  color: #6d5b85;
}
.lang-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: #6d5b85;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s;
}
.lang-btn:hover {
  color: var(--accent-gold);
}
.lang-btn.lang-active {
  color: var(--accent-gold);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.lang-sep {
  color: #4a3561;
  user-select: none;
}

.donate-options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1.25rem;
}
.donate-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin: 0.75rem 0 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(35, 21, 67, 0.7);
  color: var(--accent-gold);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.donate-back svg {
  width: 1.55rem;
  height: 1.55rem;
}
.donate-back:hover {
  border-color: var(--accent-gold);
  background: rgba(45, 28, 82, 0.9);
  color: #f0e6d2;
}
.donate-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: rgba(35, 21, 67, 0.55);
  color: var(--text-light);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.donate-option:hover {
  border-color: var(--accent-gold);
  background: rgba(45, 28, 82, 0.75);
}
.donate-option.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.donate-option-label {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-gold);
  font-size: 0.95rem;
}
.donate-option-amount {
  font-size: 0.95rem;
  color: var(--text-light);
}
.donate-option-note {
  font-size: 11px;
  color: #6d5b85;
  margin-top: 0.85rem;
}

.ml-status-bar {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.legal-prose h2 {
  font-family: var(--font-display);
  color: var(--accent-gold);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
}

.reading-ai-text .reading-ai-h,
.reading-ai-text h2,
.reading-ai-text h3,
.chat-message.ai .reading-ai-h,
.chat-message.ai h2,
.chat-message.ai h3 {
  font-family: var(--font-display);
  color: var(--text-light);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 0.75rem;
}
.reading-ai-text h3,
.chat-message.ai h3 {
  font-size: 1.15rem;
}
.reading-ai-text p,
.chat-message.ai p {
  margin: 0 0 0.75rem;
}
.reading-ai-text p:last-child,
.chat-message.ai p:last-child {
  margin-bottom: 0;
}
.reading-ai-text strong,
.chat-message.ai strong {
  color: var(--accent-gold);
  font-weight: 700;
}

/* ---------- Face-down draw overlay (Pick) ---------- */
.draw-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(10, 5, 22, 0.92);
  backdrop-filter: blur(6px);
  overflow: hidden;
  padding: 6px;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.draw-panel {
  width: 100%;
  max-width: 28rem;
  height: calc(100dvh - 12px);
  max-height: calc(100dvh - 12px);
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.55rem 0.55rem 0.45rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}
.draw-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  flex-shrink: 0;
}
.draw-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  /* 14 half-columns × 12 rows: alternating 6/7 cards for a chessboard stagger */
  grid-template-columns: repeat(14, minmax(0, 1fr));
  grid-template-rows: repeat(12, minmax(0, 1fr));
  gap: 4px;
}
.draw-slot,
.draw-slot-empty {
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
  /* Each card spans 2 half-columns; start column set inline for stagger */
}
.draw-slot-empty {
  pointer-events: none;
}
.draw-card-back {
  position: relative;
  /* Same portrait scale in every cell; letterbox if the cell is not 2:3 */
  aspect-ratio: 2 / 3;
  width: min(100cqw, calc(100cqh * 2 / 3));
  height: min(100cqh, calc(100cqw * 3 / 2));
  padding: 0;
  margin: 0;
  border-radius: 3px;
  border: 1.5px solid #5a6b3a;
  background:
    linear-gradient(145deg, rgba(212, 168, 67, 0.12) 0%, transparent 42%),
    radial-gradient(circle at 50% 40%, #3d2566 0%, #1a0f30 70%);
  cursor: pointer;
  overflow: hidden;
  transform-origin: center center;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.draw-card-back::after {
  content: "✦";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: rgba(212, 168, 67, 0.4);
  pointer-events: none;
}
/* Only real pointer hover — sticky :hover on iOS was pausing animations */
@media (hover: hover) and (pointer: fine) {
  .draw-card-back:hover,
  .draw-card-back:focus-visible {
    border-color: var(--accent-gold);
    box-shadow: 0 0 8px rgba(212, 168, 67, 0.4);
    outline: none;
    z-index: 2;
    animation-play-state: paused;
  }
}
.draw-card-back.draw-settled {
  animation: none !important;
  opacity: 0.35;
  filter: grayscale(0.3);
  pointer-events: none;
}
.draw-card-back.draw-chosen {
  opacity: 1;
  filter: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 14px rgba(212, 168, 67, 0.6);
  z-index: 3;
  pointer-events: none;
}
.draw-card-back.draw-flipping {
  animation: drawFlipReveal 0.32s ease forwards;
}
.draw-card-back .draw-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px;
  opacity: 0;
}
.draw-card-back.draw-flipping .draw-face {
  animation: drawFaceIn 0.32s ease forwards;
}
.draw-card-back.draw-flipping::after {
  opacity: 0;
  transition: opacity 0.12s;
}

.draw-confirm {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(18, 10, 36, 0.94);
  border-radius: 0.85rem;
  text-align: center;
}
.draw-confirm.hidden {
  display: none !important;
}
.draw-confirm-img {
  height: min(42vh, 280px);
  width: auto;
  max-width: 70%;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(212, 168, 67, 0.45);
  box-shadow: 0 0 24px rgba(212, 168, 67, 0.25);
}

@keyframes drawTwinkleSoft {
  0%, 100% { opacity: 0.88; }
  50% { opacity: 1; }
}
@keyframes drawShakeHeavy {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  20% { transform: translate3d(-5px, 0, 0) rotate(-4deg); }
  40% { transform: translate3d(5px, 0, 0) rotate(4deg); }
  60% { transform: translate3d(-4px, 0, 0) rotate(-3deg); }
  80% { transform: translate3d(4px, 0, 0) rotate(3deg); }
}
@keyframes drawDriftHeavy {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  25% { transform: translate3d(4px, -5px, 0) rotate(4deg) scale(1.08); }
  50% { transform: translate3d(-4px, 3px, 0) rotate(-3deg) scale(1.1); }
  75% { transform: translate3d(3px, 4px, 0) rotate(2deg) scale(1.06); }
}
@keyframes drawSpin {
  0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  50% { transform: translate3d(0, 0, 0) rotate(180deg) scale(1.1); }
  100% { transform: translate3d(0, 0, 0) rotate(360deg) scale(1); }
}
@keyframes drawJump {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  30% { transform: translate3d(0, -10px, 0) scale(1.08); }
  50% { transform: translate3d(0, -3px, 0) scale(1.03); }
  70% { transform: translate3d(0, -7px, 0) scale(1.06); }
}
@keyframes drawPulsePop {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  40% { transform: translate3d(0, 0, 0) scale(1.22); }
  60% { transform: translate3d(0, 0, 0) scale(0.92); }
}
@keyframes drawWobble {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  20% { transform: translate3d(3px, 0, 0) rotate(14deg); }
  40% { transform: translate3d(-3px, 0, 0) rotate(-12deg); }
  60% { transform: translate3d(2px, 0, 0) rotate(10deg); }
  80% { transform: translate3d(-2px, 0, 0) rotate(-8deg); }
}
@keyframes drawFlipReveal {
  0% { transform: scaleX(1); }
  45% { transform: scaleX(0.08); }
  100% { transform: scaleX(1); }
}
@keyframes drawFaceIn {
  0%, 45% { opacity: 0; }
  100% { opacity: 1; }
}

.draw-card-back.anim-quiet {
  -webkit-animation: drawTwinkleSoft var(--draw-dur, 3.5s) ease-in-out infinite;
  animation: drawTwinkleSoft var(--draw-dur, 3.5s) ease-in-out infinite;
  -webkit-animation-delay: var(--draw-delay, 0s);
  animation-delay: var(--draw-delay, 0s);
}
.draw-card-back.anim-standout {
  z-index: 1;
  border-color: #c4b04a;
  box-shadow: 0 0 10px rgba(212, 168, 67, 0.45);
}
/* One transform animation only — dual opacity+transform often drops motion on iOS */
.draw-card-back.anim-standout.anim-shake {
  -webkit-animation: drawShakeHeavy var(--draw-dur, 0.75s) ease-in-out infinite;
  animation: drawShakeHeavy var(--draw-dur, 0.75s) ease-in-out infinite;
}
.draw-card-back.anim-standout.anim-drift {
  -webkit-animation: drawDriftHeavy var(--draw-dur, 1.5s) ease-in-out infinite;
  animation: drawDriftHeavy var(--draw-dur, 1.5s) ease-in-out infinite;
}
.draw-card-back.anim-standout.anim-spin {
  -webkit-animation: drawSpin var(--draw-dur, 1.2s) linear infinite;
  animation: drawSpin var(--draw-dur, 1.2s) linear infinite;
}
.draw-card-back.anim-standout.anim-jump {
  -webkit-animation: drawJump var(--draw-dur, 0.8s) ease-in-out infinite;
  animation: drawJump var(--draw-dur, 0.8s) ease-in-out infinite;
}
.draw-card-back.anim-standout.anim-pulse {
  -webkit-animation: drawPulsePop var(--draw-dur, 0.95s) ease-in-out infinite;
  animation: drawPulsePop var(--draw-dur, 0.95s) ease-in-out infinite;
}
.draw-card-back.anim-standout.anim-wobble {
  -webkit-animation: drawWobble var(--draw-dur, 0.9s) ease-in-out infinite;
  animation: drawWobble var(--draw-dur, 0.9s) ease-in-out infinite;
}

@supports not (width: 1cqw) {
  .draw-card-back {
    width: 70%;
    height: auto;
    max-height: 100%;
    aspect-ratio: 2 / 3;
  }
}

/* ---------- Picker ---------- */
.picker-card {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.3;
}
.picker-card:hover {
  border-color: var(--accent-gold);
  background: #3d2566;
  transform: scale(1.03);
}
.picker-card.used { opacity: 0.28; pointer-events: none; }
.picker-card .num {
  color: var(--accent-gold);
  font-weight: 700;
  font-size: 12px;
  display: block;
  margin-bottom: 2px;
}
.picker-card img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 4px;
  border: 1px solid rgba(212,168,67,0.25);
}

/* ---------- Camera modal ---------- */
.camera-frame {
  border: 3px solid var(--accent-gold);
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  position: relative;
  aspect-ratio: 2 / 3.5;
  max-height: 48vh;
  margin-left: auto;
  margin-right: auto;
}
.camera-frame.compact {
  max-height: 14vh;
}
#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scan-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px rgba(212,168,67,0.85),
              inset 0 0 40px rgba(212,168,67,0.15);
}
.scan-guide::after {
  content: "◈";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 40px;
  color: rgba(212,168,67,0.5);
  text-shadow: 0 0 18px rgba(212,168,67,0.7);
}

/* ---------- Recognition results ---------- */
.match-option {
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  transition: all 0.2s;
  cursor: pointer;
  min-height: 150px;
  padding: 8px !important;
}
.match-option:hover {
  border-color: var(--accent-gold);
  background: #2a1b4e;
  transform: translateY(-2px);
}
.match-option img {
  height: 68px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid rgba(212,168,67,0.3);
}
.match-confidence {
  font-size: 13px;
  color: var(--accent-gold);
  font-weight: 700;
  letter-spacing: 0.6px;
}

/* ---------- Reading summary ---------- */
.reading-summary {
  background: linear-gradient(135deg, #3d2566 0%, var(--bg-card) 100%);
  border: 1px solid var(--accent-gold);
  border-radius: 14px;
}

/* ---------- Model selector ---------- */
.model-select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.model-select:hover,
.model-select:focus {
  border-color: var(--accent-purple);
  outline: none;
}
.model-select option {
  background: var(--bg-card);
  color: var(--text-light);
}

/* ---------- Chat ---------- */
.chat-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0,0,0,0.6);
  transform: translateX(100%);
  transition: transform 0.35s ease, visibility 0.35s;
  z-index: 60;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  visibility: hidden;
}
.chat-drawer.open {
  transform: translateX(0);
  pointer-events: auto;
  visibility: visible;
}
@media (max-width: 480px) {
  .chat-drawer { max-width: 100%; }
}

.chat-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-message.user {
  background: var(--chat-user);
  color: var(--text-light);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.chat-message.ai {
  background: var(--chat-ai);
  color: var(--text-light);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.chat-message.error {
  background: rgba(231,76,60,0.12);
  border: 1px solid rgba(231,76,60,0.4);
  color: #f5b7b1;
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-purple); }

/* ---------- Misc ---------- */
.modal-backdrop {
  background: rgba(10, 5, 22, 0.82);
  backdrop-filter: blur(6px);
}
.text-shadow-gold { text-shadow: 0 0 24px rgba(212,168,67,0.35); }

@keyframes titleTwinkle {
  0%, 100% {
    opacity: 0.25;
    text-shadow: 0 0 4px rgba(212, 168, 67, 0.05);
    transform: scale(0.92);
  }
  50% {
    opacity: 1;
    text-shadow: 0 0 16px rgba(212, 168, 67, 0.95), 0 0 28px rgba(212, 168, 67, 0.45);
    transform: scale(1.08);
  }
}
.title-star {
  display: inline-block;
  -webkit-animation: titleTwinkle 2.2s ease-in-out infinite;
  animation: titleTwinkle 2.2s ease-in-out infinite;
  will-change: opacity, transform, text-shadow;
}
.title-star--delay {
  -webkit-animation-delay: 1.1s;
  animation-delay: 1.1s;
}

.divider-glow {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
}

.hidden { display: none !important; }

@media (max-width: 480px) {
  body { font-size: 18px; }

  .camera-panel {
    min-height: calc(100dvh - 24px);
  }

  .camera-frame {
    max-height: 42vh;
  }

  .camera-frame.compact {
    max-height: 11vh;
  }

  #capturePreview {
    max-height: 58px;
  }

  .match-option {
    min-height: 142px;
  }

  .match-option img {
    height: 60px;
  }
}

@media (max-height: 720px) {
  .camera-panel {
    margin-top: 8px !important;
    margin-bottom: 8px !important;
    padding: 12px !important;
  }

  .camera-frame.compact {
    max-height: 9vh;
  }

  #cameraStatus {
    margin-bottom: 8px !important;
  }

  #capturePreview {
    max-height: 50px;
  }

  .match-option {
    min-height: 128px;
    padding: 6px !important;
  }

  .match-option img {
    height: 52px;
  }
}

@keyframes spiritPulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}
.spirit-pulse { animation: spiritPulse 1.8s ease-in-out infinite; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.35s ease both; }

/* Spinner */
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(212,168,67,0.25);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
