/* The page shell: tokens for both themes, the top bar, the chapter sidebar,
   chapters and cards, folded options, the birth-data sheet. Loaded after
   style.css (the components) and docs.css (the documents). */

:root {
  color-scheme: light;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --bg: #f4f2ec; --bg-2: #ebe8df; --panel: #ffffff; --panel-2: #f9f8f4;
  --ink: #1f1d26; --muted: #6b6776; --faint: #9a96a3; --border: #e4e0d6; --border-2: #d6d1c4;
  --accent: #5a49c2; --accent-ink: #ffffff; --accent-soft: rgba(90, 73, 194, 0.09); --accent-line: rgba(90, 73, 194, 0.35);
  --saffron: #b8650f; --saffron-soft: rgba(184, 101, 15, 0.10);
  --line: #6a5acd; --red: #c0392b; --good: #1d7a4c; --bad: #a5281b; --warn: #8a6100;
  --wheel-ring: #b9b3a6; --wheel-line: #d3cdc0; --wheel-house: #fbfaf7; --wheel-inner: #fffefb;
  --shadow: 0 1px 2px rgba(25, 20, 45, 0.04), 0 6px 20px rgba(25, 20, 45, 0.05);
  --shadow-lg: 0 24px 60px rgba(20, 16, 40, 0.22);
  --radius: 14px; --top: 60px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131218; --bg-2: #1a1920; --panel: #1c1b23; --panel-2: #22212a;
    --ink: #ecebf1; --muted: #a6a2b3; --faint: #77737f; --border: #2e2c37; --border-2: #3b3946;
    --accent: #a597ff; --accent-ink: #15131c; --accent-soft: rgba(165, 151, 255, 0.12); --accent-line: rgba(165, 151, 255, 0.4);
    --saffron: #e9a352; --saffron-soft: rgba(233, 163, 82, 0.12);
    --line: #8f80f0; --red: #ff7a6a; --good: #63d29a; --bad: #ff8a7a; --warn: #e6bd55;
    --wheel-ring: #5a5766; --wheel-line: #3a3844; --wheel-house: #1f1e27; --wheel-inner: #22212a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131218; --bg-2: #1a1920; --panel: #1c1b23; --panel-2: #22212a;
  --ink: #ecebf1; --muted: #a6a2b3; --faint: #77737f; --border: #2e2c37; --border-2: #3b3946;
  --accent: #a597ff; --accent-ink: #15131c; --accent-soft: rgba(165, 151, 255, 0.12); --accent-line: rgba(165, 151, 255, 0.4);
  --saffron: #e9a352; --saffron-soft: rgba(233, 163, 82, 0.12);
  --line: #8f80f0; --red: #ff7a6a; --good: #63d29a; --bad: #ff8a7a; --warn: #e6bd55;
  --wheel-ring: #5a5766; --wheel-line: #3a3844; --wheel-house: #1f1e27; --wheel-inner: #22212a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

html { scroll-padding-top: calc(var(--top) + 16px); }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }

/* ---------- the frame ---------- */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); grid-template-rows: var(--top) auto; min-height: 100vh; }
.topbar {
  grid-column: 1 / -1; position: sticky; top: 0; z-index: 50; height: var(--top);
  display: flex; align-items: center; gap: 14px; padding: 0 18px 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--saffron)); color: #fff; font-size: 17px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: .01em; }
.brand-text small { font-size: 11px; color: var(--muted); white-space: nowrap; }

