/* Medcard web — grandma.click product space (grandma-product-ui canon).
   Dark is the default; light is the person's saved choice (localStorage),
   applied via html[data-theme="light"] by theme-boot.js before paint.
   Instrument Serif is intentionally absent: it has no Cyrillic. */

@font-face { font-family: 'Geist'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/static/fonts/geist-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Geist'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/static/fonts/geist-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url('/static/fonts/jetbrains-mono-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url('/static/fonts/jetbrains-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  /* Surfaces */
  --bg-base: #0A0A0F;
  --bg-surface: #111118;
  --bg-elevated: #1A1A24;
  --bg-overlay: #22222E;
  /* Borders */
  --border-subtle: #1E1E28;
  --border-default: #2A2A38;
  --border-strong: #3A3A4A;
  /* Text */
  --text-primary: #ECECEF;
  --text-secondary: #9999A3;
  --text-tertiary: #5C5C6B;
  --text-disabled: #3A3A48;
  /* Brand accent — magenta */
  --accent: #B8156B;
  --accent-hover: #D11B7E;
  --accent-muted: #4A0E2C;
  --accent-glow: #B8156B33;
  /* Accent as text on the page background (links, hover titles) */
  --accent-ink: #E0479A;
  /* Semantic — muted, never neon */
  --success: #4ADE80; --success-bg: #0F2A1A;
  --warning: #FBBF24; --warning-bg: #2A1F0A;
  --danger:  #F87171; --danger-bg:  #2A1010;
  --info:    #60A5FA; --info-bg:    #0F1A2A;
  /* Chart */
  --chart-1: #B8156B;
  --chart-line: #D11B7E;
  --chart-grid: #2A2A38;
  --chart-axis: #7A7A88;
  --band: rgba(74, 222, 128, 0.07);
  --band-edge: rgba(74, 222, 128, 0.32);
  /* Radii */
  --radius-xs: 2px; --radius-sm: 4px; --radius-md: 6px; --radius-lg: 10px; --radius-full: 9999px;
  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --z-sticky: 200;

  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans: 'Geist', -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

/* Light theme — warm paper, never white. Every text token passes WCAG AA
   (≥4.5:1) on --bg-base and --bg-surface. */
html[data-theme="light"] {
  --bg-base: #EFEDE8;
  --bg-surface: #F7F5F1;
  --bg-elevated: #E7E4DD;
  --bg-overlay: #DEDAD1;
  --border-subtle: #E0DCD4;
  --border-default: #D1CCC2;
  --border-strong: #B5AFA3;
  --text-primary: #16141A;
  --text-secondary: #4F4C57;
  --text-tertiary: #67636F;
  --text-disabled: #B5B1BA;
  --accent: #B8156B;
  --accent-hover: #9E115B;
  --accent-muted: #F2D7E5;
  --accent-glow: #B8156B33;
  --accent-ink: #A8135F;
  --success: #116B33; --success-bg: #DDEFE2;
  --warning: #8A4B04; --warning-bg: #F6EAD3;
  --danger:  #B42318; --danger-bg:  #F8E1DE;
  --info:    #1D4ED8; --info-bg:    #DEE6F6;
  --chart-line: #B8156B;
  --chart-grid: #D9D4CA;
  --chart-axis: #67636F;
  --band: rgba(17, 107, 51, 0.08);
  --band-edge: rgba(17, 107, 51, 0.35);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 22px;
  letter-spacing: -0.01em;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-muted); color: var(--text-primary); }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
.mono { font-family: var(--mono); }
.meta {
  font-family: var(--mono); font-size: 10.5px; line-height: 16px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-tertiary);
}
.muted { color: var(--text-secondary); }
.icon { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ── Brand lockup: .grandma + module pill, tail collapses on scroll ── */
.gm-lockup { display: inline-flex; align-items: center; gap: 9px; line-height: 1; user-select: none; min-width: 0; }
.gm-mark { font-family: var(--sans); font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary);
  display: inline-flex; align-items: baseline; font-size: 20px; }
.gm-dot { color: var(--accent); }
.gm-tail { display: inline-flex; overflow: hidden; }
.gm-tail span { display: inline-block; max-width: var(--w, none); opacity: 1;
  transition: max-width 0.42s var(--ease-out), opacity 0.3s var(--ease-out); }
