/* 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: 12px; text-align: left;
  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); }
.nav { display: flex; align-items: center; gap: 4px; min-width: 0; }
.nav-item { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 11px;
  border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background 150ms var(--ease-out), color 150ms var(--ease-out), box-shadow 150ms var(--ease-out); }
.nav-item .icon { width: 15px; height: 15px; }
.nav-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.is-active { background: var(--bg-elevated); color: var(--text-primary); box-shadow: inset 0 -2px 0 var(--accent); }
.nav-item:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.nav-analysis-mobile { display: none; }
.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; }

@media (max-width: 820px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .topbar-actions { display: none; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky); justify-content: space-around; gap: 0;
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    border-top: 1px solid var(--border-subtle); background: color-mix(in srgb, var(--bg-surface) 96%, transparent);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
  .nav-item { flex: 1 1 0; flex-direction: column; gap: 3px; height: 50px; min-height: 50px; padding: 0 2px;
    color: var(--text-tertiary); font-size: 10px; line-height: 12px; }
  .nav-item .icon { width: 19px; height: 19px; }
  .nav-item:hover, .nav-item.is-active { background: transparent; box-shadow: none; }
  .nav-item.is-active { color: var(--accent-ink); }
  .nav-family-desktop { display: none; }
  .nav-analysis-mobile { display: flex; }
  .nav.has-mobile-analysis-active .nav-home.is-active { color: var(--text-tertiary); }
  .chat-form { bottom: calc(82px + env(safe-area-inset-bottom)); }
}

/* ── 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: 4px; min-height: 44px; padding: 0 16px 0 10px;
  margin-bottom: 14px; border: 1px solid var(--border-default); border-radius: 12px; text-align: left;
  background: var(--bg-surface); color: var(--text-primary); font-size: 15px; font-weight: 500; line-height: 1.2;
  max-width: 100%; -webkit-tap-highlight-color: transparent;
  transition: background 150ms var(--ease-out), border-color 150ms var(--ease-out), transform 120ms var(--ease-out); }
.back .icon { flex: none; width: 20px; height: 20px; stroke-width: 2.25; }
.back:hover { background: var(--bg-elevated); border-color: var(--border-strong); }
.back:active { transform: scale(.97); background: var(--bg-elevated); }
.back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.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; }
.original-viewer { display: flex; flex-direction: column; min-width: 0; }
.original-viewer-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.original-viewer-head .page-head { min-width: 0; }
.original-viewer-name { color: var(--text-secondary); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
.original-external { flex: none; }
.original-stage { display: grid; place-items: center; min-width: 0; min-height: 62vh; overflow: hidden;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-base); }
.original-stage img { display: block; width: 100%; height: auto; max-height: 78vh; object-fit: contain; }
.original-stage iframe { display: block; width: 100%; height: 78vh; min-height: 620px; border: 0; background: #fff; }
.original-unsupported { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 28px; text-align: center; }
.original-pager { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; margin-top: 14px; }
.original-pager .btn:first-child { justify-self: start; }
.original-pager .btn:last-child { justify-self: end; }

/* ── 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: 12px; text-align: left; 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; }
.settings-title-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.settings-theme-control { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.settings-grid .pwa-settings { margin-bottom: 0; }
.drive-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drive-card-head .side-title { margin-bottom: 0; }
.drive-state { flex: none; font-family: var(--mono); font-size: 10.5px; line-height: 18px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-secondary); }
.drive-state.is-connected { color: var(--success); }
.drive-state.is-warning { color: var(--warning); }
.drive-steps { display: grid; gap: 8px; margin: 16px 0 0; padding-left: 22px; color: var(--text-secondary); font-size: 13px; line-height: 20px; }
.drive-steps strong { color: var(--text-primary); overflow-wrap: anywhere; }
.drive-actions { display: flex; gap: 8px; margin-top: 16px; }
.drive-finish { max-width: 760px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }
.drive-finish .btn { align-self: flex-start; }
.drive-pending { margin-top: 14px; }
@media (max-width: 640px) {
  /* Logout lives in /settings on phones: the topbar stays one row at 360–390px. */
  .topbar [data-logout] { display: none; }
  .drive-card-head { align-items: flex-start; }
  .drive-actions, .drive-actions form, .drive-actions .btn, .drive-finish .btn { width: 100%; }
}
.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: 12px; text-align: left;
  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: 12px; text-align: left;
  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; }
.profile-link-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.profile-head { align-items: flex-end; }
.profile-progress { display: inline-flex; align-items: center; justify-content: center; min-width: 68px; height: 34px; padding: 0 12px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 12px; }
.profile-note { max-width: 760px; margin-top: 18px; }
.profile-freshness, .profile-health-review { display: grid; gap: 16px; margin-top: 18px; }
.profile-review-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.profile-review-head h2 { margin: 0 0 5px; font-size: 18px; line-height: 24px; }
.profile-review-head p { color: var(--text-secondary); font-size: 13.5px; line-height: 20px; }
.profile-review-date { flex: none; color: var(--text-tertiary); font-size: 11px; line-height: 20px; }
.profile-freshness-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.profile-freshness-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; padding: 11px 12px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--bg-elevated); }
.profile-freshness-item > div { display: grid; gap: 2px; min-width: 0; }
.profile-freshness-item strong { font-size: 13px; line-height: 18px; }
.profile-freshness-item small { color: var(--text-tertiary); font-size: 11px; line-height: 16px; }
.profile-freshness-state { flex: none; color: var(--success); font-size: 11px; line-height: 16px; text-align: right; }
.profile-freshness-item.is-due { border-color: color-mix(in srgb, var(--warning) 40%, var(--border-subtle)); }
.profile-freshness-item.is-due .profile-freshness-state { color: var(--warning); }
.profile-freshness-item.is-missing .profile-freshness-state { color: var(--text-tertiary); }
.profile-review-boundary { margin: 0; }
.profile-review-summary { padding: 12px 14px; border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-muted); font-size: 14px; line-height: 21px; }
.profile-review-group { display: grid; gap: 9px; }
.profile-review-group h3 { font-size: 14px; line-height: 20px; }
.profile-review-item { display: grid; gap: 8px; padding: 13px 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--bg-elevated); }
.profile-review-item.is-urgent { border-color: color-mix(in srgb, var(--danger) 45%, var(--border-subtle)); }
.profile-review-item.is-soon { border-color: color-mix(in srgb, var(--warning) 45%, var(--border-subtle)); }
.profile-review-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.profile-review-item strong { font-size: 14px; line-height: 20px; }
.profile-review-item p, .profile-review-empty { color: var(--text-secondary); font-size: 13px; line-height: 20px; }
.profile-review-item ul { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; list-style: none; }
.profile-review-item li { padding: 3px 7px; border-radius: 12px; text-align: left; background: var(--bg-base); color: var(--text-tertiary); font-size: 10.5px; line-height: 15px; }
.profile-review-question .profile-field { margin-top: 2px; }
.profile-review-question .btn { justify-self: start; }
.profile-form { display: grid; gap: 12px; margin-top: 18px; }
.profile-section { padding: 0; overflow: clip; }
.profile-section summary { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 18px 20px;
  cursor: pointer; list-style: none; }
.profile-section summary::-webkit-details-marker { display: none; }
.profile-section summary::after { content: "+"; grid-column: 3; grid-row: 1; color: var(--text-tertiary); font-size: 22px; line-height: 1; }
.profile-section[open] summary::after { content: "−"; }
.profile-section summary > span:nth-child(2) { display: grid; gap: 3px; }
.profile-section summary strong { font-size: 17px; line-height: 23px; }
.profile-section summary small { color: var(--text-secondary); font-size: 13px; line-height: 19px; font-weight: 400; }
.profile-section-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: var(--radius-sm); background: var(--accent-muted); color: var(--accent-ink); }
.profile-section-icon .icon { width: 19px; height: 19px; }
.profile-section-done { display: inline-flex; align-items: center; gap: 5px; margin-right: 28px; color: var(--success); font-size: 12px; white-space: nowrap; }
.profile-section-done .icon { width: 14px; height: 14px; }
.profile-section summary::after, .profile-section-done { grid-column: 3; grid-row: 1; }
.profile-section summary:has(.profile-section-done)::after { display: none; }
.profile-section-body { display: grid; gap: 18px; padding: 20px; border-top: 1px solid var(--border-subtle); }
.profile-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.profile-fields-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.profile-field { display: flex; min-width: 0; flex-direction: column; gap: 7px; color: var(--text-primary); font-size: 14px; font-weight: 500; }
.profile-field > span small { color: var(--text-tertiary); font-size: 12px; font-weight: 400; }
.profile-field-wide { grid-column: 1 / -1; }
.profile-field .textarea { min-height: 100px; resize: vertical; }
.profile-choice-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.profile-choice-field legend { margin-bottom: 7px; padding: 0; color: var(--text-primary); font-size: 14px; font-weight: 500; }
.profile-choice-field .input-hint { margin: -2px 0 9px; }
.profile-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-choice { position: relative; }
.profile-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.profile-choice span { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border-default);
  border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out), color 150ms var(--ease-out); }
