/* ═══════════ ศาลาโหร — design tokens (จากสเปค 1a) ═══════════ */
:root {
  --bg-base: #100e1c;
  --bg-panel: #171429;
  --gold: #e0b869;
  --gold-light: #f0d9a8;
  --gold-grad-from: #e6c078;
  --gold-grad-to: #c99738;
  --on-gold: #20180a;
  --text-primary: #f4ecdc;
  --text-body: #f2ece0;
  --text-muted: rgba(242, 236, 224, .62);
  --text-faint: rgba(242, 236, 224, .35);
  --terra: #c98b5c;
  --border-gold-strong: rgba(224, 184, 105, .45);
  --border-gold: rgba(224, 184, 105, .18);
  --border-gold-faint: rgba(224, 184, 105, .16);
  --fill-gold-wash: rgba(224, 184, 105, .09);
  --font-ui: 'IBM Plex Sans Thai', system-ui, sans-serif;
  --font-serif: 'Trirong', serif;
  --gutter: 22px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg-base);
  color: var(--text-body);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100dvh;
  padding-bottom: 84px; /* เผื่อ tab bar มือถือ */
}
button { font-family: inherit; cursor: pointer; }
a { text-decoration: none; color: inherit; }
input { font-family: inherit; }
h1, h2, h3 { line-height: 1.3; }

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

/* ═══════════ App bar ═══════════ */
.appbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(16, 14, 28, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-gold-faint);
}
.appbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 12px var(--gutter);
  max-width: 1320px; margin: 0 auto;
}
.wordmark { display: block; line-height: 0; }
.wordmark img { height: 44px; width: auto; display: block; }
.topnav { display: none; }
.appbar-right { display: flex; align-items: center; gap: 10px; }
.vip-badge {
  padding: 7px 12px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-grad-from), var(--gold-grad-to));
  color: var(--on-gold); font-weight: 600; font-size: 11.5px; line-height: 1;
}
.vip-badge.off {
  background: none; border: 1px solid var(--border-gold-strong); color: var(--gold);
}
.menu-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid rgba(224, 184, 105, .4);
  background: none; color: var(--gold); font-size: 14px; line-height: 1;
}

/* ═══════════ Layout (main + sidebar) ═══════════ */
.layout { max-width: 1320px; margin: 0 auto; display: block; }
.main { min-width: 0; }
.sidebar { display: none; }

.view { display: none; animation: viewIn .35s ease; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ═══════════ Hero ═══════════ */
.hero { position: relative; margin-top: 16px; padding: 0 var(--gutter) 22px; text-align: center; }
.hero-aura {
  position: absolute; left: 50%; top: 6px;
  width: 300px; height: 300px; border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(224, 184, 105, .22), transparent 62%);
  animation: auraPulse 6s ease-in-out infinite;
  pointer-events: none;
}
.hero-flex { position: relative; }
.hero-stage-wrap { position: relative; }
.hero-stage {
  position: relative; height: 192px; overflow: hidden;
  max-width: 390px; margin: 0 auto;
}
.zodiac-wheel {
  position: absolute; left: 50%; top: 0;
  transform: translateX(-50%);
  opacity: .75;
  animation: wheelSpin 120s linear infinite;
}
.khom {
  position: absolute; left: 50%; top: 0;
  width: 179px; height: 348px;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  animation: khomFloat 5.5s ease-in-out infinite, khomBreath 4s ease-in-out infinite;
  filter: drop-shadow(0 12px 26px rgba(0, 0, 0, .55)) drop-shadow(0 0 22px rgba(224, 184, 105, .28));
}
.stage-scrim {
  position: absolute; left: -22px; right: -22px; bottom: 0; height: 110px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(16, 14, 28, 0) 0%, rgba(16, 14, 28, .5) 34%, rgba(16, 14, 28, .9) 72%, var(--bg-base) 100%);
}
.stage-shadow {
  position: absolute; left: 50%; bottom: 4px;
  width: 210px; height: 26px; border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(224, 184, 105, .22), transparent 70%);
}
.hero-caption {
  margin-top: 2px;
  font-weight: 500; font-size: 12px; line-height: 1;
  color: rgba(224, 184, 105, .9); letter-spacing: .4px;
}
.hero-date { margin-top: 6px; font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }
.hero-headline {
  margin-top: 3px;
  font-family: var(--font-serif);
  font-weight: 500; font-size: 22px; line-height: 1.28;
  color: var(--text-primary);
  min-height: 2.5em;
}
.hero-body {
  margin: 10px auto 0; max-width: 480px;
  font-size: 13.5px; line-height: 1.75; color: var(--text-muted);
}
.lucky-row {
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px;
}
.lucky-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--fill-gold-wash); border: 1px solid var(--border-gold);
  font-size: 11.5px; line-height: 1.4; color: var(--text-body);
}
.lucky-pill b { color: var(--gold); font-weight: 600; }
.lucky-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35); display: inline-block; }

