/* Layout concept: штурманский планшет — сверху «показания» (код из 4 чисел), дальше разделы как карточки журнала; матрица 3×3 — центральный прибор. */
@font-face { font-family: "Unbounded KT"; src: url("../fonts/unbounded-600.woff") format("woff"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Golos KT"; src: url("../fonts/golos-400.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Golos KT"; src: url("../fonts/golos-600.woff") format("woff"); font-weight: 600; font-display: swap; }

:root {
  --bg: #f2f3f8; --surface: #ffffff; --surface-2: #e8eaf3; --ink: #191b33; --ink-2: #4b4f70; --ink-3: #7a7e9c;
  --line: #d6d9e7; --accent: #b85e14; --accent-soft: #f7e6d4; --accent-ink: #ffffff;
  --good: #1d7f53; --good-soft: #dcf0e5; --bad: #b5392f; --bad-soft: #f7e0dd; --warn: #9a6a10;
  --d1: #d06b12; --d2: #5f79ad; --d3: #a07a05; --d4: #85553a; --d5: #1b845a; --d6: #a8437c; --d7: #6a6680; --d8: #2b4790; --d9: #c63a2f; --d0: #7a7e9c;
  --f-display: "Unbounded KT", "Arial Black", system-ui, sans-serif;
  --f-body: "Golos KT", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 14px; --r-s: 9px;
  --shadow: 0 1px 2px rgba(25, 27, 51, .06), 0 6px 18px rgba(25, 27, 51, .05);
  --nav-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1128; --surface: #181b37; --surface-2: #21254a; --ink: #e9eaf6; --ink-2: #b0b4d2; --ink-3: #8186aa;
    --line: #2d325c; --accent: #f0a04a; --accent-soft: #3a2c1f; --accent-ink: #1a1206;
    --good: #57c98f; --good-soft: #17352a; --bad: #f07a6e; --bad-soft: #3d1f22; --warn: #e2b450;
    --d1: #f39a4c; --d2: #a8bbe6; --d3: #e3c24f; --d4: #c99474; --d5: #52c996; --d6: #e481b8; --d7: #aaa6c0; --d8: #85a2ef; --d9: #f36c60; --d0: #8186aa;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1128; --surface: #181b37; --surface-2: #21254a; --ink: #e9eaf6; --ink-2: #b0b4d2; --ink-3: #8186aa;
  --line: #2d325c; --accent: #f0a04a; --accent-soft: #3a2c1f; --accent-ink: #1a1206;
  --good: #57c98f; --good-soft: #17352a; --bad: #f07a6e; --bad-soft: #3d1f22; --warn: #e2b450;
  --d1: #f39a4c; --d2: #a8bbe6; --d3: #e3c24f; --d4: #c99474; --d5: #52c996; --d6: #e481b8; --d7: #aaa6c0; --d8: #85a2ef; --d9: #f36c60; --d0: #8186aa;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--f-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 24px);
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--bg); z-index: 30; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; }
.wrap { max-width: 760px; margin: 0 auto; display: grid; gap: 16px; }

/* Верхняя строка */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--bg); margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))); padding: 12px max(16px, env(safe-area-inset-left, 0px)) 10px; border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand { font-family: var(--f-display); font-weight: 600; font-size: 17px; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 6px); gap: 2px; }
.brand-mark i { width: 6px; height: 6px; border-radius: 1.5px; background: var(--ink-3); }
.brand-mark i:nth-child(3n+1) { background: var(--accent); }
.topbar .sub { color: var(--ink-3); font-size: 12px; margin-left: auto; text-align: right; }

/* Нижняя навигация */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
.nav-in { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.nav button { border: 0; background: none; padding: 6px 0; min-width: 0; border-radius: 10px; display: grid; justify-items: center; gap: 2px; color: var(--ink-3); font-size: 11px; cursor: pointer; }
.nav button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.nav button[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); }