.profile-choice span:hover { border-color: var(--border-strong); color: var(--text-primary); }
.profile-choice input:checked + span { border-color: var(--accent); background: var(--accent-muted); color: var(--text-primary); }
.profile-choice input:focus-visible + span { outline: 2px solid var(--accent-ink); outline-offset: 3px; }
.profile-bmi { margin: 0; padding: 11px 13px; border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--text-secondary); font-size: 13px; }
.profile-bmi strong { color: var(--text-primary); }
.profile-oura { display: flex; flex-direction: column; gap: 18px; margin-top: 28px; }
.profile-oura-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.profile-oura-copy { display: flex; align-items: flex-start; gap: 14px; max-width: 720px; }
.profile-oura h2 { margin-bottom: 6px; font-size: 18px; }
.profile-oura p { color: var(--text-secondary); }
.profile-oura ol { margin: 12px 0 0; padding-left: 20px; color: var(--text-secondary); font-size: 13px; line-height: 21px; }
.profile-oura-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.profile-oura-question { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--bg-elevated); }
.profile-oura-question-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.profile-oura-question-head > div { display: grid; gap: 3px; }
.profile-oura-question-head strong { font-size: 14px; }
.profile-oura-question-head small { color: var(--text-secondary); font-size: 12px; line-height: 18px; }
.profile-oura-prompt { min-height: 154px; resize: none; color: var(--text-secondary); font-size: 14px; line-height: 21px; }
.profile-oura-copy-status { min-height: 18px; color: var(--text-secondary); font-size: 12px; line-height: 18px; }
.profile-oura-copy-status[data-state="copied"] { color: var(--success); }
.profile-oura-copy-status[data-state="error"] { color: var(--danger); }
.profile-oura-form { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }
.profile-oura-form-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.profile-oura-date { width: 220px; }
.profile-oura-save { display: flex; gap: 8px; }
.profile-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.profile-connector { display: grid; gap: 11px; margin-top: 5px; padding: 13px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--bg-elevated); }
.profile-connector.is-connected { border-color: color-mix(in srgb, var(--success) 38%, var(--border-subtle)); }
.profile-connector-head { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.profile-connector-head > div { display: grid; gap: 2px; }
.profile-connector-head strong { font-size: 14px; }
.profile-connector-head small, .profile-connector p { color: var(--text-secondary); font-size: 12px; line-height: 18px; font-weight: 400; }
.profile-connector p { margin: 0; }
.profile-connector-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 9px; color: var(--accent-ink); background: var(--accent-muted); }
.profile-connector-icon .icon { width: 16px; height: 16px; }
.profile-connector-state { color: var(--success); font-size: 11px; font-weight: 650; }
.profile-connector-pick { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.profile-connector-pick label { grid-column: 1 / -1; color: var(--text-tertiary); font-size: 12px; font-weight: 500; }
.profile-connector-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-connector .btn { min-height: 40px; }
.profile-connector-error { color: var(--text-tertiary) !important; }
.profile-save-status { display: inline-flex; min-height: 44px; align-items: center; gap: 7px; color: var(--text-tertiary); font-size: 11px; }
.profile-save-status::before { width: 7px; height: 7px; border-radius: 12px; text-align: left; background: currentColor; content: ""; }
.profile-save-status[data-state="saved"] { color: var(--success); }
.profile-save-status[data-state="saving"] { color: var(--warning); }
.profile-save-status[data-state="error"] { color: var(--danger); }

/* Person-level information architecture */
.person-subnav { display: flex; gap: 4px; margin: 20px 0 0; padding: 4px; overflow-x: auto; scrollbar-width: none;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-surface); }
.person-subnav::-webkit-scrollbar { display: none; }
.person-subnav-item { display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 7px; min-height: 40px;
  padding: 0 12px; border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13px; font-weight: 550; white-space: nowrap; }