.gm-lockup.is-collapsed .gm-tail span { max-width: 0; opacity: 0; }
.gm-lockup .gm-tail span:nth-child(6) { transition-delay: 0s; }
.gm-lockup .gm-tail span:nth-child(5) { transition-delay: .035s; }
.gm-lockup .gm-tail span:nth-child(4) { transition-delay: .07s; }
.gm-lockup .gm-tail span:nth-child(3) { transition-delay: .105s; }
.gm-lockup .gm-tail span:nth-child(2) { transition-delay: .14s; }
.gm-lockup .gm-tail span:nth-child(1) { transition-delay: .175s; }
.gm-lockup:not(.is-collapsed) .gm-tail span:nth-child(1) { transition-delay: 0s; }
.gm-lockup:not(.is-collapsed) .gm-tail span:nth-child(2) { transition-delay: .035s; }
.gm-lockup:not(.is-collapsed) .gm-tail span:nth-child(3) { transition-delay: .07s; }
.gm-lockup:not(.is-collapsed) .gm-tail span:nth-child(4) { transition-delay: .105s; }
.gm-lockup:not(.is-collapsed) .gm-tail span:nth-child(5) { transition-delay: .14s; }
.gm-lockup:not(.is-collapsed) .gm-tail span:nth-child(6) { transition-delay: .175s; }
.gm-pill { display: inline-flex; align-items: center; background: var(--accent); color: #fff;
  font-family: var(--sans); font-weight: 500; letter-spacing: -0.01em; border-radius: var(--radius-full);
  line-height: 1; white-space: nowrap; font-size: 12px; padding: 5px 11px 6px; }
.gm-lg { gap: 12px; }
.gm-lg .gm-mark { font-size: 30px; }
.gm-lg .gm-pill { font-size: 14px; padding: 7px 14px 8px; }

/* ── Developer mark ── */
.gm-watermark { display: inline-flex; align-items: baseline; gap: 6px; font-family: var(--sans);
  font-size: 12px; line-height: 1; color: var(--text-tertiary); letter-spacing: 0; text-transform: none; }
.gm-watermark-label { font-weight: 400; opacity: .85; }
.gm-watermark-link { font-weight: 600; color: inherit; }
.gm-watermark-link:hover { color: var(--text-primary); }
.gm-watermark-link:hover .gm-dot { color: var(--accent-hover); }

/* ── Theme rocker: real checkbox, two halves, pressed half on accent ── */
.gm-rocker { display: inline-block; position: relative; vertical-align: middle; font-size: 9px;
  text-align: center; width: 7em; height: 4em; overflow: hidden; cursor: pointer; flex: none;
  border-bottom: .5em solid var(--rk-frame);
  --rk-frame: #2b2b33; --rk-well: #15151b; --rk-idle: #30303a; --rk-edge: #22222a; --rk-idle-ink: rgba(236,236,239,.5); }
html[data-theme="light"] .gm-rocker {
  --rk-frame: #dcd7cd; --rk-well: #cbc5b9; --rk-idle: #f3f0ea; --rk-edge: #d8d2c6; --rk-idle-ink: rgba(22,20,26,.5); }
.gm-rocker::before { content: ""; position: absolute; top: .5em; left: 0; right: 0; bottom: 0;
  background: var(--rk-well); border: .5em solid var(--rk-frame); border-bottom: 0; }
.gm-rocker input { opacity: 0; width: 0; height: 0; position: absolute; }
.gm-rocker .sw-l, .gm-rocker .sw-r { position: absolute; display: flex; align-items: center; justify-content: center;
  height: 2.5em; width: 3em; transition: .2s; user-select: none; }
.gm-rocker svg { width: 1.6em; height: 1.6em; display: block; }
.gm-rocker .sw-l { left: .5em; bottom: 0; background: var(--accent); color: #fff; transform: rotate(0) skewX(0); }
.gm-rocker .sw-r { right: .5em; bottom: .4em; height: 2.4em; width: 2.75em; background: var(--rk-idle);
  color: var(--rk-idle-ink); transform: rotate(-15deg) skewX(-15deg); }
.gm-rocker .sw-l::before, .gm-rocker .sw-r::before { content: ""; position: absolute; width: .4em; height: 2.45em;
  bottom: -.45em; background: var(--rk-edge); }
.gm-rocker .sw-l::before { left: -.4em; background: transparent; transform: skewY(-65deg); }
.gm-rocker .sw-r::before { right: -.375em; transform: skewY(65deg); }
.gm-rocker input:checked + .sw-l { background: var(--rk-idle); color: var(--rk-idle-ink); bottom: .4em; left: .85em;
  height: 2.4em; width: 2.75em; transform: rotate(15deg) skewX(15deg); }
.gm-rocker input:checked + .sw-l::before { background: var(--rk-edge); left: -.375em; transform: skewY(-65deg); }
.gm-rocker input:checked + .sw-l + .sw-r { background: var(--accent); color: #fff; right: .5em; bottom: 0;
  height: 2.5em; width: 3em; transform: rotate(0) skewX(0); }
.gm-rocker input:checked + .sw-l + .sw-r::before { background: transparent; }
.gm-rocker input:focus-visible + .sw-l { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Shell ── */
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 32px; min-height: 64px;
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle); position: sticky; top: 0; z-index: var(--z-sticky); }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
main { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 32px 32px; flex: 1; }
.page-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; padding: 18px 32px;
  border-top: 1px solid var(--border-subtle); margin-top: 40px; }
.page-footer .meta { white-space: nowrap; }
.page-footer .gm-watermark { margin-left: auto; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font-family: inherit; font-size: 13px;
  font-weight: 500; letter-spacing: -0.01em; cursor: pointer; background: transparent; color: var(--text-primary);
  white-space: nowrap; transition: background 150ms var(--ease-out), border-color 150ms var(--ease-out),
  color 150ms var(--ease-out), transform 200ms var(--ease-spring); }
.btn .icon { width: 14px; height: 14px; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-glow); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-0.5px); }
.btn-secondary { border-color: var(--border-default); }
.btn-secondary:hover { background: var(--bg-elevated); border-color: var(--border-strong); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }
.btn-block { width: 100%; height: 44px; font-size: 14px; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: var(--radius-xs);
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em;
  line-height: 1.45; white-space: nowrap; }
