/* Medbook design system (docs/design-system.md, Revision 2 — aligned to the logo).
   One stylesheet for the web cabinet, the Telegram Mini App and the public pages.
   System fonts, no external resources. */
:root {
  /* Colours measured from requirements/branding/Medbook_Logo_Transparent.png */
  --ink: #00244E;            /* logo navy: text, primary fill, selected nav */
  --ink-pressed: #003060;    /* logo navy shade: hover/pressed primary */
  --brand: #00968A;          /* logo teal: icon tiles, indicators, focus ring */
  --brand-bright: #00A29C;   /* small graphics only */
  --teal: #007A70;           /* teal text on white (AA 5.0:1) */
  --mint: #E8F7F3;           /* mint wash: icon tiles, selected chips, done rows */
  --mint-line: #AEEADE;      /* logo back page: borders of selected / done */
  --paper: #F5F8FA;
  --sheet: #FFFFFF;
  --line: #E2E8EE;
  --line-strong: #CCD6E0;
  --field-line: #7D8FA1;     /* text-field border: WCAG 1.4.11 non-text contrast >= 3:1 on sheet and paper */
  --muted: #5A6B7B;
  --alert: #B3261E;
  --alert-tint: #FBEDEC;
  --on-ink: #FFFFFF;
  --snack-action: #AEEADE;
  --menu-shadow: 0 8px 24px rgba(0, 36, 78, .14), 0 1px 3px rgba(0, 36, 78, .08);
  --fab-shadow: 0 6px 16px rgba(0, 36, 78, .22);
  --r-sheet: 16px;
  --r-ctl: 12px;
  --r-chip: 10px;
  --pad: 20px;
  --nav-h: 72px;
  /* Motion tokens (docs/auth-guest-google.md, "Premium, fluid UI") */
  --dur-fast: 150ms;
  --dur-base: 240ms;
  --dur-slow: 360ms;
  --ease-std: cubic-bezier(0.2, 0, 0, 1);
  --ease-emph: cubic-bezier(0.05, 0.7, 0.1, 1);
  --ease-spring: cubic-bezier(0.3, 1.15, 0.45, 1);
  --scrim: rgba(0, 20, 44, .5);
  --shimmer: rgba(255, 255, 255, .65);
  --press-tint: color-mix(in srgb, var(--sheet) 92%, var(--ink));
  color-scheme: light dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 26px;
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    /* The dark theme is the logo navy, not a neutral grey. */
    --ink: #E8EEF3;
    --ink-pressed: #FFFFFF;
    --brand: #4FD1C5;
    --brand-bright: #4FD1C5;
    --teal: #4FD1C5;
    --mint: #0F3342;
    --mint-line: #1F5C64;
    --paper: #071A30;
    --sheet: #0D2440;
    --line: #1C3657;
    --line-strong: #2B4B72;
    --field-line: #5A7A9F;
    --muted: #9DB2C8;
    --alert: #FFB4AB;
    --alert-tint: #3A1F2B;
    --on-ink: #00244E;
    --snack-action: #00736A;  /* on the light snackbar (ink) of the dark theme: 4.9:1 */
    --menu-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    --fab-shadow: 0 6px 16px rgba(0, 0, 0, .4);
    --scrim: rgba(0, 8, 20, .62);
    --shimmer: rgba(255, 255, 255, .07);
  }
}
/* A gentle spring (about 2 % overshoot) where linear() easing exists. */
@supports (transition-timing-function: linear(0, 1)) {
  :root { --ease-spring: linear(0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%, 0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%, 1.001 85.9%, 1); }
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--paper); color: var(--ink); min-height: 100vh; overflow-wrap: anywhere; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
/* Headings echo the heavy geometric wordmark: Bold, -0.5 % tracking. */
h1 { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.005em; }
h2 { font-size: 18px; line-height: 24px; font-weight: 700; letter-spacing: -0.005em; }
h3 { font-size: 18px; line-height: 26px; font-weight: 500; }
p { font-size: 18px; line-height: 26px; }
a { color: var(--teal); text-underline-offset: 3px; }
.tnum, time { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 16px; line-height: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- Buttons: every button carries a leading icon (or a trailing chevron) ---------- */
button { font: inherit; color: inherit; }
.btn, .btn-secondary, .btn-text, .btn-danger, .pub-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 12px 20px; border-radius: var(--r-ctl);
  font-size: 18px; line-height: 24px; font-weight: 600; cursor: pointer;
  text-decoration: none; border: 1.5px solid transparent; background: none;
  transition: transform var(--dur-fast) var(--ease-std), background-color var(--dur-fast) var(--ease-std), color var(--dur-fast) var(--ease-std), border-color var(--dur-fast) var(--ease-std);
}
.btn > .ic, .btn-secondary > .ic, .btn-text > .ic, .btn-danger > .ic, .pub-action > .ic,
.btn > .ic svg, .btn-secondary > .ic svg, .btn-text > .ic svg, .btn-danger > .ic svg, .pub-action > .ic svg { width: 20px; height: 20px; }
.btn > .ic.trail { margin-left: -2px; }
.btn { background: var(--ink); color: var(--on-ink); min-height: 56px; width: 100%; }
.btn:hover, .btn:active { background: var(--ink-pressed); }
.btn-secondary { background: var(--sheet); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary > .ic { color: var(--brand); }
.btn-secondary:hover { border-color: var(--brand); }
.btn-text { color: var(--teal); padding-left: 10px; padding-right: 12px; }
.btn-text:hover { background: var(--mint); }
.btn-danger { color: var(--alert); padding-left: 10px; padding-right: 12px; }
.btn-danger:hover { background: var(--alert-tint); }
button:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn-row > .btn-secondary { flex: 1 1 auto; }
@media (min-width: 640px) { .btn.fit { width: auto; min-width: 220px; } }

/* ---------- Icons ---------- */
.ic { width: 24px; height: 24px; flex: none; display: inline-block; }
.ic svg { width: 24px; height: 24px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Icon tile: the logo's teal cross on a pale page. */
.tile { width: 40px; height: 40px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--mint); color: var(--brand); }
.tile .ic, .tile .ic svg { width: 22px; height: 22px; }

/* ---------- Flags and the language dropdown ---------- */
.lang-flag { width: 20px; height: 14px; flex: none; display: inline-block; border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.lang-flag svg { width: 20px; height: 14px; display: block; }
.lang { position: relative; flex: none; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 10px 0 12px;
  border-radius: 22px; border: 1px solid var(--line-strong); background: var(--sheet); color: var(--ink);
  font-size: 16px; line-height: 22px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: border-color .15s;
}
.lang-btn:hover, .lang-btn[aria-expanded="true"] { border-color: var(--brand); }
.lang-btn:focus-visible { border-radius: 22px; }
.lang-btn .lang-chev, .lang-btn .lang-chev svg { width: 18px; height: 18px; }
.lang-btn .lang-chev { color: var(--muted); transition: transform .15s; }
.lang-btn[aria-expanded="true"] .lang-chev { transform: rotate(180deg); }
.lang-code { display: none; }
@media (max-width: 400px) { .lang-name { display: none; } .lang-code { display: inline; } }
.lang-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; min-width: 208px;
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-ctl);
  box-shadow: var(--menu-shadow); padding: 6px; display: grid; gap: 2px;
}
.lang-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 12px;
  border: 0; border-radius: 8px; background: none; color: var(--ink); text-align: left;
  font-size: 18px; line-height: 24px; font-weight: 500; cursor: pointer; text-decoration: none;
}
.lang-item:hover, .lang-item:focus-visible { background: var(--mint); }
.lang-item:focus-visible { outline-offset: -2px; border-radius: 8px; }
.lang-item-name { flex: 1 1 auto; }
.lang-item .lang-tick { color: var(--brand); visibility: hidden; }
.lang-item[aria-checked="true"] { font-weight: 600; }
.lang-item[aria-checked="true"] .lang-tick { visibility: visible; }
.section > .lang { margin: 0 4px; }
.section > .lang .lang-menu { right: auto; left: 0; }

