/* ============================================================
   สวนวินทร์ · Luxury Thai Redesign ("หิรัญบัฏ" Royal Silk)
   Default = light editorial: กระดาษสาอุ่น + หมึกเข้ม + ชาดราชวงศ์ + ทองคำเปลว
   Dark mode = "ราตรีเพชรา" Celestial Night: ทองโบราณบนหลังคาราตรี
   Fonts: Trirong (display serif ไทย) + Anuphan (body) + Cormorant Italic (accent ละติน)
   หมายเหตุ: แก้เฉพาะ skin/tokens — selector ทั้งหมดคงเดิมเพื่อไม่พัง landing.js/app.js
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Trirong:wght@400;500;600;700&family=Anuphan:wght@300;400;500;600;700&family=Cormorant:ital,wght@0,500;1,400;1,500&display=swap');

/* ---------- TOKENS: Light — Royal Silk (default) ---------- */
:root {
  --display: 'Trirong', Georgia, serif;
  --font: 'Anuphan', 'Sarabun', system-ui, -apple-system, sans-serif;

  /* shell */
  --bg: #F6EFE2;
  --bg-solid: #F8F2E7;
  --surface: #FFFDF7;
  --surface-2: #F3EBDA;
  --surface-sunk: #EEE4CE;
  --sidebar: #2C1B10;

  /* primary = ชาดราชวงศ์ (CTA / active) */
  --primary: #8C2F1B;
  --primary-strong: #742615;
  --on-primary: #FFF6EA;
  --bar: linear-gradient(90deg, #B0812E, #8C2F1B 55%, #D9AE5F);

  /* accent = หมึกซีเอียสสำหรับ heading/link */
  --accent: #55291A;
  --accent-soft: #F6E7DC;
  --gold2: #55291A;       /* legacy heading token (app.js) */
  --lilac: #8A54A8;       /* Max / ระดับสูง */
  --lilac-soft: #F4EAF8;

  --gold: #B0812E;        /* ทองคำเปลว — ใช้อย่างประณีต */
  --ink: #2B2013;
  --body: #4C4232;
  --muted: #7B6F58;
  --dim: #A79B80;

  --line: #E3D7BF;
  --line-soft: #EFE6D2;
  --line-strong: #D2C2A2;

  /* semantic multi-color — ปรับโทนอุ่นให้เข้าผ้าไหม */
  --ok: #1F7A48;
  --ok-bg: #E4F2E6;
  --warn: #A16207;
  --warn-bg: #FBF0CF;
  --warn-line: #EDD48A;
  --bad: #B0322E;
  --bad-bg: #FAE4DE;

  --tone-love: #C2334D;
  --tone-love-bg: #FBECEE;
  --tone-money: #0F766E;
  --tone-money-bg: #E1F1EE;
  --tone-work: #22689E;
  --tone-work-bg: #E8F1F9;
  --tone-health: #2F7D52;
  --tone-health-bg: #E6F3EA;
  --tone-mind: #7C4DBA;
  --tone-mind-bg: #F3ECFB;

  --radius: 16px;
  --radius-lg: 20px;
  --radius-sm: 12px;
  --shadow:
    0 0 0 1px rgba(64,45,24,.05),
    inset 0 1px 0 rgba(255,255,255,.65),
    0 2px 6px -2px rgba(64,45,24,.10),
    0 10px 26px -12px rgba(64,45,24,.22);
  --shadow-lg:
    0 0 0 1px rgba(64,45,24,.06),
    inset 0 1px 0 rgba(255,255,255,.65),
    0 18px 44px -14px rgba(64,45,24,.30),
    0 30px 60px -30px rgba(92,31,20,.25);
  --shadow-glow: 0 10px 30px rgba(140,47,27,.20);
  --focus-ring: 0 0 0 3px rgba(140,47,27,.28);
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);

  --grad: linear-gradient(135deg, #C98D4B 0%, #8C2F1B 100%);
  --grad-warm: linear-gradient(135deg, #D9AE5F 0%, #8C2F1B 55%, #5C1F14 100%);
  --grad-bar: linear-gradient(90deg, #B0812E, #8C2F1B, #D9AE5F);
}

/* ---------- TOKENS: Dark — Celestial Night ---------- */
:root[data-theme="dark"] {
  --bg: #0C0B13;
  --bg-solid: #0C0B13;
  --surface: #16141F;
  --surface-2: #1E1B2A;
  --surface-sunk: #100E18;
  --sidebar: #08070E;

  --primary: #E3C567;
  --primary-strong: #EBD08A;
  --on-primary: #231A04;
  --bar: linear-gradient(90deg, #E3C567, #9B8AC4 55%, #F0E2B6);

  --accent: #EAD9A8;
  --accent-soft: rgba(227,197,103,.12);
  --gold2: #F0E2B6;
  --lilac: #BBA3E3;
  --lilac-soft: rgba(186,163,227,.14);

  --gold: #E3C567;
  --ink: #F4F0E3;
  --body: #D2CCBB;
  --muted: #9C947F;
  --dim: #6F6857;

  --line: rgba(214,199,160,.16);
  --line-soft: rgba(214,199,160,.09);
  --line-strong: rgba(214,199,160,.28);

  --ok: #7FDCA6;
  --ok-bg: rgba(46,160,96,.16);
  --warn: #EFC75E;
  --warn-bg: rgba(240,196,80,.14);
  --warn-line: rgba(240,196,80,.38);
  --bad: #F2A69C;
  --bad-bg: rgba(217,88,74,.16);

  --tone-love: #F08CA0;
  --tone-love-bg: rgba(232,110,133,.15);
  --tone-money: #5FD3C4;
  --tone-money-bg: rgba(53,168,152,.16);
  --tone-work: #7CC0EF;
  --tone-work-bg: rgba(84,150,220,.16);
  --tone-health: #7FD9A8;
  --tone-health-bg: rgba(63,170,105,.16);
  --tone-mind: #CDB4F2;
  --tone-mind-bg: rgba(150,110,220,.17);

  --shadow:
    0 0 0 1px rgba(255,255,255,.06),
    inset 0 1px 0 rgba(255,255,255,.04),
    0 2px 16px rgba(0,0,0,.35);
  --shadow-lg:
    0 0 0 1px rgba(255,255,255,.08),
    inset 0 1px 0 rgba(255,255,255,.05),
    0 18px 50px rgba(0,0,0,.5);
  --shadow-glow: 0 0 32px rgba(227,197,103,.16);
  --focus-ring: 0 0 0 3px rgba(227,197,103,.4);

  --grad: linear-gradient(135deg, #E3C567 0%, #9B8AC4 100%);
  --grad-warm: linear-gradient(135deg, #EBD08A 0%, #B0812E 55%, #6E5318 100%);
  --grad-bar: linear-gradient(90deg, #E3C567, #9B8AC4, #F0E2B6);
}

/* ---------- prefers-color-scheme (no-JS default) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0C0B13; --bg-solid: #0C0B13;
    --surface: #16141F; --surface-2: #1E1B2A; --surface-sunk: #100E18; --sidebar: #08070E;
    --primary: #E3C567; --primary-strong: #EBD08A; --on-primary: #231A04;
    --bar: linear-gradient(90deg,#E3C567,#9B8AC4 55%,#F0E2B6);
    --accent: #EAD9A8; --accent-soft: rgba(227,197,103,.12); --gold2: #F0E2B6;
    --lilac: #BBA3E3; --lilac-soft: rgba(186,163,227,.14);
    --gold: #E3C567; --ink: #F4F0E3; --body: #D2CCBB; --muted: #9C947F; --dim: #6F6857;
    --line: rgba(214,199,160,.16); --line-soft: rgba(214,199,160,.09); --line-strong: rgba(214,199,160,.28);
    --ok: #7FDCA6; --ok-bg: rgba(46,160,96,.16); --warn: #EFC75E; --warn-bg: rgba(240,196,80,.14); --warn-line: rgba(240,196,80,.38);
    --bad: #F2A69C; --bad-bg: rgba(217,88,74,.16);
    --tone-love: #F08CA0; --tone-love-bg: rgba(232,110,133,.15);
    --tone-money: #5FD3C4; --tone-money-bg: rgba(53,168,152,.16);
    --tone-work: #7CC0EF; --tone-work-bg: rgba(84,150,220,.16);
    --tone-health: #7FD9A8; --tone-health-bg: rgba(63,170,105,.16);
    --tone-mind: #CDB4F2; --tone-mind-bg: rgba(150,110,220,.17);
    --shadow: 0 0 0 1px rgba(255,255,255,.06), inset 0 1px 0 rgba(255,255,255,.04), 0 2px 16px rgba(0,0,0,.35);
    --shadow-lg: 0 0 0 1px rgba(255,255,255,.08), inset 0 1px 0 rgba(255,255,255,.05), 0 18px 50px rgba(0,0,0,.5);
    --shadow-glow: 0 0 32px rgba(227,197,103,.16);
    --focus-ring: 0 0 0 3px rgba(227,197,103,.4);
    --grad: linear-gradient(135deg,#E3C567,#9B8AC4);
    --grad-warm: linear-gradient(135deg,#EBD08A,#B0812E 55%,#6E5318);
    --grad-bar: linear-gradient(90deg,#E3C567,#9B8AC4,#F0E2B6);
  }
}

/* ============================================================
   BASE
   ============================================================ */
* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color-scheme: light;
}
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) { color-scheme: dark; }
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--body);
  min-height: 100vh;
  text-wrap: pretty;
  background-color: var(--bg-solid);
  background-image:
    radial-gradient(900px 420px at 8% -8%, rgba(176,129,46,.10), transparent 55%),
    radial-gradient(700px 380px at 92% 0%, rgba(140,47,27,.06), transparent 50%),
    radial-gradient(500px 360px at 70% 100%, rgba(92,31,20,.05), transparent 55%);
  background-attachment: fixed;
}
:root[data-theme="dark"] body {
  background-image:
    radial-gradient(900px 420px at 0% 0%, rgba(227,197,103,.09), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(155,138,196,.10), transparent 50%),
    radial-gradient(600px 400px at 80% 100%, rgba(140,47,27,.08), transparent 50%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) body {
    background-image:
      radial-gradient(900px 420px at 0% 0%, rgba(227,197,103,.09), transparent 55%),
      radial-gradient(700px 380px at 100% 0%, rgba(155,138,196,.10), transparent 50%),
      radial-gradient(600px 400px at 80% 100%, rgba(140,47,27,.08), transparent 50%);
  }
}
h1, h2, h3, h4 {
  font-family: var(--display); color: var(--ink); font-weight: 600; margin: 0;
  text-wrap: balance;
}
p { margin: 0 0 .6em; text-wrap: pretty; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
b, strong { font-weight: 600; }
img { max-width: 100%; height: auto; }
/* neutral image edge — pure black/white only (never tinted) */
img.content-img, .brand-logo, .qr-fold img, .pay-box img {
  outline: 1px solid rgba(0, 0, 0, 0.1);
  outline-offset: -1px;
}
:root[data-theme="dark"] img.content-img,
:root[data-theme="dark"] .brand-logo,
:root[data-theme="dark"] .qr-fold img,
:root[data-theme="dark"] .pay-box img {
  outline-color: rgba(255, 255, 255, 0.1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) img.content-img,
  :root:not([data-theme="light"]):not([data-theme="dark"]) .brand-logo,
  :root:not([data-theme="light"]):not([data-theme="dark"]) .qr-fold img,
  :root:not([data-theme="light"]):not([data-theme="dark"]) .pay-box img {
    outline-color: rgba(255, 255, 255, 0.1);
  }
}
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }

.hidden { display: none !important; }
.muted, .dim { color: var(--dim); }
.spacer { flex: 1; }

/* decorative starfield (aria-hidden) — faint indigo/teal points, dark only */
.stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0; }
:root[data-theme="dark"] .stars {
  opacity: 1;
  background:
    radial-gradient(1.5px 1.5px at 20% 30%, rgba(165,180,252,.4), transparent),
    radial-gradient(1.5px 1.5px at 70% 20%, rgba(45,212,191,.28), transparent),
    radial-gradient(1.5px 1.5px at 40% 70%, rgba(240,206,139,.22), transparent),
    radial-gradient(1.5px 1.5px at 85% 60%, rgba(196,181,253,.3), transparent),
    radial-gradient(1.5px 1.5px at 55% 90%, rgba(165,180,252,.2), transparent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .stars {
    opacity: 1;
    background:
      radial-gradient(1.5px 1.5px at 20% 30%, rgba(165,180,252,.4), transparent),
      radial-gradient(1.5px 1.5px at 70% 20%, rgba(45,212,191,.28), transparent),
      radial-gradient(1.5px 1.5px at 40% 70%, rgba(240,206,139,.22), transparent),
      radial-gradient(1.5px 1.5px at 85% 60%, rgba(196,181,253,.3), transparent),
      radial-gradient(1.5px 1.5px at 55% 90%, rgba(165,180,252,.2), transparent);
  }
}

.wrap { position: relative; z-index: 1; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* 3px top line */
.topline { height: 3px; background: var(--bar); position: relative; z-index: 30; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  color: var(--accent); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 10px 22px; cursor: pointer; line-height: 1.2;
  min-height: 40px;
  transition-property: transform, box-shadow, background, opacity, border-color, color;
  transition-duration: .15s;
  transition-timing-function: var(--ease-out);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-gold { /* primary — ชาดราชวงศ์ (สว่าง) / ทองโบราณ (มืด) */
  color: var(--on-primary); background: var(--primary); border-color: transparent;
  font-weight: 700; box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 6px 18px rgba(140,47,27,.28);
}
:root[data-theme="dark"] .btn-gold { background: var(--grad); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 0 24px rgba(227,197,103,.20); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .btn-gold { background: var(--grad); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 0 24px rgba(227,197,103,.20); } }

.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-lg { padding: 13px 30px; font-size: 15.5px; }
.btn-block { display: flex; width: 100%; }

/* social */
.btn-google { background: #fff; color: #3c4043; border: 1px solid #e0d5da; font-weight: 600; }
.btn-google:hover { background: #f7f7f9; }
:root[data-theme="dark"] .btn-google {
  background: var(--surface-2); color: var(--ink); border-color: var(--line-strong);
}
:root[data-theme="dark"] .btn-google:hover { background: var(--surface); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .btn-google {
    background: var(--surface-2); color: var(--ink); border-color: var(--line-strong);
  }
}
.btn-line { background: #06C755; color: #fff; border-color: transparent; font-weight: 600; }
.btn-line:hover { background: #05b34d; }

/* ============================================================
   PILLS / BADGES
   ============================================================ */
.pill {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .12em;
  color: var(--accent); background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 12px;
}
:root[data-theme="dark"] .pill { color: var(--on-primary); background: var(--grad); border-color: transparent; }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .pill { color: var(--on-primary); background: var(--grad); border-color: transparent; } }

.status-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 5px 14px; }
.status-pending { color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-line); }

/* โทนแพ็กเกจ (app.js ตั้ง class pill-free/pill-pro/pill-max ที่ planPill + owner line) */
.pill.pill-free { color: var(--muted); background: var(--surface-2); border-color: var(--line-strong); }
.pill.pill-pro { color: #6B4A10; background: linear-gradient(135deg, #F5DFA8, #E6C275); border-color: transparent; }
.pill.pill-max { color: #FFF6EA; background: linear-gradient(135deg, #8C2F1B, #B0812E 60%, #D9AE5F); border-color: transparent; }
:root[data-theme="dark"] .pill.pill-free { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
:root[data-theme="dark"] .pill.pill-pro { color: #4A3508; background: linear-gradient(135deg, #F5DFA8, #E6C275); border-color: transparent; }
:root[data-theme="dark"] .pill.pill-max { color: #231A04; background: linear-gradient(135deg, #EBD08A, #D9AE5F); border-color: transparent; }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]) .pill.pill-free { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .pill.pill-pro { color: #4A3508; background: linear-gradient(135deg, #F5DFA8, #E6C275); border-color: transparent; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .pill.pill-max { color: #231A04; background: linear-gradient(135deg, #EBD08A, #D9AE5F); border-color: transparent; }
}

/* ============================================================
   STYLE C SHELL — sidebar desktop · brand top mobile · lotus bottom nav
   ============================================================ */
.brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--display); font-size: 18px; color: var(--ink); text-decoration: none; white-space: nowrap; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: #fff; padding: 4px; object-fit: contain;
  box-shadow: 0 2px 8px -3px rgba(79, 70, 229, .25);
}
.theme-toggle {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; cursor: pointer;
  color: var(--accent); background: var(--surface-2);
  border: 1px solid var(--line-strong); flex: none;
  transition: transform .15s var(--ease-out), background .15s;
}
.theme-toggle:hover { transform: rotate(12deg); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }

.owner-line { display: flex; align-items: center; gap: 10px; margin: 2px 0 0; font-size: 13.5px; color: var(--muted); }
.owner-line:empty { display: none; }
.owner-line .owner-nm { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* landing top nav (index.html) */
.nav {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}

/* App shell layout */
.app-shell {
  display: flex; min-height: 100vh; align-items: stretch;
  max-width: none; margin: 0; padding: 0;
}
.app-side { display: none; }
.app-maincol {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  min-height: 100vh;
}

/* Mobile top brand bar — ตรง mockup: ชื่อกลาง + ดอกทอง */
.app-top {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 6px;
  background: transparent;
  position: sticky; top: 0; z-index: 25;
}
.app-top-brand {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--ink); gap: 0;
  justify-self: center;
}
.app-top-brand:hover { text-decoration: none; }
.atb-title {
  font-family: var(--display); font-size: 22px; font-weight: 600;
  letter-spacing: .02em; line-height: 1.15; color: var(--ink);
}
.atb-lotus { display: flex; margin-top: -2px; opacity: .95; }
.app-top-end { display: flex; align-items: center; gap: 6px; justify-self: end; }
.app-top-ghost {
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.app-top-ghost:hover { color: var(--primary); background: var(--accent-soft); }
.app-top .pill { font-size: 10px; padding: 2px 8px; }

/* Bottom nav — mockup C: 5 ช่อง + ดอกบัวกลางลอย */
.tabbar {
  display: flex; align-items: flex-end; justify-content: space-around;
  gap: 0;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 28px rgba(64,45,24,.10);
}
:root[data-theme="dark"] .tabbar {
  background: rgba(12,11,19,.94);
  box-shadow: 0 -8px 28px rgba(0,0,0,.4);
}
.tabbar button {
  flex: 1; max-width: 88px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px 4px; margin: 0; border: 0; border-radius: 14px;
  background: transparent; color: var(--dim);
  font-family: var(--font); font-size: 10px; font-weight: 600;
  cursor: pointer; min-height: 52px;
  transition: color .15s, transform .12s;
}
.tabbar button .tl { line-height: 1.2; }
.tabbar button .ti {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; color: inherit;
}
.tabbar button.on { color: var(--primary); }
.tabbar button.on .ti { color: var(--primary); }
.tabbar button.tab-center {
  max-width: 96px; position: relative; top: -10px;
}
.tabbar button.tab-center .ti-lotus {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  border: 2px solid color-mix(in srgb, var(--primary) 25%, var(--line));
  box-shadow:
    0 8px 20px rgba(140,47,27,.22),
    0 0 0 4px color-mix(in srgb, var(--surface) 90%, transparent);
}
.tabbar button.tab-center.on .ti-lotus,
.tabbar button.tab-center .ti-lotus {
  background: linear-gradient(160deg, #A04327, #5C1F14);
  color: #FFF6EA;
  border-color: transparent;
}
.tabbar button.tab-center .tl {
  font-size: 10px; font-weight: 700; color: var(--primary); margin-top: 2px;
}
:root[data-theme="dark"] .tabbar button.tab-center .ti-lotus {
  box-shadow: 0 8px 22px rgba(0,0,0,.45), 0 0 0 4px rgba(11,15,25,.9);
}

/* Desktop sidebar Style C */
@media (min-width: 900px) {
  .app-top { display: none; }
  .tabbar { display: none; }
  .app-side {
    display: flex; flex-direction: column;
    width: 248px; flex: none;
    background: var(--sidebar, #2C1B10);
    color: #EFE4D2;
    padding: 20px 14px 16px;
    border-right: 1px solid rgba(255,255,255,.06);
    position: sticky; top: 0; height: 100vh;
  }
  .side-brand {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: #fff; padding: 4px 8px 18px;
  }
  .side-logo {
    width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center;
    background: rgba(217,174,95,.18); color: #E3C567;
  }
  .side-brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .side-brand-text strong { font-family: var(--display); font-size: 16px; font-weight: 600; }
  .side-brand-text small { font-size: 11px; color: #B3A488; }
  .side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
  .side-link {
    display: flex; align-items: center; gap: 10px;
    width: 100%; text-align: left;
    border: 0; border-radius: 12px; padding: 11px 12px;
    background: transparent; color: #D8CCB2;
    font-family: var(--font); font-size: 13.5px; font-weight: 600;
    cursor: pointer; transition: background .15s, color .15s;
  }
  .side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
  .side-link.on {
    background: var(--primary); color: var(--on-primary);
    box-shadow: 0 6px 16px rgba(140,47,27,.35);
  }
  .side-link .si { display: flex; opacity: .9; }
  .side-foot {
    border-top: 1px solid rgba(255,255,255,.08);
    padding-top: 14px; margin-top: 12px;
    display: flex; flex-direction: column; gap: 10px;
  }
  .side-user { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
  .side-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #C98D4B, #8C2F1B);
    color: #FFF6EA; display: grid; place-items: center;
    font-family: var(--display); font-weight: 600; font-size: 14px;
  }
  .side-user-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .side-user-meta strong {
    font-size: 13px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .side-user-meta .pill { align-self: flex-start; }
  .side-actions { display: flex; gap: 8px; align-items: center; }
  .side-actions .theme-toggle {
    background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #EAD9A8;
  }
  .side-actions .btn {
    flex: 1; color: #E2E8F0; border-color: rgba(255,255,255,.14);
    background: rgba(255,255,255,.06);
  }
  .app-main {
    max-width: 1080px; margin: 0 auto; width: 100%;
    padding: 28px 32px 40px;
  }
  .app-maincol { background: var(--bg); }
}

/* ============================================================
   MAIN + VIEWS
   ============================================================ */
.app-main { max-width: 1120px; margin: 0 auto; padding: 12px 18px 96px; }
.view { display: none; }
/* flex column + gap คงที่ — แทน `.card + .card` เดิมที่พังทุกครั้งที่มี element ที่ไม่ใช่ .card
   มาคั่น (เช่น #summaryBox/#coupleSection ว่าง ๆ ในหน้าสมุดของฉัน) → gap จับได้ทุกกรณี */
.view.on { display: flex; flex-direction: column; gap: 20px; }
/* wrapper ที่อาจว่าง (#summaryBox/#coupleSection/#todayBody ตอนยังไม่ render) — collapse
   ตอนว่างไม่งั้นเป็น flex item ที่สร้าง gap ghost ระหว่างการ์ด */
.view.on > *:empty { display: none; }
/* split + stagger enter when a tab view becomes visible */
.view.on > .card,
.view.on > .view-head,
.view.on > .datestrip,
.view.on > .chat-wrap,
.view.on > .plan-grid {
  animation: enterSoft .42s var(--ease-out) both;
}
.view.on > *:nth-child(1) { animation-delay: 0ms; }
.view.on > *:nth-child(2) { animation-delay: 80ms; }
.view.on > *:nth-child(3) { animation-delay: 160ms; }
.view.on > *:nth-child(4) { animation-delay: 240ms; }
.view.on > *:nth-child(5) { animation-delay: 320ms; }
.view.on > *:nth-child(n+6) { animation-delay: 360ms; }
@keyframes enterSoft {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0); filter: blur(0); }
}
.view-head h2 { font-family: var(--display); font-size: 22px; color: var(--ink); margin-bottom: 4px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 20px 24px; box-shadow: var(--shadow);
}
/* nested surfaces inside cards: outer 16 + pad ≈ inner 10–12 */
.card .school,
.card .yaam,
.card .upsell,
.card .wk-pick,
.card .day-summary {
  border-radius: 12px;
}
.card-gold { border-color: var(--line-strong); }
.card-hover {
  transition-property: transform, box-shadow;
  transition-duration: .15s;
  transition-timing-function: var(--ease-out);
}
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-glow); }

/* loading / spinner */
.loading { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 14px; padding: 20px 4px; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* welcome card */
.welcome { text-align: center; padding: 40px 32px; }
.welcome .em {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%;
  border: 1.5px dashed var(--line-strong); background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); color: var(--accent); font-size: 26px;
}
.welcome h3 { font-size: 23px; color: var(--ink); margin-bottom: 8px; }
.welcome p { font-size: 14px; line-height: 1.8; color: var(--muted); max-width: 340px; margin: 0 auto 20px; }

/* ============================================================
   วันนี้ — date strip + grid
   ============================================================ */
.datestrip { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.nav-day {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer;
  transition-property: transform, background, border-color;
  transition-duration: .15s;
  transition-timing-function: var(--ease-out);
}
.nav-day:hover { background: var(--surface-2); }
.nav-day:active { transform: scale(0.96); }
/* native date ถูกแทนด้วย .dp — คง rule เก่าไว้เผื่อ edge */
.datestrip input[type="date"]:not(.dp-native) {
  font-family: var(--font); font-size: 14px; color: var(--ink); width: auto;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); padding: 8px 12px;
  font-variant-numeric: tabular-nums;
  min-height: 40px;
}
.today-lbl { font-family: var(--display); font-size: 17px; color: var(--ink); }

.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.today-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
/* โหมดเดือน/สัปดาห์/คู่รายวัน — กินเต็มความกว้าง */
.today-grid.is-month,
.today-grid.is-week,
.today-grid.is-couple-day {
  grid-template-columns: 1fr;
}
.today-grid.is-month #colRight:empty,
.today-grid.is-week #colRight:empty,
.today-grid.is-couple-day #colRight:empty {
  display: none;
}
/* โครงดวงคู่รายวัน: สรุปซ้าย · ยามขวา — กันล้นขอบ */
.couple-day-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 16px;
  align-items: start;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.couple-day-layout > * { min-width: 0; max-width: 100%; }
.couple-day-card { margin: 0; text-align: center; overflow: hidden; }
.couple-date-line {
  font-size: 14px; color: var(--muted); margin: 6px 0 2px;
  letter-spacing: normal; line-height: 1.5;
}
.couple-stars-note {
  font-size: 13.5px; color: var(--muted); letter-spacing: normal;
}
.couple-extras {
  text-align: left; margin: 16px auto 0; max-width: 36em;
  padding-left: 1.2em; font-size: 14px; line-height: 1.75; color: var(--body);
}
.couple-extras li { margin-bottom: 8px; }
.couple-yaam-card {
  margin: 0;
  overflow: hidden;
  padding: 18px 14px 16px !important;
}
.couple-yaam-title {
  font-family: var(--display); color: var(--accent);
  margin: 0 0 12px; font-size: 16px; letter-spacing: normal;
}
/* ฤกษ์คู่ 12 ยาม — 4 คอลัมน์พอดีการ์ด ไม่ overflow ซ้ายขวา */
.couple-yaam-card .yaam-wrap {
  overflow: visible;
  width: 100%;
  max-width: 100%;
}
.couple-yaam-card .yaam-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
  width: 100%;
}
.couple-yaam-card .yaam {
  min-width: 0;
  padding: 8px 2px;
  overflow: hidden;
}
.couple-yaam-card .yaam .yt,
.couple-yaam-card .yaam .yg,
.couple-yaam-card .yaam .ya,
.couple-yaam-card .yaam .ys {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  font-size: 10.5px;
}
.couple-yaam-card .yaam .yg { font-size: 12.5px; }
.couple-yaam-card .yaam-legend {
  font-size: 11.5px;
  margin-top: 10px;
  line-height: 1.45;
}
/* ดวงคู่ใต้ปฏิทิน (day-summary) — เต็มความกว้าง การ์ดเดียวซ้อน */
.day-summary .couple-day-layout {
  grid-template-columns: 1fr;
  gap: 12px;
}
.day-summary .couple-yaam-card .yaam-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .couple-day-layout { grid-template-columns: 1fr; }
  .couple-yaam-card .yaam-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 400px) {
  .couple-yaam-card .yaam-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }
  .couple-yaam-card { padding: 14px 10px 12px !important; }
}
/* รายละเอียดใต้ปฏิทินเดือน (สภา + ห้าสำนัก) */
.month-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  min-width: 0;
}
.month-detail-grid > * { min-width: 0; }
/* จอใหญ่ — ขยายกรอบแอปเมื่อดูปฏิทินเดือน */
@media (min-width: 1100px) {
  .app-main:has(.today-grid.is-month) {
    max-width: min(1360px, 98vw);
  }
  .today-grid.is-month .month-grid { gap: 8px; margin-top: 18px; }
  .today-grid.is-month .mg-cell {
    min-height: 92px;
    padding: 8px 4px 6px;
    border-radius: 12px;
  }
  .today-grid.is-month .mg-day { font-size: 16px; }
  .today-grid.is-month .mg-stars { font-size: 13px; letter-spacing: 1px; }
  .today-grid.is-month .mg-ico { width: 22px; height: 22px; font-size: 11px; }
  .today-grid.is-month .mg-topics { gap: 4px; margin-top: 6px; }
  .today-grid.is-month .mg-head { font-size: 13px; padding: 6px 0 8px; }
  .today-grid.is-month .wk-card { padding: 28px 28px 24px !important; }
}
@media (min-width: 900px) and (max-width: 1099px) {
  .today-grid.is-month .mg-cell { min-height: 74px; }
  .today-grid.is-month .mg-day { font-size: 14.5px; }
}
@media (max-width: 900px) {
  .month-detail-grid { grid-template-columns: 1fr; }
}

/* ---- sabha (verdict card) — Style C score ring ---- */
.sabha {
  text-align: center; padding: 28px 24px 22px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
:root[data-theme="dark"] .sabha {
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
/* ห้าม letter-spacing กับข้อความไทย */
.sabha .lbl {
  font-size: 12.5px; letter-spacing: normal; color: var(--muted); font-weight: 600;
  text-transform: none;
}
/* วงคะแนนรวม — หลัก indigo + ขอบทองบาง + เติม teal ตอนคะแนนสูง */
.score-ring {
  --pct: 70;
  width: 148px; height: 148px; margin: 12px auto 10px;
  border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(closest-side, var(--surface) 78%, transparent 79% 100%),
    conic-gradient(
      from -90deg,
      var(--primary) 0 calc(var(--pct) * 0.72 * 1%),
      var(--tone-money) calc(var(--pct) * 0.72 * 1%) calc(var(--pct) * 1%),
      var(--surface-2) calc(var(--pct) * 1%) 100%
    );
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--gold) 55%, transparent),
    0 10px 28px rgba(64,45,24,.14);
  position: relative;
}
:root[data-theme="dark"] .score-ring {
  background:
    radial-gradient(closest-side, var(--surface) 78%, transparent 79% 100%),
    conic-gradient(
      from -90deg,
      var(--primary) 0 calc(var(--pct) * 0.72 * 1%),
      var(--tone-money) calc(var(--pct) * 0.72 * 1%) calc(var(--pct) * 1%),
      var(--surface-2) calc(var(--pct) * 1%) 100%
    );
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--gold) 40%, transparent),
    0 12px 32px rgba(0,0,0,.35);
}
.score-ring-inner {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  z-index: 1;
}
.score-ring .sr-label {
  font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: normal;
}
.score-ring .sr-num {
  font-family: var(--display); font-size: 42px; font-weight: 600;
  color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums;
}
.score-ring .sr-badge {
  margin-top: 4px; font-size: 11px; font-weight: 700;
  color: var(--on-primary); background: var(--primary);
  border-radius: 999px; padding: 2px 10px;
}
.score-ring.tone-high .sr-badge { background: var(--tone-money); }
.score-ring.tone-mid .sr-badge { background: var(--primary); }
.score-ring.tone-low .sr-badge { background: var(--warn); color: #FFF8E7; }

/* ---- Style C dashboard hero (วันนี้) ---- */
.c-dash {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; text-align: center;
  padding: 28px 22px 22px !important;
}
.c-greet { width: 100%; }
.c-greet-hi {
  font-family: var(--display); font-size: clamp(22px, 5vw, 28px);
  font-weight: 600; color: var(--ink); line-height: 1.25;
}
.c-greet-date { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.c-summary {
  width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 14px; padding: 14px 16px;
}
.c-summary-title {
  font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 6px;
}
.c-summary-text {
  font-size: 14.5px; line-height: 1.75; color: var(--body); margin: 0;
}
.c-badges { justify-content: flex-start; width: 100%; margin-top: 0; }
.c-metrics {
  width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.c-metric {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 10px 10px 12px; text-align: left;
}
.cm-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.cm-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.cm-pct { font-family: var(--display); font-size: 16px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.cm-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.cm-bar i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.c-metric.tone-love .cm-bar i { background: var(--tone-love); }
.c-metric.tone-money .cm-bar i { background: var(--tone-money); }
.c-metric.tone-health .cm-bar i { background: var(--tone-health); }
.c-metric.tone-love .cm-label { color: var(--tone-love); }
.c-metric.tone-money .cm-label { color: var(--tone-money); }
.c-metric.tone-health .cm-label { color: var(--tone-health); }
.c-pillar {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--muted);
}
.c-quota {
  width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 14px; padding: 12px 14px;
}
.cq-top {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 8px;
}
.cq-num { color: var(--ink); font-variant-numeric: tabular-nums; }
.cq-bar { height: 8px; border-radius: 999px; background: var(--surface); overflow: hidden; margin-bottom: 8px; }
.cq-bar i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--tone-money));
}
.cq-link {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 700; color: var(--primary);
  text-decoration: underline; text-underline-offset: 2px;
}
.cq-link:hover { color: var(--primary-strong); }
@media (max-width: 400px) {
  .c-metrics { grid-template-columns: 1fr; }
  .score-ring { width: 132px; height: 132px; }
  .score-ring .sr-num { font-size: 36px; }
}

.sabha.c-dash .stars-big { display: none; } /* แดชบอร์ด C ใช้วงคะแนน */
.sabha .verdict {
  font-family: var(--display); font-size: 24px; font-weight: 500; color: var(--ink);
  margin: 8px auto 12px; line-height: 1.5; max-width: 22em;
  letter-spacing: normal; text-wrap: pretty;
}
/* glyph ตัวเลขไทย/สัญลักษณ์ — ฟอนต์ Trirong/Anuphan มี glyph ครบอยู่แล้ว คง fallback กันกรณีขาดชุด */
.stars-big, .stars-sm, .yaam .yf, .glyph,
.school li::before, .plan li::before, .demo-line::before {
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'Apple Symbols', sans-serif;
}

/* letter-spacing ได้เฉพาะสัญลักษณ์ดาว (ไม่ใช่ไทย) */
.stars-big { font-size: 20px; letter-spacing: 4px; color: var(--gold); }
:root[data-theme="dark"] .stars-big { color: var(--primary); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .stars-big { color: var(--primary); } }
.sabha .pillar { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.sabha .pillar .gz { font-family: var(--display); color: var(--accent); font-weight: 600; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.badges .bd { font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; }

/* ---- deity / timeline ---- */
.deity-card {
  padding: 20px 22px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface);
  box-shadow: var(--shadow);
}
.deity-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); }
.deity-head .em {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--primary); background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); color: var(--accent); font-size: 16px;
}
:root[data-theme="dark"] .deity-head .em { border-color: var(--lilac); color: var(--lilac); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .deity-head .em { border-color: var(--lilac); color: var(--lilac); } }
.deity-head .nm { font-family: var(--display); font-size: 17px; color: var(--ink); }
.deity-head .stars-sm { margin-left: auto; }
.stars-sm { font-size: 13px; letter-spacing: 2px; color: var(--gold); }
:root[data-theme="dark"] .stars-sm { color: var(--primary); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .stars-sm { color: var(--primary); } }
.deity-teaser { font-size: 14.5px; line-height: 1.8; color: var(--body); margin: 12px 0 4px; }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.tl-item:last-child { border-bottom: none; }
.tl-time { font-family: var(--display); color: var(--accent); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.tl-label { font-weight: 600; color: var(--accent); font-size: 13px; margin-bottom: 2px; }
.tl-text { font-size: 14px; line-height: 1.7; color: var(--body); }

.upsell { margin-top: 12px; padding: 13px 16px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--accent-soft); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upsell p { font-size: 13.5px; color: var(--muted); margin: 0; flex: 1; }

/* ---- schools (ห้าเซียน) — แต่ละสำนักมีโทนสีรอง กันทื่อ ---- */
.school-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.school {
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); box-shadow: none;
  border-top: 3px solid var(--school-tone, var(--primary));
}
.school .sh { display: flex; align-items: baseline; gap: 8px; padding-bottom: 7px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.school .sc { font-size: 12px; letter-spacing: normal; color: var(--school-tone, var(--accent)); font-weight: 700; }
.school .mn { font-size: 11px; color: var(--dim); }
.school .st { margin-left: auto; }
.school ul { list-style: none; margin: 8px 0 0; padding: 0; }
.school li { font-size: 13px; line-height: 1.65; color: var(--body); margin-bottom: 4px; padding-left: 14px; position: relative; }
.school li::before { content: '◆'; position: absolute; left: 0; color: var(--school-tone, var(--gold)); font-size: 8px; top: 4px; }
/* nth fallback if JS ไม่ใส่ data-school */
.school-grid .school:nth-child(1) { --school-tone: #5B4AA8; } /* โหรไทย */
.school-grid .school:nth-child(2) { --school-tone: #B0322E; } /* แปดักษร */
.school-grid .school:nth-child(3) { --school-tone: #22689E; } /* สี่เสา */
.school-grid .school:nth-child(4) { --school-tone: #A16207; } /* เวท */
.school-grid .school:nth-child(5) { --school-tone: #8A54A8; } /* ดาวม่วง */
.school[data-school="thai"],  .school.sc-thai  { --school-tone: #5B4AA8; }
.school[data-school="bazi"],  .school.sc-bazi  { --school-tone: #B0322E; }
.school[data-school="saju"],  .school.sc-saju  { --school-tone: #22689E; }
.school[data-school="vedic"], .school.sc-vedic { --school-tone: #A16207; }
.school[data-school="ziwei"], .school.sc-ziwei { --school-tone: #8A54A8; }
/* dark: โทนสว่างขึ้นให้อ่านบนพื้นเข้ม */
:root[data-theme="dark"] .school-grid .school:nth-child(1),
:root[data-theme="dark"] .school.sc-thai  { --school-tone: #B0A6EC; }
:root[data-theme="dark"] .school-grid .school:nth-child(2),
:root[data-theme="dark"] .school.sc-bazi  { --school-tone: #F2A69C; }
:root[data-theme="dark"] .school-grid .school:nth-child(3),
:root[data-theme="dark"] .school.sc-saju  { --school-tone: #7CC0EF; }
:root[data-theme="dark"] .school-grid .school:nth-child(4),
:root[data-theme="dark"] .school.sc-vedic { --school-tone: #EFC75E; }
:root[data-theme="dark"] .school-grid .school:nth-child(5),
:root[data-theme="dark"] .school.sc-ziwei { --school-tone: #D4B8EE; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .school-grid .school:nth-child(1),
  :root:not([data-theme="light"]):not([data-theme="dark"]) .school.sc-thai  { --school-tone: #B0A6EC; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .school-grid .school:nth-child(2),
  :root:not([data-theme="light"]):not([data-theme="dark"]) .school.sc-bazi  { --school-tone: #F2A69C; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .school-grid .school:nth-child(3),
  :root:not([data-theme="light"]):not([data-theme="dark"]) .school.sc-saju  { --school-tone: #7CC0EF; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .school-grid .school:nth-child(4),
  :root:not([data-theme="light"]):not([data-theme="dark"]) .school.sc-vedic { --school-tone: #EFC75E; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .school-grid .school:nth-child(5),
  :root:not([data-theme="light"]):not([data-theme="dark"]) .school.sc-ziwei { --school-tone: #D4B8EE; }
}

/* ---- yaam grid ---- */
.yaam-wrap { overflow-x: auto; }
.yaam-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; min-width: 320px; }
.yaam { text-align: center; padding: 8px 3px; border-radius: 9px; border: 1px solid var(--line-soft); background: var(--surface); }
.yaam .yt { font-size: 10px; color: var(--dim); }
.yaam .yg { font-family: var(--display); font-size: 13.5px; color: var(--muted); margin: 1px 0; }
.yaam .ya { font-size: 10.5px; color: var(--muted); }
.yaam .yf { font-size: 10px; color: var(--accent); }
.yaam .ys { font-size: 9.5px; color: var(--dim); }
.yaam.top { border-color: var(--primary); background: var(--surface-2); }
.yaam.top .yt, .yaam.top .yg, .yaam.top .ya { color: var(--accent); font-weight: 600; }
.yaam.now { outline: 2px solid var(--accent); outline-offset: 1px; }
:root[data-theme="dark"] .yaam.now { outline-color: var(--primary); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .yaam.now { outline-color: var(--primary); } }
.yaam-legend { font-size: 12px; color: var(--dim); margin-top: 10px; }

/* ---- lucky colors ---- */
.colors-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.colors-row .lbl { font-size: 13px; color: var(--muted); font-weight: 700; }
.chip {
  font-size: 12.5px; font-weight: 600; color: var(--accent);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 5px 15px; cursor: pointer; user-select: none;
  min-height: 32px;
  transition-property: background, color, border-color, transform;
  transition-duration: .15s;
  transition-timing-function: var(--ease-out);
}
.chip:hover { border-color: var(--accent); }
.chip:active { transform: scale(0.96); }
.chip.on { color: var(--on-primary); background: var(--primary); border-color: transparent; }
:root[data-theme="dark"] .chip.on { background: var(--grad); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .chip.on { background: var(--grad); } }

/* ============================================================
   CHAT
   ============================================================ */
/* แถบควบคุมแท็บวันนี้ — เรียบ โล่ง starlight */
#todayBody {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: stretch;
  min-width: 0;
}
#todayBody > .today-grid { width: 100%; max-width: 100%; }

/* ── sight toolbar ── */
.sight-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  padding: 4px 0 2px;
}
.sight-seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(49, 46, 129, 0.05);
  box-shadow: inset 0 0 0 1px rgba(49, 46, 129, 0.08);
}
:root[data-theme="dark"] .sight-seg {
  background: rgba(165, 180, 252, 0.08);
  box-shadow: inset 0 0 0 1px rgba(165, 180, 252, 0.14);
}
.sight-chip {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--dim);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  min-height: 36px;
  cursor: pointer;
  transition-property: background, color, transform, box-shadow;
  transition-duration: .18s;
  transition-timing-function: var(--ease-out);
}
.sight-chip:active { transform: scale(0.96); }
.sight-chip.on {
  color: var(--on-primary);
  background: var(--primary);
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.22);
}
:root[data-theme="dark"] .sight-chip.on {
  color: var(--on-primary);
  background: var(--primary);
  box-shadow: 0 2px 12px rgba(129, 140, 248, 0.28);
}
.sight-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.sight-nav {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition-property: background, transform;
  transition-duration: .15s;
  transition-timing-function: var(--ease-out);
}
.sight-nav:hover { background: var(--accent-soft); }
.sight-nav:active { transform: scale(0.96); }
.sight-today-btn {
  font-family: var(--font);
  font-size: 12.5px; font-weight: 700;
  color: var(--accent);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 36px;
  cursor: pointer;
  transition-property: background, transform;
  transition-duration: .15s;
}
.sight-today-btn:hover { background: var(--accent-soft); }
.sight-today-btn:active { transform: scale(0.96); }
.sight-range {
  display: none;
  width: 100%;
  text-align: center;
  font-family: var(--display);
  font-size: 15px;
  color: var(--muted);
  letter-spacing: normal;
  padding: 0 4px;
}
.sight-range.on { display: block; }

/* การ์ดดูดวง — Style C surface */
.sight-card {
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow) !important;
  background: var(--surface) !important;
  border-radius: 20px !important;
  padding: 24px 22px 20px !important;
}
:root[data-theme="dark"] .sight-card {
  box-shadow: var(--shadow-lg) !important;
  background: var(--surface) !important;
  border-color: var(--line) !important;
}
.sight-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 0 2px;
}
.sight-card-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  text-wrap: balance;
}
.sight-card-stars {
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'Apple Symbols', sans-serif;
  font-size: 15px;
  letter-spacing: 3px;
  color: var(--gold);
}
:root[data-theme="dark"] .sight-card-stars { color: var(--primary); }

.chat-mode {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 4px;
  background: var(--surface-2); border-radius: 999px;
  align-self: flex-start; width: fit-content; max-width: 100%;
}
.mode-pill {
  font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--dim);
  background: transparent; border: none; border-radius: 999px; padding: 7px 16px; cursor: pointer;
  min-height: 36px;
  transition-property: background, color, transform;
  transition-duration: .15s;
  transition-timing-function: var(--ease-out);
}
.mode-pill:active { transform: scale(0.96); }
.mode-pill.on { color: var(--on-primary); background: var(--primary); }
:root[data-theme="dark"] .mode-pill.on { background: var(--grad); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .mode-pill.on { background: var(--grad); } }

.quota-strip {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--dim); font-variant-numeric: tabular-nums;
}
.bar { display: inline-block; flex: 1; max-width: 260px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar i {
  display: block; height: 100%; border-radius: 999px; background: var(--primary);
  transition-property: width;
  transition-duration: .3s;
  transition-timing-function: var(--ease-out);
}
:root[data-theme="dark"] .bar i { background: var(--grad-bar); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .bar i { background: var(--grad-bar); } }

.chat-wrap { display: flex; flex-direction: column; gap: 14px; }
.chat-scroll { display: flex; flex-direction: column; gap: 14px; min-height: 340px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.chat-suggest { display: flex; gap: 8px; flex-wrap: wrap; }

.msg { display: flex; flex-direction: column; max-width: 74%; gap: 5px; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; align-items: flex-start; }
.msg .bubble {
  font-size: 14.5px; line-height: 1.8; padding: 13px 18px; border-radius: 16px;
  text-wrap: pretty;
  transition-property: transform, box-shadow, opacity;
  transition-duration: .2s;
  transition-timing-function: var(--ease-out);
}
.msg.me .bubble {
  background: var(--primary); color: var(--on-primary);
  border-radius: 16px 16px 4px 16px; font-weight: 500;
  box-shadow: 0 4px 14px rgba(140,47,27,.20);
}
:root[data-theme="dark"] .msg.me .bubble { background: var(--grad); font-weight: 600; box-shadow: 0 4px 18px rgba(227,197,103,.16); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .msg.me .bubble { background: var(--grad); font-weight: 600; box-shadow: 0 4px 18px rgba(227,197,103,.16); } }
.msg.bot .bubble {
  background: var(--surface); border: 1px solid var(--line); color: var(--body);
  border-radius: 4px 16px 16px 16px;
  box-shadow: var(--shadow);
}
/* ข้อความใหม่เข้า chat — soft enter */
.msg.enter .bubble {
  animation: enterSoft .35s var(--ease-out) both;
}
/* LIFF in-app: ลด distraction ขอบนอก รู้สึกเป็นมินิแอป */
html[data-liff="1"] .topline { height: 2px; }
html[data-liff="1"] body.liff-inapp { overscroll-behavior-y: contain; }
html[data-liff="1"] .brand { font-size: 17px; }
.deity-tag { display: flex; align-items: center; gap: 7px; padding-left: 4px; font-size: 12px; color: var(--accent); font-weight: 700; }
.deity-tag span:first-child {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 1.2px solid var(--primary); background: var(--accent-soft);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--display); color: var(--accent); font-size: 10.5px;
}

/* typing */
.bubble.typing { display: inline-flex; gap: 4px; align-items: center; }
.bubble.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); display: inline-block; animation: blink 1.2s infinite both; }
.bubble.typing i:nth-child(2) { animation-delay: .2s; }
.bubble.typing i:nth-child(3) { animation-delay: .4s; }
.bubble.typing .typing-note { font-size: 12px; color: var(--dim); margin-left: 4px; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* ask mode extras */
.msg.ask .deity-tag { color: var(--lilac); }
.ask-sources { font-size: 12px; color: var(--dim); padding-left: 4px; margin-top: 2px; }
.ask-coming { text-align: center; padding: 30px 24px; color: var(--muted); align-self: center; }
.ask-coming .em {
  width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%;
  border: 1.5px dashed var(--line-strong); background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 20px;
}
.ask-coming p { font-size: 14px; line-height: 1.8; max-width: 360px; margin: 0 auto; }

/* quota out */
.quota-out { max-width: 100%; text-align: center; padding: 22px; border: 1px dashed var(--line-strong); border-radius: 14px; background: var(--accent-soft); gap: 14px; align-items: center; }
.quota-out p { font-size: 13.5px; line-height: 1.75; color: var(--body); margin: 0; }

/* chat input */
.chat-input { display: flex; gap: 10px; align-items: flex-end; }
.chat-input textarea {
  flex: 1; resize: none; font-family: var(--font); font-size: 14.5px; color: var(--ink);
  border: 1.5px solid var(--line-strong); border-radius: 14px; background: var(--surface);
  padding: 13px 16px; line-height: 1.6; max-height: 120px;
}
.chat-input textarea::placeholder { color: var(--dim); }
.chat-input textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.chat-input .btn { border-radius: 12px; padding: 13px 24px; }

/* ============================================================
   FORMS (profile + payment)
   ============================================================ */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], select, textarea {
  width: 100%; font-family: var(--font); font-size: 14px; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-sunk); padding: 11px 14px; line-height: 1.4;
}
input::placeholder, textarea::placeholder { color: var(--dim); }
select { appearance: none; cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
input:disabled { opacity: .5; cursor: not-allowed; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { width: auto; }

.form-err { color: #C0392B; font-size: 13px; min-height: 1em; margin: 4px 0; }
:root[data-theme="dark"] .form-err { color: #FFB3A7; }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .form-err { color: #FFB3A7; } }
.form-ok { color: var(--ok); font-size: 13px; min-height: 1em; margin: 4px 0; }
:root[data-theme="dark"] .form-ok { color: #9FD6B6; }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .form-ok { color: #9FD6B6; } }

/* completeness meter */
.meter { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.meter .bar { flex: 1; max-width: none; height: 9px; }
.meter .bar i { background: linear-gradient(90deg, var(--primary), var(--primary-strong)); }
.meter .pct { font-family: var(--display); font-size: 18px; color: var(--accent); font-variant-numeric: tabular-nums; }
.meter-hint { font-size: 12.5px; color: var(--dim); margin: 0 0 18px; }

/* summary card */
.summary-card h3 { font-family: var(--display); font-size: 16px; color: var(--accent); margin-bottom: 14px; }
.pillars4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.pillar-box { text-align: center; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 10px 4px; background: var(--surface-sunk); }
.pillar-box .pl { font-size: 11px; color: var(--dim); }
.pillar-box .gz { font-family: var(--display); font-size: 15px; color: var(--accent); margin: 2px 0; }
.pillar-box .th { font-size: 11px; color: var(--muted); }
.summary-facts { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.fact { display: flex; gap: 10px; }
.fact .k { color: var(--dim); min-width: 110px; }
.fact .v { color: var(--ink); font-weight: 600; }

/* link LINE section */
.link-section h3 { font-family: var(--display); color: var(--accent); font-size: 17px; margin-bottom: 12px; }
.link-status { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted); margin-bottom: 14px; }
.link-status .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.link-status .dot.on { background: #7FBF95; }
.link-status .dot.off { background: var(--dim); }
.link-code-box { text-align: center; padding: 18px; border: 1px dashed var(--line-strong); border-radius: 14px; background: var(--accent-soft); }
.link-code { font-family: var(--display); font-size: 34px; letter-spacing: .28em; color: var(--accent); font-weight: 700; padding-left: .28em; font-variant-numeric: tabular-nums; }
.link-count { font-size: 12.5px; color: var(--dim); margin-top: 4px; }
.link-cmd { font-size: 13.5px; color: var(--body); margin-top: 10px; }
.link-cmd b { color: var(--on-primary); background: var(--primary); padding: 2px 10px; border-radius: 6px; }
:root[data-theme="dark"] .link-cmd b { background: var(--grad); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .link-cmd b { background: var(--grad); } }

/* ---------- TASK-111: identity settings — 3 ทาง (email/Google/LINE) ---------- */
/* หัวการ์ด */
.identity-head { margin-bottom: 14px; }
.identity-head h3 { font-family: var(--display); color: var(--gold2); font-size: 17px; margin-bottom: 4px; }
.identity-head p { font-size: 12.5px; color: var(--muted); margin: 0; }
/* แบนเนอร์ "ล็อกอินทางเดียว" — เด่นสีอ่อน เตือนให้ผูกทางอื่นเพิ่ม */
.identity-single-banner {
  margin-bottom: 14px; padding: 10px 14px;
  border: 1px dashed var(--warn-line); border-radius: 12px;
  background: var(--warn-bg); font-size: 12.5px; line-height: 1.55; color: var(--warn);
  display: flex; align-items: flex-start; gap: 8px;
}
:root[data-theme="dark"] .identity-single-banner { color: var(--warn); }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]) .identity-single-banner { color: var(--warn); }
}
.identity-single-banner .ib-ico { flex: none; font-family: var(--display); font-size: 14px; line-height: 1.4; }

.identity-row {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 14px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--line-soft);
}
.identity-row:first-of-type { padding-top: 2px; }
.identity-row:last-child { border-bottom: none; padding-bottom: 2px; }
.id-icon {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: var(--surface-2); color: var(--accent); border: 1px solid var(--line);
}
.id-icon.g { color: #4285F4; }      /* Google blue */
.id-icon.l { color: #06C755; }      /* LINE green */
:root[data-theme="dark"] .id-icon.g { color: #8AB4F8; }
:root[data-theme="dark"] .id-icon.l { color: #4ADE80; }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]) .id-icon.g { color: #8AB4F8; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .id-icon.l { color: #4ADE80; }
}
/* ไอคอนที่ผูกแล้ว → ขอบสีเขียวสื่อสถานะปลอดภัย */
.identity-row.linked .id-icon { border-color: #B9E3C6; }
:root[data-theme="dark"] .identity-row.linked .id-icon { border-color: rgba(122,191,149,.5); }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]) .identity-row.linked .id-icon { border-color: rgba(122,191,149,.5); }
}
.id-info { min-width: 0; }
.id-name { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.id-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); margin-top: 3px;
}
.id-status .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.id-status .dot.on { background: #7FBF95; }
.id-status .dot.off { background: var(--dim); }
/* actions: ปุ่มผูก/ตั้ง (primary gold) อยู่ซ้ายกว่า เด่น · ปุ่มยกเลิก (ghost) เล็ก อยู่ขวา */
.id-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.id-actions .btn-sm { padding: 6px 14px; font-size: 12.5px; }
.id-actions .btn-sm.btn-gold { font-weight: 700; }
/* unlink เป็น secondary — สีจางกว่าตั้งแต่ต้น แยกจากปุ่มผูกที่เด่น */
.id-actions .unlink-btn { color: var(--dim); }
.id-actions .unlink-btn:hover:not([disabled]) { color: var(--warn); border-color: var(--warn-line); }
/* note แทนปุ่ม unlink ที่ดับ — ตัวเล็กสี muted อธิบายเหตุตรง ๆ */
.id-locked-note { font-size: 11px; color: var(--dim); line-height: 1.4; max-width: 110px; text-align: right; }
.id-extra { grid-column: 2 / 4; }
.id-extra:empty { display: none; }
/* code box ภายใน id-extra — reuse .link-code-box เดิม ปรับ margin */
.id-extra .link-code-box { margin-top: 8px; padding: 14px; }

@media (max-width: 400px) {
  .identity-row { grid-template-columns: 32px 1fr; gap: 10px; }
  .id-icon { width: 32px; height: 32px; font-size: 13px; }
  .id-actions { grid-column: 2 / 3; justify-content: flex-start; margin-top: 6px; }
  .id-locked-note { grid-column: 2 / 3; max-width: none; text-align: left; margin-top: 2px; }
  .id-extra { grid-column: 2 / 3; }
}

/* ============================================================
   PACKAGES
   ============================================================ */
.current-plan { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.current-plan .big { font-family: var(--display); font-size: 17px; color: var(--ink); }

.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: stretch; margin-bottom: 0; }
.plan { display: flex; flex-direction: column; padding: 22px 24px; position: relative; }
.plan.feat { border: 1.5px solid var(--accent); background: var(--surface); box-shadow: var(--shadow-glow); }
:root[data-theme="dark"] .plan.feat { border-color: var(--primary); box-shadow: 0 0 30px rgba(227,197,103,.14); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .plan.feat { border-color: var(--primary); box-shadow: 0 0 30px rgba(227,197,103,.14); } }
.plan h3 { font-family: var(--display); font-size: 19px; color: var(--ink); }
.plan .price { font-size: 30px; font-weight: 700; color: var(--accent); line-height: 1.15; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: 13px; color: var(--dim); font-weight: 400; }
.plan ul { list-style: none; margin: 14px 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plan li { font-size: 13.5px; color: var(--body); padding-left: 20px; position: relative; }
.plan li::before { content: '◆'; position: absolute; left: 0; color: var(--accent); font-size: 11px; }
.plan .btn { margin-top: auto; }
.plan .tag {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  color: var(--on-primary); background: var(--primary); border-radius: 999px; padding: 3px 16px;
}
:root[data-theme="dark"] .plan .tag { background: var(--grad); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .plan .tag { background: var(--grad); } }

/* pay box */
.pay-box h3 { font-family: var(--display); font-size: 16px; color: var(--accent); margin-bottom: 8px; }
.pay-info { font-size: 13.5px; line-height: 1.75; color: var(--body); margin-bottom: 12px; }

/* ============================================================
   LANDING (index.html)
   ============================================================ */
.hero {
  text-align: center; padding: 60px 20px 40px;
  background:
    radial-gradient(ellipse 70% 55% at 50% -5%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 70%),
    radial-gradient(ellipse 40% 40% at 90% 20%, color-mix(in srgb, var(--tone-money) 10%, transparent), transparent 60%),
    radial-gradient(ellipse 35% 35% at 10% 30%, color-mix(in srgb, var(--lilac) 8%, transparent), transparent 55%);
}
.hero .eyebrow {
  font-size: 12px; letter-spacing: .14em; color: var(--gold); font-weight: 700; margin-bottom: 16px;
  text-transform: uppercase;
}
.hero h1 { font-family: var(--display); font-size: clamp(30px, 6vw, 50px); font-weight: 600; color: var(--ink); line-height: 1.3; margin: 0; text-wrap: balance; }
.hero h1 .hl {
  color: transparent;
  background: var(--grad-warm);
  -webkit-background-clip: text; background-clip: text;
}
.hero .sub { max-width: 620px; margin: 18px auto 30px; font-size: 16px; line-height: 1.8; color: var(--muted); text-wrap: pretty; }
/* landing hero enter — split + stagger */
.hero .eyebrow, .hero h1, .hero .sub, .hero-cta, .demo-card {
  animation: enterSoft .5s var(--ease-out) both;
}
.hero .eyebrow { animation-delay: 0ms; }
.hero h1 { animation-delay: 90ms; }
.hero .sub { animation-delay: 180ms; }
.hero-cta { animation-delay: 270ms; }
.demo-card { animation-delay: 360ms; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.demo-card { max-width: 520px; margin: 40px auto 0; text-align: left; }
.demo-card .dh { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.demo-card .dh .t { font-family: var(--display); font-size: 14.5px; color: var(--accent); }
.demo-card .dh .brand-logo { width: 34px; height: 34px; padding: 3px; }
.demo-verdict { font-size: 15px; color: var(--ink); margin: 6px 0; font-weight: 600; font-family: var(--display); }
.demo-line { font-size: 13.5px; color: var(--muted); margin: 4px 0; padding-left: 16px; position: relative; }
.demo-line::before { content: '◆'; position: absolute; left: 0; color: var(--accent); font-size: 10px; top: 3px; }

.section { padding: 44px 20px; max-width: 1120px; margin: 0 auto; }
.section-title { text-align: center; font-family: var(--display); font-size: 27px; color: var(--ink); margin-bottom: 6px; }
.section-sub { text-align: center; font-size: 14px; color: var(--dim); margin-bottom: 28px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature { padding: 22px 24px; }
.feature .ico {
  width: 34px; height: 34px; border-radius: 10px; margin-bottom: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); border: 1px solid var(--line-strong); color: var(--accent);
}
.feature .ico svg { width: 16px; height: 16px; display: block; }
.feature h3 { font-family: var(--display); font-size: 16.5px; color: var(--ink); margin-bottom: 6px; }
.feature p { font-size: 13.5px; line-height: 1.75; color: var(--muted); margin: 0; }

.foot { text-align: center; padding: 36px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--dim); max-width: 1120px; margin: 0 auto; }
.foot a { color: var(--accent); }

/* ============================================================
   MODAL (auth)
   ============================================================ */
.modal-back {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 23, 42, .48); backdrop-filter: blur(3px);
}
.modal-back.on { display: flex; }
.modal {
  width: 100%; max-width: 430px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 20px; padding: 26px;
  box-shadow: var(--shadow-lg); max-height: 92vh; overflow-y: auto;
  animation: enterSoft .35s var(--ease-out) both;
}
:root[data-theme="dark"] .modal {
  background: linear-gradient(170deg, #241610, #170E08);
  border-color: var(--line);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]) .modal {
    background: linear-gradient(170deg, #241610, #170E08);
    border-color: var(--line);
  }
}
.modal-head { display: flex; align-items: center; margin-bottom: 4px; }
.modal-head h2 { font-family: var(--display); font-size: 21px; color: var(--ink); }
.modal-head .close {
  margin-left: auto; background: none; border: none; color: var(--dim);
  font-size: 22px; cursor: pointer; line-height: 1;
  width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  transition-property: transform, color, background;
  transition-duration: .15s;
  transition-timing-function: var(--ease-out);
}
.modal-head .close:hover { color: var(--ink); background: var(--surface-2); }
.modal-head .close:active { transform: scale(0.96); }
.modal-sub { font-size: 13px; color: var(--dim); margin-bottom: 16px; }

.social-auth { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 12px; margin: 14px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-divider span { flex: none; }

.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tabs button {
  flex: 1; font-family: var(--font); font-size: 14px; font-weight: 600; color: var(--muted);
  background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px; cursor: pointer;
}
.auth-tabs button.on { color: var(--on-primary); background: var(--primary); border-color: transparent; font-weight: 700; }
:root[data-theme="dark"] .auth-tabs button.on { background: var(--grad); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .auth-tabs button.on { background: var(--grad); } }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(12px);
  z-index: 200; background: var(--ink); color: #fff;
  font-size: 14px; padding: 12px 22px; border-radius: 999px;
  box-shadow: 0 8px 26px rgba(0,0,0,.25); opacity: 0; pointer-events: none;
  transition-property: opacity, transform;
  transition-duration: .22s;
  transition-timing-function: var(--ease-out);
  max-width: 90vw; text-align: center;
}
:root[data-theme="dark"] .toast { background: var(--grad); color: var(--on-primary); font-weight: 600; }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .toast { background: var(--grad); color: var(--on-primary); font-weight: 600; } }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .today-grid { grid-template-columns: 1fr; }
  .plan-grid { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app-main { padding: 20px 16px 40px; }
  .topbar, .nav { padding: 12px 16px; }
  .school-grid { grid-template-columns: 1fr; }
}

/* mobile tweaks (shell ใช้ bottom tab + brand top แล้ว) */
@media (max-width: 560px) {
  .view.on { gap: 16px; }
  .nav { padding: 10px 12px; gap: 8px; }
  .app-main { padding: 8px 14px 100px; }

  .datestrip { gap: 8px; }
  .datestrip .dp-strip { flex: 1 1 110px; }
  .datestrip .btn { flex: none; }
  .datestrip .today-lbl { width: 100%; font-size: 16px; margin-top: -2px; }

  .yaam-strip { grid-template-columns: repeat(4, 1fr); min-width: 0; }
  .yaam .yt, .yaam .ya, .yaam .yf, .yaam .ys { font-size: 11px; }

  .field-row { flex-direction: column; gap: 0; }
  .pillars4 { grid-template-columns: repeat(2, 1fr); }
  .msg { max-width: 88%; }
  .modal { padding: 22px; }
  .hero { padding: 44px 16px 30px; }
}

@media (max-width: 360px) {
  body { font-size: 14.5px; }
  .sabha .verdict { font-size: 20px; line-height: 1.6; }
  .link-code { font-size: 28px; letter-spacing: .18em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .view.on > .card,
  .view.on > .view-head,
  .view.on > .datestrip,
  .view.on > .chat-wrap,
  .view.on > .plan-grid,
  .hero .eyebrow, .hero h1, .hero .sub, .hero-cta, .demo-card,
  .modal {
    animation: none !important;
    filter: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ---------- การ์ดบัญชีธนาคาร (แจ้งโอน แบบ SORNCheck) ---------- */
.bank-card{background:linear-gradient(160deg,var(--card),var(--card-2,var(--card)));border:1px solid var(--line-strong);border-radius:16px;padding:16px 18px;box-shadow:var(--shadow)}
.bank-card-head{font-family:var(--display);color:var(--accent);font-size:15px;font-weight:700;margin-bottom:10px}
.bank-row{display:flex;align-items:center;gap:10px;padding:6px 0;border-bottom:1px dashed var(--line);flex-wrap:wrap}
.bank-row:last-of-type{border-bottom:0}
.bank-k{color:var(--muted);min-width:76px;font-size:13px}
.bank-no{font-family:ui-monospace,'SFMono-Regular',monospace;font-size:18px;letter-spacing:.5px;color:var(--ink);font-variant-numeric:tabular-nums}
.bank-amt{margin-top:10px;font-size:13px;color:var(--muted)}
.qr-fold{margin-top:12px}
.qr-fold>summary{cursor:pointer;color:var(--accent);font-size:13px;user-select:none}
/* ---------- back-office verification ---------- */
.admin-filter{display:flex;gap:8px;margin-bottom:14px;flex-wrap:wrap}
.admin-filter .fpill{padding:6px 14px;border-radius:999px;border:1px solid var(--line-strong);background:var(--card);color:var(--muted);cursor:pointer;font-size:13px}
.admin-filter .fpill.on{background:var(--accent);color:#fff;border-color:var(--accent)}
.status-badge{padding:2px 10px;border-radius:999px;font-size:12px;font-weight:600}
.status-pending{background:#FDECC8;color:#8A5A00}
.status-approved{background:#D6EFDC;color:#1E6B38}
.status-rejected{background:#F6D5CE;color:#9C2A15}

/* การ์ดชวนอัปเกรดเมื่อเลื่อนวันเกินระยะที่แพ็กเกจเปิดให้ (TASK-037) */
.upgrade-card { text-align: center; border-color: var(--line-strong); }
.upgrade-card .em {
  width: 56px; height: 56px; margin: 2px auto 14px; border-radius: 50%;
  border: 1.5px dashed var(--line-strong); background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); color: var(--accent); font-size: 22px;
}
.upgrade-card h3 { font-size: 18px; color: var(--ink); margin-bottom: 8px; }
.upgrade-card p { font-size: 14px; line-height: 1.8; color: var(--muted); max-width: 320px; margin: 0 auto 18px; }

/* ---------- มุมมองสัปดาห์/เดือน + segmented control แท็บวันนี้ (TASK-038) ---------- */
.seg-mode { margin-bottom: 0; }
.seg-pill { flex: none; }
.wk-hilite { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 16px; max-width: none; }
.wk-pick {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 12px 10px; border: none; border-radius: 14px;
  background: var(--surface-2); text-align: left; min-width: 0;
}
:root[data-theme="dark"] .wk-pick { background: var(--surface-2); }
.wk-pick.good { background: var(--tone-money-bg); }
.wk-pick.care { background: var(--warn-bg); }
.wk-pick .wk-k { font-size: 11.5px; letter-spacing: normal; color: var(--dim); font-weight: 600; }
.wk-pick.good .wk-k { color: var(--accent); }
.wk-pick .wk-v { font-size: 13.5px; color: var(--ink); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.wk-pick .wk-n { font-size: 12px; color: var(--muted); }
.wk-mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 14px auto 0; max-width: 440px; }
.wk-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0;
  padding: 8px 2px; border-radius: 9px; border: 1px solid var(--line-soft);
  background: var(--surface); cursor: pointer; font-family: var(--font);
}
.wk-day:hover { border-color: var(--accent); }
.wk-day .wk-dw { font-size: 11px; color: var(--dim); }
.wk-day .wk-st { font-family: var(--display); font-size: 14px; color: var(--ink); }
.wk-day.best { border-color: var(--primary); background: var(--surface-2); }
.wk-day.best .wk-dw, .wk-day.best .wk-st { color: var(--accent); font-weight: 600; }
.wk-day.care .wk-st { color: var(--muted); }
.wk-day.now { outline: 2px solid var(--accent); outline-offset: 1px; }
:root[data-theme="dark"] .wk-day.now { outline-color: var(--primary); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]):not([data-theme="dark"]) .wk-day.now { outline-color: var(--primary); } }
.wk-hint { font-size: 12px; color: var(--dim); margin-top: 10px; }

/* ---------- ภาพรวมวัน inline ใต้ปฏิทิน ---------- */
.day-summary {
  margin-top: 16px; padding: 18px 18px 16px;
  border: 1px solid var(--line-soft); border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
:root[data-theme="dark"] .day-summary {
  background: var(--surface-2);
  border-color: var(--line);
}
.day-summary:empty { display: none; }
.day-summary.day-summary-open {
  animation: enterSoft .35s var(--ease-out) both;
}
.ds-kicker {
  font-size: 12.5px; font-weight: 700; letter-spacing: normal;
  color: var(--accent); margin-bottom: 6px;
}
.day-summary-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding-bottom: 12px; margin-bottom: 10px; border-bottom: 1px solid var(--line-soft);
}
.day-summary-head .ds-date { font-family: var(--display); font-size: 20px; color: var(--ink); font-weight: 600; }
.day-summary-head .ds-stars { font-family: var(--display); font-size: 16px; color: var(--gold); letter-spacing: 2px; }
:root[data-theme="dark"] .day-summary-head .ds-stars { color: var(--primary); }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]) .day-summary-head .ds-stars { color: var(--primary); }
}
.ds-sub { font-size: 13.5px; color: var(--muted); margin: 0 0 14px; line-height: 1.55; }
.ds-section-lbl {
  font-size: 12.5px; font-weight: 700; color: var(--accent);
  margin: 12px 0 6px;
}
.day-summary-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.day-summary-actions {
  margin-top: 18px; display: flex; justify-content: center;
  padding-top: 14px; border-top: 1px solid var(--line-soft);
}
.day-summary-actions .btn { min-width: 220px; }

@media (max-width: 400px) {
  .wk-hilite { grid-template-columns: 1fr; }
  .wk-mini { gap: 4px; }
  .wk-day .wk-dw { font-size: 10px; }
  .wk-day .wk-st { font-size: 12.5px; }
}

/* ---------- ปฏิทินฤกษ์ เดือน/สัปดาห์ — icon เรื่องเด่น ---------- */
.couple-toggle { margin-bottom: 0; }
.cal-card-lead {
  text-align: center; font-size: 14px; color: var(--muted);
  margin: 4px 0 14px; line-height: 1.55; text-wrap: pretty;
}

.month-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin: 14px 0 0; width: 100%;
}
.mg-head {
  font-size: 11px; font-weight: 700; color: var(--dim); text-align: center;
  padding: 4px 0; letter-spacing: .04em;
}
.mg-cell {
  min-height: 58px; padding: 6px 2px 5px; border-radius: 12px; cursor: pointer;
  border: none; background: transparent;
  box-shadow: inset 0 0 0 1px rgba(30, 27, 75, 0.06);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: var(--font);
  transition-property: transform, background, box-shadow;
  transition-duration: .15s;
  transition-timing-function: var(--ease-out);
}
.mg-cell:hover {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.22);
  transform: translateY(-1px);
}
.mg-cell:active:not(.empty) { transform: scale(0.96); }
.mg-cell.empty { cursor: default; background: transparent; border-color: transparent; }
.mg-cell.empty:hover { border-color: transparent; transform: none; }
.mg-cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }
:root[data-theme="dark"] .mg-cell.today { outline-color: var(--primary); }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]) .mg-cell.today { outline-color: var(--primary); }
}
.mg-cell.selected { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--accent-soft); border-color: var(--accent); }
:root[data-theme="dark"] .mg-cell.selected { outline-color: var(--primary); background: var(--surface-2); border-color: var(--primary); }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]) .mg-cell.selected { outline-color: var(--primary); background: var(--surface-2); border-color: var(--primary); }
}
.mg-cell.best {
  background: var(--tone-money-bg);
  box-shadow: inset 0 0 0 1.5px rgba(13, 148, 136, 0.35);
}
.mg-cell.care {
  background: var(--warn-bg);
  opacity: .9;
  box-shadow: inset 0 0 0 1px rgba(180, 83, 9, 0.2);
}
.mg-day { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.mg-cell.best .mg-day { color: var(--tone-money); }
.mg-stars { font-family: var(--display); font-size: 11px; color: var(--gold); line-height: 1; }
:root[data-theme="dark"] .mg-stars { color: var(--primary); }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]) .mg-stars { color: var(--primary); }
}