.badge-neutral { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-default); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-info { background: var(--info-bg); color: var(--info); }

.tone-high, .tone-low, .tone-abnormal, .tone-danger { color: var(--danger); }
.tone-warning { color: var(--warning); }

/* ── Cards & sections ── */
.card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 20px; min-width: 0; }
.section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title { font-size: 18px; line-height: 26px; font-weight: 600; letter-spacing: -0.02em; }
.page-head { display: flex; flex-direction: column; gap: 6px; }
.page-title { font-size: 34px; line-height: 40px; font-weight: 600; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.page-lead { color: var(--text-secondary); max-width: 620px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 13px;
  margin-bottom: 10px; min-height: 32px; }
.back:hover { color: var(--text-primary); }
.note { font-size: 12px; line-height: 18px; color: var(--text-tertiary); margin-top: 12px; }

/* ── Overview: family cards ── */
.family { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; margin-top: 24px; align-items: start; }
.person-card { display: flex; flex-direction: column; gap: 18px; padding: 0; overflow: hidden; }
.person-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px 16px; border-bottom: 1px solid var(--border-subtle); transition: background 150ms var(--ease-out); }
.person-card-head:hover { background: var(--bg-elevated); }
.person-card-head:hover .go { color: var(--accent-ink); transform: translateX(2px); }
.person-name { font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.go { color: var(--text-tertiary); transition: color 150ms var(--ease-out), transform 200ms var(--ease-spring); display: inline-flex; }
.go .icon { width: 18px; height: 18px; }
.person-block { padding: 0 20px; }
.person-block:last-child { padding-bottom: 20px; }
.block-label { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.block-label .icon { width: 13px; height: 13px; color: var(--text-tertiary); }
.empty-line { font-size: 13px; color: var(--text-secondary); }

.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border-subtle); min-width: 0; }
.row:first-child { border-top: 0; padding-top: 2px; }
.row-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-side { flex: none; text-align: right; }
a.row:hover .row-title { color: var(--accent-ink); }
.row-title { font-weight: 500; transition: color 150ms var(--ease-out); }
.row-sub { font-size: 12.5px; line-height: 18px; color: var(--text-secondary); }
.value { font-family: var(--mono); font-size: 13px; font-weight: 500; white-space: nowrap; }
.unit { color: var(--text-secondary); font-weight: 400; font-size: 11.5px; margin-left: 3px; }
.date { font-family: var(--mono); font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; }

