/* ============================================================
   TỬ VI — Lịch Vạn Niên (Almanac) Design System
   Warm parchment · deep maroon · gold ornament
   All dynamic values driven by CSS vars set on .almanac-root
   ============================================================ */

.almanac-root {
  /* defaults — overridden live by Tweaks via inline vars */
  --paper:      #f2e6cb;
  --paper-deep: #e8d6b0;
  --card:       #fbf4e4;
  --card-edge:  #efe2c4;
  --ink:        #41301f;
  --ink-soft:   #836a4c;
  --ink-faint:  #a3886860;
  --red:        #8c1d1d;
  --red-dark:   #6a1414;
  --red-bright: #ab2e22;
  --gold:       #b58836;
  --gold-line:  #a87c30;
  --gold-soft:  #d8b878;
  --radius:     16px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-ui:      'Be Vietnam Pro', system-ui, sans-serif;

  font-family: var(--font-ui);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Page surface ---------- */
.almanac-page {
  position: relative;
  width: 100%;
  min-height: 100%;
  background:
    radial-gradient(120% 80% at 50% -10%, #fbf1d9 0%, rgba(251,241,217,0) 55%),
    radial-gradient(140% 120% at 50% 120%, var(--paper-deep) 0%, rgba(232,214,176,0) 60%),
    var(--paper);
}
.almanac-page.tex::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: .06;
  mix-blend-mode: multiply;
}

.scene {
  position: relative;
  padding: 60px 22px 46px;
  min-height: 100%;
  box-sizing: border-box;
  z-index: 1;
  opacity: 1;
  animation: pageIn .45s cubic-bezier(.2,.7,.2,1);
}
@keyframes pageIn { from { transform: translateY(12px) } to { transform: none } }

/* ---------- Tear-off almanac edge ---------- */
.tear-edge {
  position: relative;
  height: 16px;
  background:
    radial-gradient(circle at 8px 0, transparent 6px, var(--card) 6.5px) 0 0/16px 16px repeat-x;
  filter: drop-shadow(0 2px 1px rgba(106,20,20,.12));
}
.tear-strip {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 0 9px;
}
.tear-hole {
  width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d9c49a, #b89a63);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.5);
}

/* ---------- Gold ornamental frame ---------- */
.gold-frame {
  position: relative;
  border: 1.5px solid var(--gold-line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 5px color-mix(in srgb, var(--gold) 40%, transparent);
}
.corner {
  position: absolute; width: 16px; height: 16px; pointer-events: none;
  border: 2px solid var(--gold); opacity: .9;
}
.corner.tl { top: -2px; left: -2px; border-right: none; border-bottom: none; border-top-left-radius: 6px; }
.corner.tr { top: -2px; right: -2px; border-left: none; border-bottom: none; border-top-right-radius: 6px; }
.corner.bl { bottom: -2px; left: -2px; border-right: none; border-top: none; border-bottom-left-radius: 6px; }
.corner.br { bottom: -2px; right: -2px; border-left: none; border-top: none; border-bottom-right-radius: 6px; }
.ornament-off .corner { display: none; }

/* ---------- Type ---------- */
.kicker {
  font-family: var(--font-ui);
  font-size: 11px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  color: var(--red); display: inline-flex; align-items: center; gap: 8px;
}
.kicker::before, .kicker::after {
  content: ""; height: 1px; width: 20px; background: var(--gold-line); opacity: .7;
}
.display {
  font-family: var(--font-display);
  font-weight: 800; line-height: 1.02; color: var(--red);
  letter-spacing: -.01em;
}
.display .accent { color: var(--red-bright); }
.subtitle-en {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  color: var(--ink-soft); letter-spacing: .02em;
}
.han { font-family: var(--font-display); }

/* ---------- Section pill (maroon banner) ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 9px; white-space: nowrap;
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  color: #f7e7c4;
  font-family: var(--font-display); font-weight: 700;
  font-size: 14px; letter-spacing: .02em;
  padding: 8px 16px 9px;
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--red-dark), 0 6px 14px rgba(106,20,20,.28);
  border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
}
.pill .pill-ico { color: var(--gold-soft); display:flex; }

/* ---------- Cards ---------- */
.card-cream {
  position: relative;
  background: linear-gradient(180deg, #fdf8ec, var(--card));
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 #fff inset, 0 10px 24px -14px rgba(74,44,26,.45);
}
.card-cream.framed { box-shadow: 0 1px 0 #fff inset, 0 10px 24px -14px rgba(74,44,26,.45), 0 0 0 1px color-mix(in srgb,var(--gold) 35%, transparent); }

.hairline { height: 1px; background: linear-gradient(90deg, transparent, var(--gold-line), transparent); opacity: .6; }

/* ---------- Buttons ---------- */
.btn {
  width: 100%; border: none; cursor: pointer; white-space: nowrap;
  font-family: var(--font-display); font-weight: 700;
  font-size: 15px; letter-spacing: .03em;
  padding: 15px 18px; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn-primary {
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  color: #fbeccb;
  border: 1px solid color-mix(in srgb, var(--gold) 60%, transparent);
  box-shadow: 0 3px 0 var(--red-dark), 0 14px 24px -12px rgba(106,20,20,.6);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-gold {
  background: linear-gradient(180deg, #e7c882, var(--gold));
  color: #3c2a10;
  border: 1px solid #c9a85a;
  box-shadow: 0 3px 0 #94701f, 0 14px 24px -12px rgba(120,90,30,.5);
}
.btn-ghost {
  background: transparent; color: var(--red);
  border: 1.4px solid var(--gold-line);
}
.btn-ghost:hover { background: color-mix(in srgb, var(--gold) 12%, transparent); }
.btn-sm { font-size: 13px; padding: 11px 14px; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- Almanac cover (home hero) ---------- */
.cover-frame { padding: 0; overflow: hidden; }
.hero { position: relative; line-height: 0; }
.hero-img {
  display: block; width: 100%; height: auto;
  background: radial-gradient(120% 90% at 50% 0%, #2a3550, #141a2c);
}
.hero-tag {
  position: absolute; top: 11px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-ui); font-size: 9.5px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; white-space: nowrap;
  color: var(--gold-soft);
  padding: 4px 12px; border-radius: 999px;
  background: rgba(26,17,9,.5); backdrop-filter: blur(3px);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
}
.hero-fade {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 34%;
  background: linear-gradient(180deg, transparent, var(--card) 92%);
  pointer-events: none;
}
.cover-body {
  position: relative; text-align: center;
  margin-top: -1px; padding: 6px 20px 18px;
  background: linear-gradient(180deg, var(--card), #fdf8ec);
}

/* ---------- Feature cards (home) ---------- */
.feature-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.feature-img {
  border-radius: 12px; overflow: hidden; line-height: 0;
  border: 1px solid var(--card-edge);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 28%, transparent),
              0 6px 14px -10px rgba(74,44,26,.5);
}
.feature-img img { display: block; width: 100%; height: auto; }
.feature {
  position: relative;
  background: linear-gradient(180deg, #fdf8ec, var(--card));
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  text-align: center;
  box-shadow: 0 10px 24px -16px rgba(74,44,26,.5);
}
.feature .feature-head {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  color: #f6e6c3; border-radius: 999px; white-space: nowrap;
  font-family: var(--font-display); font-weight: 700; font-size: 11.5px; letter-spacing:.01em;
  padding: 7px 8px; margin-bottom: 12px;
  border: 1px solid color-mix(in srgb,var(--gold) 50%, transparent);
  box-shadow: 0 2px 0 var(--red-dark);
}

/* ---------- Camera viewport (re-themed warm scan) ---------- */
.viewport {
  position: relative; width: 100%; aspect-ratio: 4/5;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 20%, #3a2a1a 0%, #241910 60%, #1a1109 100%);
  box-shadow: inset 0 0 0 1.5px var(--gold-line), inset 0 0 40px rgba(0,0,0,.6);
}
.viewport .vp-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    linear-gradient(color-mix(in srgb,var(--gold) 40%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb,var(--gold) 40%, transparent) 1px, transparent 1px);
  background-size: 28px 28px; mix-blend-mode: screen;
  -webkit-mask-image: radial-gradient(80% 80% at 50% 50%, #000 40%, transparent 78%);
          mask-image: radial-gradient(80% 80% at 50% 50%, #000 40%, transparent 78%);
}
.viewport .vp-vignette {
  position:absolute; inset:0; pointer-events:none;
  background: radial-gradient(75% 75% at 50% 45%, transparent 55%, rgba(0,0,0,.5));
}
.guide {
  position: absolute; pointer-events: none;
  border: 2px solid color-mix(in srgb, var(--gold-soft) 85%, transparent);
  box-shadow: 0 0 26px color-mix(in srgb, var(--gold) 55%, transparent),
              inset 0 0 22px color-mix(in srgb, var(--gold) 30%, transparent);
  animation: guidePulse 2s ease-in-out infinite;
}
.guide.hand { inset: 9% 17%; border-radius: 46% 46% 40% 40% / 52% 52% 38% 38%; }
.guide.face { inset: 14% 24%; border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%; }
@keyframes guidePulse { 0%,100%{opacity:.75} 50%{opacity:1} }

.vp-label {
  position: absolute; left: 12px; bottom: 12px;
  font-family: var(--font-ui); font-size: 10px; letter-spacing:.18em; text-transform:uppercase;
  color: var(--gold-soft); opacity:.85;
  display:flex; align-items:center; gap:6px;
}
.vp-label .dot { width:6px; height:6px; border-radius:50%; background: #e7b24a; box-shadow:0 0 8px #e7b24a; animation: blink 1.4s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }

/* scanning overlay */
.scan-overlay { position: absolute; inset: 0; background: rgba(20,12,6,.55); backdrop-filter: blur(1px); }
.scan-bar {
  position: absolute; left: 6%; right: 6%; height: 3px; top: 10%;
  background: linear-gradient(90deg, transparent, var(--gold-soft) 30%, #fff3d6, var(--gold-soft) 70%, transparent);
  box-shadow: 0 0 18px var(--gold-soft), 0 0 40px color-mix(in srgb,var(--gold) 60%, transparent);
  animation: scan 2.1s cubic-bezier(.5,0,.5,1) infinite;
}
@keyframes scan { 0%{top:8%} 50%{top:86%} 100%{top:8%} }
.scan-caption {
  position: absolute; left: 16px; right: 16px; bottom: 18px; text-align: center;
  font-family: var(--font-ui); font-size: 12.5px; color: var(--gold-soft);
  letter-spacing: .02em;
}
.palm-line, .mesh-line { stroke: var(--gold-soft); fill: none; opacity:.7; }
.mesh-dot { fill: var(--gold-soft); opacity:.8; }
.ai-tag {
  font-family: var(--font-ui); font-size: 8px; font-weight:600; letter-spacing:.1em;
  fill: #f6e6c3;
}
.ai-tag-bg { fill: var(--red); opacity:.85; }

/* ---------- Progress steps ---------- */
.steps { display: flex; align-items: center; gap: 6px; }
.step-dot {
  width: 22px; height: 22px; border-radius: 50%;
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-weight:700; font-size: 11px;
  border: 1.4px solid var(--gold-line); color: var(--ink-soft);
  background: var(--card);
}
.step-dot.on { background: linear-gradient(180deg,var(--red-bright),var(--red)); color:#f6e6c3; border-color: transparent; box-shadow:0 2px 6px rgba(106,20,20,.3); }
.step-dot.done { background: var(--gold); color:#3c2a10; border-color: transparent; }
.step-line { flex:1; height:1.5px; background: var(--gold-line); opacity:.45; }
.step-line.fill { background: var(--gold); opacity:.9; }

/* ---------- Inputs ---------- */
.field-label { font-size: 11px; font-weight:600; letter-spacing:.04em; color: var(--ink-soft); text-transform: uppercase; margin-bottom: 7px; display:block; }
.field {
  width: 100%; box-sizing: border-box;
  background: var(--card); color: var(--ink);
  border: 1.4px solid var(--card-edge);
  border-radius: var(--radius);
  padding: 14px 14px; font-family: var(--font-ui); font-size: 15px;
  text-align: left; cursor: pointer;
  display:flex; align-items:center; justify-content: space-between; gap: 10px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field:hover, .field.active { border-color: var(--gold-line); box-shadow: 0 0 0 3px color-mix(in srgb,var(--gold) 18%, transparent); }
.field.placeholder { color: var(--ink-soft); }
.field-ico { color: var(--red); display:flex; flex-shrink:0; }

.gender-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gender-opt {
  display:flex; align-items:center; justify-content:center; gap: 8px;
  background: var(--card); border: 1.4px solid var(--card-edge); border-radius: var(--radius);
  padding: 13px; font-family: var(--font-display); font-weight:600; font-size:15px; color: var(--ink-soft);
  cursor: pointer; transition: all .15s ease;
}
.gender-opt.sel { border-color: var(--gold-line); color: var(--red); background: color-mix(in srgb,var(--gold) 12%, var(--card)); box-shadow: 0 0 0 3px color-mix(in srgb,var(--gold) 16%, transparent); }
.gender-opt .g-ico { color: var(--red); }

/* ---------- Modal (DOB popper) ---------- */
.modal-overlay {
  position: absolute; inset: 0; z-index: 80;
  background: rgba(40,22,10,.5); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 1;
  animation: fade .25s ease;
}
@keyframes fade { from{opacity:0} to{opacity:1} }
.modal-sheet {
  width: 100%; background: var(--paper);
  border-radius: 26px 26px 0 0;
  border-top: 1.5px solid var(--gold-line);
  box-shadow: 0 -16px 40px rgba(40,22,10,.4);
  padding: 10px 18px 26px;
  transform: none;
  animation: sheetUp .32s cubic-bezier(.2,.8,.2,1);
  position: relative;
}
@keyframes sheetUp { from{ transform: translateY(100%) } to{ transform:none } }
.modal-grip { width: 42px; height: 5px; border-radius: 999px; background: var(--ink-faint); margin: 4px auto 12px; }

.wheels { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 10px; position: relative; }
.wheel {
  height: 180px; overflow-y: auto; scroll-snap-type: y mandatory;
  -ms-overflow-style: none; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
          mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}
.wheel::-webkit-scrollbar { display: none; }
.wheel-pad { height: 72px; }
.wheel-item {
  height: 36px; scroll-snap-align: center;
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-size: 18px; color: var(--ink-soft);
  transition: color .15s, transform .15s, opacity .15s; opacity:.5;
}
.wheel-item.sel { color: var(--red); font-weight: 800; font-size: 22px; opacity: 1; }
.wheel-window {
  position: absolute; left: 0; right: 0; top: 72px; height: 36px;
  border-top: 1.5px solid var(--gold-line); border-bottom: 1.5px solid var(--gold-line);
  pointer-events: none; background: color-mix(in srgb,var(--gold) 8%, transparent);
}
.wheel-cap { text-align:center; font-size: 10px; letter-spacing:.14em; text-transform:uppercase; color: var(--ink-soft); margin-bottom: 4px; }

/* ---------- Tử Vi chart (4x4 lá số) ---------- */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary-stat .lbl { font-size: 10px; letter-spacing:.1em; text-transform:uppercase; color: var(--ink-soft); }
.summary-stat .val { font-family: var(--font-display); font-weight:800; font-size: 20px; color: var(--red); }

.laso {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 5px;
}
.cung {
  position: relative;
  background: linear-gradient(180deg,#fdf8ec,var(--card));
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  padding: 6px 6px 7px;
  min-height: 78px;
  display:flex; flex-direction: column;
  cursor: pointer; transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease;
  overflow: hidden;
}
.cung:active { transform: scale(.97); }
.cung.menh { border-color: var(--gold-line); background: color-mix(in srgb,var(--gold) 12%, var(--card)); box-shadow: 0 0 0 1.5px color-mix(in srgb,var(--gold) 55%, transparent); }
.cung.than { border-color: var(--red); box-shadow: 0 0 0 1.5px color-mix(in srgb,var(--red) 40%, transparent); }
.cung-top { display:flex; align-items:center; justify-content:space-between; gap:4px; }
.cung-name { font-family: var(--font-display); font-weight:700; font-size: 11.5px; color: var(--ink); line-height:1; }
.cung-branch { font-size: 8.5px; color: var(--ink-soft); letter-spacing:.06em; }
.cung-stars { margin-top: 5px; display:flex; flex-direction:column; gap:1px; }
.cung-star { font-size: 9px; line-height:1.25; color: var(--gold-line); font-weight:600; }
.cung-star.major { color: var(--red); }
.cung-badge {
  position:absolute; top:5px; right:5px;
  font-size:7.5px; font-weight:800; letter-spacing:.06em; font-family:var(--font-ui);
  padding: 1px 4px; border-radius: 4px;
}
.cung-badge.menh { background: var(--gold); color:#3c2a10; }
.cung-badge.than { background: var(--red); color:#f6e6c3; }

.laso-center {
  grid-column: 2 / 4; grid-row: 2 / 4;
  background:
    radial-gradient(circle at 50% 38%, color-mix(in srgb,var(--gold) 16%, var(--card)), var(--card));
  border: 1px solid var(--gold-line);
  border-radius: 10px;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
  text-align:center; padding: 8px;
}

/* coin-seal cung icon */
.seal {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink:0;
  display:flex; align-items:center; justify-content:center; position: relative;
  background: radial-gradient(circle at 38% 32%, #e7c882, var(--gold));
  box-shadow: inset 0 0 0 1px #94701f, 0 1px 2px rgba(0,0,0,.2);
  color: var(--red-dark); font-family: var(--font-display); font-weight: 800;
}
.seal .seal-han { font-size: 11px; line-height: 1; }
.seal::after { content:""; position:absolute; inset:4.5px; border:1px solid rgba(60,42,16,.35); border-radius:3px; }
.seal.lg { width: 40px; height: 40px; }
.seal.lg .seal-han { font-size: 20px; }
.seal.lg::after { inset: 8px; }
.seal.red { background: radial-gradient(circle at 38% 32%, var(--red-bright), var(--red-dark)); color: var(--gold-soft); box-shadow: inset 0 0 0 1px #4d0e0e, 0 1px 2px rgba(0,0,0,.3); }

/* ---------- Reading sections ---------- */
.read-card { position: relative; }
.read-head {
  display:flex; align-items:center; gap: 10px; margin-bottom: 10px;
}
.read-head .pill { box-shadow: 0 2px 0 var(--red-dark); }
.read-body { font-size: 13.5px; line-height: 1.72; color: var(--ink); }
.read-body p { margin: 0 0 8px; }
.read-more {
  font-family: var(--font-display); font-weight:700; font-size: 12px; color: var(--red);
  display:inline-flex; align-items:center; gap:5px; cursor:pointer; margin-top: 2px;
}
.read-more:hover { color: var(--red-bright); }

.prose h2 { font-family: var(--font-display); color: var(--red); font-size: 16px; margin: 14px 0 6px; }
.prose h3 { font-family: var(--font-display); color: var(--red-bright); font-size: 14px; margin: 12px 0 4px; }
.prose p { font-size: 13.5px; line-height: 1.72; margin: 0 0 9px; color: var(--ink); }
.prose strong { color: var(--red); font-weight: 700; }
.prose em { color: var(--ink-soft); font-style: italic; }
.prose ul { margin: 4px 0 10px 18px; }
.prose li { font-size: 13.5px; line-height: 1.6; margin: 3px 0; }

/* ---------- misc ---------- */
.divider-flourish { display:flex; align-items:center; justify-content:center; gap:10px; color: var(--gold-line); }
.divider-flourish::before, .divider-flourish::after { content:""; height:1px; width: 46px; background: currentColor; opacity:.6; }
.diamond { width:6px; height:6px; background: var(--gold); transform: rotate(45deg); }

.cloud-wm {
  position:absolute; pointer-events:none; opacity:.10; color: var(--red);
}
.ornament-subtle .cloud-wm { display:none; }

.note { font-size: 11.5px; color: var(--ink-soft); text-align:center; line-height:1.5; }
.scroll-soft { overflow-y: auto; }
.scroll-soft::-webkit-scrollbar { width: 0; }