.person-subnav-item:hover { color: var(--text-primary); background: var(--bg-elevated); }
.person-subnav-item.is-active { color: var(--text-primary); background: var(--bg-elevated); box-shadow: inset 0 -2px 0 var(--accent); }
.person-subnav-item:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 1px; }
.person-subnav-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 12px; text-align: left; background: var(--bg-base); color: var(--text-tertiary); font-family: var(--mono); font-size: 9px; }
.person-subnav-count.is-alert { color: var(--warning); }
.person-quick-actions { display: flex; align-items: center; gap: 16px; margin: 12px 4px 24px; color: var(--text-secondary); font-size: 13px; }
.person-quick-actions a { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
.person-quick-actions a:hover { color: var(--text-primary); }

/* Questionnaire hub and focused section editor */
.profile-overview { display: grid; gap: 18px; margin-top: 24px; }
.profile-overview-copy { display: flex; align-items: center; gap: 16px; }
.profile-overview-num { display: inline-flex; align-items: center; justify-content: center; width: 58px; height: 58px; flex: none;
  border-radius: var(--radius-md); background: var(--accent-muted); color: var(--accent-ink); font-size: 18px; font-weight: 650; }
.profile-overview h2, .profile-hub-card h2, .source-card h2, .review-empty h2 { font-size: 16px; line-height: 22px; }
.profile-overview p, .profile-hub-card p, .source-card-head p, .review-empty p { margin-top: 3px; color: var(--text-secondary); font-size: 13px; line-height: 20px; }
.profile-progress-track { height: 6px; overflow: hidden; border-radius: 12px; text-align: left; background: var(--bg-elevated); }
.profile-progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.profile-progress-track.is-0 span { width: 0; }
.profile-progress-track.is-1 span { width: 16.67%; }
.profile-progress-track.is-2 span { width: 33.33%; }
.profile-progress-track.is-3 span { width: 50%; }
.profile-progress-track.is-4 span { width: 66.67%; }
.profile-progress-track.is-5 span { width: 83.33%; }
.profile-progress-track.is-6 span { width: 100%; }
.profile-review-callout { display: grid; grid-template-columns: 38px minmax(0, 1fr) 16px; gap: 12px; align-items: center; margin-top: 12px; }
.profile-review-callout > span:nth-child(2) { display: grid; gap: 3px; }
.profile-review-callout strong { font-size: 14px; }
.profile-review-callout small { color: var(--text-secondary); font-size: 12px; line-height: 18px; }
.profile-review-callout:hover { border-color: var(--border-default); }
.profile-section-list { margin-top: 28px; }
.profile-section-menu { padding: 0; overflow: hidden; }
.profile-section-link { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto 16px; gap: 13px; align-items: center; min-height: 82px;
  padding: 13px 16px; border-bottom: 1px solid var(--border-subtle); }
.profile-section-link:last-child { border-bottom: 0; }
.profile-section-link:hover { background: var(--bg-elevated); }
.profile-section-link-copy { display: grid; gap: 3px; min-width: 0; }
.profile-section-link-copy strong { font-size: 14px; line-height: 20px; }
.profile-section-link-copy small { color: var(--text-secondary); font-size: 12px; line-height: 18px; }
.profile-section-link-state { display: grid; gap: 2px; justify-items: end; text-align: right; }
.profile-answer-count { color: var(--text-secondary); font-size: 11px; }
.profile-answer-count.is-empty { color: var(--text-tertiary); }
.profile-review-state { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 8px; border-radius: 12px; text-align: left;
  background: var(--success-bg); color: var(--success); font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.profile-review-state.is-due { background: var(--warning-bg); color: var(--warning); }
.profile-review-state.is-missing { background: var(--bg-elevated); color: var(--text-tertiary); }
.profile-hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.profile-hub-card { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.profile-hub-link:hover { border-color: var(--border-default); }
.profile-privacy-note, .profile-review-boundary-note { margin-top: 18px; border-left: 2px solid var(--border-default); padding: 4px 0 4px 16px; }
.profile-privacy-note summary, .profile-review-boundary-note summary { min-height: 40px; display: flex; align-items: center; cursor: pointer; color: var(--text-secondary); font-size: 13px; font-weight: 600; }
.profile-privacy-note p, .profile-review-boundary-note p { max-width: 760px; padding: 4px 0 8px; color: var(--text-secondary); font-size: 13px; line-height: 21px; }
.profile-step { color: var(--text-tertiary); font-size: 10px; line-height: 16px; text-transform: uppercase; letter-spacing: .07em; }
.profile-editor { margin-top: 24px; padding: 0; overflow: hidden; }
.profile-editor-body { display: grid; gap: 22px; padding: 24px; }
.profile-editor-actions { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-top: 1px solid var(--border-subtle); background: var(--bg-elevated); }
.profile-source-link { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; color: var(--accent-ink); font-size: 13px; }
.profile-step-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }

/* Recommendations */
.review-section { margin-top: 30px; }
.review-section-lead { margin: -4px 0 14px; color: var(--text-secondary); font-size: 13px; }
.review-list { display: grid; gap: 10px; }
.review-card { padding: 0; overflow: hidden; }
.review-card.is-urgent { border-color: color-mix(in srgb, var(--danger) 45%, var(--border-subtle)); }
.review-card.is-soon { border-color: color-mix(in srgb, var(--warning) 45%, var(--border-subtle)); }
.review-card > summary { display: grid; grid-template-columns: minmax(0, 1fr) auto 16px; gap: 14px; align-items: center; min-height: 76px;
  padding: 15px 18px; cursor: pointer; list-style: none; }
.review-card > summary::-webkit-details-marker { display: none; }
.review-card > summary > .icon { transition: transform 150ms var(--ease-out); }
.review-card[open] > summary > .icon { transform: rotate(180deg); }
.review-card-copy { display: grid; gap: 4px; min-width: 0; }
.review-card-copy strong { font-size: 14px; line-height: 20px; }
.review-card-copy small { color: var(--text-secondary); font-size: 12px; line-height: 18px; }
.review-card-detail { display: grid; gap: 18px; padding: 18px; border-top: 1px solid var(--border-subtle); background: var(--bg-elevated); }
.review-card-detail h3 { margin-bottom: 4px; font-size: 12px; line-height: 18px; }
.review-card-detail p { color: var(--text-secondary); font-size: 13px; line-height: 21px; }
.review-card-full { color: var(--text-primary) !important; font-size: 14px !important; }
.review-card-detail ul, .review-evidence { display: flex; flex-wrap: wrap; gap: 6px; }
.review-card-detail li, .review-evidence li { padding: 4px 8px; border-radius: 12px; text-align: left; background: var(--bg-base); color: var(--text-tertiary); font-size: 10.5px; }
.review-question { display: grid; gap: 12px; }
.review-question-head { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; align-items: center; }
.review-question > p { color: var(--text-secondary); font-size: 13px; }
.review-question .btn { justify-self: start; }
.review-empty { display: flex; align-items: flex-start; gap: 14px; margin-top: 24px; }

/* External health sources */
.source-card { display: grid; gap: 16px; margin-top: 24px; }
.source-card-head { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.source-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.source-summary { padding: 12px; border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--text-secondary); font-size: 13px; }
.source-summary .mono { color: var(--text-tertiary); font-size: 10px; }
.source-connect-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.source-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.source-grid .source-card { margin-top: 12px; }
.oura-advisor-flow { border-top: 1px solid var(--border-subtle); }
.oura-advisor-flow > summary { display: grid; grid-template-columns: minmax(0, 1fr) auto 16px; gap: 12px; align-items: center; min-height: 58px; padding-top: 14px; cursor: pointer; list-style: none; }
.oura-advisor-flow > summary::-webkit-details-marker { display: none; }
.oura-advisor-flow > summary > span { font-weight: 600; }
.oura-advisor-flow > summary > small { color: var(--text-tertiary); font-size: 11px; }
.oura-advisor-flow[open] > summary > .icon { transform: rotate(180deg); }
.oura-advisor-body { display: grid; gap: 18px; padding-top: 14px; }
.settings-theme-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; }

@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) {
  .person-subnav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: auto; margin-top: 18px; padding: 3px; overflow: visible; }
  .person-subnav-item { min-width: 0; min-height: 44px; padding: 0 5px; font-size: 11.5px; }
  .person-subnav-count { min-width: 18px; height: 18px; padding: 0 4px; }
  .person-quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0 20px; }
  .person-quick-actions a { min-width: 0; min-height: 44px; padding: 0 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--bg-surface); }
  .profile-overview { margin-top: 18px; }
  .profile-overview-copy { align-items: flex-start; }
  .profile-overview-num { width: 52px; height: 52px; }
  .profile-section-list { margin-top: 24px; }
  .profile-section-list .section-head { align-items: flex-start; flex-direction: column; gap: 3px; }
  .profile-section-link { grid-template-columns: 34px minmax(0, 1fr) 16px; gap: 11px; min-height: 78px; padding: 13px 14px; }
  .profile-section-link-state { grid-column: 2; grid-row: 2; display: flex; justify-items: start; align-items: center; gap: 7px; text-align: left; }
  .profile-section-link > .icon:last-child { grid-column: 3; grid-row: 1 / span 2; }
  .profile-hub-grid, .source-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-hub-card { grid-template-columns: 34px minmax(0, 1fr); padding: 15px; }
  .profile-hub-card form, .profile-hub-card > .icon:last-child { grid-column: 2; }
  .profile-hub-link { grid-template-columns: 34px minmax(0, 1fr) 16px; }
  .profile-hub-link > .icon:last-child { grid-column: 3; }
  .profile-hub-card .btn { width: 100%; min-height: 44px; }
  .profile-editor { margin-top: 18px; }
  .profile-editor-body { padding: 18px 15px; }
  .profile-editor-actions { position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 20; padding: 10px 15px; }
  .profile-editor-actions .btn { min-height: 44px; }
  .profile-step-nav .btn { min-height: 44px; max-width: 48%; }
  .profile-review-boundary-note { margin-top: 16px; }
  .review-card > summary { grid-template-columns: minmax(0, 1fr) 16px; gap: 10px; padding: 14px; }
  .review-card > summary .badge { grid-column: 1; justify-self: start; }
  .review-card > summary > .icon { grid-column: 2; grid-row: 1 / span 2; }
  .review-card-detail { padding: 15px; }
  .review-question .btn { width: 100%; }
  .source-card { margin-top: 18px; }
  .source-card-head { grid-template-columns: 34px minmax(0, 1fr); }
  .source-card-head .profile-connector-state { grid-column: 2; }
  .source-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .source-actions .btn { width: 100%; min-height: 44px; }
  .source-connect-form { grid-template-columns: minmax(0, 1fr); }
  .oura-advisor-flow > summary { grid-template-columns: minmax(0, 1fr) 16px; }
  .oura-advisor-flow > summary small { grid-column: 1; }
  .oura-advisor-flow > summary > .icon { grid-column: 2; grid-row: 1 / span 2; }
  .profile-progress { white-space: nowrap; }
  .profile-review-head { flex-direction: column; align-items: stretch; }
  .profile-review-head form .btn { width: 100%; }
  .profile-freshness-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-freshness-item { align-items: flex-start; }
  .profile-review-item-head { flex-direction: column; gap: 7px; }
  .profile-review-question .btn { width: 100%; }
  .profile-section summary { grid-template-columns: 34px minmax(0, 1fr); padding: 15px; }
  .profile-section-icon { width: 34px; height: 34px; }
  .profile-section summary::after { grid-column: 2; justify-self: end; }
  .profile-section-done { display: none; }
  .profile-section-body { padding: 16px 15px; }
  .profile-fields, .profile-fields-3 { grid-template-columns: minmax(0, 1fr); }
  .profile-field-wide { grid-column: auto; }
  .profile-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-choice span { justify-content: center; height: 100%; text-align: center; }
  .profile-oura-copy { align-items: flex-start; }
  .profile-oura-head, .profile-oura-form-foot, .profile-oura-question-head { flex-direction: column; align-items: stretch; }
  .profile-oura-actions, .profile-oura-save { display: grid; grid-template-columns: minmax(0, 1fr); }
  .profile-oura-actions .btn, .profile-oura-save .btn, .profile-oura-question-head .btn { width: 100%; }
  .profile-oura-prompt { min-height: 286px; }
  .profile-oura-date { width: auto; }
  .profile-actions .btn { width: 100%; }
  .profile-connector-head { grid-template-columns: 32px minmax(0, 1fr); }
  .profile-connector-state { grid-column: 2; }
  .profile-connector-pick { grid-template-columns: minmax(0, 1fr); }
  .profile-connector-pick label { grid-column: auto; }
  .profile-connector-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-connector .btn { width: 100%; min-height: 44px; }
  .profile-save-status { width: 100%; justify-content: center; }
  .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); } }

/* ── Conversations (server-side chats) ── */
.explain-tools { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; }
.explain-tool { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; padding: 4px 0; min-height: 28px;
  font: inherit; font-size: 12.5px; color: var(--text-secondary); cursor: pointer; }