/* ── Person page ── */
.person-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; margin-top: 28px; }
.person-main { min-width: 0; }
.person-main > .section:first-child { margin-top: 0; }
.person-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }
.side-title { font-size: 15px; line-height: 22px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.side-title .icon { color: var(--text-tertiary); }

.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.chart-card { padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.chart-card.is-alert { border-color: color-mix(in srgb, var(--danger) 35%, var(--border-subtle)); }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.chart-name { font-weight: 500; font-size: 14px; line-height: 20px; overflow-wrap: anywhere; }
.chart-value { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.chart-num { font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chart-unit { color: var(--text-secondary); font-size: 13px; }
.chart-ref { font-size: 12px; line-height: 18px; color: var(--text-secondary); }
.chart-svg { display: block; width: 100%; height: auto; margin-top: 6px; overflow: visible; }
.chart-svg .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-svg .band { fill: var(--band); }
.chart-svg .band-edge { stroke: var(--band-edge); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .line { fill: none; stroke: var(--chart-line); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { fill: var(--bg-surface); stroke: var(--chart-line); stroke-width: 1.75; }
.chart-svg .dot.is-alert { fill: var(--danger); stroke: var(--bg-surface); stroke-width: 2; }
.chart-svg .v { font-family: var(--mono); font-size: 10px; fill: var(--text-secondary); font-weight: 500; }
.chart-svg .v.is-alert { fill: var(--danger); }
.chart-svg .d { font-family: var(--mono); font-size: 9.5px; fill: var(--chart-axis); letter-spacing: 0.02em; }
.chart-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.chart-foot a { color: var(--text-secondary); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; min-height: 28px; }
.chart-foot a:hover { color: var(--accent-ink); }
.chart-foot a .icon { width: 13px; height: 13px; }
.chart-single { font-size: 12.5px; color: var(--text-secondary); padding: 4px 0 2px; }

.timeline { display: flex; flex-direction: column; }
.doc { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 4px 16px; padding: 16px 18px;
  border-top: 1px solid var(--border-subtle); transition: background 150ms var(--ease-out); }
.doc:first-child { border-top: 0; }
.doc:hover { background: var(--bg-elevated); }
.doc:hover .doc-title { color: var(--accent-ink); }
.doc-date { font-family: var(--mono); font-size: 12px; line-height: 22px; color: var(--text-secondary); }
.doc-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-title { font-weight: 600; font-size: 15px; line-height: 22px; transition: color 150ms var(--ease-out); overflow-wrap: anywhere; }
.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; line-height: 18px; color: var(--text-secondary); }
.doc-summary { color: var(--text-secondary); font-size: 13px; line-height: 20px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list-card { padding: 0; overflow: hidden; }

.med { padding: 9px 0; border-top: 1px solid var(--border-subtle); }
.med:first-child { border-top: 0; padding-top: 0; }
.med-name { font-weight: 500; overflow-wrap: anywhere; }
.med-sub { font-size: 12.5px; line-height: 18px; color: var(--text-secondary); overflow-wrap: anywhere; }
.rem { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border-subtle); align-items: flex-start; }
.rem:first-child { border-top: 0; padding-top: 0; }
.rem-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rem-when { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }

/* ── Record page ── */
.kind-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 24px; margin-top: 20px; }
.fact dt { margin-bottom: 2px; }
.fact dd { overflow-wrap: anywhere; }
.fact a { color: var(--accent-ink); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.record-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 28px; }
.record-grid .wide { grid-column: 1 / -1; }
.summary-text { font-size: 16px; line-height: 26px; }
.bullets li { position: relative; padding: 7px 0 7px 16px; border-top: 1px solid var(--border-subtle); overflow-wrap: anywhere; }
.bullets li:first-child { border-top: 0; padding-top: 0; }
.bullets li::before { content: ""; position: absolute; left: 0; top: 16px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.bullets li:first-child::before { top: 9px; }
.bullets .sub { display: block; font-size: 12.5px; line-height: 18px; color: var(--text-secondary); }
.card-title { font-size: 15px; line-height: 22px; font-weight: 600; margin-bottom: 12px; }

.results { display: flex; flex-direction: column; }
.results-head, .result { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 110px; gap: 12px; align-items: baseline; }
.results-head { padding: 0 0 10px; border-bottom: 1px solid var(--border-default); }
.result { padding: 10px 0; border-top: 1px solid var(--border-subtle); }
.results-head + .result { border-top: 0; }
.r-name { overflow-wrap: anywhere; }
.r-raw { display: block; font-size: 11.5px; color: var(--text-secondary); line-height: 16px; }
.r-value { font-family: var(--mono); font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.r-ref { font-family: var(--mono); font-size: 12px; color: var(--text-secondary); overflow-wrap: anywhere; }
.r-flag { text-align: right; }

.originals { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.orig { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border-default);
  border-radius: var(--radius-md); background: var(--bg-base); transition: border-color 150ms var(--ease-out); min-width: 0; }
.orig:hover { border-color: var(--accent); }
.orig img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: top; border-radius: var(--radius-sm); background: var(--bg-elevated); display: block; }
.orig-icon { width: 100%; aspect-ratio: 3 / 4; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--text-secondary); }
.orig-icon .icon { width: 28px; height: 28px; stroke-width: 1.25; }
.orig-name { font-size: 12px; line-height: 16px; color: var(--text-secondary); overflow-wrap: anywhere; }

/* ── Login & states ── */
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 26px; padding: 28px; }
.login-title { font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -0.02em; }
.login-copy { color: var(--text-secondary); margin-top: 6px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.input { width: 100%; height: 44px; background: var(--bg-base); border: 1px solid var(--border-default); color: var(--text-primary);
  font-family: inherit; font-size: 16px; padding: 0 12px; border-radius: var(--radius-sm);
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.input-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-error { font-family: var(--mono); font-size: 12px; line-height: 18px; color: var(--danger); background: var(--danger-bg);
  border-radius: var(--radius-xs); padding: 8px 10px; }
.login-rocker { display: flex; justify-content: center; }
.state { padding: 48px 0; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.state-heading { font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -0.02em; }
.state-copy { color: var(--text-secondary); max-width: 420px; }


/* ── Actions & forms ── */
.btn-destructive { border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.btn-destructive:hover { background: var(--danger-bg); }
.btn-mini { height: 28px; padding: 0 9px; font-size: 12px; gap: 5px; color: var(--text-secondary); }
.btn-mini .icon { width: 13px; height: 13px; }
.btn[disabled] { opacity: .5; cursor: progress; }
.mini-actions { display: flex; flex-wrap: wrap; gap: 2px; margin-left: -9px; }
.mini-actions form, .choice form { display: contents; }
.link { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.more { display: inline-block; margin-top: 6px; font-size: 12.5px; color: var(--accent-ink); }
.notice { margin-top: 18px; padding: 10px 14px; border-left: 2px solid var(--info); color: var(--text-primary);
  background: var(--info-bg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 13.5px; }
.input-hint { font-size: 12px; line-height: 18px; color: var(--text-secondary); margin-top: -4px; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px; background-size: 5px 5px; background-repeat: no-repeat; }
.textarea { height: auto; min-height: 84px; padding: 10px 12px; line-height: 22px; resize: vertical; }
.stack-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.stack-form .input-label { margin: 4px 0 -2px; }
.stack-form .btn { align-self: flex-start; margin-top: 6px; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.tool summary { margin: 0; }
.tool summary::after { content: "+"; margin-left: auto; font-family: var(--mono); color: var(--text-tertiary); font-size: 16px; }
.tool[open] summary::after { content: "−"; }
.inline-tool { margin-top: 10px; }
.inline-tool > summary { display: inline-flex; }
.inline-tool[open] > summary { background: var(--bg-elevated); }
.confirm { margin-top: 10px; padding: 12px 14px; border-left: 2px solid var(--danger); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.confirm p { color: var(--text-secondary); font-size: 13.5px; }
.choice { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.choice-inner { margin-top: 10px; }
.manage .choice { margin-top: 0; align-items: flex-start; }
.manage .inline-tool { margin-top: 0; }

/* ── Upload zone ── */
.top-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; margin-top: 24px; align-items: stretch; }
.person-upload { margin-top: 22px; }
.drop { display: flex; flex-direction: column; gap: 12px; }
.drop-area { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; padding: 26px 18px; min-height: 150px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg-base); cursor: pointer; transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out); }
.drop-area:hover, .drop-area.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg-base)); }
.drop-area:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.drop-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.drop-icon { width: 40px; height: 40px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center;
  background: var(--accent-muted); color: var(--accent-ink); margin-bottom: 4px; }
.drop-icon .icon { width: 18px; height: 18px; }
.drop-title { font-size: 16px; line-height: 22px; font-weight: 600; letter-spacing: -0.01em; }
.drop-hint { font-size: 12.5px; line-height: 18px; color: var(--text-secondary); max-width: 440px; }
.drop-files { font-family: var(--mono); font-size: 11.5px; line-height: 17px; color: var(--text-primary); overflow-wrap: anywhere; max-width: 100%; }
.drop-row { display: flex; gap: 10px; }
.drop-row .input { flex: 1; min-width: 0; }
.drop-row .btn { height: 44px; }
.progress { height: 4px; border-radius: 2px; background: var(--bg-elevated); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 200ms var(--ease-out); }

/* ── Ask ── */
.ask { display: flex; flex-direction: column; gap: 10px; }
.ask .side-title { margin-bottom: 0; }
.ask-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ask-hint { font-size: 12px; line-height: 18px; color: var(--text-secondary); }
.ask-out { padding: 12px 14px; border-left: 2px solid var(--accent); background: var(--bg-base); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 22px; }
.ask-out.is-waiting { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); white-space: normal; }
.ask-out.is-error { border-left-color: var(--danger); color: var(--danger); }
.ask-question { font-weight: 600; font-size: 16px; margin: 4px 0 12px; }
.ask-answer { white-space: pre-wrap; overflow-wrap: anywhere; }
.spinner { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2px solid var(--border-default);
  border-top-color: var(--accent); animation: spin .8s linear infinite; }
.status-card .spinner { width: 26px; height: 26px; margin-top: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pending documents ── */
.pending { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-top: 1px solid var(--border-subtle); transition: background 150ms var(--ease-out); }
.pending:first-child { border-top: 0; }
.pending:hover { background: var(--bg-elevated); }
.pending-icon { display: inline-flex; color: var(--text-secondary); }
.pending-icon.tone-info { color: var(--info); }
.pending-body { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }

/* ── Record status ── */
.status-card { display: flex; gap: 16px; align-items: flex-start; margin-top: 20px; }
.status-card.is-warning { border-color: color-mix(in srgb, var(--warning) 40%, var(--border-subtle)); }
.status-card.is-danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--border-subtle)); }
.status-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.status-title { font-size: 18px; line-height: 26px; font-weight: 600; letter-spacing: -0.02em; }

/* ── Tabs & months ── */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 0 0 16px; padding-bottom: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13px; font-weight: 500; border: 1px solid var(--border-subtle); transition: all 150ms var(--ease-out); }
.tab:hover { color: var(--text-primary); background: var(--bg-elevated); }
.tab.is-active { color: var(--text-primary); background: var(--bg-elevated); border-color: var(--border-default); box-shadow: inset 0 -2px 0 0 var(--accent); }
.tab-count { font-family: var(--mono); font-size: 10.5px; color: var(--text-tertiary); }
.month + .month { margin-top: 20px; }
.month-title { font-size: 13px; line-height: 20px; font-weight: 600; color: var(--text-secondary); margin: 0 0 8px 2px; letter-spacing: 0; }
[hidden] { display: none !important; }

.rem { flex-wrap: wrap; }
.rem .mini-actions { flex-basis: 100%; }
.row-rem { flex-wrap: wrap; }
.row-rem .mini-actions { flex-basis: 100%; }
.rem-date { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.med form { margin-top: 2px; margin-left: -9px; }


/* ── Passkey login & devices ── */
.btn-tall { height: 52px; font-size: 15px; font-weight: 600; white-space: normal; text-align: center; line-height: 20px; }
.btn-tall .icon { width: 18px; height: 18px; }
.btn.is-busy { opacity: .7; cursor: progress; }
.login-sub { text-align: center; font-size: 12.5px; color: var(--text-secondary); margin-top: -6px; }
.login-switch { font-size: 13px; color: var(--accent-ink); text-align: center; display: block; text-decoration: underline; text-underline-offset: 3px; }
.login-code > summary { list-style: none; }
.login-code[open] > summary { margin-bottom: 14px; }
.input-code { font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase; text-align: center; font-size: 17px; }
.device-out { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-base); }
.device-code { font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: 0.08em; color: var(--text-primary); overflow-wrap: anywhere; }
.device-link { display: flex; gap: 6px; }
.device-link .input { flex: 1; min-width: 0; font-size: 12px; height: 36px; }
.device-link .btn { flex: none; }

/* ── Responsive ── */
@media (max-width: 960px) {
  .top-grid { grid-template-columns: minmax(0, 1fr); }
  .person-layout { grid-template-columns: minmax(0, 1fr); }
  .person-side { position: static; order: -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 760px) {
  .record-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar { padding: 10px 16px; gap: 10px; min-height: 60px; }
  main { padding: 18px 16px 24px; }
  .page-footer { padding: 16px; margin-top: 28px; }
  .page-title { font-size: 28px; line-height: 34px; }
  .section { margin-top: 28px; }
  .family { grid-template-columns: minmax(0, 1fr); margin-top: 18px; }
  .person-card-head { padding: 16px; }
  .person-block { padding: 0 16px; }
  .person-block:last-child { padding-bottom: 16px; }
  .person-layout { margin-top: 20px; gap: 16px; }
  .person-side { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .doc { grid-template-columns: minmax(0, 1fr); padding: 14px 16px; gap: 2px; }
  .doc-date { line-height: 18px; }
  .card { padding: 16px; }
  .list-card, .person-card { padding: 0; }
  .drop-row .input { flex: none; }
  .results-head { display: none; }
  .result { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
  .r-name { grid-column: 1 / -1; grid-row: 1; }
  .r-value { grid-column: 1; grid-row: 2; }
  .r-flag { grid-column: 2; grid-row: 2; }
  .r-ref { grid-column: 1 / -1; grid-row: 3; }
  .actions .btn { flex: 1 1 100%; height: 44px; }
  .btn-logout-text { display: none; }
  .btn-logout { width: 40px; padding: 0; height: 40px; }
  .facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; }
  .top-grid { grid-template-columns: minmax(0, 1fr); margin-top: 18px; }
  .drop-row { flex-direction: column; }
  .drop-row .btn { width: 100%; }
  .drop-area { min-height: 132px; padding: 20px 14px; }
  .tools-grid { grid-template-columns: minmax(0, 1fr); }
  .status-card { flex-direction: column; gap: 10px; }
  .choice .btn { flex: 1 1 100%; height: 44px; }
  .pending { padding: 12px 16px; }
  .originals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
}

/* Settings page */
.settings-grid { margin-top: 24px; }
.settings-grid .card { display: flex; flex-direction: column; }
.settings-grid .stack-form { margin-top: 8px; }
.settings-grid .muted strong { color: var(--text-primary); font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  /* Logout lives in /settings on phones: the topbar stays one row at 360–390px. */
  .topbar [data-logout] { display: none; }
}
.row-badge { display: block; margin-top: 3px; line-height: 1; }
.drop-for { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-ink); margin-top: -2px; }
.charts { align-items: start; }

/* ── AI: descriptions, «✦ Пояснити» panel ── */
.spark { color: var(--accent-ink); font-size: 1.05em; line-height: 1; }
.btn .spark { margin-right: -1px; }
.btn-explain .spark { color: var(--accent-ink); }
.desc { margin: 2px 0 2px; }
.desc-text { font-size: 12.5px; line-height: 18px; color: var(--text-secondary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.desc-text.is-open { display: block; -webkit-line-clamp: unset; }
.desc-more { background: none; border: 0; padding: 2px 0; font: inherit; font-size: 12px; color: var(--accent-ink); cursor: pointer; }
.chart-actions { display: inline-flex; align-items: center; gap: 4px; }
.chart-actions .btn-mini { color: var(--text-secondary); }
.chart-actions .btn-mini:hover { color: var(--text-primary); }
.page-head-row { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.person-links { display: flex; gap: 4px; padding: 10px 14px; border-top: 1px solid var(--border-subtle); margin-top: auto; }
.person-links a { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary);
  padding: 6px 8px; border-radius: var(--radius-sm); min-height: 36px; }
.person-links a:hover { color: var(--text-primary); background: var(--bg-elevated); }
.person-links .icon { width: 14px; height: 14px; }
.follow-date { margin-top: 8px; }
html.is-locked, html.is-locked body { overflow: hidden; }

.explain { position: fixed; inset: 0; z-index: 500; }
.explain-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 8, .55); opacity: 0; transition: opacity 200ms var(--ease-out); }
html[data-theme="light"] .explain-backdrop { background: rgba(40, 36, 30, .28); }
.explain-sheet { position: absolute; display: flex; flex-direction: column; background: var(--bg-surface);
  border: 1px solid var(--border-default); box-shadow: 0 12px 32px rgba(0,0,0,.45);
  transition: transform 260ms var(--ease-out); }
.explain.is-open .explain-backdrop { opacity: 1; }
.explain-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-subtle); }
.explain-head-text { min-width: 0; }
.explain-title { font-size: 18px; line-height: 24px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; overflow-wrap: anywhere; }
.explain-close { width: 40px; height: 40px; padding: 0; flex: none; }
.explain-close .icon { width: 18px; height: 18px; }
.explain-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.explain-thread { display: flex; flex-direction: column; gap: 14px; }
.explain-q { align-self: flex-end; max-width: 85%; background: var(--accent-muted); color: var(--text-primary);
  padding: 8px 12px; border-radius: 12px 12px 2px 12px; font-size: 14px; line-height: 20px; overflow-wrap: anywhere; }
.explain-a { font-size: 15px; line-height: 24px; overflow-wrap: anywhere; }
.explain-a p + p, .explain-a p + ul, .explain-a ul + p { margin-top: 10px; }
.explain-a ul { display: flex; flex-direction: column; gap: 6px; }
.explain-a li { position: relative; padding-left: 16px; }
.explain-a li::before { content: ""; position: absolute; left: 2px; top: 10px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.explain-wait { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); font-size: 14px; }
.explain-error { color: var(--danger); font-size: 14px; }
.explain-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 13px; line-height: 18px; padding: 7px 12px; min-height: 36px; border-radius: var(--radius-full);
  border: 1px solid var(--border-default); background: var(--bg-base); color: var(--text-primary); cursor: pointer;
  transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out); text-align: left; }