/* ---------- Sheets and rows ---------- */
.section { margin-top: 24px; }
.section > h2 { margin: 0 4px 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 8px; }
.sheet { background: var(--sheet); border-radius: var(--r-sheet); overflow: hidden; border: 1px solid var(--line); }
.sheet.padded { padding: 20px; display: grid; gap: 16px; }
.row {
  display: flex; align-items: center; gap: 16px; width: 100%;
  min-height: 56px; padding: 14px 20px; background: none; border: 0; text-align: left;
  color: var(--ink); text-decoration: none; position: relative;
  transition: background-color .2s;
}
.row + .row::before, .row + .row-group::before, .row-group + .row::before {
  content: ""; position: absolute; top: 0; left: 20px; right: 0; border-top: 1px solid var(--line);
}
.row.with-icon + .row::before, .row + .row.with-icon::before { left: 76px; }
button.row, a.row { cursor: pointer; }
button.row:hover, a.row:hover { background: color-mix(in srgb, var(--sheet) 94%, var(--ink)); }
.row > .ic { color: var(--muted); }
.row-body { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.row-title { font-size: 18px; line-height: 26px; font-weight: 500; }
.row-sub { font-size: 16px; line-height: 22px; color: var(--muted); }
.row-trail { flex: none; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 16px; text-align: right; }
.row-trail.strong { color: var(--ink); font-weight: 700; font-size: 18px; }
.row.done { background: var(--mint); }
.row.done > .ic, .state-ok { color: var(--teal); }
.row.done .tile, .row-wrap.done .tile { background: var(--sheet); box-shadow: inset 0 0 0 1px var(--mint-line); }
.state-missed { color: var(--alert); }
.row .chev { color: var(--muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 20px 16px 20px; margin-top: -6px; }
.row-wrap { position: relative; }
.row-wrap + .row-wrap::before { content: ""; position: absolute; top: 0; left: 20px; right: 0; border-top: 1px solid var(--line); }
.row-wrap:has(> .row.with-icon) + .row-wrap::before { left: 76px; }
.row-wrap > .row.with-icon + .row-actions { padding-left: 76px; }
.row-wrap > .row::before { display: none; }
.row-wrap.done { background: var(--mint); transition: background-color .2s; }
.row-wrap.done .row > .ic { color: var(--teal); }
.row.flag > .ic { color: var(--alert); }
.row.flag .tile { background: var(--alert-tint); color: var(--alert); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 8px; }
.field > span, .field-label { font-size: 16px; line-height: 22px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--sheet);
  border: 1px solid var(--field-line); border-radius: var(--r-ctl);
  min-height: 56px; padding: 14px 16px; width: 100%; max-width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { min-height: 120px; resize: vertical; line-height: 26px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.check input { width: 24px; height: 24px; min-height: 0; padding: 0; accent-color: var(--brand); flex: none; }
.field-error { color: var(--alert); font-size: 16px; line-height: 22px; }
.form { display: grid; gap: 20px; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 44px; padding: 8px 14px; border-radius: 22px;
  border: 1px solid var(--line-strong); background: var(--sheet); color: var(--ink);
  font-size: 16px; line-height: 22px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--mint); border-color: var(--mint-line); font-weight: 600; }
.chip[aria-pressed="true"] .ic { color: var(--brand); }
.chip .ic, .chip .ic svg { width: 18px; height: 18px; }

/* ---------- Notices ---------- */
.notice { background: var(--sheet); border-radius: var(--r-ctl); padding: 16px 20px; border: 1px solid var(--line); display: grid; gap: 12px; }
.notice.alert { background: var(--alert-tint); border-color: transparent; color: var(--ink); }
.notice.alert strong { color: var(--alert); }
.notice.dev { border-style: dashed; border-color: var(--mint-line); background: var(--mint); }
.empty { padding: 24px 20px; display: grid; gap: 16px; }
.skeleton { padding: 16px 20px; display: grid; gap: 10px; }
.skeleton i { display: block; height: 14px; border-radius: 6px; background: var(--line); position: relative; overflow: hidden; }
.skeleton i::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--shimmer), transparent); animation: shimmer 1.2s var(--ease-std) infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton i:nth-child(2) { width: 60%; }