.cta-row { display: flex; gap: 10px; margin-top: 14px; justify-content: center; }
.btn-primary {
  flex: 1; max-width: 260px;
  padding: 13px 18px; border: 0; border-radius: 12px;
  background: linear-gradient(180deg, var(--gold-grad-from), var(--gold-grad-to));
  color: var(--on-gold); font-weight: 600; font-size: 14px; line-height: 1;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(224, 184, 105, .25); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  padding: 13px 16px; border-radius: 12px;
  border: 1px solid var(--border-gold-strong);
  background: none; color: var(--gold); font-weight: 500; font-size: 14px; line-height: 1;
  transition: background .15s ease;
}
.btn-ghost:hover { background: var(--fill-gold-wash); }

/* ═══════════ Panel ศาสตร์ทั้งหมด ═══════════ */
.panel {
  background: var(--bg-panel);
  border-top: 1px solid var(--border-gold-faint);
  padding: 14px var(--gutter) 28px;
}
.panel-plain { background: none; border-top: 0; margin-top: 8px; }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.panel-head h2 { font-weight: 600; font-size: 14px; color: var(--text-body); }
.panel-link { font-size: 12px; color: rgba(224, 184, 105, .85); }

.grid-sciences { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sci-card {
  padding: 11px 8px; border-radius: 14px;
  background: var(--fill-gold-wash);
  border: 1px solid var(--border-gold);
  text-align: center; color: var(--text-body);
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.sci-card:hover { background: rgba(224, 184, 105, .16); border-color: var(--border-gold-strong); transform: translateY(-2px); }
.sci-glyph { display: block; font-family: var(--font-serif); font-size: 20px; color: var(--gold); line-height: 1.2; }
.sci-label { display: block; font-weight: 500; font-size: 11.5px; line-height: 1.3; margin-top: 8px; }

.ad-slot {
  margin-top: 10px; height: 50px; border-radius: 12px;
  border: 1px dashed rgba(242, 236, 224, .22);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-faint);
}

/* ── ศาสตร์พิเศษ (พรีเมียม จ่ายรายครั้ง) ── */
.premium-head { margin-top: 20px; }
.premium-head h2 { color: var(--gold); }
.premium-row { display: grid; grid-template-columns: 1fr; gap: 12px; }
.premium-card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left;
  padding: 18px 16px 16px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(224, 184, 105, .16), rgba(224, 184, 105, .05) 60%);
  border: 1.5px solid var(--border-gold-strong);
  box-shadow: 0 0 24px rgba(224, 184, 105, .1);
  color: var(--text-body);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.premium-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 8px 32px rgba(224, 184, 105, .22);
}
.pm-badge {
  position: absolute; top: -10px; right: 14px;
  padding: 4px 12px; border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-grad-from), var(--gold-grad-to));
  color: var(--on-gold); font-size: 10.5px; font-weight: 700; line-height: 1;
}
.pm-art {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  width: 122px; height: 128px;
  filter: drop-shadow(0 0 14px rgba(224, 184, 105, .28));
  pointer-events: none;
}
.pm-art svg, .pm-art img { width: 100%; height: 100%; object-fit: contain; display: block; }
.premium-card { padding-right: 146px; min-height: 168px; justify-content: center; }
.premium-card:hover .pm-art { filter: drop-shadow(0 0 22px rgba(224, 184, 105, .5)); }
@media (min-width: 768px) {
  .premium-card { padding: 26px 190px 24px 22px; min-height: 200px; }
  .pm-art { width: 168px; height: 172px; right: 14px; }
  .pm-title { font-size: 20px; }
  .pm-sub { font-size: 13px; }
  .pm-price { font-size: 13.5px; padding: 7px 14px; }
}
.pm-title { font-family: var(--font-serif); font-weight: 600; font-size: 17px; color: var(--gold-light); }
.pm-sub { font-size: 12px; line-height: 1.6; color: var(--text-muted); }
.pm-price {
  margin-top: 4px; padding: 6px 12px; border-radius: 999px;
  background: rgba(224, 184, 105, .14);
  border: 1px solid var(--border-gold);
  color: var(--gold); font-weight: 700; font-size: 12.5px; line-height: 1;
}
@media (min-width: 768px) {
  .premium-row { grid-template-columns: 1fr 1fr; }
}