.chip:hover { border-color: var(--accent); }
.chip[disabled] { opacity: .5; cursor: progress; }
.explain-foot { padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border-subtle); }
.explain-form { display: flex; gap: 8px; }
.explain-form .input { flex: 1; min-width: 0; }
.explain-form.is-busy { opacity: .6; pointer-events: none; }
.explain-send { width: 44px; height: 44px; padding: 0; flex: none; }
.explain-send .icon { width: 18px; height: 18px; }
.explain-note { font-size: 11.5px; line-height: 16px; color: var(--text-tertiary); margin-top: 8px; }
html[data-theme="light"] .explain-note { color: var(--text-secondary); }
@media (max-width: 899px) {
  .explain-sheet { left: 0; right: 0; bottom: 0; height: 85vh; height: 85dvh; border-radius: 16px 16px 0 0; border-bottom: 0; transform: translateY(100%); }
  .explain-sheet::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--border-strong); }
  .explain-head { padding-top: 22px; }
}
@media (min-width: 900px) {
  .explain-sheet { top: 0; right: 0; bottom: 0; width: 460px; border-top: 0; border-right: 0; border-bottom: 0; transform: translateX(100%); }
}
.explain.is-open .explain-sheet { transform: none; }

/* ── Exports ── */
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.pack { display: flex; flex-direction: column; gap: 6px; transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out); }
.pack:hover { border-color: var(--accent); }
.pack-name { font-size: 16px; line-height: 22px; font-weight: 600; letter-spacing: -0.01em; }
.pack-list { font-size: 13px; line-height: 19px; color: var(--text-secondary); overflow-wrap: anywhere; }
.pack-go { display: inline-flex; align-items: center; gap: 4px; margin-top: auto; padding-top: 6px; }
.pack-go .icon { width: 13px; height: 13px; }
.saved { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border-subtle); }
.saved:first-child { border-top: 0; }
.saved-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.saved-main:hover .row-title { color: var(--accent-ink); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; }
.custom-pack { display: flex; flex-direction: column; gap: 22px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.pick-item { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-default);
  border-radius: var(--radius-md); cursor: pointer; background: var(--bg-base); transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out); min-width: 0; }