/* ---------- Cabinet shell ---------- */
.cabinet main#root { min-height: 100vh; }
.app { min-height: 100vh; padding-bottom: calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 640px; margin: 0 auto; padding: 10px var(--pad); display: grid; gap: 10px; }
.topbar-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.logo { height: 30px; width: auto; display: block; }
.view { max-width: 640px; margin: 0 auto; padding: 24px var(--pad) 0; }
.view > h1 { margin: 0 4px; }
.view > .lead { margin: 8px 4px 0; }
.view > .sheet, .view > .lead + .notice { margin-top: 24px; }
.view > .back { margin: -8px 0 8px -4px; padding-left: 4px; }
.view > .section:first-child, .view > .back + h1 { margin-top: 0; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--sheet); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: var(--nav-h); padding: 8px 2px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 13px; line-height: 16px; font-weight: 500; position: relative;
}
.tab span.lbl { font-size: 13px; line-height: 15px; max-width: 100%; text-align: center; overflow-wrap: normal; word-break: normal; }
@media (min-width: 400px) { .tab span.lbl { font-size: 16px; line-height: 18px; } }
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tab[aria-current="page"] .ic { color: var(--brand); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }
.fab {
  position: fixed; right: 20px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 6;
  display: inline-flex; align-items: center; gap: 8px; min-height: 56px; padding: 14px 22px 14px 18px;
  border-radius: var(--r-ctl); border: 0; background: var(--ink); color: var(--on-ink);
  font-size: 18px; font-weight: 600; cursor: pointer; box-shadow: var(--fab-shadow);
}
.fab:hover { background: var(--ink-pressed); }
.fab:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: var(--r-ctl); }
@media (min-width: 960px) {
  .app { padding-bottom: 48px; padding-left: 240px; }
  .tabs {
    top: 0; right: auto; width: 240px; bottom: 0; display: flex; flex-direction: column; gap: 4px;
    border-top: 0; border-right: 1px solid var(--line); padding: 84px 12px 24px;
  }
  .tab { flex-direction: row; justify-content: flex-start; gap: 14px; min-height: 52px; padding: 12px 16px; border-radius: var(--r-ctl); font-size: 18px; }
  .tab span.lbl { font-size: 18px; }
  .tab[aria-current="page"] { background: var(--mint); }
  .tab[aria-current="page"]::before { top: 14px; bottom: 14px; left: 0; right: auto; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .fab { bottom: 32px; right: 32px; }
  .topbar { margin-left: -240px; padding-left: 240px; }
}

/* Home hero: the one memorable element */
.hero { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-sheet); padding: 24px 20px 20px; display: grid; gap: 16px; }
.hero-line { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.hero-time { font-size: 48px; line-height: 52px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.hero-med { display: grid; gap: 2px; min-width: 0; }
.hero.calm .hero-time { font-size: 28px; line-height: 34px; letter-spacing: 0; }

/* Bottom sheet */
.backdrop { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.backdrop::before { content: ""; position: absolute; inset: 0; background: var(--scrim); animation: scrim-in var(--dur-base) var(--ease-std) both; }
.modal { position: relative; background: var(--sheet); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; overscroll-behavior: contain; border-radius: var(--r-sheet) var(--r-sheet) 0 0; border-top: 1px solid var(--line); padding: 8px 0 calc(20px + env(safe-area-inset-bottom)); animation: sheet-in var(--dur-slow) var(--ease-spring) both; will-change: transform; }
.modal-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 2px auto 2px; }
.backdrop.closing { pointer-events: none; }
.backdrop.closing::before { animation: scrim-out var(--dur-base) var(--ease-std) both; }
.backdrop.closing .modal { animation: sheet-out var(--dur-base) var(--ease-std) both; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px 8px 20px; }
.modal-body { padding: 4px 20px 0; display: grid; gap: 16px; }
.modal .sheet { border: 1px solid var(--line); }
.icon-btn { width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; border-radius: var(--r-ctl); cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--mint); color: var(--brand); }
@media (min-width: 640px) {
  .backdrop { align-items: center; }
  .modal { border-radius: var(--r-sheet); border: 1px solid var(--line); animation-name: dialog-in; box-shadow: var(--menu-shadow); }
  .backdrop.closing .modal { animation-name: dialog-out; }
  .modal-grip { display: none; }
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes scrim-in { from { opacity: 0; } }
@keyframes scrim-out { to { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes dialog-in { from { transform: translateY(16px) scale(.97); opacity: 0; } }
@keyframes dialog-out { to { transform: translateY(8px) scale(.98); opacity: 0; } }

/* Snackbar */
.snackbar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--nav-h) + 88px + env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 560px;
  background: var(--ink); color: var(--on-ink); border-radius: var(--r-ctl);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 8px 6px 20px; min-height: 56px; font-size: 16px; line-height: 22px;
  box-shadow: var(--fab-shadow);
  animation: snack-in var(--dur-base) var(--ease-emph) both;
}
.snackbar.leaving { animation: snack-out var(--dur-fast) var(--ease-std) both; pointer-events: none; }
@keyframes snack-in { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes snack-out { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, 8px); } }
.snackbar button { background: none; border: 0; color: var(--snack-action); font-weight: 600; font-size: 18px; min-height: 48px; padding: 8px 12px; cursor: pointer; border-radius: 8px; }
.public .snackbar { bottom: calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 960px) { .cabinet .snackbar { bottom: 104px; margin-left: 120px; } }

/* Auth screens */
.auth { max-width: 480px; margin: 0 auto; padding: 24px var(--pad) 48px; display: grid; gap: 24px; }
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; }
.auth h1 { margin-top: 16px; }
.consent-text { display: grid; gap: 12px; }

