/* JyotishAI — layout: a fixed top bar with the brand and primary nav, a content column (max 1120px),
   dashboards as card grids that collapse to one column on phones. Colours: midnight blue, indigo, ivory, gold. */
:root {
  /* dark-first: deep space */
  --bg: #070a22; --bg-2: rgba(21,26,63,.75); --panel: rgba(16,20,52,.72); --fg: #efe9da; --fg-2: #c9c3b2; --muted: #9a95a8; --line: rgba(226,192,103,.22);
  --accent: #8e93ea; --accent-2: #aeb2f5; --gold: #e2c067; --gold-2: #f0d78a; --good: #6fcf97; --warn: #f2b05c; --bad: #ef7a73;
  --chart-stroke: #e2c067; --chart-fill: rgba(10,13,40,.85); --chart-text: #efe9da; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 40px rgba(0,0,0,.45); --glow: 0 0 40px rgba(226,192,103,.12);
  color-scheme: dark;
  --font-display: "Cormorant Garamond", "Noto Serif Devanagari", Georgia, serif;
  --font-body: "Mukta", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) {
  --bg: #f4f1fa; --bg-2: rgba(239,233,219,.8); --panel: rgba(255,253,247,.82); --fg: #1b1f3a; --fg-2: #4a4f6e; --muted: #7a7f9c; --line: rgba(43,47,119,.18);
  --accent: #2b2f77; --accent-2: #3f44a8; --gold: #b8892b; --gold-2: #e2c067; --good: #2e7d4f; --warn: #b26a00; --bad: #b3362f;
  --chart-stroke: #2b2f77; --chart-fill: rgba(255,253,247,.9); --chart-text: #1b1f3a; --shadow: 0 1px 2px rgba(27,31,58,.08), 0 8px 24px rgba(27,31,58,.08); --glow: none;
  color-scheme: light; } }
:root[data-theme="light"] {
  --bg: #f4f1fa; --bg-2: rgba(239,233,219,.8); --panel: rgba(255,253,247,.82); --fg: #1b1f3a; --fg-2: #4a4f6e; --muted: #7a7f9c; --line: rgba(43,47,119,.18);
  --accent: #2b2f77; --accent-2: #3f44a8; --gold: #b8892b; --gold-2: #e2c067; --good: #2e7d4f; --warn: #b26a00; --bad: #b3362f;
  --chart-stroke: #2b2f77; --chart-fill: rgba(255,253,247,.9); --chart-text: #1b1f3a; --shadow: 0 1px 2px rgba(27,31,58,.08), 0 8px 24px rgba(27,31,58,.08); --glow: none;
  color-scheme: light; }