.pick-item:hover { border-color: var(--border-strong); }
.pick-item input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick-box { width: 18px; height: 18px; flex: none; margin-top: 1px; border: 1.5px solid var(--border-strong); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; color: transparent; transition: all 150ms var(--ease-out); }
.pick-box .icon { width: 13px; height: 13px; stroke-width: 2.5; }
.pick-item:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--bg-base)); }
.pick-item input:checked + .pick-box { background: var(--accent); border-color: var(--accent); color: #fff; }
.pick-item input:focus-visible + .pick-box { box-shadow: 0 0 0 3px var(--accent-glow); }
.pick-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.pick-name { font-weight: 500; line-height: 20px; }
.pick-meta { font-family: var(--mono); font-size: 11px; line-height: 16px; color: var(--text-secondary); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-item input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-item span { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: var(--radius-full);
  border: 1px solid var(--border-default); font-size: 13px; font-weight: 500; color: var(--text-secondary); cursor: pointer;
  transition: all 150ms var(--ease-out); }
.seg-item span:hover { color: var(--text-primary); border-color: var(--border-strong); }
.seg-item input:checked + span { background: var(--accent-muted); border-color: var(--accent); color: var(--text-primary); }
.seg-item input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-glow); }
.custom-dates { display: none; gap: 12px; margin-top: 12px; max-width: 420px; }
.custom-dates label { flex: 1; min-width: 0; }
.period:has(input[value="custom"]:checked) .custom-dates { display: flex; }
.btn-show { align-self: flex-start; height: 44px; padding: 0 22px; }