/* ═══════════ หน้าใน (ไพ่ / ปฏิทิน / โปรไฟล์) ═══════════ */
.page-head { padding: 24px var(--gutter) 0; text-align: center; }
.page-title {
  font-family: var(--font-serif);
  font-weight: 500; font-size: 24px; color: var(--text-primary);
}
.page-sub { margin-top: 6px; font-size: 13px; color: var(--text-muted); max-width: 460px; margin-inline: auto; }

/* ── ไพ่ยิปซี ── */
.tarot-topic { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 16px var(--gutter) 0; }
.chip {
  padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--border-gold);
  background: var(--fill-gold-wash); color: var(--text-body);
  font-weight: 500; font-size: 12.5px; line-height: 1;
  transition: all .15s ease;
}
.chip.active {
  background: linear-gradient(180deg, var(--gold-grad-from), var(--gold-grad-to));
  color: var(--on-gold); border-color: transparent; font-weight: 600;
}
.tarot-stage {
  display: flex; justify-content: center; align-items: center; gap: 14px;
  min-height: 200px; padding: 20px var(--gutter) 0;
  perspective: 900px;
}
.tcard {
  width: 96px; height: 165px; border-radius: 11px;
  position: relative; transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.2, .7, .3, 1);
  border: 0; background: none; padding: 0;
}
.tcard-inner {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.3, .1, .3, 1);
}
.tcard.flipped .tcard-inner { transform: rotateY(180deg); }
.tcard-face {
  position: absolute; inset: 0; border-radius: 11px;
  backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
}
.tcard-back {
  background: linear-gradient(160deg, #2a2148, #453069);
  border: 1px solid rgba(224, 184, 105, .45);
  color: var(--gold); font-family: var(--font-serif); font-size: 24px;
}
.tcard-front {
  transform: rotateY(180deg);
  background: #f4ecdc;
  border: 1px solid var(--gold-grad-to);
  color: #20180a; padding: 0; overflow: hidden;
}
.tcard-front img {
  width: 100%; height: 100%; object-fit: cover; border-radius: inherit;
  display: block;
}
.tcard.pickable:hover { transform: translateY(-10px); }
.tcard.pickable .tcard-inner { box-shadow: 0 8px 22px rgba(0, 0, 0, .4); }
.tcard.dimmed { opacity: .35; pointer-events: none; }
/* ── กองไพ่ + สับไพ่ (riffle) ── */
.deck { position: relative; width: 96px; height: 165px; }
.deck .dcard {
  position: absolute; inset: 0; border-radius: 11px;
  background: linear-gradient(160deg, #2a2148, #453069);
  border: 1px solid rgba(224, 184, 105, .45);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-family: var(--font-serif); font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
}
.deck .dcard:nth-child(1) { transform: rotate(-2deg) translateY(2px); }
.deck .dcard:nth-child(3) { transform: rotate(2deg) translateY(-1px); }
.deck .dcard:nth-child(5) { transform: rotate(-1deg); }
.deck.riffling .dcard:nth-child(odd) { animation: riffleL .52s ease-in-out infinite; }
.deck.riffling .dcard:nth-child(even) { animation: riffleR .52s ease-in-out infinite; }
.deck.riffling .dcard:nth-child(1) { animation-delay: 0s; }
.deck.riffling .dcard:nth-child(2) { animation-delay: .09s; }
.deck.riffling .dcard:nth-child(3) { animation-delay: .17s; }
.deck.riffling .dcard:nth-child(4) { animation-delay: .26s; }
.deck.riffling .dcard:nth-child(5) { animation-delay: .34s; }
.deck.riffling .dcard:nth-child(6) { animation-delay: .43s; }
@keyframes riffleL {
  0%, 100% { transform: translate(0, 0) rotate(0); z-index: 1; }
  45% { transform: translate(-84px, -10px) rotate(-11deg); z-index: 6; }
  60% { transform: translate(-60px, -4px) rotate(-7deg); z-index: 6; }
}
@keyframes riffleR {
  0%, 100% { transform: translate(0, 0) rotate(0); z-index: 1; }
  45% { transform: translate(84px, -10px) rotate(11deg); z-index: 6; }
  60% { transform: translate(60px, -4px) rotate(7deg); z-index: 6; }
}

/* กองไพ่ขนาดเล็ก (ตอนสับ/ตัดจากสำรับที่แผ่) */
.deck.mini { width: 58px; height: 94px; }
.deck.mini .dcard { border-radius: 8px; font-size: 15px; }

/* ── ตัดไพ่: แยกสองกอง สลับ แล้วรวม ── */
.cutwrap { position: relative; width: 58px; height: 94px; }
.cutwrap .deck { position: absolute; inset: 0; }
.deck.cut-a { animation: cutA 1.15s ease both; }
.deck.cut-b { animation: cutB 1.15s ease both; }
@keyframes cutA {
  0% { transform: none; z-index: 1; }
  35% { transform: translate(-16px, 4px) rotate(-4deg); z-index: 1; }
  70% { transform: translate(-6px, -8px) rotate(-2deg); z-index: 3; }
  100% { transform: none; z-index: 3; }
}
@keyframes cutB {
  0% { transform: translateY(-6px); z-index: 3; }
  35% { transform: translate(76px, -22px) rotate(10deg); z-index: 3; }
  70% { transform: translate(60px, 14px) rotate(5deg); z-index: 1; }
  100% { transform: translateY(4px); z-index: 1; }
}

/* ── แจกไพ่ออกจากกอง ── */
.tcard.dealing {
  animation: dealIn .55s cubic-bezier(.2, .75, .3, 1) backwards;
}
@keyframes dealIn {
  from {
    transform: translateX(var(--dx, 0)) translateY(-12px) rotate(var(--dr, 0)) scale(.92);
    opacity: .4;
  }
  to { transform: none; opacity: 1; }
}
.tarot-hint { color: var(--text-muted); font-size: 13px; text-align: center; width: 100%; }
.tarot-stage { flex-wrap: wrap; }

/* ── แผ่สำรับให้เลือก 3 ใบ ── */
.spread {
  display: flex; flex-wrap: wrap; justify-content: center;
  padding: 10px 8px 4px 8px; max-width: 400px; /* 11 ใบ/แถว → 2 แถวสมดุล */
  row-gap: 12px;
}
.spread-card {
  width: 58px; height: 94px; margin-right: -26px;
  border-radius: 8px; border: 1px solid rgba(224, 184, 105, .45);
  background: linear-gradient(160deg, #2a2148, #453069);
  color: var(--gold); font-family: var(--font-serif); font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: -3px 3px 8px rgba(0, 0, 0, .35);
  position: relative; padding: 0;
  transition: transform .18s ease, box-shadow .18s ease;
  animation: spreadIn .35s ease backwards;
}
.spread-card:last-child { margin-right: 0; }
.spread-card:hover { transform: translateY(-9px); z-index: 5; }
.spread-card.sel {
  transform: translateY(-14px); z-index: 6;
  border-color: var(--gold-light);
  background: linear-gradient(160deg, #453069, #6a3a7e);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .45), 0 0 14px rgba(224, 184, 105, .35);
}
.spread-card.sel::after {
  content: attr(data-order);
  position: absolute; top: -9px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-grad-from), var(--gold-grad-to));
  color: var(--on-gold); font-family: var(--font-ui);
  font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
@keyframes spreadIn {
  from { opacity: 0; transform: translateY(14px) scale(.9); }
  to { opacity: 1; transform: none; }
}

/* ── ช่องไพ่ตอนเปิดผล: อดีต/ปัจจุบัน/อนาคต ── */
.tcard-slot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.slot-label { font-size: 12px; font-weight: 600; color: rgba(224, 184, 105, .9); letter-spacing: .4px; }
.slot-tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--fill-gold-wash); border: 1px solid var(--border-gold);
  font-size: 11px; font-weight: 600; color: var(--gold);
}
.result-card.tarot-3 { display: flex; gap: 14px; align-items: flex-start; }
.result-card.tarot-3 + .tarot-3 { margin-top: 12px; }
.t-result-img.t-small { width: 84px; margin: 0; flex: none; }
.result-card.tarot-3 .t-body { min-width: 0; }
.result-card.tarot-3 h3 { margin-top: 6px; }
.tarot-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 20px var(--gutter); }
.tarot-actions .btn-primary { flex: none; min-width: 150px; }
.btn-primary:disabled {
  opacity: .45; cursor: default;
  transform: none !important; box-shadow: none !important;
}
.tarot-result { max-width: 560px; margin: 0 auto; padding: 0 var(--gutter) 30px; }
.result-card {
  background: var(--bg-panel); border: 1px solid var(--border-gold);
  border-radius: 16px; padding: 20px;
  animation: viewIn .4s ease;
}
.t-result-img {
  display: block; width: 128px; margin: 0 auto 14px;
  border-radius: 8px; border: 1px solid var(--border-gold-strong);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .35);
}
.result-card h3 {
  font-family: var(--font-serif); font-weight: 600; font-size: 19px;
  color: var(--gold);
}
.result-card .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.result-card p { margin-top: 10px; font-size: 13.5px; line-height: 1.75; }
.result-card .advice {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--fill-gold-wash); border: 1px solid var(--border-gold);
  font-size: 13px;
}
.result-card .advice b { color: var(--gold); }