* { box-sizing: border-box; }
html, body { margin: 0; }
#cosmos { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; display: block; }
#cosmos-gl { position: fixed; inset: 0; z-index: -2; width: 100%; height: 100%; display: block; image-rendering: auto; }
@media print { #cosmos-gl { display: none; } }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 16px; line-height: 1.55; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); } h2 { font-size: clamp(1.5rem, 3vw, 2rem); } h3 { font-size: 1.25rem; } h4 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.eyebrow { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: .9em; }
[hidden] { display: none !important; }

/* Top bar */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50; background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand-mark { width: 36px; height: 36px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--gold-2), var(--gold) 60%, var(--accent) 61%); box-shadow: inset 0 0 0 2px var(--panel); flex: none; }
.brand-name { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; letter-spacing: .01em; }
.brand-tag { font-size: .72rem; color: var(--muted); display: block; margin-top: -4px; }
.spacer { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--fg); padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #0b0e2e; border-color: var(--accent); font-weight: 600; }
:root[data-theme="light"] .btn-primary { color: #fff; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .btn-primary { color: #fff; } }
.btn-primary:hover { background: var(--accent-2); }
.btn-gold { background: var(--gold); color: #1b1f3a; border-color: var(--gold); font-weight: 700; }
.btn-primary { box-shadow: 0 0 0 0 rgba(226,192,103,0); }
.btn-primary:hover { box-shadow: 0 0 24px rgba(142,147,234,.35); }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; max-width: 1120px; margin: 0 auto; padding: 0 12px 8px; }
.nav a { padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--fg-2); font-size: .9rem; white-space: nowrap; }
.nav a:hover { background: var(--bg-2); color: var(--fg); }
.nav a.active { background: var(--accent); color: #0b0e2e; }
:root[data-theme="light"] .nav a.active, :root[data-theme="light"] .msg.user { color: #fff; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .nav a.active, :root:not([data-theme="dark"]) .msg.user { color: #fff; } }
.nav-toggle { display: none; }
@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .nav { display: none; flex-direction: column; padding-bottom: 12px; }
  .nav.open { display: flex; }
  .brand-tag { display: none; }
}

/* Layout */
.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.section { display: none; }
.section.active { display: block; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.hero { padding: 28px 0 28px; display: grid; grid-template-columns: 1fr 1.05fr; gap: 32px; align-items: start; }
.hero h1 { font-size: clamp(2.3rem, 5.5vw, 4rem); text-shadow: 0 2px 6px rgba(0,0,0,.55), 0 4px 40px rgba(0,0,0,.6); }
.hero p.lead { text-shadow: 0 1px 4px rgba(0,0,0,.5), 0 2px 18px rgba(0,0,0,.5); }
:root[data-theme="light"] .hero h1, :root[data-theme="light"] .hero p.lead { text-shadow: 0 1px 12px rgba(255,255,255,.8); }
.hero .eyebrow { text-shadow: 0 1px 12px rgba(0,0,0,.4); }
.hero-visual { position: relative; margin-top: 56px; display: grid; place-items: center; overflow: hidden; padding: 24px 0; }
.zodiac-ring { position: absolute; width: min(460px, 100%); aspect-ratio: 1; max-width: 100%; pointer-events: none; opacity: .9; animation: spin 240s linear infinite; }
.zodiac-ring text { fill: var(--gold); font-family: var(--font-display); font-size: 15px; letter-spacing: .1em; }
.zodiac-ring circle, .zodiac-ring line { stroke: var(--gold); fill: none; }
.hero-visual .kundli { max-width: 340px; filter: drop-shadow(0 0 28px rgba(226,192,103,.18)); position: relative; }
@media (prefers-reduced-motion: reduce) { .zodiac-ring { animation: none; } }
#birthForm.card { box-shadow: var(--shadow), var(--glow); }
@media (max-width: 800px) { .hero { grid-template-columns: 1fr; } }
.hero p.lead { font-size: 1.15rem; color: var(--fg-2); max-width: 36rem; margin-top: 12px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.feature { display: grid; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); text-decoration: none; color: inherit; transition: transform .2s, border-color .2s; }
.feature:hover { transform: translateY(-2px); }
.feature:hover { border-color: var(--gold); }
.feature strong { font-family: var(--font-display); font-size: 1.15rem; }
.notice { border-left: 3px solid var(--gold); background: var(--bg-2); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: .92rem; }
.notice.warn { border-color: var(--warn); } .notice.bad { border-color: var(--bad); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--bg-2); color: var(--fg-2); border: 1px solid var(--line); }
.pill.good { color: var(--good); border-color: var(--good); } .pill.warn { color: var(--warn); border-color: var(--warn); } .pill.bad { color: var(--bad); border-color: var(--bad); } .pill.gold { color: var(--gold); border-color: var(--gold); }

/* Forms */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 600px) { .form { grid-template-columns: 1fr; } }
.field { display: grid; gap: 4px; min-width: 0; position: relative; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .85rem; font-weight: 600; color: var(--fg-2); }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--fg); min-width: 0; }
.field input::placeholder, .chat-input textarea::placeholder { color: var(--muted); }
.field input:invalid { border-color: var(--bad); }
.field .err { color: var(--bad); font-size: .8rem; min-height: 1em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-time { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.dropdown { backdrop-filter: blur(14px); position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; max-height: 240px; overflow: auto; box-shadow: var(--shadow); }
.dropdown button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; cursor: pointer; }
.dropdown button:hover, .dropdown button.hl { background: var(--bg-2); }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 400 !important; } .field .check input { width: auto; margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
tr:hover td { background: var(--bg-2); }

/* Tabs & accordion */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--fg-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--gold); font-weight: 600; }
details { border: 1px solid var(--line); border-radius: 8px; padding: 0; background: var(--panel); }
details + details { margin-top: 8px; }
summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; color: var(--gold); font-weight: 700; }
details[open] summary::after { content: '–'; }
details .body { padding: 0 14px 14px; color: var(--fg-2); }