.export-head .meta { margin-bottom: 2px; }
.export-actions { margin-top: 18px; }
.export-actions form { display: contents; }
.notice-muted { border-left-color: var(--border-strong); background: var(--bg-surface); color: var(--text-secondary); }
.series-list { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.series.is-alert { border-color: color-mix(in srgb, var(--danger) 30%, var(--border-subtle)); }
.series-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; }
.series-title { font-size: 18px; line-height: 26px; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.series-unit { font-size: 14px; font-weight: 400; color: var(--text-secondary); margin-left: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 20px; margin: 14px 0 6px; padding: 12px 0;
  border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); }
.stats dd { font-size: 14px; line-height: 22px; overflow-wrap: anywhere; }
.series-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 10px; }
.chart-wide { margin-top: 0; }
.chart-wide .v { font-size: 10.5px; }
.vtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.vtable th { text-align: left; font-family: var(--mono); font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); padding: 0 10px 8px 0; border-bottom: 1px solid var(--border-default); }
.vtable td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border-subtle); vertical-align: baseline; overflow-wrap: anywhere; }
.vtable tr:last-child td { border-bottom: 0; }
.vtable td a { font-size: 12.5px; }
.save-pack { margin-top: 16px; max-width: 520px; }
.print-foot { display: none; }
.prompt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.prompt-actions { display: inline-flex; align-items: center; gap: 12px; }
.prompt-row .btn { margin-top: 0; }
.saved-mark { display: inline-flex; align-items: center; gap: 5px; color: var(--success); font-size: 13px; }
.saved-mark .icon { width: 14px; height: 14px; }
.settings-wide { grid-column: 1 / -1; }
.settings-wide .side-title .spark { font-size: 16px; }