.explain-tool:hover { color: var(--accent-ink); }
.explain-tool[disabled] { opacity: .5; cursor: progress; }
.explain-tool .icon { width: 13px; height: 13px; }
.explain-at { font-family: var(--mono); font-size: 10.5px; line-height: 16px; color: var(--text-tertiary); margin-top: 8px !important; }
html[data-theme="light"] .explain-at { color: var(--text-secondary); }
.explain-error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--danger); font-size: 14px; }
.ask-out.is-html { white-space: normal; border-left-color: var(--accent); color: var(--text-primary); }
.ask-out.is-html ol, .explain-a ol { display: flex; flex-direction: column; gap: 6px; padding-left: 20px; list-style: decimal; }
.ask-more { align-self: flex-start; font-size: 13.5px; }

.chat-group .month-title { margin-bottom: 10px; }
.chat-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--border-subtle); }
.chat-row:first-child { border-top: 0; }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.chat-main:hover .chat-title { color: var(--accent-ink); }
.chat-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-width: 0; }
.chat-subject { font-size: 12.5px; line-height: 18px; color: var(--text-secondary); overflow-wrap: anywhere; }
.chat-title { font-size: 15px; line-height: 22px; overflow-wrap: anywhere; }
.chat-snippet { font-size: 13px; line-height: 19px; color: var(--text-secondary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chat-del { margin-top: 0; flex: none; }
.chat-del .confirm { position: absolute; right: 0; top: calc(100% + 6px); margin: 0; z-index: 5; background: var(--bg-elevated); border-radius: var(--radius-sm); min-width: 240px; box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, .5)); }
/* 0.44.3: список обрізав підтвердження в останньому рядку (overflow: hidden у .list-card). */
.list-card:has(details[open]) { overflow: visible; }
.chat-del { position: relative; }
.chat-head .page-title .spark { font-size: .8em; vertical-align: 2px; }
.chat-head .chat-top { margin-bottom: 2px; }
.chat-page { max-width: 820px; margin-top: 24px; display: flex; flex-direction: column; gap: 16px; }
.chat-thread .explain-a { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 16px 18px; }
.chat-thread .explain-q { margin-top: 6px; }
.chat-form { position: sticky; bottom: 12px; background: var(--bg-base); padding: 6px; border-radius: var(--radius-md);
  box-shadow: 0 0 0 1px var(--border-default); }
.chat-new { margin-top: 8px; }
@media (max-width: 640px) {
  .chat-row { padding: 12px 16px; }
  .chat-del-text { display: none; }
  .chat-thread .explain-a { padding: 14px; }
  .chat-new .btn { width: 100%; height: 44px; }
}
.chat-go { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--accent-ink); min-height: 32px; }
.chat-go .icon { width: 13px; height: 13px; }
.lang-switch { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.seg-links { display: inline-flex; gap: 0; border: 1px solid var(--border-default); border-radius: 12px; text-align: left; padding: 3px; }
.seg-link { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; height: 38px; padding: 0 12px;
  border-radius: 12px; text-align: left; font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.06em; color: var(--text-secondary);
  transition: background 150ms var(--ease-out), color 150ms var(--ease-out); }
.seg-link:hover { color: var(--text-primary); }
.seg-link.is-active { background: var(--accent); color: #fff; }

/* ── Dashboard (person page) ── */
.dash-head { align-items: flex-end; }
.dash-links { display: flex; gap: 8px; flex-wrap: wrap; }
.drop-compact { padding: 14px; gap: 10px; }
.drop-compact .drop-area { flex-direction: row; justify-content: flex-start; text-align: left; min-height: 76px; padding: 14px 16px; gap: 14px; }
.drop-compact .drop-icon { margin: 0; flex: none; }
.drop-compact .drop-title { font-size: 15px; }
.drop-compact .drop-for { display: none; }
.drop-compact .drop-hint { max-width: none; }
.drop-compact .drop-area > .drop-title, .drop-compact .drop-area > .drop-hint { display: block; }
.drop-compact .drop-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.state-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.6fr); gap: 10px; margin-top: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; min-height: 92px; border-radius: var(--radius-lg);
  background: var(--bg-surface); border: 1px solid var(--border-subtle); min-width: 0;
  transition: border-color 150ms var(--ease-out), transform 200ms var(--ease-spring); }
a.stat:hover { border-color: var(--border-strong); }
a.stat:active { transform: scale(.98); }
.stat-num { display: inline-flex; align-items: center; gap: 6px; font-size: 30px; line-height: 36px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-num .icon { width: 20px; height: 20px; stroke-width: 2; }
.stat-label { font-family: var(--mono); font-size: 10.5px; line-height: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); }
.stat-danger .stat-num { color: var(--danger); }
.stat-success .stat-num { color: var(--success); }
.stat.is-zero .stat-num { color: var(--text-tertiary); }
.stat-next { gap: 6px; }
.stat-text { font-weight: 500; line-height: 20px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.stat-cal { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--accent-ink); min-height: 32px; }
.stat-cal .icon { width: 14px; height: 14px; }
.med-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.med-chips .meta { display: inline-flex; align-items: center; gap: 5px; margin-right: 2px; }
.med-chips .meta .icon { width: 12px; height: 12px; }
.med-chip { display: inline-flex; align-items: baseline; gap: 4px; padding: 5px 11px; border-radius: 12px; text-align: left;
  background: var(--bg-surface); border: 1px solid var(--border-default); font-size: 13px; }