/* Карточки и общие элементы */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.card h2 { font-family: var(--f-display); font-weight: 600; font-size: 17px; letter-spacing: .01em; }
.card h3 { font-size: 15px; font-weight: 600; }
.eyebrow { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.stack { display: grid; gap: 10px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; font-size: 16px; min-width: 0; }
.input:focus { border-color: var(--accent); outline: none; }
textarea.input { resize: vertical; min-height: 64px; line-height: 1.4; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.err { color: var(--bad); font-size: 13px; }
.note { background: var(--surface-2); border-radius: var(--r-s); padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
ul.clean { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }

/* Люди */
.people { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.people::-webkit-scrollbar { display: none; }
.person { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.person b { font-weight: 600; }
.person span { font-family: var(--f-mono); font-size: 12px; color: var(--ink-3); }
.person[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.addform { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 8px; align-items: end; }
@media (max-width: 520px) { .addform { grid-template-columns: 1fr 1fr; } .addform .btn { grid-column: 1 / -1; } }

/* Цифры */
.dg { font-family: var(--f-display); font-weight: 600; color: var(--c, var(--ink)); }
.d1 { --c: var(--d1); } .d2 { --c: var(--d2); } .d3 { --c: var(--d3); } .d4 { --c: var(--d4); } .d5 { --c: var(--d5); }
.d6 { --c: var(--d6); } .d7 { --c: var(--d7); } .d8 { --c: var(--d8); } .d9 { --c: var(--d9); } .d0 { --c: var(--d0); }
.badge { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 10px; font-family: var(--f-display); font-weight: 600; font-size: 17px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); }
.badge.sm { min-width: 26px; height: 26px; font-size: 13px; border-radius: 8px; }
.composite { font-family: var(--f-mono); font-size: 13px; color: var(--ink-3); }

/* Герой — код */
.hero { padding: 18px 16px 16px; gap: 14px; position: relative; overflow: hidden; }
.hero .who { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.hero .who h1 { font-size: 20px; font-weight: 600; }
.hero .who .date { font-family: var(--f-mono); color: var(--ink-2); font-size: 14px; }
.code { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.code .cell { background: var(--surface-2); border-radius: 12px; padding: 10px 3px 8px; display: grid; justify-items: center; gap: 2px; text-align: center; min-width: 0; }
.code .cell .n { font-family: var(--f-display); font-weight: 600; font-size: clamp(30px, 9vw, 44px); line-height: 1.05; color: var(--c); }
.code .cell .l { font-size: 11px; color: var(--ink-2); font-weight: 600; max-width: 100%; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code .cell .p { font-size: 11px; color: var(--ink-3); }
.code .cell .composite { font-size: 12px; }
.phase { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }

/* Раскрывающиеся разделы */
details.sec { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
details.sec > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary .t { display: grid; gap: 1px; min-width: 0; flex: 1; }
details.sec > summary .t b { font-family: var(--f-display); font-weight: 600; font-size: 15px; }
details.sec > summary .t span { font-size: 13px; color: var(--ink-2); }
details.sec > summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); transition: transform .2s; flex: none; margin-right: 4px; }
details.sec[open] > summary::after { transform: rotate(-135deg); }
details.sec .body { padding: 0 16px 16px; display: grid; gap: 12px; min-width: 0; }
details.sec .body > *, .card > *, .block > * { min-width: 0; }
.tag.long { white-space: normal; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .cols2 { grid-template-columns: 1fr; } }
.list-plus li::marker { color: var(--good); }
.list-minus li::marker { color: var(--bad); }
.block { border-left: 3px solid var(--c, var(--line)); padding: 2px 0 2px 12px; display: grid; gap: 4px; }

/* Матрица */
.matrix-wrap { display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 600px) { .matrix-wrap { grid-template-columns: 1fr; } }
.matrix { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 300px; width: 100%; }
.mcell { aspect-ratio: 1 / 1; max-width: 100%; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; position: relative; padding: 4px; text-align: center; }
.mcell .v { font-family: var(--f-display); font-weight: 600; font-size: clamp(16px, 5vw, 22px); color: var(--c); letter-spacing: .02em; word-break: break-all; line-height: 1.1; }
.mcell .v em { font-style: normal; opacity: .55; }
.mcell .k { position: absolute; top: 5px; left: 7px; font-size: 10px; color: var(--ink-3); font-weight: 600; }
.mcell.empty { background: transparent; border: 1.5px dashed var(--line); }
.mcell.empty .v { color: var(--ink-3); font-size: 13px; font-family: var(--f-body); }
.lines { display: grid; gap: 8px; }
.line { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.line .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--line); }
.line.on .dot { background: var(--good); }
.line.part .dot { background: var(--warn); }

/* Циклы */
.cycle { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cycle .arrow { color: var(--ink-3); }

/* Календарь */
.years { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.years button, .months button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px 4px; cursor: pointer; display: grid; justify-items: center; gap: 0; min-width: 56px; }
.years button small, .months button small { font-size: 11px; color: var(--ink-3); }
.years button .dg, .months button .dg { font-size: 18px; }
.years button[aria-pressed="true"], .months button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
@media (max-width: 520px) { .months { grid-template-columns: repeat(4, 1fr); } }
.months button { min-width: 0; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { font-size: 11px; color: var(--ink-3); text-align: center; font-weight: 600; padding-bottom: 2px; }
.cal button { border: 1px solid transparent; background: var(--surface-2); border-radius: 9px; padding: 4px 0 5px; cursor: pointer; display: grid; justify-items: center; min-width: 0; }
.cal button small { font-size: 11px; color: var(--ink-3); }
.cal button .dg { font-size: 16px; line-height: 1.2; }
.cal button.today { border-color: var(--ink-3); }
.cal button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.pos4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 520px) { .pos4 { grid-template-columns: repeat(2, 1fr); } }
.pos4 > div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: grid; gap: 2px; min-width: 0; }

/* Таблицы */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.tbl th, table.tbl td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.nowrap { white-space: nowrap; }
table.tbl th { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.letters { display: flex; flex-wrap: wrap; gap: 4px; }
.letter { display: grid; justify-items: center; background: var(--surface-2); border-radius: 8px; padding: 3px 6px; min-width: 30px; }
.letter b { font-size: 15px; font-weight: 600; }
.letter.vow b { color: var(--accent); }
.letter small { font-family: var(--f-display); font-size: 12px; color: var(--c); }

/* Сценарий подсказок */
.empty-state { text-align: center; padding: 28px 16px; color: var(--ink-2); display: grid; gap: 10px; justify-items: center; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 14px; z-index: 40; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.view { display: grid; gap: 14px; min-width: 0; }
.view > * { min-width: 0; }
.view[hidden] { display: none !important; }
.foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 8px 0 0; }

/* Джьотиш: южноиндийский квадрат */
.code.trio { grid-template-columns: repeat(3, 1fr); }
.code .cell .n.sm { font-family: var(--f-body); font-weight: 600; font-size: clamp(13px, 4vw, 20px); line-height: 1.15; white-space: normal; overflow-wrap: normal; hyphens: auto; padding: 4px 2px 2px; }
details.dasha .sub.pre { opacity: .5; }
.south { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); aspect-ratio: 1 / 1; width: 100%; max-width: 480px; margin: 0 auto; border: 1.5px solid var(--ink-3); border-radius: 8px; overflow: hidden; background: var(--surface); }
.south .sc { border: .5px solid var(--line); position: relative; padding: 16px 2px 2px; min-width: 0; min-height: 0; overflow: hidden; }
.south .sn { position: absolute; top: 3px; left: 5px; font-size: 10px; color: var(--ink-3); font-weight: 600; letter-spacing: .02em; }
.south .hn { position: absolute; top: 3px; right: 5px; font-size: 10px; color: var(--ink-3); font-family: var(--f-mono); }
.south .pls { display: flex; flex-wrap: wrap; gap: 0 5px; align-content: flex-start; justify-content: center; font-size: clamp(11px, 3.4vw, 15px); line-height: 1.3; }
.pl { font-weight: 600; color: var(--c, var(--ink)); white-space: nowrap; }
.pl sup { font-size: .66em; font-weight: 400; color: var(--ink-3); margin-left: 1px; }
.pl i { font-style: normal; font-size: .62em; color: var(--bad); margin-left: 1px; vertical-align: super; font-weight: 600; }
.pl.lg { color: var(--accent); }
.south .sc.lag { background: var(--accent-soft); }
.south .sc.lag::after { content: ""; position: absolute; left: 0; bottom: 0; width: 18px; height: 18px; background: linear-gradient(to top right, transparent calc(50% - 1px), var(--accent) calc(50% - 1px), var(--accent) calc(50% + 1px), transparent calc(50% + 1px)); }
.south .sc.lagmo { background: color-mix(in srgb, var(--d2) 12%, transparent); }
.south .ctr { grid-row: 2 / 4; grid-column: 2 / 4; display: grid; place-content: center; text-align: center; gap: 4px; border: .5px solid var(--line); background: var(--surface-2); padding: 6px; }
.south .ctr b { font-family: var(--f-display); font-weight: 600; font-size: clamp(13px, 3.8vw, 18px); }
.south .ctr span { font-size: 12px; color: var(--ink-3); }
.cities { display: grid; gap: 4px; margin-top: 6px; }
.cities:empty { display: none; }
.cities button { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 7px 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.cities button small { color: var(--ink-3); display: block; font-size: 12px; font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; align-self: end; padding-bottom: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
details.adv summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.dasha { border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
details.dasha.cur { border-color: var(--accent); }
details.dasha summary { padding: 8px 10px; cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
details.dasha summary::-webkit-details-marker { display: none; }
details.dasha .subs { padding: 0 10px 8px; display: grid; gap: 2px; }
details.dasha .sub { font-size: 13px; padding: 2px 6px; display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; }
details.dasha .sub.cur { font-weight: 600; background: var(--accent-soft); border-radius: 6px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