/* ── กราฟชีวิต ── */
.graph-wrap { max-width: 640px; margin: 0 auto; padding: 18px var(--gutter) 30px; }
.graph-wrap .info-box { margin-top: 12px; }
.info-box {
  background: var(--fill-gold-wash);
  border: 1px solid var(--border-gold);
  border-left: 3px solid var(--gold);
  border-radius: 12px;
  padding: 14px 16px;
}
.info-box h2 {
  font-family: var(--font-serif);
  font-size: 15px; font-weight: 600; color: var(--gold);
  margin-bottom: 6px;
}
.info-box p { font-size: 12.5px; line-height: 1.75; color: var(--text-body); }
.info-box p + p { margin-top: 8px; }
.info-box b { color: var(--gold-light); font-weight: 600; }
.info-box .info-note {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--border-gold);
  font-size: 11.5px; color: var(--text-muted);
}
.info-box .info-note b { color: var(--text-muted); }
.info-more p:first-child { margin-top: 8px; }
.info-toggle {
  margin-top: 8px; padding: 0;
  background: none; border: 0;
  color: var(--gold); font-size: 12px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}
.info-toggle:hover { color: var(--gold-light); }
.graph-profile {
  display: flex; align-items: center; gap: 14px;
  background: var(--fill-gold-wash);
  border: 1px solid var(--border-gold);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.gp-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--gold);
  background: rgba(224, 184, 105, .12);
  border: 1px solid var(--border-gold-strong);
}
.gp-info { display: grid; gap: 2px; min-width: 0; flex: 1; }
.gp-info b { font-size: 15px; color: var(--text-primary); }
.gp-info span { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.gp-edit { padding: 9px 14px; font-size: 12.5px; flex: none; }
.graph-card {
  background: var(--bg-panel); border: 1px solid var(--border-gold);
  border-radius: 16px; padding: 16px 14px 8px;
}
.graph-card svg { width: 100%; height: auto; display: block; }
.graph-meta { font-size: 12px; color: var(--text-muted); margin: 0 4px 8px; }
.graph-wrap .pr-row { margin-top: 12px; }
.base-table-scroll { overflow-x: auto; margin: 4px 0 10px; }
.base-table {
  border-collapse: collapse; width: 100%; min-width: 520px;
  font-size: 11px; text-align: center;
}
.base-table th {
  text-align: left; font-weight: 500; color: var(--text-muted);
  padding: 4px 8px 4px 4px; white-space: nowrap;
}
.base-table td { padding: 4px 2px; border: 1px solid var(--border-gold-faint); min-width: 30px; }
.base-table .bt-pred { font-size: 9.5px; color: var(--text-muted); border: 1px solid var(--border-gold-faint); }
.base-table .bt-sum td { color: var(--gold-light); }
.base-table .bt-num td { color: var(--gold); font-weight: 700; background: var(--fill-gold-wash); }
.cycle-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 2px 0 6px;
}
.cycle-btn {
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border-gold); background: none;
  color: var(--gold); font-size: 11.5px; line-height: 1;
}
.cycle-btn:disabled { opacity: .35; cursor: default; }
.cycle-btn:not(:disabled):hover { background: var(--fill-gold-wash); }
.cycle-label { font-size: 12px; font-weight: 600; color: var(--text-body); text-align: center; }
.graph-legend {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
  padding: 8px 0 10px; font-size: 11px; color: var(--text-muted);
}
.graph-legend span { display: inline-flex; align-items: center; gap: 5px; }
.graph-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.life-head { font-size: 15px; font-weight: 600; margin: 18px 2px 10px; color: var(--text-body); }
.life-item {
  background: var(--bg-panel); border: 1px solid var(--border-gold);
  border-radius: 12px; margin-bottom: 8px; overflow: hidden;
}
.life-item summary {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; cursor: pointer; list-style: none;
}
.life-item summary::-webkit-details-marker { display: none; }
.life-item[open] summary { border-bottom: 1px solid var(--border-gold-faint); }
.life-badge {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-weight: 600; font-size: 14px;
  background: var(--fill-gold-wash); color: var(--gold);
}
.life-badge.lvl-high { background: rgba(158, 216, 158, .15); color: #9ed89e; }
.life-badge.lvl-low { background: rgba(224, 100, 76, .15); color: #e0644c; }
.life-name { font-weight: 600; font-size: 13.5px; flex: 1; }
.life-name small { font-weight: 400; color: var(--text-muted); }
.life-lvl { font-size: 11px; color: var(--text-muted); text-align: right; }
.life-item p { padding: 10px 14px 0; font-size: 13px; line-height: 1.7; }
.life-item p:last-child { padding-bottom: 14px; }
.life-desc { color: var(--text-muted); font-size: 11.5px !important; }
.rel-list { list-style: none; margin-top: 8px; }
.rel-list li { padding: 8px 0; border-bottom: 1px solid var(--border-gold-faint); font-size: 13px; line-height: 1.7; }
.rel-list li:last-child { border-bottom: 0; }

/* ── ปฏิทิน ── */
.cal-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 11px;
  padding: 18px var(--gutter) 0; max-width: 640px; margin: 0 auto;
}
.cal-card {
  background: var(--bg-panel); border: 1px solid var(--border-gold);
  border-radius: 16px; padding: 16px 14px; min-height: 104px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
}
.cal-card .c-glyph { font-family: var(--font-serif); font-size: 20px; color: var(--gold); }
.cal-card .c-title { font-weight: 600; font-size: 13.5px; line-height: 1.3; color: var(--text-body); }
.cal-card .c-value { font-family: var(--font-serif); font-size: 17px; color: var(--gold-light); line-height: 1.35; }
.cal-card .c-sub { font-size: 11.5px; line-height: 1.5; color: var(--text-muted); }
.wanphra-list { list-style: none; max-width: 596px; margin: 0 auto; }
.wanphra-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border-gold-faint);
  font-size: 13px;
}
.wanphra-list li span:last-child { color: var(--text-muted); font-size: 12px; }
.wanphra-list li.today { color: var(--gold); font-weight: 600; }
.note { margin: 14px auto 0; max-width: 596px; font-size: 11px; color: var(--text-faint); line-height: 1.6; }