.pin-hint { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pin-hint .icon { width: 15px; height: 15px; color: var(--warning); }

.dash-tools { position: sticky; top: 64px; z-index: 50; display: flex; flex-direction: column; gap: 10px; padding: 10px 0;
  margin: 0 -2px 6px; background: color-mix(in srgb, var(--bg-base) 94%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.dash-search { position: relative; display: block; max-width: 420px; }
.dash-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.dash-search .input { padding-left: 38px; font-size: 16px; }
.dash-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; scroll-snap-type: x proximity; }
.dash-chips::-webkit-scrollbar { display: none; }
.dchip { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 12px; text-align: left;
  border: 1px solid var(--border-default); background: var(--bg-surface); color: var(--text-secondary);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; scroll-snap-align: start;
  transition: background 150ms var(--ease-out), color 150ms var(--ease-out), border-color 150ms var(--ease-out); }
.dchip:hover { color: var(--text-primary); border-color: var(--border-strong); }
.dchip.is-active { background: var(--accent-muted); border-color: var(--accent); color: var(--text-primary); }
.dchip-dot { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: var(--bg-base);
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
html[data-theme="light"] .dchip-dot { color: #fff; }
.dash-filter-note { font-size: 13px; color: var(--text-secondary); margin: 2px 0 8px; }
.link-btn { background: none; border: 0; padding: 4px 0; font: inherit; color: var(--accent-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.tile-group + .tile-group { margin-top: 22px; }
.tile-group .month-title { margin-bottom: 10px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 12px; min-width: 0;
  background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  transition: border-color 150ms var(--ease-out), transform 200ms var(--ease-spring); }
.tile:hover { border-color: var(--border-strong); }
.tile:active { transform: scale(.985); }
.tile.is-alert { border-color: color-mix(in srgb, var(--danger) 32%, var(--border-subtle)); }
.tile-open { position: absolute; inset: 0; z-index: 1; background: none; border: 0; border-radius: inherit; cursor: pointer; }
.tile-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; min-height: 36px; }
.tile-name { font-size: 13.5px; line-height: 18px; font-weight: 500; color: var(--text-secondary); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-top: 2px; }
.tile-pin-form { position: relative; z-index: 2; margin: -8px -8px 0 0; }
.tile-pin { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 0;
  border-radius: 12px; text-align: left; color: var(--text-tertiary); cursor: pointer; transition: color 150ms var(--ease-out), transform 200ms var(--ease-spring); }
.tile-pin .icon { width: 18px; height: 18px; }
.tile-pin:hover { color: var(--text-primary); }
.tile-pin:active { transform: scale(.85); }
.tile-pin.is-on { color: var(--warning); }
.tile-pin.is-on .icon { fill: currentColor; }
.tile-value { display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; min-width: 0; }
.tile-num { font-size: 26px; line-height: 30px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-unit { font-size: 12px; color: var(--text-secondary); }
.tile-spark { position: relative; height: 38px; margin: 2px 0; }
.sparkline { display: block; width: 100%; height: 38px; overflow: visible; }
.spark-band { fill: var(--band); }
.spark-line { fill: none; stroke: var(--chart-line); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--chart-line);
  box-shadow: 0 0 0 2px var(--bg-surface); left: 100%; top: 50%; }
.spark-dot.is-alert { background: var(--danger); }
.spark-empty { display: flex; align-items: center; height: 38px; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); }
.tile-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.tile-delta { font-family: var(--mono); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tile-trend { font-size: 11px; line-height: 15px; }
.tone-dir-better { color: var(--success); }
.tone-dir-worse { color: var(--danger); }
.tone-dir-within { color: var(--info); }
.tone-dir-same { color: var(--text-secondary); }
.tile-date { font-family: var(--mono); font-size: 11px; color: var(--text-tertiary); }
.tile-flag { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--danger); }
.person-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.person-bottom .person-side { position: static; margin-top: 36px; }
.person-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.person-main { min-width: 0; }
.person-layout .person-side { position: sticky; top: calc(var(--topbar-h, 64px) + 16px); max-height: calc(100dvh - var(--topbar-h, 64px) - 32px); overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin; }
.person-layout .state-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.person-layout .state-tiles > a.stat { grid-column: span 2; }
.person-layout .state-tiles > a.stat-comparison { grid-column: span 3; }
.stat-boundary .stat-num, .boundary-label { color: var(--warning); }
.stat-boundary.is-zero .stat-num { color: var(--text-tertiary); }
.boundary-note { color: var(--text-secondary); margin-top: 12px; }
.stat-hint { font-size: 11px; line-height: 16px; color: var(--text-secondary); }
.person-layout .stat-next { grid-column: 1 / -1; }
.summary-periods { margin: 12px 0 8px; flex-wrap: wrap; }
.summary-note, .chart-hint { margin: 8px 0 14px; }
.summary-note, .chart-hint, .person-side .note { color: var(--text-secondary); }
.archive-section { margin-top: 28px; }
.archive-guidance { border-left: 2px solid var(--border-strong); padding: 4px 0 4px 14px; color: var(--text-secondary); }
.archive-guidance summary, .method-note summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--text-primary); font-size: 14px; font-weight: 600; }
.archive-guidance p { font-size: 13px; line-height: 1.6; margin-bottom: 8px; }
.method-note p { font-size: 12.5px; line-height: 1.6; color: var(--text-secondary); }
.archive-label { color: var(--text-secondary); }
.prescription-list summary { cursor: pointer; padding: 10px 0; color: var(--text-secondary); }
.prescriptions-card > summary { min-height: 44px; display: flex; align-items: center; gap: 7px; cursor: pointer; margin: -8px 0; }
.prescriptions-card > summary .icon { width: 16px; height: 16px; }
.prescriptions-card-body { padding-top: 12px; }
.past-prescriptions { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-subtle); }
.past-prescriptions > summary { cursor: pointer; min-height: 44px; font-size: 14px; margin: 0; }
.med-source { display: block; font-size: 12px; line-height: 18px; overflow-wrap: anywhere; margin: 7px 0; min-height: 44px; padding: 4px 0; }
.med-source span { display: block; }
.docs-expand { margin: 0 0 14px; }
.document-year { margin: 16px 0; }
.document-year > summary { cursor: pointer; min-height: 44px; padding: 12px 0; }
.document-filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin: 22px 0; }
.document-filters label { display: flex; flex-direction: column; gap: 8px; flex: 1 1 180px; min-width: 0; }
.document-filters label:first-child { flex-grow: 2; }
@media (max-width: 960px) {
  .person-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .person-layout .person-side { display: contents; position: static; max-height: none; overflow: visible; }
  .person-main { order: 2; }
  .person-layout .prescriptions-card { order: 1; }
  .person-layout #reminders { order: 3; }
}
@media (max-width: 640px) {
  .document-filters { align-items: stretch; }
  .person-layout .state-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .person-layout .state-tiles > a.stat, .person-layout .state-tiles > a.stat-comparison { grid-column: auto; }
  .person-layout .state-tiles > a.stat-boundary { grid-column: 1 / -1; }
  .person-layout .state-tiles > a.stat-comparison { display: none; }
  .person-main { order: 1; }
  .person-layout .prescriptions-card { order: 2; }
  .document-filters label { flex-basis: 100%; }
  .document-filters .btn { min-height: 44px; }
}

/* Tile details sheet */
.detail { position: fixed; inset: 0; z-index: 450; }
.detail-sheet, .detail-body { min-width: 0; max-width: 100vw; }
.detail-body { overflow-x: hidden; }
.detail .explain-backdrop { opacity: 0; transition: opacity 220ms var(--ease-out); }
.detail.is-open .explain-backdrop { opacity: 1; }
.detail.is-open .explain-sheet { transform: none; }
.detail-ref { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.detail-body { gap: 14px; }
.detail-body > * { flex-shrink: 0; }
.detail-periods { flex-wrap: nowrap; min-height: 44px; overflow-x: auto; scrollbar-width: none; }
.detail-chart { min-height: 200px; position: relative; }
.detail-chart.is-loading { opacity: .45; transition: opacity 150ms var(--ease-out); }
.detail-svg { width: 100%; height: auto; display: block; }
.detail-svg .v { font-size: 11px; }
.detail-svg .d { font-size: 10px; }
.detail-svg .axis-y { font-family: var(--mono); font-size: 9px; fill: var(--chart-axis); }
.detail-svg .hit { fill: transparent; cursor: pointer; }
.detail-svg .hit:focus { outline: none; }
.detail-svg .hit:focus-visible { stroke: var(--accent); stroke-width: 2; }
.detail-svg .dot.is-picked { stroke-width: 3; r: 6; }
.detail-tip { padding: 10px 12px; border-radius: var(--radius-md); background: var(--bg-elevated); border: 1px solid var(--border-default);
  font-size: 13.5px; line-height: 21px; }
.detail-desc { font-size: 14px; line-height: 22px; color: var(--text-secondary); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
[data-detail-pin].is-on { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, var(--border-default)); }
[data-detail-pin].is-on .icon { fill: currentColor; }
.detail-table td:last-child { text-align: right; width: 44px; }
.detail-table { table-layout: fixed; }
.detail-table th:nth-child(1) { width: 30%; }
.detail-table th:nth-child(2) { width: 22%; }
.detail-table th:nth-child(4) { width: 44px; }
.detail-table .detail-range { white-space: normal; overflow-wrap: anywhere; }
.detail-table .doc-link { width: 36px; height: 36px; justify-content: center; align-items: center; text-decoration: none; }
.date-required-form { margin-top: 16px; }
.date-required-row, .queue-date-form { display: flex; gap: 10px; align-items: center; }
.date-required-row .input, .queue-date-form .input { flex: 1; min-width: 0; }
.date-pending-list { display: grid; gap: 8px; margin-top: 12px; }
.date-pending-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; }
.date-pending-item > span:first-child { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.drop-inline { margin-top: 14px; }
.drop-inline .drop-area { min-height: 116px; padding: 16px; }
.drop-inline > .drop-submit { align-self: flex-start; }

.record-edit-form { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.record-edit-section .section-head { margin-bottom: 12px; }
.record-edit-section .card-title { margin-bottom: 0; }
.record-edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.record-edit-wide { grid-column: 1 / -1; }
.record-edit-grid .input-label, .record-edit-row .input-label { margin: 0; }
.record-edit-grid .input-label > .input, .record-edit-row .input-label > .input { margin-top: 6px; }
.field-hint { display: block; margin-top: 5px; color: var(--text-tertiary); font-size: 11.5px; line-height: 17px; }
.record-edit-rows { display: flex; flex-direction: column; gap: 10px; }
.record-edit-row { display: grid; grid-template-columns: minmax(150px, 1.5fr) repeat(3, minmax(110px, 1fr)) auto; gap: 10px; align-items: end;
  padding: 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-base); }
.prescription-edit-row { grid-template-columns: repeat(5, minmax(120px, 1fr)) auto; }
.record-edit-remove { height: 42px; }
.record-edit-actions { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--border-default);
  border-radius: var(--radius-md); background: var(--bg-surface); }
.sheet-handle { display: none; }
@media (max-width: 899px) {
  .sheet-handle { display: block; position: absolute; top: 0; left: 50%; width: 72px; height: 22px; margin-left: -36px; z-index: 2; cursor: grab; }
  .sheet-handle::after { content: ""; position: absolute; top: 8px; left: 18px; width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); }
  .detail-sheet::before { display: none; }
}