/* icon เรื่องเด่นในช่องวัน */
.mg-topics {
  display: flex; flex-wrap: wrap; gap: 3px; justify-content: center;
  margin-top: 2px; max-width: 100%;
}
.mg-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 7px;
  font-size: 10px; font-weight: 700; line-height: 1;
  letter-spacing: 0; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 1px rgba(70,36,46,.06);
}
.mg-ico.t-wed    { background: var(--tone-mind-bg); color: var(--tone-mind); box-shadow: 0 0 0 1px rgba(138,84,168,.15); }
.mg-ico.t-good   { background: var(--warn-bg); color: var(--warn); box-shadow: 0 0 0 1px rgba(180,83,9,.14); }
.mg-ico.t-work   { background: var(--tone-work-bg); color: var(--tone-work); }
.mg-ico.t-money  { background: var(--tone-money-bg); color: var(--tone-money); }
.mg-ico.t-love   { background: var(--tone-love-bg); color: var(--tone-love); }
.mg-ico.t-travel { background: var(--tone-work-bg); color: #0369A1; }
.mg-ico.t-merit  { background: var(--tone-mind-bg); color: var(--tone-mind); }
.mg-ico.t-rest   { background: var(--surface-2); color: var(--muted); }
.mg-ico.t-couple { background: var(--tone-love-bg); color: var(--tone-love); }
.mg-ico.t-bond   { background: #FFF7ED; color: #C2410C; }
.mg-ico.t-none   { background: var(--surface-2); color: var(--dim); font-weight: 500; }
.couple-hint {
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
  margin: -4px 0 12px; padding: 10px 12px;
  border-radius: 10px; background: var(--accent-soft);
  border: 1px solid var(--line-soft);
}
/* strip date picker ใน sight-bar — เบา โปร่ง */
.sight-date .dp-strip { max-width: 200px; }
.sight-date .dp-strip .dp-trigger {
  border: none;
  background: rgba(49, 46, 129, 0.05);
  box-shadow: inset 0 0 0 1px rgba(49, 46, 129, 0.08);
  min-height: 36px;
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
}
:root[data-theme="dark"] .sight-date .dp-strip .dp-trigger {
  background: rgba(165, 180, 252, 0.08);
  box-shadow: inset 0 0 0 1px rgba(165, 180, 252, 0.14);
}
.sight-date .dp-strip .dp-ico {
  width: 24px; height: 24px; border-radius: 50%;
  background: transparent;
}
:root[data-theme="dark"] .mg-ico.t-wed    { background: var(--tone-mind-bg); color: var(--tone-mind); }
:root[data-theme="dark"] .mg-ico.t-good   { background: var(--warn-bg); color: var(--warn); }
:root[data-theme="dark"] .mg-ico.t-work   { background: var(--tone-work-bg); color: var(--tone-work); }
:root[data-theme="dark"] .mg-ico.t-money  { background: var(--tone-money-bg); color: var(--tone-money); }
:root[data-theme="dark"] .mg-ico.t-love   { background: var(--tone-love-bg); color: var(--tone-love); }
:root[data-theme="dark"] .mg-ico.t-travel { background: var(--tone-work-bg); color: var(--tone-work); }
:root[data-theme="dark"] .mg-ico.t-merit  { background: var(--tone-mind-bg); color: var(--tone-mind); }
:root[data-theme="dark"] .mg-ico.t-rest   { background: var(--surface-2); color: var(--muted); }
:root[data-theme="dark"] .mg-ico.t-couple { background: var(--tone-love-bg); color: var(--tone-love); }
:root[data-theme="dark"] .mg-ico.t-bond   { background: rgba(255,180,100,.14); color: #FFD0A0; }

/* ตำนาน icon — แถวมินิมอล */
.sight-legend,
.topic-legend {
  display: flex; flex-wrap: wrap; gap: 6px 10px; justify-content: center;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
:root[data-theme="dark"] .sight-legend,
:root[data-theme="dark"] .topic-legend {
  border-top-color: var(--line);
}
.tl-item {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--muted); font-weight: 600;
  opacity: .9;
}
.tl-label { white-space: nowrap; }

/* ชิปเรื่องเด่นใน day summary */
.topic-chips { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.topic-chip {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line-soft);
}
:root[data-theme="dark"] .topic-chip {
  background: var(--surface-2);
  border-color: var(--line);
}
.topic-chip .tc-short {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.topic-chip.t-wed .tc-short    { background: var(--tone-mind-bg); color: var(--tone-mind); }
.topic-chip.t-good .tc-short   { background: var(--warn-bg); color: var(--warn); }
.topic-chip.t-work .tc-short   { background: var(--tone-work-bg); color: var(--tone-work); }
.topic-chip.t-money .tc-short  { background: var(--tone-money-bg); color: var(--tone-money); }
.topic-chip.t-love .tc-short   { background: var(--tone-love-bg); color: var(--tone-love); }
.topic-chip.t-travel .tc-short { background: var(--tone-work-bg); color: var(--tone-work); }
.topic-chip.t-merit .tc-short  { background: var(--tone-mind-bg); color: var(--tone-mind); }
.topic-chip.t-rest .tc-short   { background: var(--surface-2); color: var(--muted); }
.topic-chip.t-couple .tc-short { background: var(--tone-love-bg); color: var(--tone-love); }
.topic-chip.t-bond .tc-short   { background: #FFF7ED; color: #C2410C; }
.topic-chip.t-none .tc-short   { background: var(--surface-2); color: var(--dim); }
:root[data-theme="dark"] .topic-chip.t-bond .tc-short { background: rgba(255,180,100,.14); color: #FFD0A0; }
.tc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tc-label { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.tc-tip { font-size: 13px; color: var(--muted); line-height: 1.45; }

@media (max-width: 400px) {
  .month-grid { gap: 3px; }
  .mg-cell { min-height: 56px; padding: 4px 2px; }
  .mg-day { font-size: 12px; }
  .mg-stars { font-size: 10px; }
  .mg-ico { width: 18px; height: 18px; font-size: 9px; border-radius: 6px; }
  .tl-label { font-size: 11px; }
  .cal-explain { padding: 12px; }
}

/* ---------- TASK-110: modal สรุปคะแนน 5 เซียนของวันใดวันหนึ่ง ---------- */
/* reuse .modal-back/.modal ที่มี (auth) — เพิ่มเฉพาะส่วนเนื้อหาเฉพาะ */
.day-modal-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.day-modal-head .dm-date { font-family: var(--display); font-size: 19px; color: var(--ink); }
.day-modal-head .dm-stars { font-family: var(--display); font-size: 15px; color: var(--gold); letter-spacing: 2px; }
:root[data-theme="dark"] .day-modal-head .dm-stars { color: var(--primary); }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]) .day-modal-head .dm-stars { color: var(--primary); }
}
.dm-sub { font-size: 12.5px; color: var(--dim); margin-bottom: 14px; }
/* แถวเสียงเซียนใน modal — ชื่อ + แท่งใหญ่ + คำแนะนำสั้น */
.voice-row {
  display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft);
}
.voice-row:last-child { border-bottom: none; }
.voice-row .vr-name { font-size: 12.5px; color: var(--body); font-weight: 600; }
.voice-row .vr-name small { display: block; font-weight: 400; color: var(--dim); font-size: 10.5px; }
.voice-row .vr-bar {
  height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden;
  position: relative; margin-bottom: 4px;
}
.voice-row .vr-fill {
  height: 100%; border-radius: 5px; background: var(--dim);
  transition-property: width;
  transition-duration: .2s;
  transition-timing-function: var(--ease-out);
}
.voice-row .vr-fill.v4 { background: linear-gradient(90deg, var(--tone-money), var(--primary)); }
.voice-row .vr-fill.v3 { background: var(--primary); }
.voice-row .vr-fill.v2 { background: var(--tone-work); }
.voice-row .vr-fill.v1 { background: var(--warn); }
.voice-row:nth-child(1) .vr-name { color: #5B4AA8; }
.voice-row:nth-child(2) .vr-name { color: #B0322E; }
.voice-row:nth-child(3) .vr-name { color: #22689E; }
.voice-row:nth-child(4) .vr-name { color: #A16207; }
.voice-row:nth-child(5) .vr-name { color: #8A54A8; }
:root[data-theme="dark"] .voice-row:nth-child(1) .vr-name { color: #B0A6EC; }
:root[data-theme="dark"] .voice-row:nth-child(2) .vr-name { color: #F2A69C; }
:root[data-theme="dark"] .voice-row:nth-child(3) .vr-name { color: #7CC0EF; }
:root[data-theme="dark"] .voice-row:nth-child(4) .vr-name { color: #EFC75E; }
:root[data-theme="dark"] .voice-row:nth-child(5) .vr-name { color: #D4B8EE; }
.voice-row .vr-tip { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
/* ปุ่มดูวันเต็ม */
.dm-actions { margin-top: 16px; display: flex; justify-content: center; }
.dm-actions .btn { min-width: 180px; }
/* โหมดคู่ — ฝั่ง A/B ใน modal */
.voice-row.couple-A .vr-name::before { content: '☉ '; color: var(--accent); }
.voice-row.couple-B .vr-name::before { content: '☾ '; color: var(--lilac); }

/* ≤400px — การ์ดแน่นขึ้น + เลขบัญชีไม่ล้น
   (บล็อกนี้ต้องอยู่ท้ายไฟล์ ถัดจากนิยาม .bank-no ด้านบน ไม่งั้นโดน override) */
@media (max-width: 400px) {
  .card { padding: 15px 14px; }
  .sabha { padding: 22px 14px 18px; }
  .welcome { padding: 28px 16px; }
  .bank-no { font-size: 15px; letter-spacing: .2px; }
}

/* ============================================================
   CUSTOM DATE PICKER (แทน native type=date)
   ============================================================ */
.dp { position: relative; display: block; min-width: 0; }
.dp-native {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0,0,0,0) !important;
  white-space: nowrap !important; border: 0 !important;
  opacity: 0 !important; pointer-events: none !important;
}
.dp-trigger {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 1px 0 rgba(70,36,46,.03);
  transition-property: border-color, box-shadow, background, transform;
  transition-duration: .15s;
  transition-timing-function: var(--ease-out);
}
.dp-trigger:hover { background: var(--surface); border-color: var(--accent); }
.dp-trigger:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.dp-trigger:active { transform: scale(0.98); }
.dp-ico {
  flex: none; width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.dp-ico svg { display: block; }
.dp-label { flex: 1; min-width: 0; line-height: 1.35; }
.dp-label.ph { color: var(--dim); }
.dp-chev { flex: none; color: var(--muted); font-size: 12px; opacity: .8; }

/* strip variant — กระชับใน datestrip */
.dp-strip { flex: 1 1 140px; min-width: 0; max-width: 220px; }
.dp-strip .dp-trigger {
  min-height: 40px; padding: 8px 12px;
  background: var(--surface); border-radius: 12px;
}
.dp-strip .dp-ico { width: 26px; height: 26px; border-radius: 7px; }
.dp-strip .dp-label { font-weight: 600; font-size: 14px; }

.dp-pop {
  position: absolute; z-index: 80; top: calc(100% + 8px); left: 0;
  width: min(320px, calc(100vw - 24px));
  padding: 12px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(6px) scale(0.98);
  pointer-events: none;
  transition-property: opacity, transform;
  transition-duration: .16s;
  transition-timing-function: var(--ease-out);
}
.dp-pop.on {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: auto;
}
.dp-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin-bottom: 10px;
}
.dp-pickers {
  flex: 1; min-width: 0;
  display: flex; gap: 6px; align-items: stretch;
}
.dp-sel-wrap {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.dp-sel-lbl {
  font-size: 10px; font-weight: 700; color: var(--dim);
  letter-spacing: normal; line-height: 1.2;
}
.dp-month, .dp-year {
  width: 100%; min-height: 36px;
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  color: var(--ink); letter-spacing: normal;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface-2); padding: 6px 8px;
  cursor: pointer;
  appearance: auto;
}
.dp-month:focus, .dp-year:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus-ring);
}
.dp-year { flex: 0 0 auto; min-width: 5.5em; max-width: 6.5em; }
.dp-sel-wrap:has(.dp-year) { flex: 0 0 auto; }
.dp-nav {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--accent); font-size: 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  align-self: flex-end;
  transition-property: transform, background;
  transition-duration: .12s;
}
.dp-nav:hover { background: var(--accent-soft); }
.dp-nav:active { transform: scale(0.96); }

.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.dp-dow {
  text-align: center; font-size: 11px; font-weight: 700;
  color: var(--muted); padding: 4px 0 6px;
}
.dp-cell {
  aspect-ratio: 1; min-height: 36px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--ink);
  font-family: var(--font); font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition-property: background, color, transform;
  transition-duration: .12s;
  transition-timing-function: var(--ease-out);
}
.dp-cell.empty { pointer-events: none; }
.dp-cell:not(.empty):not(.off):hover { background: var(--accent-soft); color: var(--accent); }
.dp-cell:active:not(.off) { transform: scale(0.96); }
.dp-cell.today { box-shadow: inset 0 0 0 1.5px var(--line-strong); font-weight: 700; }
.dp-cell.sel {
  background: var(--grad); color: var(--on-primary); font-weight: 700;
  box-shadow: none;
}
.dp-cell.sel:hover { color: var(--on-primary); }
.dp-cell.off { opacity: .28; cursor: not-allowed; }

.dp-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line-soft);
}
.dp-today-btn, .dp-clear-btn {
  border: 0; background: transparent; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 700;
  color: var(--accent); padding: 8px 10px; border-radius: 8px;
  min-height: 36px;
}
.dp-today-btn:hover, .dp-clear-btn:hover { background: var(--accent-soft); }

@media (max-width: 720px) {
  .datestrip .dp-strip { flex: 1 1 120px; max-width: none; }
  .dp-pop { left: 50%; transform: translate(-50%, 6px) scale(0.98); }
  .dp-pop.on { transform: translate(-50%, 0) scale(1); }
}

/* ============================================================
   Luxury Thai — book chapters & paper feel (app.html)
   ============================================================ */
/* เนื้อกระดาษบาง ๆ ทั้งเว็บ — fixed layer ไม่กวน interaction */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 80;
  pointer-events: none; opacity: .028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}
@media (prefers-reduced-motion: reduce) { body::after { display: none; } }

.view-head { margin-bottom: 4px; }
.chapter-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font); font-size: 10.5px; font-weight: 600;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 8px;
}
.chapter-eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--gold); opacity: .7; }
.view-head h2 { font-size: clamp(23px, 2.6vw, 27px); font-weight: 600; letter-spacing: .01em; }
.vh-sub { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); max-width: 46ch; }
.view.on > .view-head + .card,
.view.on > .view-head ~ .card:first-of-type { scroll-margin-top: 70px; }

/* อ่านยาวสบายตาแบบหนังสือ — bubble/การ์ดข้อความเพิ่มระยะบรรทัดเล็กน้อย */
.chat-wrap .bubble, .demo-verdict, .c-verdict, .pay-box p { line-height: 1.75; }