/* ── โปรไฟล์ ── */
.profile-form { max-width: 460px; margin: 0 auto; padding: 20px var(--gutter) 0; display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field span { font-weight: 500; font-size: 12.5px; color: var(--text-muted); }
.field em { color: var(--terra); font-style: normal; }
.field input {
  padding: 12px 14px; border-radius: 12px;
  background: var(--bg-panel); border: 1px solid var(--border-gold);
  color: var(--text-body); font-size: 14px;
  color-scheme: dark;
}
.field input:focus { outline: none; border-color: var(--border-gold-strong); }
.profile-result { max-width: 560px; margin: 20px auto 0; padding: 0 var(--gutter) 30px; display: grid; gap: 12px; }
.save-banner {
  background: rgba(158, 216, 158, .08);
  border: 1px solid rgba(158, 216, 158, .35);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  animation: viewIn .35s ease;
}
.save-banner p { font-size: 13.5px; line-height: 1.7; }
.save-banner b { color: #9ed89e; }
.banner-actions {
  display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px;
}
.banner-btn {
  padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--border-gold-strong);
  background: var(--fill-gold-wash);
  color: var(--gold); font-weight: 600; font-size: 13px; line-height: 1;
  transition: background .15s ease, transform .15s ease;
}
.banner-btn:hover { background: rgba(224, 184, 105, .22); transform: translateY(-1px); }
.pr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }

/* ═══════════ Sidebar ═══════════ */
.side-widget {
  background: var(--bg-panel); border: 1px solid var(--border-gold);
  border-radius: 16px; padding: 18px;
}
.side-widget h3 { font-family: var(--font-serif); font-size: 16px; font-weight: 600; color: var(--gold); }
.side-widget .sw-line { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 8px 0; border-bottom: 1px solid var(--border-gold-faint); }
.side-widget .sw-line:last-child { border-bottom: 0; }
.side-widget .sw-line span:last-child { color: var(--gold-light); text-align: right; }
.ad-slot-side { height: 250px; margin-top: 14px; }

/* ═══════════ Tab bar ═══════════ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(16, 14, 28, .94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-gold-faint);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: rgba(242, 236, 224, .5);
  font-weight: 500; font-size: 10.5px; line-height: 1.6;
}
.tab-glyph { font-size: 17px; line-height: 1; }
.tab.active { color: var(--gold); }

/* ═══════════ Modal ═══════════ */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 7, 16, .72);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 560px; max-height: 86dvh;
  background: var(--bg-panel);
  border: 1px solid var(--border-gold);
  border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column;
  animation: sheetUp .3s cubic-bezier(.2, .8, .3, 1);
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 10px;
}
.modal-head h2 { font-family: var(--font-serif); font-weight: 600; font-size: 19px; color: var(--gold); }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border-gold); background: none;
  color: var(--text-muted); font-size: 13px;
}
.modal-body { padding: 4px 20px 26px; overflow-y: auto; }
.modal-body .m-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.m-form { display: grid; gap: 12px; }
.m-form input, .m-form select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  background: var(--bg-base); border: 1px solid var(--border-gold);
  color: var(--text-body); font-size: 14px; font-family: inherit;
  color-scheme: dark;
}
.m-form .btn-primary { flex: none; max-width: none; }
.m-result { margin-top: 16px; }
.m-result .name-part + .name-part { margin-top: 12px; }
.zodiac-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.zodiac-grid .sci-card .sci-glyph { font-size: 18px; }
.big-number {
  font-family: var(--font-serif); font-size: 44px; font-weight: 600;
  color: var(--gold); text-align: center; line-height: 1.2;
}
.grade {
  text-align: center; font-weight: 600; font-size: 13px;
  margin-top: 2px;
}
.grade.good { color: #9ed89e; }
.grade.mid { color: var(--gold-light); }
.grade.bad { color: #e08c7c; }
.big-number.bad { color: #e0644c; }
.big-number.good { color: #7fce7f; }
.siamsi-poem {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 16.5px; line-height: 2.1;
  color: var(--gold-light);
  margin-top: 6px;
}
.siamsi-sticks {
  display: flex; justify-content: center; align-items: flex-end; gap: 10px;
  height: 70px; margin: 10px 0 16px;
}
.siamsi-sticks i {
  width: 8px; border-radius: 4px 4px 0 0; display: block;
  background: #e2c37f;
}
.siamsi-sticks i:nth-child(1) { height: 46px; }
.siamsi-sticks i:nth-child(2) { height: 60px; background: #d99a5b; }
.siamsi-sticks i:nth-child(3) { height: 40px; }
.siamsi-sticks i:nth-child(4) { height: 54px; background: var(--terra); }
.shaking .siamsi-sticks { animation: shake .18s linear infinite; }
@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-4px) rotate(-2deg); }
  75% { transform: translateX(4px) rotate(2deg); }
}
.lotto-nums { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.lotto-ball {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--gold-grad-from), var(--gold-grad-to));
  color: var(--on-gold); font-family: var(--font-serif); font-weight: 600; font-size: 20px;
}
.moon-vis { text-align: center; font-size: 64px; line-height: 1.3; }

/* ═══════════ ปุ่มแชร์คำทำนาย ═══════════ */
.share-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--border-gold);
  flex-wrap: wrap; width: 100%;
}
.result-card.tarot-3 + .share-row { border-top: 0; }
.share-row > span { font-size: 11.5px; color: var(--text-muted); }
.share-mini {
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border-gold-strong);
  background: var(--fill-gold-wash); color: var(--gold);
  font-size: 12px; font-weight: 600; line-height: 1;
  transition: background .15s ease;
}
.share-mini:hover { background: rgba(224, 184, 105, .2); }
/* ── ป๊อปอัพพรีวิวการ์ดแชร์ ── */
.share-pop[hidden] { display: none; }
.share-pop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8, 7, 16, .8);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.share-pop-card {
  width: 100%; max-width: 440px; max-height: 92dvh;
  background: var(--bg-panel);
  border: 1px solid var(--border-gold);
  border-radius: 22px;
  display: flex; flex-direction: column;
  animation: sheetUp .3s cubic-bezier(.2, .8, .3, 1);
}
.share-pop-body { padding: 4px 20px 22px; overflow-y: auto; text-align: center; }
.share-preview {
  display: block; max-width: 100%; max-height: 52dvh;
  margin: 0 auto 14px;
  border-radius: 14px;
  border: 1px solid var(--border-gold);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
}
.share-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.share-actions .btn-primary { flex: none; max-width: none; }
.share-pop .note { margin-top: 12px; }