.identity {
  margin-left: auto; width: auto; display: flex; align-items: center; gap: 10px; min-width: 0;
  background: var(--panel); color: var(--ink); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 6px 5px 6px; font-weight: 400; font-size: 13px; cursor: pointer; box-shadow: var(--shadow);
}
.identity:hover { border-color: var(--accent-line); filter: none; }
.id-avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-size: 16px;
}
.id-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; text-align: left; line-height: 1.2; }
.id-name { font-weight: 650; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.id-meta { color: var(--muted); font-size: 12px; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.id-edit {
  background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 12.5px;
  white-space: nowrap;
}
.top-actions { display: flex; align-items: center; gap: 6px; }
.ghost-link { color: var(--muted); text-decoration: none; font-size: 13.5px; padding: 8px 10px; border-radius: 8px; }
.ghost-link:hover { color: var(--ink); background: var(--accent-soft); }
.icon-btn {
  width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: 10px;
  background: transparent; color: var(--muted); border: 1px solid transparent; font-size: 17px; font-weight: 400;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--ink); filter: none; }
.nav-toggle { display: none; }
.burger, .burger::before, .burger::after { display: block; width: 16px; height: 2px; border-radius: 2px; background: currentColor; position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -5px; } .burger::after { top: 5px; }

/* ---------- the sidebar ---------- */
.sidebar {
  position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto;
  padding: 14px 12px 24px 14px; border-right: 1px solid var(--border); background: var(--bg);
}
.nav-group { margin: 18px 10px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.nav-group:first-child { margin-top: 6px; }
.chap {
  display: grid; grid-template-columns: 30px 1fr; gap: 4px; align-items: start;
  padding: 8px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; margin-bottom: 1px;
  transition: background .12s;
}
.chap:hover { background: var(--bg-2); }
.chap .num { font-family: var(--serif); font-size: 13px; color: var(--faint); padding-top: 1px; }
.chap .t { display: block; font-size: 14px; font-weight: 600; line-height: 1.3; }
.chap .s { display: block; font-size: 12px; color: var(--muted); font-family: var(--serif); font-style: italic; line-height: 1.3; margin-top: 1px; }
.chap.on { background: var(--accent-soft); }
.chap.on .num, .chap.on .t { color: var(--accent); }
.subnav { margin: 2px 0 8px 40px; padding-left: 10px; border-left: 1px solid var(--border-2); }
.subnav a {
  display: block; font-size: 12.5px; color: var(--muted); text-decoration: none; padding: 3px 8px; border-radius: 6px;
  margin-left: -11px; border-left: 2px solid transparent;
}
.subnav a:hover { color: var(--ink); }
.subnav a.on { color: var(--accent); border-left-color: var(--accent); background: none; }
.nav-foot { margin: 22px 10px 0; font-size: 11.5px; color: var(--faint); }

/* ---------- the content ---------- */
main.content { display: block; padding: 22px 34px 80px; min-width: 0; max-width: 1440px; }
.chapter { display: none; }
.chapter.on { display: block; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chapter.on { animation: none; } * { transition: none !important; } }
.ch-head { margin: 10px 0 26px; max-width: 880px; }
.ch-kicker { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--saffron); }
.ch-head h1 { margin: 6px 0 10px; font-family: var(--serif); font-weight: 600; font-size: clamp(26px, 3.2vw, 36px); line-height: 1.12; letter-spacing: -.005em; }
.ch-lede { margin: 0; font-size: 16px; line-height: 1.62; color: var(--muted); max-width: 72ch; }
.ch-src { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 14px 0 0; }
.ch-src li { font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }

.cards { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
.cards > * { grid-column: 1 / -1; }
.cards > .span-8 { grid-column: span 8; } .cards > .span-6 { grid-column: span 6; } .cards > .span-4 { grid-column: span 4; }
.stack { display: grid; gap: 20px; }
@media (max-width: 1280px) { .cards > .span-6 { grid-column: 1 / -1; } }
@media (max-width: 1180px) { .cards > .span-8, .cards > .span-4 { grid-column: 1 / -1; } .stack { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 8px 28px; }
.split > * { min-width: 0; }

.panel { border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); margin: 0; max-width: none; }
.panel h2 { text-transform: none; letter-spacing: 0; color: var(--ink); }
.card-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 14px; }
.card-head h2 { margin: 0; font-family: var(--serif); font-size: 21px; font-weight: 600; line-height: 1.25; }
.card-head .sk { color: var(--muted); font-family: var(--serif); font-style: italic; font-size: 14.5px; }
.card-head .src {
  margin-left: auto; font-size: 11.5px; color: var(--muted); white-space: nowrap;
  border: 1px solid var(--border); background: var(--panel-2); border-radius: 999px; padding: 2px 9px; align-self: center;
}
.card-head .help { align-self: center; }
.card-head .src + .help { margin-left: 0; }
.card-head h2 + .help, .card-head .sk + .help { margin-left: auto; }
.nc {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--saffron); background: var(--saffron-soft);
  border-radius: 999px; padding: 2px 9px; align-self: center; white-space: nowrap;
}
.nonclassical { border-top: 3px solid color-mix(in srgb, var(--saffron) 55%, transparent); }
.card-sub { margin: -6px 0 12px; font-size: 13px; color: var(--muted); }
.sub3 { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; margin: 18px 0 8px; color: var(--muted); }
.sub3 .hint2 { letter-spacing: 0; font-weight: 400; }
.chart-name { font-family: var(--serif); font-size: 19px; }