/* Kundli chart */
.kundli { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.kundli text { font-family: var(--font-body); fill: var(--chart-text); }
.kundli .sign { font-family: var(--font-data); fill: var(--gold); font-size: 11px; font-weight: 700; }
.kundli .pl { font-size: 12px; font-weight: 600; cursor: default; }
.kundli .pl.retro { fill: var(--bad); }
.kundli .frame { fill: var(--chart-fill); stroke: var(--chart-stroke); stroke-width: 1.5; }
.chart-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.tip { position: fixed; z-index: 99; background: #efe9da; color: #0b0e2e; padding: 6px 10px; border-radius: 6px; font-size: .8rem; pointer-events: none; max-width: 260px; }

/* Dasha tree */
.dasha-tree { display: grid; gap: 6px; }
.dasha-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.dasha-row.current { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--panel)); }
.dasha-row.l2 { margin-left: 18px; } .dasha-row.l3 { margin-left: 36px; font-size: .9rem; }

/* Chat */
.chat { display: grid; grid-template-rows: auto 1fr auto; gap: 10px; min-height: 420px; }
.chat-log { display: grid; gap: 10px; align-content: start; max-height: 60vh; overflow: auto; padding: 4px; }
.msg { padding: 10px 14px; border-radius: 12px; max-width: 85%; white-space: pre-wrap; }
.msg.user { background: var(--accent); color: #0b0e2e; justify-self: end; border-bottom-right-radius: 2px; }
.msg.ai { background: var(--bg-2); border: 1px solid var(--line); border-bottom-left-radius: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: .82rem; cursor: pointer; }
.chips button:hover { border-color: var(--gold); }
.chat-input { display: flex; gap: 8px; }
.chat-input textarea { flex: 1; resize: vertical; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }

/* Score bars */
.bar { height: 8px; background: var(--bg-2); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); }
.big { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; line-height: 1; }

/* Report prose */
.prose { max-width: 70ch; color: var(--fg-2); } .prose p + p { margin-top: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .95rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.footer { border-top: 1px solid var(--line); margin-top: 40px; padding-top: 18px; font-size: .85rem; color: var(--muted); text-shadow: 0 1px 8px rgba(0,0,0,.3); }
.section > .card-head h2, .section > .card-head .eyebrow { text-shadow: 0 1px 14px rgba(0,0,0,.35); }
@media print { #cosmos { display: none; } }
.toast { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: #efe9da; color: #0b0e2e; padding: 10px 16px; border-radius: 8px; z-index: 100; box-shadow: var(--shadow); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.day { border: 1px solid var(--line); border-radius: 6px; padding: 6px; min-height: 58px; font-size: .78rem; background: var(--panel); }
.day.good { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--panel)); }
.day.bad { opacity: .6; }
.day b { display: block; font-family: var(--font-data); }
@media (max-width: 600px) { .month-grid { grid-template-columns: repeat(4, minmax(0,1fr)); } }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } @media (max-width: 600px) { .settings-grid { grid-template-columns: 1fr; } }
@media print { .topbar, .nav, .hero-actions, .chat-input, .chips, .chart-tools, .no-print { display: none !important; } .section { display: block !important; } body { background: #fff; color: #000; } .card { break-inside: avoid; } }