@media (max-width: 960px) {
  .state-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-next { grid-column: 1 / -1; }
  .person-bottom { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (max-width: 640px) {
  .dash-head { align-items: flex-start; }
  .dash-links { width: calc(100vw - 32px); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .dash-links::-webkit-scrollbar { display: none; }
  .dash-links .btn { flex: none; width: auto; height: 44px; }
  .state-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { min-height: 80px; padding: 12px; }
  .stat-num { font-size: 24px; line-height: 30px; gap: 4px; }
  .stat-num .icon { width: 16px; height: 16px; }
  .stat-label { font-size: 9.5px; letter-spacing: 0.04em; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 12px 12px 10px; }
  .tile-num { font-size: 22px; line-height: 26px; }
  .dash-tools { top: 60px; margin: 0 -16px 6px; padding: 10px 16px; }
  .dash-search { max-width: none; }
  .drop-compact .drop-area { min-height: 72px; }
  .detail-body { padding-left: 16px; padding-right: 16px; }
  .detail-table th, .detail-table td { padding-right: 6px; }
  .detail-table .detail-date { font-size: 11.5px; }
  .detail-table .detail-value { font-size: 12.5px; }
  .date-required-row, .queue-date-form { align-items: stretch; flex-direction: column; }
  .date-pending-item { align-items: flex-start; }
  .record-edit-grid { grid-template-columns: minmax(0, 1fr); }
  .record-edit-wide { grid-column: auto; }
  .record-edit-row, .prescription-edit-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-edit-row .input-label:first-of-type, .prescription-edit-row .input-label:first-of-type { grid-column: 1 / -1; }
  .record-edit-remove { grid-column: 1 / -1; justify-self: start; }
}
.drop-text { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.drop-compact .drop-text { align-items: flex-start; gap: 2px; }
.person-card-side { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.mini-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mini-tile { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--bg-base); border: 1px solid var(--border-subtle); min-width: 0; transition: border-color 150ms var(--ease-out); }
.mini-tile:hover { border-color: var(--border-strong); }
.mini-tile.is-alert { border-color: color-mix(in srgb, var(--danger) 30%, var(--border-subtle)); }
.mini-name { font-size: 12.5px; line-height: 17px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-value .mono { font-size: 17px; font-weight: 600; }
.mini-spark, .mini-spark .sparkline, .mini-spark .spark-empty { height: 28px; }
.mini-spark .spark-dot { box-shadow: 0 0 0 2px var(--bg-base); }

.tile-meta { font-family: var(--mono); font-size: 10.5px; line-height: 15px; color: var(--text-tertiary); letter-spacing: 0.02em; }
.tile-meta .tile-flag { font-size: inherit; }

/* ── Touch & mobile pass: 44px targets, safe areas, sheets above the keyboard ── */
.topbar { padding-top: max(12px, env(safe-area-inset-top)); padding-left: max(32px, env(safe-area-inset-left)); padding-right: max(32px, env(safe-area-inset-right)); }
.page-footer { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.gm-watermark-link { padding: 14px 0; margin: -14px 0; }
.drop-picks { display: none; gap: 8px; }
.drop-pick { position: relative; overflow: hidden; }
.drop-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; font-size: 16px; }
@media (max-width: 640px), (pointer: coarse) {
  .btn, .btn-mini, .btn-sm { min-height: 44px; }
  .btn-mini { padding: 0 12px; font-size: 13px; }
  .btn-logout { width: 44px; height: 44px; }
  .mini-actions { gap: 4px; margin-left: -12px; }
  .back, .stat-cal, .chat-go, .explain-tool, .link-btn, .desc-more, .more, .person-links a, .ask-more { min-height: 44px; display: inline-flex; align-items: center; }
  .dchip, .tab, .chip, .seg-link { min-height: 44px; height: 44px; }
  .seg-item span { height: 44px; padding: 0 16px; }
  .row { min-height: 44px; align-items: center; }
  details > summary.side-title, .tool summary { min-height: 44px; }
  .doc-link, .detail-table .doc-link { width: 44px; height: 44px; }
  .gm-lockup { min-height: 44px; }
  .gm-rocker { font-size: 11px; }
  .tile-open { -webkit-tap-highlight-color: transparent; }
  .chat-form .input, .explain-form .input { height: 48px; }
  .explain-send { width: 48px; height: 48px; }
}
@media (max-width: 640px) {
  main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); gap: 6px; }
  .drop-picks { display: flex; }
  .drop-picks .btn { flex: 1 1 0; height: 48px; }
  .drop-area { min-height: 96px; }
  .drop-compact .drop-area { min-height: 64px; }
  .drop-hint { font-size: 12.5px; }
}
@media (max-width: 380px) {
  .gm-mark { font-size: 18px; }
  .gm-pill { font-size: 11px; padding: 4px 9px 5px; }
  .gm-lockup { gap: 6px; }
  .gm-rocker { font-size: 10px; }
  .tiles { gap: 6px; }
  .tile { padding: 10px 10px 9px; }
  .tile-num { font-size: 20px; }
  .tile-delta { font-size: 11px; }
  .stat-label { font-size: 9px; }
  .page-title { font-size: 26px; line-height: 32px; }
}

/* Bottom sheets: opacity + transform only; handle for swipe; follow the on-screen keyboard. */
.explain-sheet { will-change: transform; }
@media (max-width: 899px) {
  .explain-sheet { transition: transform 260ms var(--ease-out), opacity 200ms var(--ease-out); opacity: .4; }
  .explain.is-open .explain-sheet, .detail.is-open .explain-sheet { opacity: 1; }
  .explain-sheet::before { display: none; }
  .explain-sheet { height: min(85dvh, var(--vvh, 85dvh)); bottom: var(--kb, 0px); }
  .explain-body { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
}
.dash-tools { top: var(--topbar-h, 64px); }
@media (max-width: 640px) { .dash-tools { top: var(--topbar-h, 60px); } }
.gm-watermark-link { padding: 16px 0; margin: -16px 0; }
@media (max-width: 640px), (pointer: coarse) {
  .fact a { display: inline-block; padding: 12px 8px; margin: -12px -8px; }
  .login-switch { min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .chat-del > summary { min-width: 44px; justify-content: center; }
}
@media (max-width: 640px) {
  /* Blur behind sticky bars is expensive on phones: an opaque bar scrolls smoother. */
  .topbar, .dash-tools { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg-base); }
  .topbar { background: var(--bg-surface); }
}

/* ── «＋ Документ», /upload, черга ── */
.btn-add { height: 36px; padding: 0 14px 0 11px; gap: 6px; }
.btn-add .icon { width: 16px; height: 16px; stroke-width: 2; }
.btn-add .add-short { display: none; }
.btn-add.is-current { background: var(--accent-muted); color: var(--text-primary); }
.who { margin: 0 0 4px; }
.who legend { margin-bottom: 8px; }
.who-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.who-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.who-chip span { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 12px; text-align: left;
  border: 1px solid var(--border-default); font-size: 14px; font-weight: 500; color: var(--text-secondary); cursor: pointer;
  transition: background 150ms var(--ease-out), border-color 150ms var(--ease-out), color 150ms var(--ease-out); }
.who-chip span .icon { width: 15px; height: 15px; }
.who-chip span:hover { color: var(--text-primary); border-color: var(--border-strong); }
.who-chip input:checked + span { background: var(--accent-muted); border-color: var(--accent); color: var(--text-primary); }
.who-chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-glow); }
.upload-page { margin-top: 20px; }
.upload-page .drop-area { min-height: 180px; }
.queue-list { display: flex; flex-direction: column; gap: 10px; }
.qcard { display: flex; flex-direction: column; gap: 10px; position: relative; transition: border-color 300ms var(--ease-out); }
.qcard-head { display: flex; align-items: flex-start; gap: 12px; }
.qcard-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.qcard-note { font-size: 13.5px; color: var(--text-secondary); }
.qcard-note strong { color: var(--text-primary); font-weight: 600; }
.qcard .choice { margin-top: 0; }
.qcard-open { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--accent-ink); min-height: 32px; }
.qcard-open .icon { width: 13px; height: 13px; }
.qcard-need_person { border-color: color-mix(in srgb, var(--warning) 35%, var(--border-subtle)); }
.qcard-failed { border-color: color-mix(in srgb, var(--danger) 35%, var(--border-subtle)); }
.qcard.is-added, .pending.is-added { box-shadow: inset 3px 0 0 var(--accent); }
.btn.is-suggested { border-color: var(--accent); }
.qcard .spinner { width: 18px; height: 18px; }

/* ── Головна: інформаційний дашборд ── */
.empty-hero { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 32px; margin-top: 20px; max-width: 640px; }
.empty-hero .drop-icon { width: 48px; height: 48px; }
.empty-person { max-width: 820px; }
.empty-person .person-upload { margin-top: 16px; }
.important { margin-top: 18px; }
.imp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.imp { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; min-height: 104px; border-radius: var(--radius-lg);
  background: var(--bg-surface); border: 1px solid var(--border-subtle); min-width: 0; }
a.imp:hover { border-color: var(--border-strong); }
.imp-label { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-secondary); }
.imp-label .icon { width: 13px; height: 13px; }
.imp-num { font-size: 34px; line-height: 40px; font-weight: 600; letter-spacing: -0.02em; color: var(--danger); }
.imp-out.is-zero .imp-num { color: var(--text-tertiary); }
.imp-out { border-color: color-mix(in srgb, var(--danger) 25%, var(--border-subtle)); }
.imp-out.is-zero { border-color: var(--border-subtle); }
.imp-text { font-weight: 500; font-size: 15px; line-height: 21px; overflow-wrap: anywhere; }
.imp-sub { font-size: 13px; line-height: 19px; color: var(--text-secondary); overflow-wrap: anywhere; }
.imp-link { color: var(--text-primary); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.imp-link:hover { color: var(--accent-ink); }
.imp-queue { border-color: color-mix(in srgb, var(--info) 30%, var(--border-subtle)); }
.med-home-queue .note { margin-bottom: 12px; }
.med-queue-row.is-review { box-shadow: inset 3px 0 0 var(--warning); }
.med-queue-row.is-failed { box-shadow: inset 3px 0 0 var(--danger); }
.imp .stat-cal { align-self: flex-start; margin-top: auto; }
.fam-card { display: flex; flex-direction: column; gap: 12px; transition: border-color 150ms var(--ease-out); }
.fam-card:hover { border-color: var(--border-strong); }
.fam-card:hover .go { color: var(--accent-ink); transform: translateX(2px); }
.fam-card.has-out { border-color: color-mix(in srgb, var(--danger) 22%, var(--border-subtle)); }
.fam-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.fam-name-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fam-label { display: inline-flex; align-items: center; gap: 5px; }
.fam-label .icon { width: 12px; height: 12px; }
.fam-meds { display: flex; flex-direction: column; gap: 6px; }
.fam-med { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-base); }
.fam-med-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fam-med-name { font-size: 13.5px; line-height: 18px; font-weight: 500; overflow-wrap: anywhere; }
.fam-med-dose { font-family: var(--mono); font-size: 10.5px; line-height: 15px; color: var(--text-secondary); }
.fam-med-times { display: flex; justify-content: flex-end; gap: 5px; flex-wrap: wrap; min-width: 0; }
.fam-med-time { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 3px 7px; border: 1px solid var(--border-default);
  border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 11.5px; line-height: 16px; white-space: nowrap; }