/* tables: quieter rules, a hover row, numbers aligned */
table { font-size: 13px; }
th { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; border-bottom: 1px solid var(--border-2); }
td { border-bottom: 1px solid var(--border); }
tbody tr:hover > td { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }

/* the inputs */
input, select { background: var(--panel-2); border-color: var(--border-2); border-radius: 8px; color: var(--ink); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { cursor: pointer; }
button { background: var(--accent); color: var(--accent-ink); border-radius: 10px; }
button.secondary { color: var(--accent); border-color: var(--accent-line); }
.help { border-color: var(--accent-line); width: 18px; height: 18px; font-size: 11px; }
.help:hover { color: var(--accent-ink); }
.help.static { cursor: default; vertical-align: 1px; }
.varga-picker label.on, .docs-langs button.on, .docs-tabs button.on { color: var(--accent-ink); }

/* segmented radio groups */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; margin: 0 0 12px; background: var(--bg-2); border-radius: 10px; align-items: center; }
.seg .hint2 { padding: 0 8px 0 6px; }
.seg label { margin: 0; padding: 5px 11px; border-radius: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.seg label:has(input:checked) { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); }

/* folded options: the defaults stay out of the way */
details.opts { border: 1px solid var(--border); border-radius: 11px; background: var(--panel-2); margin: 0 0 14px; }
details.opts > summary {
  list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--muted);
}
details.opts > summary::-webkit-details-marker { display: none; }
details.opts > summary::before {
  content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s; margin-right: 2px;
}
details.opts[open] > summary::before { transform: rotate(45deg); }
details.opts > summary:hover { color: var(--ink); }
details.opts > :not(summary) { padding: 4px 12px 12px; margin: 0; }
details.opts .row { display: flex; flex-wrap: wrap; gap: 10px 14px; }
details.opts .row > label, details.opts .dr-settings > label { flex: 1 1 240px; margin: 0; }
.opts-count { font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 1px 8px; }
.opts-reset {
  margin-left: auto; width: auto; padding: 2px 8px; font-size: 12px; font-weight: 600; background: transparent;
  color: var(--accent); border: 0; border-radius: 6px;
}
.opts-reset:hover { background: var(--accent-soft); filter: none; }
.opts-reset[hidden] { display: none; }
.opts-body { display: grid; gap: 4px; }

/* the charts card */
.chart-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 12px; }
.tb-field { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 12.5px; }
.tb-field select { width: auto; margin: 0; padding: 5px 8px; font-size: 13px; }
.tb-hint { margin-left: auto; }
.popover { position: relative; }
.popover > summary {
  list-style: none; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink);
  border: 1px solid var(--border-2); border-radius: 8px; padding: 5px 10px; background: var(--panel-2);
}
.popover > summary::-webkit-details-marker { display: none; }
.popover > summary::after { content: " ▾"; color: var(--muted); }
.popover-body {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 240px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  display: grid; gap: 8px; text-align: left;
}
.popover-body label { justify-content: flex-start; }
.varga-picker { justify-content: flex-start; gap: 5px; }
.varga-picker label { padding: 4px 10px; background: var(--panel-2); }
.varga-picker label:hover { border-color: var(--accent-line); color: var(--ink); }
.charts-grid { gap: 18px; }
.one-chart { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 10px 8px; }