@media (max-width: 760px) {
  .series-body { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .chart-wide .v, .chart-wide .d { font-size: 12px; }
}
@media (max-width: 640px) {
  .page-head-row { align-items: flex-start; flex-direction: column; }
  .page-head-row > .btn { align-self: stretch; height: 44px; }
  .pick-grid { grid-template-columns: minmax(0, 1fr); }
  .btn-show { align-self: stretch; }
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .export-actions .btn { flex: 1 1 calc(50% - 5px); height: 44px; }
  .saved { padding: 12px 16px; }
  .vtable th:last-child, .vtable td:last-child { padding-right: 0; }
}

/* ── Print: export as PDF (light paper, no chrome, series never split) ── */
@media print {
  :root, html[data-theme="light"], html {
    --bg-base: #ffffff; --bg-surface: #ffffff; --bg-elevated: #f2f0ec;
    --border-subtle: #dedad2; --border-default: #cfcac0; --border-strong: #a9a397;
    --text-primary: #111111; --text-secondary: #44424a; --text-tertiary: #5d5a64;
    --accent: #B8156B; --accent-ink: #A8135F; --danger: #B42318; --danger-bg: #F8E1DE;
    --chart-line: #B8156B; --chart-grid: #d6d1c7; --chart-axis: #5d5a64;
    --band: rgba(17, 107, 51, 0.10); --band-edge: rgba(17, 107, 51, 0.45);
    color-scheme: light;
  }
  @page { margin: 14mm 12mm; }
  body { background: #fff; font-size: 11.5pt; }
  .topbar, .page-footer, .no-print, .explain, .btn, .save-pack, .note, .back, .notice:not(.notice-muted) { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { border-color: #dedad2; box-shadow: none; }
  .series { break-inside: avoid; page-break-inside: avoid; }
  .series-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .no-print-col { display: none; }
  .print-foot { display: block; margin-top: 18px; padding-top: 8px; border-top: 1px solid #dedad2;
    font-family: var(--mono); font-size: 8.5pt; color: #5d5a64; }
  a { color: inherit; text-decoration: none; }
}
.optional { font-weight: 400; color: var(--text-tertiary); margin-left: 4px; }
.mini-actions a.btn-mini { text-decoration: none; }
.nowrap { white-space: nowrap; }
.d-short { display: none; }
.doc-link { display: inline-flex; align-items: baseline; gap: 3px; }
.doc-link .icon { width: 12px; height: 12px; flex: none; align-self: center; }
@media (max-width: 640px) {
  .d-long, .doc-long { display: none; }
  .d-short { display: inline; }
  .vtable { font-size: 13.5px; }
  .vtable td:last-child { text-align: right; width: 36px; }
  .doc-link { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; }
  .doc-link .icon { width: 16px; height: 16px; }
}
@media print { .d-long { display: inline !important; } .d-short { display: none !important; } }
@media print and (max-width: 640px) { .series-body { grid-template-columns: minmax(0, 1fr); } }