.fam-med-time .icon { width: 13px; height: 13px; }
.home-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.home-cols.is-single { grid-template-columns: minmax(0, 1fr); }
.ask-compact { gap: 12px; }
.ask-line { display: flex; gap: 8px; }
.ask-line .input { flex: 1; min-width: 0; }
.ask-line .btn { height: 44px; }

@media (max-width: 860px) { .home-cols { grid-template-columns: minmax(0, 1fr); gap: 0; } }
@media (max-width: 640px) {
  .btn-add { height: 44px; padding: 0 12px 0 10px; }
  .btn-add .add-long { display: none; }
  .btn-add .add-short { display: inline; }
  .who-chip span { height: 44px; }
  .empty-hero { padding: 22px 18px; }
  .empty-hero .btn { width: 100%; }
  .imp-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .imp { min-height: 0; }
  .ask-line { flex-direction: column; }
  .ask-line .btn { width: 100%; }
  .fam-card { gap: 10px; }
  .fam-meds { gap: 4px; }
  .fam-med { align-items: center; flex-direction: row; gap: 8px; padding: 7px 9px; }
  .fam-med-main { flex: 1 1 auto; }
  .fam-med-times { flex: 0 1 auto; justify-content: flex-end; }
  .fam-med-time { min-height: 26px; padding: 2px 6px; font-size: 11px; }
  .original-viewer-head { align-items: stretch; flex-direction: column; gap: 12px; }
  .original-external { width: 100%; }
  .original-stage { min-height: 54vh; border-radius: var(--radius-md); }
  .original-stage iframe { height: 68svh; min-height: 480px; }
  .original-pager .btn { min-width: 44px; min-height: 44px; }
  .qcard-open { min-height: 44px; }
  .upload-page .drop-area { min-height: 120px; }
}
@media (max-width: 380px) {
  .btn-add { padding: 0 10px 0 8px; gap: 4px; }
}
.pin-hint { display: block; }
.pin-hint .icon { display: inline-block; vertical-align: -3px; margin: 0 1px; }
.choice .inline-tool { margin-top: 0; }
.ask-line .input { height: 44px; }
@media (max-width: 640px) { .ask-line .input { flex: none; } }
@media (max-width: 640px), (pointer: coarse) {
  .imp-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; }
}
@media (max-width: 640px) {
  .dash-links { display: flex; gap: 8px; }
  .dash-links .btn { padding: 0 6px; gap: 5px; min-width: 0; }
}
@media (max-width: 380px) { .dash-links .btn { font-size: 12.5px; } }
@media (max-width: 640px) {
  .dash-links .btn { min-height: 44px; white-space: nowrap; line-height: 1.25; text-align: center; }
  .tile-meta { color: var(--text-secondary); }
}

/* Keep all navigation controls reachable on narrow phone screens. */
@media (max-width: 380px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar-spacer { display: none; }
  .topbar-actions { flex-basis: 100%; justify-content: flex-end; }
}