/* the glance strip */
.glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 8px; }
.glance:empty { display: none; }
.g-item {
  width: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
  background: var(--panel); color: var(--ink); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 13px; box-shadow: var(--shadow); font-weight: 400; cursor: pointer; min-width: 0;
}
.g-item:hover { border-color: var(--accent-line); filter: none; transform: translateY(-1px); }
.g-label { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.g-value { font-family: var(--serif); font-size: 17px; font-weight: 600; line-height: 1.25; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-sub { font-size: 12px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* chapter pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 34px 0 0; }
.pager a {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
  text-decoration: none; color: var(--ink); background: var(--panel);
}
.pager a:hover { border-color: var(--accent-line); }
.pager small { color: var(--muted); font-size: 12px; }
.pager b { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.pager .next { text-align: right; grid-column: 2; }

/* the moment tools */
.moment-when .row { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.moment-when .row > label { flex: 1 1 160px; }
.moment-when [hidden] { display: none !important; }
.tool-tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; margin: 6px 0 14px; background: var(--bg-2); border-radius: 12px; }
.tool-tabs button {
  width: auto; flex: 1 1 auto; background: transparent; color: var(--muted); border: 0; font-size: 13.5px; font-weight: 600;
  padding: 8px 12px; border-radius: 9px; display: inline-flex; flex-direction: column; align-items: center; line-height: 1.2;
}
.tool-tabs button small { font-weight: 400; font-size: 11px; font-family: var(--serif); font-style: italic; color: var(--faint); }
.tool-tabs button:hover { color: var(--ink); filter: none; }
.tool-tabs button[aria-selected="true"] { background: var(--panel); color: var(--accent); box-shadow: var(--shadow); }
.tool-opts[hidden], [data-tools][hidden] { display: none !important; }
.m-out .empty { color: var(--muted); font-size: 14px; }
.m-out.busy { opacity: .55; transition: opacity .15s; }
.m-out h3 { font-family: var(--serif); font-size: 18px; font-weight: 600; margin: 18px 0 8px; }

/* the dasha card */
.dasha-main { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 10px; }
.dasha-main > label { flex: 1 1 200px; margin: 0; }
.dasha-list { max-height: 520px; background: var(--panel-2); }
.sud-inline { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 8px; }
.sud-inline label { flex: 1 1 220px; display: block; }

/* sources */
.biblio { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.biblio li { padding-left: 14px; border-left: 2px solid var(--border-2); font-size: 14px; line-height: 1.45; }
.biblio b { font-family: var(--serif); font-size: 15.5px; }
.biblio li > span:not(.used) { color: var(--muted); margin-left: 6px; }
.biblio em { display: block; color: var(--muted); font-size: 13px; }
.biblio .used { display: block; font-size: 12.5px; color: var(--ink); opacity: .8; margin-top: 2px; }
.btn-link { display: inline-block; padding: 9px 16px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 600; }

/* ---------- the birth-data sheet ---------- */
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 90; width: min(440px, 100vw);
  display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); transform: translateX(104%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  visibility: hidden;
}
.sheet.open { transform: none; visibility: visible; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px 22px; }
.sheet-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.sheet-close { font-size: 24px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 0 22px 16px; }
.sheet-body .sub3:first-child { margin-top: 6px; }
.sheet-foot { border-top: 1px solid var(--border); padding: 12px 22px 18px; background: var(--panel); }
.sheet-foot .err:empty { display: none; }
.sheet-foot .err { margin: 0 0 8px; }
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(12, 10, 22, 0.38); backdrop-filter: blur(2px); }
.scrim[hidden] { display: none; }
.sidebar-scrim { z-index: 45; }

/* dark-theme fixes for colours set inline in the components */
:root[data-theme="dark"] .v-good, :root[data-theme="dark"] .fav-dot, :root[data-theme="dark"] #planets .vg { color: var(--good); }
:root[data-theme="dark"] .v-bad { color: var(--bad); }
:root[data-theme="dark"] .v-mixed { color: var(--warn); }
:root[data-theme="dark"] #chakra-points td.cp-pos { color: var(--good); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .v-good, :root:not([data-theme="light"]) .fav-dot,
  :root:not([data-theme="light"]) #planets .vg, :root:not([data-theme="light"]) #chakra-points td.cp-pos { color: var(--good); }
  :root:not([data-theme="light"]) .v-bad { color: var(--bad); }
  :root:not([data-theme="light"]) .v-mixed { color: var(--warn); }
}

/* ---------- narrow screens ---------- */
@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: grid; }
  .sidebar {
    position: fixed; top: var(--top); left: 0; bottom: 0; height: auto; width: min(300px, 86vw); z-index: 60;
    transform: translateX(-104%); transition: transform .24s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg);
    background: var(--panel); visibility: hidden;
  }
  .app.nav-open .sidebar { transform: none; visibility: visible; }
  main.content { padding: 18px 22px 64px; }
}
@media (max-width: 720px) {
  :root { --top: 56px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-text small, .ghost-link, .id-meta { display: none; }
  .brand-text b { font-size: 16px; }
  .identity { padding: 4px; gap: 8px; }
  .id-avatar { display: none; }
  .id-name { max-width: 30vw; padding-left: 8px; }
  main.content { padding: 14px 16px 56px; }
  .panel { padding: 16px 14px; border-radius: 12px; }
  .cards { gap: 14px; }
  .card-head h2 { font-size: 19px; }
  .card-head .src { margin-left: 0; }
  .ch-lede { font-size: 15px; }
  .glance { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb-hint { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .sheet { width: 100vw; }
}

/* ---------- print: the open chapter, without the frame ---------- */
@media print {
  .topbar, .sidebar, .pager, details.opts, .glance, .help { display: none !important; }
  .app { display: block; }
  .panel { box-shadow: none; break-inside: avoid; }
}

/* a notice for an error raised while the sheet is closed */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 95; max-width: min(560px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 13.5px;
}
.toast[hidden] { display: none; }
.toast button { width: auto; padding: 6px 12px; font-size: 13px; background: var(--accent); color: var(--accent-ink); flex: none; }

/* the varga picker: codes only, the names in the tooltip and on each chart */
.varga-picker .vp-name { display: none; }
.varga-picker label { min-width: 46px; justify-content: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-name { display: none; }
.glance { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
@media print { .chart-name { display: block; } }
.g-sub { white-space: normal; overflow: visible; }
.g-value { font-size: 16px; }

/* the periods running today */
.dasha-now { display: grid; gap: 12px; }
.dn-row { display: grid; grid-template-columns: 96px 1fr; gap: 2px 12px; align-items: baseline; }
.dn-lvl { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); grid-row: span 2; }
.dn-name { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.dn-dates { grid-column: 2; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dn-bar { grid-column: 2; height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; margin-top: 4px; }
.dn-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--saffron)); }
.dn-next { margin: 4px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--muted); }
.dn-next b { color: var(--ink); font-family: var(--serif); font-size: 15px; }

/* narrow screens: a toolbar field that wraps, the glance as a strip that scrolls sideways */
.tb-field { max-width: 100%; flex-wrap: wrap; }
.tb-field select { max-width: 100%; min-width: 0; }
@media (max-width: 720px) {
  .glance { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; margin: 0 -16px 8px; padding: 2px 16px 6px; scrollbar-width: none; }
  .glance::-webkit-scrollbar { display: none; }
  .g-item { flex: 0 0 auto; width: 150px; scroll-snap-align: start; }
  .tb-field { flex: 1 1 100%; }
  .tb-field select { flex: 1 1 auto; }
}
.m-out { overflow-x: auto; }

/* the documents page inside the same frame */
.docs-layout { max-width: 1440px; }
.docs-nav { top: calc(var(--top) + 12px); max-height: calc(100vh - var(--top) - 24px); }
.docs-nav a.on { background: var(--accent-soft); color: var(--accent); }
.docs-nav a:hover { background: var(--bg-2); }
@media (max-width: 720px) { .docs-layout .ghost-link { display: inline; } }

/* the dasha tree and its levels */
.dasha-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 4px; }
.dl { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--bg-2); border-radius: 10px; flex-wrap: wrap; }
.dl button { width: auto; padding: 5px 9px; font-size: 12.5px; font-weight: 600; border-radius: 8px; background: transparent;
  color: var(--faint); border: 0; }