/* ═══════════ Animations (จากสเปค) ═══════════ */
@keyframes khomFloat {
  0%, 100% { transform: translate(-50%, 0) scale(1); }
  50% { transform: translate(-50%, -7px) scale(1.008); }
}
@keyframes khomBreath { 0%, 100% { opacity: .9; } 50% { opacity: 1; } }
@keyframes wheelSpin { to { transform: translateX(-50%) rotate(360deg); } }
@keyframes auraPulse {
  0%, 100% { opacity: .5; transform: translateX(-50%) scale(1); }
  50% { opacity: .85; transform: translateX(-50%) scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ═══════════ Tablet ≥768px ═══════════ */
@media (min-width: 768px) {
  .main { max-width: 720px; margin: 0 auto; }
  .grid-sciences { grid-template-columns: repeat(4, 1fr); }
  .panel { border-radius: 18px; border: 1px solid var(--border-gold-faint); margin: 18px var(--gutter) 0; }
  .hero-stage { max-width: 480px; }
  .tcard { width: 118px; height: 203px; }
  .deck { width: 118px; height: 203px; }
}

/* ═══════════ Desktop ≥1180px ═══════════ */
@media (min-width: 1180px) {
  body { padding-bottom: 40px; }
  .tabbar { display: none; }
  .menu-btn { display: none; }
  .topnav { display: flex; gap: 4px; }
  .topnav-link {
    padding: 9px 16px; border-radius: 999px;
    font-weight: 500; font-size: 13.5px; color: var(--text-muted);
    transition: all .15s ease;
  }
  .topnav-link:hover { color: var(--text-body); background: var(--fill-gold-wash); }
  .topnav-link.active { color: var(--gold); background: var(--fill-gold-wash); }

  .layout {
    display: grid; grid-template-columns: minmax(0, 1fr) 300px;
    gap: 28px; padding: 0 28px;
    align-items: start;
  }
  .main { max-width: none; }
  .sidebar { display: block; position: sticky; top: 76px; padding-top: 24px; }

  /* hero 2 คอลัมน์ */
  .hero { text-align: left; padding: 12px 28px 30px; }
  .hero-flex { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 30px; align-items: center; }
  .hero-aura { left: 210px; }
  .hero-stage { height: 300px; max-width: none; }
  .zodiac-wheel { width: 340px; height: 340px; }
  .khom { width: 250px; height: 486px; }
  .stage-shadow { bottom: 10px; }
  .hero-caption, .hero-date { text-align: center; }
  .hero-text { text-align: left; padding-bottom: 12px; }
  .hero-headline { font-size: 34px; }
  .hero-body { margin-left: 0; font-size: 14.5px; }
  .lucky-row, .cta-row { justify-content: flex-start; }
  .panel { margin: 10px 28px 0; }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 22px; }

  /* กราฟชีวิตบนเดสก์ท็อป: กางเต็มคอลัมน์หลัก */
  .graph-wrap { max-width: 960px; }
  .graph-card { padding: 20px 22px 12px; }
  .graph-meta { font-size: 13px; }
  .base-table { font-size: 12.5px; }
  .base-table .bt-pred { font-size: 11px; }
  .cycle-label { font-size: 14px; }
  .life-item summary { padding: 13px 18px; }
  .life-name { font-size: 14.5px; }
  .graph-wrap .pr-row { gap: 14px; }
}