/* Viewer images */
.preview { display: grid; gap: 12px; }
.preview img { width: 100%; border-radius: var(--r-ctl); border: 1px solid var(--line); background: #fff; }
/* Reserved page-shaped slot: the image fades in without moving anything below it. */
.preview-slot { position: relative; aspect-ratio: 210 / 297; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--line); overflow: hidden; }
.preview-slot::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--shimmer), transparent); animation: shimmer 1.2s var(--ease-std) infinite; }
.preview-slot.loaded::after { display: none; }
.preview-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border: 0; border-radius: 0; background: #fff; opacity: 0; transition: opacity var(--dur-base) var(--ease-std); }
.preview-slot.loaded img { opacity: 1; }

/* Status line */
.status { min-height: 0; color: var(--alert); font-size: 16px; line-height: 22px; margin: 0 4px; }
.status:empty { display: none; }
.status.ok { color: var(--teal); }

/* Logo on dark backgrounds: the navy wordmark sits on a white plate (never recoloured). */
@media (prefers-color-scheme: dark) {
  .logo { background: #FFFFFF; border-radius: 10px; padding: 6px; height: 26px; box-sizing: content-box; }
}

/* ---------- Public pages (Э18–Э21) ---------- */
.public header.pub-header { border-bottom: 1px solid var(--line); background: var(--paper); }
.pub-in { max-width: 640px; margin: 0 auto; padding: 12px var(--pad); display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.public.wide .pub-in, .public.wide main.pub-main { max-width: 960px; }
main.pub-main { max-width: 640px; margin: 0 auto; padding: 24px var(--pad) 48px; display: grid; gap: 24px; }
.pub-title { display: grid; gap: 8px; }
.pub-footer { max-width: 640px; margin: 0 auto; padding: 0 var(--pad) 40px; color: var(--muted); font-size: 16px; line-height: 22px; }
.lang-link { font-size: 16px; font-weight: 600; text-decoration: none; min-height: 48px; display: inline-flex; align-items: center; gap: 8px; padding: 0 8px; }
.pub-section { display: grid; gap: 8px; }
.pub-section > h2 { margin: 0 4px; }
.pub-grid { display: grid; gap: 24px; }
.pub-col { display: grid; gap: 24px; align-content: start; }
@media (min-width: 960px) { .pub-grid.two { grid-template-columns: 1fr 1fr; align-items: start; } }
.facts-key { background: var(--alert-tint); border-radius: var(--r-sheet); padding: 20px; display: grid; gap: 8px; }
.facts-key h2 { color: var(--alert); display: flex; align-items: center; gap: 10px; }
.facts-key .big { font-size: 22px; line-height: 30px; font-weight: 700; letter-spacing: -0.005em; }
.person { display: grid; gap: 4px; }
.pub-action { background: var(--ink); color: var(--on-ink); min-height: 48px; flex: none; }
.pub-action:hover { background: var(--ink-pressed); }
.pub-done { color: var(--teal); font-size: 16px; line-height: 22px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; min-height: 48px; }
.group-title { margin: 8px 4px 0; color: var(--muted); font-size: 16px; font-weight: 600; }
.state { min-height: 60vh; display: grid; align-content: center; justify-items: start; gap: 12px; }
.em-name { font-size: 40px; line-height: 46px; font-weight: 700; letter-spacing: -0.01em; }
@media (min-width: 640px) { .em-name { font-size: 52px; line-height: 58px; } }
.em-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.em-fact { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 16px; display: grid; gap: 4px; }
.em-fact b { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.005em; }
.qr { width: 200px; height: 200px; background: #fff; border-radius: var(--r-ctl); padding: 8px; }
.text-block { display: grid; gap: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .skeleton i::after, .preview-slot::after { display: none; }
}
@media print {
  .tabs, .fab, .snackbar, .lang-link, .lang, .pub-action { display: none !important; }
  body { background: #fff; color: #000; }
}
.facts-key.calm { background: var(--sheet); border: 1px solid var(--line); }
.facts-key.calm h2 { color: var(--ink); }
.facts-key.calm h2 .ic { color: var(--muted); }
.pub-title .btn-row > .btn-secondary { flex: 0 0 auto; }
.public.wide .pub-footer { max-width: 960px; }

/* ---------- AI auto-fill (docs/ai-design.md): sparkle chip, reading state, results ---------- */
.ai-chip {
  display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; margin-left: 8px;
  min-height: 22px; padding: 0 7px 0 5px; border-radius: 6px;
  background: var(--mint); color: var(--teal); box-shadow: inset 0 0 0 1px var(--mint-line);
  font-size: 13px; line-height: 18px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.ai-chip .ic, .ai-chip .ic svg { width: 14px; height: 14px; }
.field > span .ai-chip { margin-left: 8px; }
.ai-reading { display: grid; gap: 8px; padding: 14px 16px; border-radius: var(--r-ctl); background: var(--mint); border: 1px solid var(--mint-line); }
.ai-reading .skeleton { padding: 4px 0 0; }
.ai-reading .skeleton i { background: var(--mint-line); }
@media (prefers-reduced-motion: no-preference) {
  .ai-reading .skeleton i { animation: ai-pulse 1.4s ease-in-out infinite; }
}
@keyframes ai-pulse { 50% { opacity: .45; } }
.ai-reading-head, .ai-head { display: flex; align-items: center; gap: 14px; }
.ai-head { margin: 32px 4px 0; }
.ai-head h2 { margin: 0; }
.ai-quote { display: block; font-style: italic; color: var(--muted); font-size: 16px; line-height: 22px; quotes: "«" "»"; }
.ai-quote::before { content: open-quote; }
.ai-quote::after { content: close-quote; }
.ai-note { gap: 8px; }
.ai-note p { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-note .ai-chip { margin-left: 0; }
.row-trail.flag-out { color: var(--alert); font-weight: 600; }
.row-trail.flag-ok { color: var(--teal); font-weight: 600; }
.ai-low > summary {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 4px; cursor: pointer;
  list-style: none; font-size: 18px; line-height: 24px; font-weight: 700; color: var(--ink);
}
.ai-low > summary::-webkit-details-marker { display: none; }
.ai-low > summary > .ic:first-child { color: var(--muted); }
.ai-low-chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
.ai-low[open] .ai-low-chev { transform: rotate(180deg); }
.ai-low-sub { margin: 0 4px 8px; }

/* =============================================================================================
   Premium, fluid UI (docs/auth-guest-google.md). Transforms and opacity only; every motion
   answers an action; all of it is off under prefers-reduced-motion (see the block below).
   ============================================================================================= */

/* ---------- Press feedback: scale .97 + tint on every pressable ---------- */
.chip, .tab, .fab, .icon-btn, .lang-btn, .lang-item, .snackbar button, .btn-ghost, button.row, a.row {
  transition: transform var(--dur-fast) var(--ease-std), background-color var(--dur-fast) var(--ease-std), color var(--dur-fast) var(--ease-std), border-color var(--dur-fast) var(--ease-std);
}
.btn:active:not(:disabled), .btn-secondary:active:not(:disabled), .btn-text:active:not(:disabled),
.btn-danger:active:not(:disabled), .btn-ghost:active:not(:disabled), .pub-action:active,
.chip:active:not(:disabled), .tab:active:not(:disabled), .fab:active:not(:disabled),
.icon-btn:active:not(:disabled), .lang-btn:active, .lang-item:active, .snackbar button:active,
button.row:active:not(:disabled), a.row:active { transform: scale(.97); }
button.row:active:not(:disabled), a.row:active { background: var(--press-tint); }
.btn-secondary:active:not(:disabled), .chip:active:not(:disabled) { background: var(--mint); }
.btn-text:active:not(:disabled), .icon-btn:active:not(:disabled) { background: var(--mint); }
.btn-danger:active:not(:disabled) { background: var(--alert-tint); }
/* A busy control keeps its shape (no flash of the disabled style for quick actions). */
button:disabled { transition: opacity var(--dur-base) var(--ease-std) .12s; }

/* ---------- Route changes: View Transitions (slide for push/pop, cross-fade for tabs) ---------- */
.topbar { view-transition-name: topbar; }
.tabs { view-transition-name: tabs; }
.fab { view-transition-name: fab; }
.view { view-transition-name: page; }
::view-transition-group(*) { animation-duration: var(--dur-base); animation-timing-function: var(--ease-std); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--dur-base); animation-timing-function: var(--ease-std); }
::view-transition-group(page) { animation: none; }
::view-transition-old(page), ::view-transition-new(page) { height: auto; mix-blend-mode: normal; }
html[data-nav="push"]::view-transition-old(page) { animation: vt-out-start var(--dur-base) var(--ease-std) both; }
html[data-nav="push"]::view-transition-new(page) { animation: vt-in-end var(--dur-base) var(--ease-emph) both; }
html[data-nav="pop"]::view-transition-old(page) { animation: vt-out-end var(--dur-base) var(--ease-std) both; }
html[data-nav="pop"]::view-transition-new(page) { animation: vt-in-start var(--dur-base) var(--ease-emph) both; }
html[data-nav="tab"]::view-transition-old(page) { animation: vt-fade-out var(--dur-fast) var(--ease-std) both; }
html[data-nav="tab"]::view-transition-new(page) { animation: vt-fade-in var(--dur-fast) var(--ease-std) both; }
@keyframes vt-out-start { to { opacity: 0; transform: translateX(-24px); } }
@keyframes vt-in-end { from { opacity: 0; transform: translateX(24px); } }
@keyframes vt-out-end { to { opacity: 0; transform: translateX(24px); } }
@keyframes vt-in-start { from { opacity: 0; transform: translateX(-24px); } }
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }
/* Fallback without the API: the new view plays the same entrance. */
.view.enter-push { animation: vt-in-end var(--dur-base) var(--ease-emph) both; }
.view.enter-pop { animation: vt-in-start var(--dur-base) var(--ease-emph) both; }
.view.enter-tab, .view.content-in { animation: vt-fade-in var(--dur-fast) var(--ease-std) both; }

/* ---------- Lists: enter / leave / glide into the gap ---------- */
.item-enter { animation: item-in var(--dur-base) var(--ease-emph) both; }
.item-leave { animation: item-out var(--dur-base) var(--ease-std) both; pointer-events: none; }
.item-glide { transition: transform var(--dur-base) var(--ease-std) !important; }
@keyframes item-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes item-out { to { opacity: 0; transform: translateX(8px); } }
.row.done, .row-wrap.done { transition: background-color var(--dur-base) var(--ease-std), transform var(--dur-fast) var(--ease-std); }
/* Long lists: skip rendering work for rows far off screen. */
.sheet.long > .row, .sheet.long > .row-wrap { content-visibility: auto; contain-intrinsic-size: auto 76px; }
.sheet.long > .row:focus-visible { outline-offset: -3px; }
.code-box:empty { display: none; }

/* ---------- Home hero: "Qabul qildim" morphs into a check on mint ---------- */
.hero-take { position: relative; overflow: hidden; isolation: isolate; transition: transform var(--dur-fast) var(--ease-std), color var(--dur-slow) var(--ease-emph), background-color var(--dur-fast) var(--ease-std); }
.hero-take::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--mint); transform: scaleX(0); transform-origin: left center; transition: transform var(--dur-slow) var(--ease-emph); }
.hero-take.morphed { color: var(--teal); box-shadow: inset 0 0 0 1.5px var(--mint-line); }
.hero-take.morphed::before { transform: scaleX(1); }
.hero-take.morphed:disabled { opacity: 1; }
.hero-take.morphed > .ic { animation: check-pop var(--dur-slow) var(--ease-spring) both; }
@keyframes check-pop { 0% { transform: scale(.4) rotate(-12deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.hero-next { animation: hero-in var(--dur-slow) var(--ease-emph) both; }
@keyframes hero-in { from { opacity: 0; transform: translateX(24px); } }
.row-trail, .hero-time { font-variant-numeric: tabular-nums; }

/* ---------- Auth: three paths (Google, phone, without an account) ---------- */
.auth.splash .sheet { margin-top: 56px; }
.auth-hero { display: grid; gap: 8px; }
.auth-hero h1 { margin-top: 16px; }
.auth-google { display: grid; gap: 20px; }
/* Space for the Google Identity Services button is reserved, so nothing shifts when it renders. */
.gsi-slot { min-height: 44px; display: flex; justify-content: center; align-items: center; width: 100%; color-scheme: normal; }
.gsi-slot:not(.ready) { border-radius: var(--r-ctl); background: var(--line); position: relative; overflow: hidden; max-width: 400px; margin: 0 auto; }
.gsi-slot:not(.ready)::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--shimmer), transparent); animation: shimmer 1.2s var(--ease-std) infinite; }
.gsi-slot.ready { animation: vt-fade-in var(--dur-base) var(--ease-std) both; }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 16px; line-height: 22px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1 1 auto; border-top: 1px solid var(--line); }
.auth-phone > h2 { margin: 0 2px -8px; }
.auth-guest { display: grid; gap: 8px; padding-top: 4px; border-top: 1px solid var(--line); padding-top: 20px; }
.auth-guest > .muted { text-align: center; }
.auth-privacy { justify-self: start; font-size: 16px; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: 52px; padding: 12px 20px; border-radius: var(--r-ctl); border: 0; background: none;
  color: var(--ink); font-size: 18px; line-height: 24px; font-weight: 600; cursor: pointer;
}
.btn-ghost > .ic, .btn-ghost > .ic svg { width: 20px; height: 20px; }
.btn-ghost > .ic:first-child { color: var(--brand); }
.btn-ghost > .ic.trail { color: var(--muted); }
@media (hover: hover) { .btn-ghost:hover { background: var(--mint); } }

/* ---------- Guest card and saving the account ---------- */
.guest-card { background: var(--sheet); border: 1px solid var(--mint-line); border-radius: var(--r-sheet); padding: 16px 16px 16px 20px; display: grid; gap: 16px; }
.guest-head { display: flex; align-items: flex-start; gap: 14px; }
.guest-head .row-body { padding-top: 6px; }
.guest-dismiss { margin: -4px -4px 0 auto; flex: none; color: var(--muted); }
.guest-note { margin-top: -4px; }
.save-actions { display: grid; gap: 12px; }
.save-actions > .btn-secondary { width: 100%; }
@media (min-width: 560px) {
  .guest-card .save-actions { grid-template-columns: 1fr 1fr; align-items: center; }
  .guest-card .save-actions .gsi-slot { justify-content: stretch; }
}
.row-actions .gsi-slot { justify-content: flex-start; max-width: 320px; margin: 0; }
.row.linked .tile { background: var(--mint); }

@media (prefers-reduced-motion: reduce) {
  .btn:active, .btn-secondary:active, .btn-text:active, .btn-danger:active, .btn-ghost:active,
  .pub-action:active, .chip:active, .tab:active, .fab:active, .icon-btn:active, .lang-btn:active,
  .lang-item:active, .snackbar button:active, button.row:active, a.row:active { transform: none; }
  .gsi-slot:not(.ready)::after { display: none; }
  .hero-take::before { transform: scaleX(1); opacity: 0; }
  .hero-take.morphed::before { opacity: 1; }
}

/* =============================================================================================
   One-tap intake, archive by doctor, referrals, treatment plan (docs/care-plan-referrals.md)
   ============================================================================================= */

/* ---------- Segmented control (Sana bo'yicha | Shifokorlar bo'yicha; Reja | Dorilar | …) ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--line); border-radius: var(--r-ctl); }
.seg-btn {
  min-height: 44px; padding: 8px 10px; border: 0; border-radius: 9px; background: none; color: var(--muted);
  font-size: 16px; line-height: 22px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-std), background-color var(--dur-fast) var(--ease-std), color var(--dur-fast) var(--ease-std);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-pressed="true"] { background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1px var(--mint-line); }
.seg-btn:active:not(:disabled) { transform: scale(.97); }
.seg-btn:focus-visible { outline-offset: -2px; border-radius: 9px; }
@media (max-width: 420px) { .seg.wide { grid-auto-flow: row; grid-template-columns: 1fr 1fr; } }
.panel-in { animation: vt-fade-in var(--dur-fast) var(--ease-std) both; }
.section-lead { margin: 16px 4px 0; }
.section-note { margin: 8px 4px 0; }

/* ---------- "AI o'qiyapti…" row right after an upload ---------- */
.row.ai-pending .row-sub:first-of-type { color: var(--teal); }
.ai-bar { display: block; width: 60%; height: 6px; margin-top: 6px; border-radius: 3px; background: var(--mint-line); position: relative; overflow: hidden; }
.ai-bar::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--shimmer), transparent); animation: shimmer 1.2s var(--ease-std) infinite; }