.dl button:hover:not(:disabled) { color: var(--ink); filter: none; }
.dl .dl-chip.on { color: var(--ink); background: var(--panel); box-shadow: var(--shadow); }
.dl .dl-chip.on[aria-pressed="true"] { color: var(--accent); }
.dl .dl-step { width: 28px; padding: 5px 0; font-size: 16px; line-height: 1; color: var(--accent); }
.dl .dl-step:disabled { color: var(--faint); opacity: .45; cursor: default; }
.dt-actions { display: inline-flex; gap: 4px; margin-left: auto; }
.ghost-btn { width: auto; padding: 5px 10px; font-size: 12.5px; font-weight: 600; background: transparent; color: var(--accent);
  border: 1px solid var(--border-2); border-radius: 8px; }
.ghost-btn:hover { background: var(--accent-soft); filter: none; }
.dl-name { margin: 2px 0 8px; }
.dasha-tree { padding: 4px; max-height: 560px; }
.dt-row {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) 34px 118px 76px; align-items: center; gap: 8px;
  padding: 4px 10px 4px calc(6px + (var(--indent, 0) * 18px)); border-radius: 6px; font-size: 13.5px;
  font-variant-numeric: tabular-nums; outline-offset: -2px;
}
.dt-row.lvl-1 { --indent: 0; font-size: 14px; }
.dt-row.lvl-2 { --indent: 1; }
.dt-row.lvl-3 { --indent: 2; font-size: 13px; }
.dt-row.lvl-4 { --indent: 3; font-size: 12.5px; }
.dt-row.lvl-5 { --indent: 4; font-size: 12.5px; }
.dt-row.lvl-1 + .dt-kids, .dt-kids .dt-kids { border-left: 1px solid var(--border-2); margin-left: 12px; }
.dt-kids .dt-kids { margin-left: 18px; }
.dt-row.can { cursor: pointer; }
.dt-row:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.dt-row.now { background: color-mix(in srgb, var(--accent) 13%, transparent); }
.dt-row.now .dt-chain b { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.dt-row.lvl-1 .dt-chain b { font-size: 15px; }
.dt-chev { width: 14px; height: 14px; display: grid; place-items: center; color: var(--faint); }
.dt-row.can .dt-chev::before {
  content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s;
}
.dt-row.can.open .dt-chev::before { transform: rotate(45deg); }
.dt-chain { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-up { color: var(--faint); font-weight: 600; }
.dt-chain .dsep { margin: 0 3px; color: var(--faint); }
.dt-row .ddate small { color: var(--muted); }
.dt-len { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.dt-msg { padding: 6px 12px 6px 40px; color: var(--muted); font-size: 12.5px; }
@media (max-width: 560px) {
  .dt-row { grid-template-columns: 12px minmax(0, 1fr) 96px 60px; padding-left: calc(4px + (var(--indent, 0) * 10px)); }
  .dt-row .dwd { display: none; }
  .dt-kids .dt-kids, .dt-row.lvl-1 + .dt-kids { margin-left: 6px; }
  .dt-actions { margin-left: 0; }
}

/* Jagradadi avastha beside the Baladi one */
.jag { font-size: 0.78em; color: var(--muted); margin-left: 2px; }
.jag-jagrat { color: var(--good); }
.jag-sushupti { color: var(--bad); }