/* ── Upload batch ── */
.batch-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.stat-copy .stat-num { color: var(--text-secondary); }
.batch-actions { margin-top: 16px; }
.batch-list { margin-top: 16px; padding: 0; }
.pending-icon.tone-success { color: var(--success); }
.pending-icon.tone-warning { color: var(--warning); }
.pending-icon.tone-danger { color: var(--danger); }
.batch-row.is-copy .row-title, .batch-row.is-known .row-title, .batch-row.is-gone .row-title { color: var(--text-secondary); }
.split-choice { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.split-choice[hidden] { display: none; }
.split-choice legend { margin-bottom: 6px; }
@media (max-width: 640px) {
  .batch-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Theme panels: whole topic on one chart, relative to each norm ── */
:root { --tc-1: #D11B7E; --tc-2: #A78BFA; --tc-3: #4ADE80; --tc-4: #FBBF24; --tc-5: #60A5FA; --tc-6: #FF6B9D; --tc-7: #94A3B8; --tc-8: #F87171; }
html[data-theme="light"] { --tc-1: #B8156B; --tc-2: #6D28D9; --tc-3: #116B33; --tc-4: #8A4B04; --tc-5: #1D4ED8; --tc-6: #BE185D; --tc-7: #475569; --tc-8: #B42318; }
.themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.theme-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; min-width: 0; }
.theme-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.theme-title { font-size: 17px; line-height: 24px; font-weight: 600; letter-spacing: -0.02em; }
.theme-verdict { margin: 0; padding: 9px 11px; border-left: 2px solid var(--success); color: var(--text-secondary); font-size: 13px; line-height: 20px; }
.theme-verdict.is-out { border-left-color: var(--danger); }
/* 0.44.2: рядок = назва · власний спарклайн зі смугою норми · останнє значення й норма. */
.theme-rows { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border-subtle); }
.theme-rows li { display: grid; grid-template-columns: minmax(0, 1fr) 132px minmax(88px, auto); align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border-subtle); font-size: 13px; line-height: 18px; }
.theme-rows li:last-child { border-bottom: 0; }
.theme-name { min-width: 0; overflow-wrap: anywhere; }
.theme-name small { display: block; margin-top: 2px; color: var(--text-tertiary); font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; }
.theme-spark { display: block; width: 132px; height: 36px; overflow: visible; }
.theme-spark .band { fill: var(--band); stroke: var(--band-edge); stroke-width: .75; stroke-dasharray: 2 2; }
.theme-spark .line { fill: none; stroke: var(--text-tertiary); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.theme-spark .dot { fill: var(--text-tertiary); }
.theme-spark .dot.is-last { fill: var(--success); stroke: var(--bg-surface); stroke-width: 1.5; }
.theme-spark .dot.is-alert { fill: var(--danger); }
.theme-value { display: grid; justify-items: end; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.theme-value small { font-size: 11px; color: var(--text-secondary); }
.theme-value em { font-style: normal; font-size: 10px; color: var(--text-tertiary); letter-spacing: .02em; }
.theme-value.is-out { color: var(--danger); }
@media (max-width: 520px) { .theme-rows li { grid-template-columns: minmax(0, 1fr) 84px minmax(64px, auto); gap: 10px; } .theme-spark { width: 84px; height: 30px; } }
@media (max-width: 900px) { .themes { grid-template-columns: minmax(0, 1fr); } }

/* ── Doctor sheet ── */
.doctor-controls { display: flex; flex-direction: column; gap: 16px; padding: 16px; margin-top: 16px; }
.doctor-form, .doctor-questions-form { display: flex; flex-direction: column; gap: 8px; }
.doctor-themes { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0 0 6px; }
.doctor-row { display: flex; gap: 8px; flex-wrap: wrap; }
.doctor-row .input { max-width: 220px; }
.doctor-questions-form textarea { min-height: 96px; resize: vertical; }
.doctor-sheet { display: flex; flex-direction: column; gap: 18px; margin-top: 22px; padding: 22px; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-surface); }
.doctor-sheet-head { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border-default); }
.doctor-name { font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -0.02em; }
.doctor-block-title { margin-bottom: 8px; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); }
.doctor-facts { display: grid; gap: 6px; margin: 0; }
.doctor-facts > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; }
.doctor-facts dt { color: var(--text-secondary); }
.doctor-facts dd { margin: 0; overflow-wrap: anywhere; }
.doctor-facts .is-alert dd { color: var(--danger); font-weight: 600; }
.doctor-list { display: flex; flex-direction: column; gap: 4px; margin: 0; padding-left: 18px; }
.doctor-list .meta { margin-left: 4px; }
.doctor-out strong { color: var(--danger); }
.doctor-sub { margin: 10px 0 4px; color: var(--text-secondary); font-size: 13px; }
.doctor-empty { margin: 0; color: var(--text-tertiary); }
@media (max-width: 640px) {
  .doctor-sheet { padding: 16px; }
  .doctor-facts > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
@media print {
  .nav, .btn-explain, .explain-backdrop { display: none !important; }
  .doctor-sheet { margin: 0; padding: 0; border: 0; background: transparent; }
  .doctor-block, .theme-card { break-inside: avoid; }
  .themes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  main, .page, .content { padding: 0 !important; }
}

/* ── Emergency card ── */
.ice-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.ice-edit { display: flex; flex-direction: column; gap: 20px; padding: 16px; }
.ice-access { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }
.ice-link { margin: 0; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.ice-link a { color: var(--accent-ink, var(--accent)); }
.ice-preview { display: flex; flex-direction: column; gap: 8px; }
.ice-sheet { display: flex; flex-direction: column; gap: 12px; padding: 18px; border-left: 3px solid var(--danger); }
.ice-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ice-name { font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.02em; }
.ice-age { font-family: var(--mono); color: var(--text-secondary); }
.ice-facts { display: grid; gap: 8px; margin: 0; }
.ice-facts > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; }
.ice-facts dt { color: var(--text-secondary); font-size: 13px; }
.ice-facts dd { margin: 0; overflow-wrap: anywhere; }
.ice-facts .is-alert dd { color: var(--danger); font-weight: 600; }
/* Алергени / реакції й препарати окремими рядками (0.44.1). */
.ice-allergens, .ice-reactions { display: block; }
.ice-facts .is-alert .ice-reactions { margin-top: 2px; color: var(--text-primary); font-weight: 400; }
.ice-reactions::before { content: "Реакція: "; color: var(--text-secondary); }
.ice-meds { list-style: none; margin: 0; padding: 0; display: grid; }
.ice-meds li { display: grid; gap: 1px; padding: 8px 0; border-top: 1px solid var(--border-subtle); }
.ice-meds li:first-child { padding-top: 0; border-top: 0; }
.ice-meds b { font-weight: 600; color: var(--text-primary); }
.ice-meds span { color: var(--text-secondary); font-size: .93em; }
.ice-big { font-size: 18px; font-weight: 600; }
.ice-facts a { text-decoration: underline; text-underline-offset: 2px; }
.ice-qr { display: flex; align-items: center; gap: 12px; padding-top: 10px; border-top: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: 12px; }
.ice-qr svg { width: 96px; height: 96px; flex: none; border-radius: var(--radius-sm); }
.ice-public { max-width: 560px; margin: 0 auto; padding: 24px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.ice-flag { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--danger); font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.ice-foot { margin: 0; color: var(--text-tertiary); font-size: 12px; }
.ice-public .ice-name { font-size: 26px; line-height: 32px; }
.ice-public .ice-facts dd { font-size: 16px; line-height: 24px; }
@media (max-width: 820px) { .ice-layout { grid-template-columns: minmax(0, 1fr); } .ice-facts > div { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
@media print {
  body.med-ice-page .no-print, body.med-ice-page .print-foot { display: none !important; }
  body.med-ice-page .ice-layout { display: block; margin: 0; }
  body.med-ice-page .ice-print { width: 85.6mm; min-height: 54mm; padding: 4mm; gap: 2mm; font-size: 7.5pt; line-height: 1.25; border: 1px solid #cfcac0; border-left: 3px solid #B42318; border-radius: 3mm; break-inside: avoid; }
  body.med-ice-page .ice-print .ice-name { font-size: 11pt; line-height: 1.2; }
  body.med-ice-page .ice-print .ice-facts { gap: 1mm; }
  body.med-ice-page .ice-print .ice-facts > div { grid-template-columns: 20mm minmax(0, 1fr); gap: 2mm; }
  body.med-ice-page .ice-print .ice-facts dt { font-size: 6.5pt; }
  body.med-ice-page .ice-print .ice-meds li { padding: .6mm 0; }
  body.med-ice-page .ice-print .ice-big { font-size: 9pt; }
  body.med-ice-page .ice-print .ice-qr { padding-top: 1.5mm; font-size: 6.5pt; }
  body.med-ice-page .ice-print .ice-qr svg { width: 18mm; height: 18mm; }
}

/* ── Prevention ── */
.prevention-list { margin-top: 16px; padding: 0; }
.prevention-row { display: flex; align-items: flex-start; gap: 12px; padding: 13px 18px; border-top: 1px solid var(--border-subtle); }
.prevention-row:first-child { border-top: 0; }
.prevention-row .pending-icon { margin-top: 2px; }
.prevention-row .row-sub a { text-decoration: underline; text-underline-offset: 2px; }
.prevention-note { margin-top: 2px; color: var(--text-tertiary); font-size: 12px; line-height: 18px; }
.prevention-actions { position: relative; flex: none; margin-top: 0; }
.prevention-actions .confirm { position: absolute; top: calc(100% + 6px); right: 0; z-index: var(--z-dropdown, 100); width: 280px; margin: 0;
  background: var(--bg-overlay); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.prevention-done { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.prevention-done .input { max-width: 170px; }
.prevention-skipped { margin-top: 14px; }
.prevention-disclaimer { margin-top: 16px; }
.stat-warning .stat-num { color: var(--warning); }
.stat-info .stat-num { color: var(--info); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Interactions ── */
.interactions-meds { display: flex; flex-direction: column; gap: 12px; padding: 16px; margin-top: 16px; }
.interactions-pairs { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.interaction { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-left: 3px solid var(--border-strong); }
.interaction.is-danger { border-left-color: var(--danger); }
.interaction.is-warning { border-left-color: var(--warning); }
.interaction.is-info { border-left-color: var(--info); }
.interaction-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.interaction-title { font-size: 16px; line-height: 22px; font-weight: 600; }
.interaction p { margin: 0; }
.interaction-advice { display: flex; gap: 8px; color: var(--text-secondary); }
.interaction-advice .icon { margin-top: 3px; }
.interactions-detail { margin-top: 14px; }
.interactions-detail .card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

/* ── Person basics on create ── */
.basics-fields { border: 0; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 6px; }
.basics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.basics-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.basics-hint-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding: 12px 14px; border-left: 2px solid var(--warning); }
@media (max-width: 480px) { .basics-grid { grid-template-columns: minmax(0, 1fr); } }

/* ── Inbox ── */
.inbox-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; margin-top: 16px; }
.inbox-address { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--mono); font-size: 15px; overflow-wrap: anywhere; }
.inbox-allowed p { margin: 4px 0 0; }
.badge-neutral { background: var(--bg-elevated); color: var(--text-secondary); }

/* ── Pending decisions badge ── */
.nav-add { position: relative; }
.nav-badge { position: absolute; top: 4px; right: 50%; transform: translateX(18px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: var(--radius-full);
  background: var(--danger); color: #fff; font-family: var(--mono); font-size: 10px; font-weight: 600; line-height: 17px; text-align: center; }
.add-decide .action-icon { color: var(--warning); }
@media (min-width: 821px) { .nav-badge { position: static; transform: none; margin-left: 4px; } }

/* dev.med.grandma.click: a copy of the data, never the real card */
.dev-env-badge{position:fixed;top:0;left:50%;transform:translateX(-50%);z-index:9999;background:#E8A317;color:#1a1a1a;font:600 11px/1 system-ui,sans-serif;padding:4px 10px;border-radius:0 0 8px 8px;pointer-events:none}

/* Interface size for weaker eyes (settings «Розмір», per account): the whole page scales, text and buttons alike */
html[data-scale="115"] body { zoom: 1.15; }
html[data-scale="130"] body { zoom: 1.3; }
html[data-scale="150"] body { zoom: 1.5; }

/* Breadcrumbs (templates/_crumbs.html) */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0 0 18px; font-size: 14px; line-height: 1.4; min-width: 0; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); text-decoration: none; }
.crumbs a:hover { color: var(--text-primary); text-decoration: underline; text-underline-offset: 3px; }
.crumbs .icon { width: 16px; height: 16px; }
.crumbs-sep { color: var(--text-tertiary); }
.crumbs-current { color: var(--text-primary); font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