/* ---------- Quick chips on the document screen ---------- */
.quick { display: grid; gap: 8px; }
.quick > h2 { margin: 8px 4px 0; }
.quick > .muted { margin: 0 4px; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }

/* ---------- Archive by doctor ---------- */
.doctor-groups { display: grid; gap: 12px; }
.doctor-group > summary { list-style: none; cursor: pointer; }
.doctor-group > summary::-webkit-details-marker { display: none; }
.doctor-group > summary:hover { background: color-mix(in srgb, var(--sheet) 94%, var(--ink)); }
.doctor-group > summary:focus-visible { outline-offset: -3px; }
.group-chev { color: var(--muted); transition: transform var(--dur-fast) var(--ease-std); }
.doctor-group[open] .group-chev { transform: rotate(180deg); }
.group-body { border-top: 1px solid var(--line); }
.group-body > .group-title, .modal-body > .group-title { margin: 12px 20px 4px; }
.modal-body > .group-title { margin: 4px 4px -8px; }
.group-body > .skeleton:first-child { padding-top: 16px; }
.group-body > .sheet { border: 0; border-radius: 0; }

/* ---------- Treatment plan ---------- */
.chips.progress { flex-wrap: wrap; overflow: visible; }
.chip.static { cursor: default; gap: 8px; }
.chip.static .ic { color: var(--brand); }
.chip-num { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.plan-row { gap: 12px; padding-right: 8px; }
.plan-time { flex: none; min-width: 56px; font-size: 18px; line-height: 26px; font-weight: 700; font-variant-numeric: tabular-nums; align-self: flex-start; padding-top: 2px; }
.plan-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.plan-meta > span:empty { display: none; }
.spec-label { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 6px; background: var(--mint); color: var(--teal); box-shadow: inset 0 0 0 1px var(--mint-line); font-weight: 600; }
.plan-state { font-weight: 600; }
.row.done .plan-state { color: var(--teal); }
.row.missed .plan-state { color: var(--alert); }
.plan-hit { flex: none; width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border-radius: var(--r-ctl); }
.plan-hit:hover { background: var(--mint); }
.plan-check { width: 32px; height: 32px; min-height: 0; padding: 0; margin: 0; accent-color: var(--brand); cursor: pointer; }
.plan-check:disabled { cursor: default; opacity: .45; }
.row.plan-row.done { background: var(--mint); }
.row.check.with-icon { cursor: pointer; }
.row.check > input { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .ai-bar::after { display: none; }
  .seg-btn:active { transform: none; }
}
