/* ============================================================
   Xem Tử Vi — giao diện sáng, hiện đại
   ============================================================ */
:root {
  color-scheme: light;

  --bg: #f6f7fc;
  --surface: #ffffff;
  --surface-2: #f3f4fa;
  --surface-3: #eceef7;
  --ink: #1a1c2b;
  --ink-2: #3d4157;
  --muted: #6c7189;
  --line: #e7e9f2;
  --line-strong: #d6daea;

  --primary: #7c3aed;
  --primary-soft: #f3edff;
  --pink: #e8417e;
  --gold: #e29a0b;
  --gold-soft: #fff6e0;
  --grad: linear-gradient(120deg, #7c3aed 0%, #c03adb 48%, #f0507a 100%);
  --grad-gold: linear-gradient(120deg, #f59e0b, #f97316);
  --ring: 0 0 0 4px rgba(124, 58, 237, .16);

  /* Ngũ hành của chính tinh */
  --kim: #5c667d;
  --moc: #15a150;
  --thuy: #2563eb;
  --hoa: #e5294f;
  --tho: #c26a00;

  /* Phân loại phụ tinh */
  --cat: #0e9488;
  --hung: #dc3545;
  --trung: #7a7f96;
  --luu: #7c3aed;

  --sel: #f5f0ff;
  --tamhop: #fff8e8;
  --xung: #eef5ff;

  /* Bề mặt phụ (đổi theo chế độ sáng / tối) */
  --header-bg: rgba(255, 255, 255, .78);
  --chip-bg: rgba(255, 255, 255, .85);
  --chart-bg: linear-gradient(135deg, #ece7ff 0%, #f6edf8 50%, #fff1e3 100%);
  --cell-border: rgba(214, 218, 234, .8);
  --cell-hover: #c9bff5;
  --tamhop-border: #f6dca4;
  --xung-border: #c9dcfb;
  --center-bg: rgba(255, 255, 255, .7);
  --center-card: rgba(255, 255, 255, .82);
  --danger-soft: #fff1f2;
  --ok-soft: #e3f8f2;
  --ok-ink: #0b7a6f;
  --good-soft: #eaf7ee;
  --good-ink: #15803d;
  --bad-soft: #fff0f1;
  --bad-ink: #c42a3a;
  --about-bg: linear-gradient(135deg, #faf7ff, #fff8f1);
  --tag-triet: #1e293b;
  --hero-glow: 1;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(26, 28, 60, .05);
  --shadow: 0 1px 2px rgba(26, 28, 60, .04), 0 12px 32px -12px rgba(76, 52, 160, .14);
  --shadow-lg: 0 24px 60px -20px rgba(92, 50, 180, .28);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Chế độ tối: bật bằng data-theme="dark" trên <html>. Chỉ áp dụng trên màn hình, khi in luôn dùng nền sáng. */
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0e0f1d;
    --surface: #171929;
    --surface-2: #1f2236;
    --surface-3: #282b42;
    --ink: #eceefa;
    --ink-2: #c5c9de;
    --muted: #9095b2;
    --line: #2a2d45;
    --line-strong: #3a3e5e;

    --primary: #a78bfa;
    --primary-soft: rgba(167, 139, 250, .15);
    --pink: #f472b6;
    --gold: #fbbf24;
    --gold-soft: rgba(251, 191, 36, .12);
    --ring: 0 0 0 4px rgba(167, 139, 250, .28);

    --kim: #b8c0d2;
    --moc: #4ade80;
    --thuy: #7fa8ff;
    --hoa: #ff7a90;
    --tho: #f5b041;

    --cat: #34d3be;
    --hung: #ff7b7b;
    --trung: #9da2bf;
    --luu: #c4b5fd;

    --sel: rgba(167, 139, 250, .16);
    --tamhop: rgba(251, 191, 36, .09);
    --xung: rgba(96, 165, 250, .11);

    --header-bg: rgba(14, 15, 29, .78);
    --chip-bg: rgba(31, 34, 54, .85);
    --chart-bg: linear-gradient(135deg, #231b45 0%, #2a1a3a 50%, #2e2118 100%);
    --cell-border: #2a2d45;
    --cell-hover: #6d5bd0;
    --tamhop-border: rgba(251, 191, 36, .35);
    --xung-border: rgba(96, 165, 250, .4);
    --center-bg: rgba(23, 25, 41, .7);
    --center-card: rgba(23, 25, 41, .88);
    --danger-soft: rgba(255, 123, 123, .12);
    --ok-soft: rgba(52, 211, 190, .14);
    --ok-ink: #5eead4;
    --good-soft: rgba(74, 222, 128, .12);
    --good-ink: #86efac;
    --bad-soft: rgba(255, 123, 123, .13);
    --bad-ink: #fca5a5;
    --about-bg: linear-gradient(135deg, #1b1830, #221a1f);
    --tag-triet: #64748b;
    --hero-glow: .45;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -12px rgba(0, 0, 0, .55);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* ---------- Nút đổi chế độ sáng / tối ---------- */
.header-right { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  width: 40px; height: 40px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2);
  cursor: pointer; transition: background .15s, color .15s, transform .2s;
}
.theme-toggle:hover { color: var(--primary); background: var(--primary-soft); }
.theme-toggle:active { transform: rotate(-20deg); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-weight: 800; }
h2, h3 { font-weight: 700; }
h4 { font-weight: 600; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

/* ---------- Header / Footer ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand img { border-radius: 10px; box-shadow: 0 6px 16px -6px rgba(124, 58, 237, .6); }
.nav { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.nav a { text-decoration: none; color: var(--muted); padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: .925rem; transition: color .15s, background .15s; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--primary); background: var(--surface); box-shadow: var(--shadow-sm), 0 2px 8px -2px rgba(124, 58, 237, .2); }

.site-footer { margin-top: 64px; padding: 28px 0 44px; color: var(--muted); font-size: .875rem; border-top: 1px solid var(--line); background: var(--surface); }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 56px 0 36px; overflow: hidden; isolation: isolate; }
.hero::before {
  content: '';
  position: absolute;
  inset: -40% -10% auto;
  height: 520px;
  z-index: -1;
  background:
    radial-gradient(420px 260px at 12% 60%, rgba(167, 139, 250, .35), transparent 70%),
    radial-gradient(380px 240px at 55% 30%, rgba(244, 114, 182, .25), transparent 70%),
    radial-gradient(360px 220px at 92% 55%, rgba(251, 191, 36, .25), transparent 70%);
  filter: blur(10px);
  opacity: var(--hero-glow);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--primary); background: var(--chip-bg);
  border: 1px solid rgba(124, 58, 237, .18); border-radius: 999px; padding: 5px 12px; margin-bottom: 16px;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); max-width: 820px; letter-spacing: -.03em; }
.lead { max-width: 680px; color: var(--ink-2); font-size: 1.075rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 20px 0 0; }
.chips li {
  font-size: .85rem; font-weight: 600; color: var(--ink-2);
  background: var(--chip-bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; box-shadow: var(--shadow-sm);
}
.chips li::before { content: '✦'; color: var(--gold); margin-right: 6px; }

/* ---------- Card / Buttons ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card h3 { font-size: 1.15rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: .6em; }
.card-head h3, .card-head h4 { margin: 0; }

.btn {
  font: inherit;
  font-weight: 600;
  font-size: .925rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--grad);
  border: 0;
  color: #fff;
  padding: 14px 32px;
  font-size: 1rem;
  box-shadow: 0 10px 24px -10px rgba(192, 58, 219, .7);
}
.btn-primary:hover { background: var(--grad); filter: brightness(1.06); box-shadow: 0 14px 30px -10px rgba(192, 58, 219, .8); }
.btn-icon { width: 38px; height: 38px; padding: 0; font-size: 1.25rem; line-height: 1; display: inline-grid; place-items: center; }

/* ---------- Form ---------- */
.form-laso {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  border-color: var(--line);
}
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; border: 0; margin: 0; padding: 0; }
.field > label, .field legend, .date-row label { font-weight: 600; font-size: .875rem; color: var(--ink-2); padding: 0; }
input[type="text"], input[type="number"], select {
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  width: 100%;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder { color: #a3a8bd; }
input[type="text"]:hover, input[type="number"]:hover, select:hover { background: var(--surface-3); }
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  outline: none; background: var(--surface); border-color: var(--primary); box-shadow: var(--ring);
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236c7189' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.date-row { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 12px; }
.date-row > div { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.hint { color: var(--muted); font-size: .8rem; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 4px; width: fit-content; max-width: 100%; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span { display: block; padding: 7px 18px; border-radius: 999px; font-weight: 600; font-size: .925rem; color: var(--muted); white-space: nowrap; transition: color .15s, background .15s; }
.segmented input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm), 0 2px 8px -2px rgba(124, 58, 237, .25); }
.segmented input:focus-visible + span { box-shadow: var(--ring); }

.actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 4px; }
.solar-preview { color: var(--ink-2); font-size: .9rem; font-weight: 500; }
.solar-preview:not(:empty) { background: var(--primary-soft); color: var(--primary); padding: 6px 12px; border-radius: 999px; }
.form-error { color: var(--hung); font-weight: 600; margin: 0; background: var(--danger-soft); padding: 10px 14px; border-radius: var(--radius-sm); }

/* ---------- Kết quả ---------- */
.result { margin-top: 40px; scroll-margin-top: 80px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.toolbar h2 { margin: 0; font-size: clamp(1.4rem, 3vw, 1.9rem); letter-spacing: -.02em; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chart-help { color: var(--muted); font-size: .875rem; margin: 6px 0 14px; }
.legend { white-space: nowrap; margin-left: 8px; }
.legend b { font-size: .7rem; padding: 2px 7px; border-radius: 999px; color: #fff; }
.l-dh { background: var(--grad-gold); }
.l-th { background: var(--primary); }

.chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 24px; }
.chart {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(214px, auto));
  min-width: 880px;
  gap: 8px;
  padding: 8px;
  background: var(--chart-bg);
  border-radius: 24px;
  font-size: 12px;
  line-height: 1.38;
}

.cung {
  background: var(--surface);
  border: 1px solid var(--cell-border);
  border-radius: 14px;
  padding: 8px 9px 6px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  min-width: 0;
  box-shadow: var(--shadow-sm);
  transition: background .15s, box-shadow .15s, border-color .15s, transform .15s;
}
.cung:hover { border-color: var(--cell-hover); box-shadow: 0 8px 20px -12px rgba(124, 58, 237, .45); }
.cung.tam-hop { background: var(--tamhop); border-color: var(--tamhop-border); }
.cung.xung { background: var(--xung); border-color: var(--xung-border); }
.cung.sel { background: var(--sel); border-color: var(--primary); box-shadow: 0 0 0 2px rgba(124, 58, 237, .25), 0 10px 24px -14px rgba(124, 58, 237, .6); }

.cung-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px; }
.cung-canchi { color: var(--muted); font-size: 11px; }
.cung-ten {
  font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; text-align: center; white-space: nowrap;
  color: var(--primary); background: var(--primary-soft); border-radius: 999px; padding: 2px 9px;
}
.is-menh .cung-ten { background: var(--grad); color: #fff; }
.than-badge { font-style: normal; font-size: 9.5px; background: var(--grad-gold); color: #fff; border-radius: 999px; padding: 0 5px; margin-left: 4px; }
.is-menh .than-badge { background: rgba(255, 255, 255, .28); }
.cung-dh { text-align: right; font-weight: 800; color: var(--gold); font-size: 12.5px; }

.chinh-tinh { text-align: center; margin: 6px 0 5px; min-height: 18px; }
.sao-chinh { font-weight: 800; font-size: 13.5px; text-transform: uppercase; letter-spacing: .02em; }
.sao-chinh sup { font-size: 9.5px; margin-left: 2px; font-weight: 700; opacity: .8; }
.h-kim { color: var(--kim); }
.h-moc { color: var(--moc); }
.h-thuy { color: var(--thuy); }
.h-hoa { color: var(--hoa); }
.h-tho { color: var(--tho); }

.phu-tinh { display: grid; grid-template-columns: 1fr 1fr; gap: 0 6px; flex: 1; }
.phu-tinh ul, .luu { list-style: none; margin: 0; padding: 0; }
.phu-tinh ul:last-child { text-align: right; }
.s-cat { color: var(--cat); }
.s-hung { color: var(--hung); }
.s-trung { color: var(--trung); }
.hoa-loc, .hoa-quyen, .hoa-khoa, .hoa-ky { font-weight: 700; }
.luu { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--line-strong); display: flex; flex-wrap: wrap; gap: 0 8px; font-style: italic; }
.luu li { color: var(--luu); }

.cung-foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px; margin-top: 5px; padding-top: 4px; border-top: 1px solid var(--line); }
.ts { color: var(--muted); font-size: 11px; }
.th { text-align: right; color: var(--muted); font-size: 11px; }
.tags { display: flex; gap: 3px; justify-content: center; }
.tag { font-size: 9.5px; font-weight: 700; border-radius: 999px; padding: 1px 6px; color: #fff; }
.tag-tuan { background: #64748b; }
.tag-triet { background: var(--tag-triet); }
.tag-dh { background: var(--grad-gold); }
.tag-th { background: var(--primary); }

.center {
  grid-row: 2 / 4;
  grid-column: 2 / 4;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 0%, rgba(167, 139, 250, .18), transparent 60%),
    radial-gradient(circle at 50% 100%, rgba(251, 191, 36, .14), transparent 60%),
    var(--center-bg);
  border: 1px solid var(--cell-border);
}
.lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ln-tamhop { fill: rgba(124, 58, 237, .035); stroke: var(--primary); stroke-width: .3; opacity: .45; }
.ln-xung { stroke: var(--gold); stroke-width: .3; stroke-dasharray: 1.5 1; opacity: .6; }
.center-inner {
  position: relative;
  width: min(330px, 100%);
  font-size: 12.5px;
  background: var(--center-card);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 8px 28px -14px rgba(76, 52, 160, .35);
  backdrop-filter: blur(4px);
}
.center-title {
  font-size: 13px; font-weight: 800; text-align: center; text-transform: uppercase; letter-spacing: .14em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.center-name { text-align: center; font-weight: 800; font-size: 18px; margin: 2px 0 8px; letter-spacing: -.01em; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; }

/* ---------- Luận giải ---------- */
.analysis { display: grid; gap: 16px; margin-top: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.bullets { margin: 0; padding-left: 0; list-style: none; }
.bullets li { position: relative; padding-left: 20px; margin-bottom: .55em; }
.bullets li::before { content: ''; position: absolute; left: 4px; top: .62em; width: 7px; height: 7px; border-radius: 50%; background: var(--grad); }
.section-title { margin: 20px 0 0; font-size: 1.4rem; }
.cung-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.cung-card { padding: 18px; transition: transform .15s, box-shadow .15s; }
.cung-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.cung-card p { margin-bottom: .4em; }
.cung-card h4 { font-size: 1.05rem; }
.cung-card h4 small { color: var(--muted); font-weight: 500; font-size: .85rem; }
.muc { font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.muc-tot { background: var(--ok-soft); color: var(--ok-ink); }
.muc-kha { background: var(--good-soft); color: var(--good-ink); }
.muc-tb { background: var(--surface-2); color: var(--muted); }
.muc-xau { background: var(--bad-soft); color: var(--bad-ink); }
.txt-cat { color: var(--cat); font-weight: 600; }
.txt-hung { color: var(--hung); font-weight: 600; }
.sao-han { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 4px solid var(--line-strong); }
.sao-han-tot { background: var(--ok-soft); border-left-color: var(--cat); }
.sao-han-tot b { color: var(--ok-ink); }
.sao-han-xau { background: var(--bad-soft); border-left-color: var(--hung); }
.sao-han-xau b { color: var(--bad-ink); }
.sao-han-tb { background: var(--gold-soft); border-left-color: var(--gold); }
.year-switch { display: flex; gap: 6px; }
.disclaimer { margin-top: 4px; }
.about { margin-top: 48px; }
.about .card { background: var(--about-bg); }

/* ---------- Chi tiết cung / chế độ vừa màn hình ---------- */
.btn-fit { margin-bottom: 12px; }
.cung-detail { margin-top: 16px; border-left: 4px solid var(--primary); }
.cung-detail h3 small { font-weight: 500; font-size: .85rem; }
.cung-detail p { margin-bottom: .45em; }
.s-luu { color: var(--luu); }

/* ---------- Lịch âm ---------- */
.lich-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; align-items: start; }
.convert-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.convert-out { background: var(--primary-soft); color: var(--ink-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.convert-out b { color: var(--primary); }
.today-card { background: linear-gradient(140deg, #7c3aed 0%, #b83ad6 55%, #f0507a 100%); color: #fff; border: 0; box-shadow: var(--shadow-lg); }
.today-card .card-head h3 { color: #fff; font-size: 1.05rem; font-weight: 600; opacity: .95; }
.today-card b { color: #fff; }
.today-big { display: flex; gap: 20px; align-items: center; }
.today-num { font-size: 76px; line-height: 1; font-weight: 800; letter-spacing: -.04em; text-shadow: 0 6px 24px rgba(0, 0, 0, .15); }
.today-card h4 { color: rgba(255, 255, 255, .9); }
.hoang-dao { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hoang-dao span { background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; padding: 3px 11px; font-size: .85rem; }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.month-nav h3 { margin: 0; text-align: center; flex: 1; }
.cal { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.cal th { font-size: .78rem; color: var(--muted); font-weight: 700; padding: 4px 0; text-transform: uppercase; letter-spacing: .04em; }
.cal td { background: var(--surface-2); border-radius: 12px; vertical-align: top; padding: 6px 8px; height: 66px; cursor: pointer; transition: background .15s, transform .15s; }
.cal td:hover { background: var(--primary-soft); }
.cal td.empty { cursor: default; background: transparent; }
.cal .d { font-weight: 700; font-size: 1.05rem; }
.cal .l { display: block; font-size: .72rem; color: var(--muted); }
.cal .l.m1 { color: var(--pink); font-weight: 700; }
.cal th:last-child, .cal td:last-child .d { color: var(--pink); }
.cal td.today { background: var(--grad); color: #fff; box-shadow: 0 8px 18px -8px rgba(192, 58, 219, .8); }
.cal td.today .d, .cal td.today .l { color: #fff; }
.cal td.picked:not(.today) { background: var(--surface); box-shadow: inset 0 0 0 2px var(--primary); }

/* ---------- Thành phần dùng chung (bổ sung) ---------- */
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.stack { display: grid; gap: 16px; align-content: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.year-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 560px; }
.year-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.year-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.year-table tbody tr:last-child td { border-bottom: 0; }
.year-table tr[data-nam] { cursor: pointer; transition: background .15s; }
.year-table tr[data-nam]:hover { background: var(--surface-2); }
.year-table tr.now { background: var(--primary-soft); }
.year-table.criteria { min-width: 620px; }
.muc-now { background: var(--primary-soft); color: var(--primary); }
.pill { display: inline-block; font-size: .8rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .3); }
.pill-tot { background: #34d399; border-color: #34d399; color: #053b2c; }
.pill-xau { background: #fecaca; border-color: #fecaca; color: #7f1d1d; }
.pill-tb { background: rgba(255, 255, 255, .9); color: #4c1d95; }

/* Lá số: mục lục, cách cục, tam phương, đại vận, lịch sử */
.jump { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.jump a { flex: none; text-decoration: none; font-weight: 600; font-size: .85rem; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }
.jump a:hover { color: var(--primary); border-color: var(--primary); }
.analysis > [id], .analysis .section-title { scroll-margin-top: 84px; }
.cach-cuc { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cach-cuc li { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.cach-cuc li p { margin: 6px 0 0; color: var(--ink-2); }
.tp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 8px 0 12px; }
.tp-item { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
details.more, details.sao-list { margin-top: 8px; }
details.more summary, details.sao-list summary { cursor: pointer; font-weight: 600; color: var(--primary); font-size: .9rem; }
details.more[open] summary, details.sao-list[open] summary { margin-bottom: 8px; }
details.more p { font-size: .925rem; }
.sao-list h4 { font-size: .9rem; margin: 10px 0 4px; }
.sao-list ul { margin: 0; padding-left: 18px; font-size: .9rem; }
.sao-list li { margin-bottom: 4px; }
.sao-list a { text-decoration: none; }
.sao-list a:hover { text-decoration: underline; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { display: grid; grid-template-columns: 92px 1fr; gap: 14px; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.timeline li.now { border-color: var(--primary); background: var(--sel); }
.tl-age { display: flex; flex-direction: column; }
.tl-age b { font-size: 1.15rem; }
.tl-age span { color: var(--muted); font-size: .8rem; }
.tl-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 2px; }
.history { margin-top: 16px; }
.hist-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.hist-list li { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.hist-open { flex: 1; text-align: left; background: none; border: 0; padding: 9px 12px; cursor: pointer; font: inherit; color: var(--ink); display: flex; flex-direction: column; min-width: 0; }
.hist-open:hover { background: var(--primary-soft); }
.hist-del { border: 0; background: none; color: var(--muted); font-size: 1.2rem; padding: 0 12px; cursor: pointer; }
.hist-del:hover { color: var(--hung); }
.tools-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
.tool-card { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 4px; transition: transform .15s, box-shadow .15s; }
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tool-ico { font-size: 1.6rem; }

/* Xem tuổi / cung mệnh */
.person { display: grid; gap: 12px; align-content: start; padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); }
.person h3 { margin: 0; font-size: 1rem; color: var(--primary); }
.score-wrap { display: flex; gap: 24px; align-items: center; margin-bottom: 16px; }
.score-ring { width: 140px; height: 140px; flex: none; }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 12; }
.ring-fg { fill: none; stroke-width: 12; stroke-linecap: round; transition: stroke-dasharray .6s; }
.score-tot .ring-fg { stroke: var(--cat); }
.score-kha .ring-fg { stroke: var(--moc); }
.score-tb .ring-fg { stroke: var(--gold); }
.score-xau .ring-fg { stroke: var(--hung); }
.ring-num { font-size: 34px; font-weight: 800; text-anchor: middle; fill: var(--ink); font-family: var(--font); }
.ring-sub { font-size: 11px; text-anchor: middle; fill: var(--muted); font-family: var(--font); }
.verdict { font-size: 1.6rem; margin: 2px 0 6px; }
.verdict-tot { color: var(--cat); }
.verdict-kha { color: var(--moc); }
.verdict-tb { color: var(--gold); }
.verdict-xau { color: var(--hung); }
.eyebrow-sm { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0; }
.person-card h3 { margin: 4px 0 8px; }
.result > .grid-2, .result > .grid-3, .result > .card, .result > article { margin-bottom: 16px; }
.pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pick-list button, .pick-list a {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; font: inherit; color: var(--ink); text-decoration: none;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-sm); padding: 9px 12px; cursor: pointer;
}
.pick-list button:hover, .pick-list a:hover { border-color: var(--primary); }
.pick-list .muc { margin-left: auto; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-big { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.huong-card { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: center; }
.huong-list { margin: 0 0 12px; padding-left: 18px; }
.huong-list li { margin-bottom: 6px; }
.la-ban { width: 100%; max-width: 300px; justify-self: center; }
.seg { stroke: var(--surface); stroke-width: 2; }
.seg-tot { fill: color-mix(in srgb, var(--cat) 75%, transparent); }
.seg-xau { fill: color-mix(in srgb, var(--hung) 55%, transparent); }
.seg-txt { font-size: 10px; font-weight: 700; fill: #fff; text-anchor: middle; font-family: var(--font); }
.seg-dir { font-size: 12px; font-weight: 800; fill: var(--ink); text-anchor: middle; font-family: var(--font); }
.la-ban-core { fill: var(--surface); stroke: var(--line); }
.la-ban-center { font-size: 11px; font-weight: 700; fill: var(--primary); text-anchor: middle; font-family: var(--font); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.swatch { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; background: var(--surface-2); border-radius: 999px; padding: 4px 12px 4px 4px; }
.swatch i { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); }
.num-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.num { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; }
.num-tot { background: var(--ok-soft); color: var(--ok-ink); }
.num-xau { background: var(--bad-soft); color: var(--bad-ink); }

/* Từ điển sao */
.dict-tools { display: grid; gap: 12px; margin-bottom: 16px; }
.dict-tools input[type="search"] { font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-sm); padding: 12px 16px; width: 100%; }
.dict-tools input[type="search"]:focus { outline: none; background: var(--surface); border-color: var(--primary); box-shadow: var(--ring); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { font: inherit; font-size: .825rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.chip-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.dict-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.sao-card { scroll-margin-top: 90px; }
.sao-card h3 { margin: 0; }
.sao-card.flash { box-shadow: 0 0 0 3px var(--primary), var(--shadow-lg); }

/* Lịch & ngày tốt */
.day-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.le-tag { margin-top: 4px; font-weight: 700; }
.hd-light span { background: var(--surface-2); border: 0; }
.cal td { position: relative; }
.marks { position: absolute; right: 5px; top: 5px; display: flex; gap: 2px; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.dot-hd { background: var(--cat); }
.dot-ky { background: var(--hung); }
.dot-le { background: var(--gold); }
.cal td.today .dot { box-shadow: 0 0 0 1.5px #fff; }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend .btn { margin-left: auto; }
.good-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.good-day { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 1px; background: var(--ok-soft); border: 1px solid transparent; border-radius: var(--radius-sm); padding: 9px 11px; cursor: pointer; color: var(--ink); }
.good-day:hover { border-color: var(--cat); }
.good-day b { color: var(--ok-ink); font-size: 1.05rem; }

/* Footer */
.footer-inner { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px 32px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 18px; align-content: start; }
.footer-nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; }
.footer-nav a:hover { color: var(--primary); }
.footer-copy { grid-column: 1 / -1; margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .dict-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .huong-card { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 10px 0 8px; row-gap: 8px; }
  .header-right { display: contents; }
  .theme-toggle { order: 2; margin-left: auto; }
  .nav { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; flex: none; }
  .result, .analysis > [id] { scroll-margin-top: 120px; }
}
@media (max-width: 640px) {
  .grid-3, .tp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dict-grid, .tools-grid { grid-template-columns: 1fr; }
  .score-wrap { flex-direction: column; text-align: center; }
  .timeline li { grid-template-columns: 70px 1fr; gap: 10px; }
  .footer-inner { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .cung-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lich-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .form-laso { grid-template-columns: 1fr; padding: 20px; }
  .span-2 { grid-column: auto; }
  .grid-2, .cung-cards { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .hero { padding: 32px 0 24px; }
  .chips li { font-size: .8rem; padding: 5px 11px; }
  .brand span { font-size: 1.05rem; }
  .nav a { padding: 6px 12px; font-size: .875rem; }
  .cal { border-spacing: 3px; }
  .cal td { height: 54px; padding: 4px 5px; border-radius: 9px; }
  .today-num { font-size: 56px; }
}
@media (max-width: 440px) {
  .brand span { display: none; }
  .header-right { gap: 6px; }
}

/* ---------- In ---------- */
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff; font-size: 12px; }
  .site-header, .site-footer, .hero, #form-laso, .toolbar-actions, .chart-help, .about, .analysis,
  .lines, .btn-fit, .cung-detail { display: none !important; }
  .wrap { width: 100%; }
  .result { margin: 0; }
  .chart-scroll { overflow: visible; }
  .chart { zoom: 1 !important; min-width: 0; background: #fff; padding: 0; gap: 4px; grid-template-rows: repeat(4, minmax(150px, auto)); font-size: 10.5px; }
  .cung, .center { box-shadow: none; border-color: #bbb; background: #fff !important; }
  .center-inner { box-shadow: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
