/* Design tokens — see docs/design-system.md. No hex values below :root. */
:root {
  --purple: #892E85;
  --purple-dark: #6B2268;
  --purple-light: #F7EEF7;
  --purple-light-active: #EFDEEE;
  --teal: #1D9E75;
  --teal-dark: #0F6E56;
  --teal-light: #DEF2ED;
  --text: #333333;
  --gray: #595959;
  --muted: #767676;
  --border: #D9D9D9;
  --bg: #FFFFFF;
  --page-bg: #F5F5F5;
  --section-bg: #FAFAFA;
  --gray-light: #F2F2F2;
  --error: #C03546;
  --error-bg: #FBEDEF;
  --track: #ECECEC;

  --font-sans: 'Figtree', 'Segoe UI', system-ui, -apple-system, sans-serif;
  /* Role-based type scale (see design-system.md → Typography) */
  --fs-step-title: 20px;   /* step heading in the content card */
  --fs-header-title: 18px; /* header form title — below step title on purpose */
  --fs-input: 16px;        /* inputs/selects/textareas incl. placeholders; 16px floor prevents iOS focus zoom */
  --fs-label: 15px;        /* field labels */
  --fs-ui: 14px;           /* sidebar step labels, buttons, error messages */
  --fs-helper: 13px;       /* helper/hint text */
  --fs-meta: 12px;         /* timestamps and fine meta */
  /* Generic steps for cases outside the roles above */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 24px;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Shared layout container (see design-system.md → Page layout): header,
     main area and action bar place their content inside .shell; the main
     area and the action bar share the sidebar/content grid */
  --shell-max: 1240px;
  --sidebar-w: 260px;
  --shell-gap: 40px;
  --content-max: 760px;
}

.shell {
  width: 100%;
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: 32px;
}

/* Vendored Figtree (variable) — mirrors @fontsource-variable/figtree/index.css,
   URLs rewritten to vendor/fonts/ (no-CDN hard rule) */
@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url(vendor/fonts/figtree-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url(vendor/fonts/figtree-latin-wght-normal.woff2) format('woff2-variations');
  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;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* Flex column filling the viewport: .content-shell grows so the action bar
   sits at the viewport bottom even when a step is shorter than the screen
   (sticky alone only pins it once the page scrolls) */
body {
  font-family: var(--font-sans); background: var(--page-bg); color: var(--text);
  min-height: 100vh; display: flex; flex-direction: column;
}

.header {
  position: relative; /* anchors the bottom-edge progress bar */
  background: var(--bg);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
/* Header is identical on the welcome and form screens: lockup pinned left,
   controls pinned right (the back arrow toggles display, CS/EN never moves) */
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-block: 16px; }
.header-brand { display: flex; gap: 18px; align-items: center; flex: 1; min-width: 0; }
/* brand | title lockup: divider between logo and form name */
.header-brand > div { border-left: 1px solid var(--border); padding-left: 18px; }
.brand-logo { height: 44px; width: auto; max-width: 220px; flex-shrink: 0; }
/* Mark-only lockup — desktop shows .brand-logo instead (swapped under 900px) */
.brand-logo-mark { display: none; height: 32px; width: auto; flex-shrink: 0; }
.header h1 { font-size: var(--fs-header-title); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; color: var(--purple); }
.header-meta { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; }
.header-badge { background: var(--purple-light); color: var(--purple); border-radius: var(--radius-sm); padding: 8px 14px; text-align: right; font-size: var(--fs-xs); white-space: nowrap; flex-shrink: 0; }
/* Step position on desktop lives in the sidebar; the badge is mobile-only */
@media (min-width: 900px) { .header-badge { display: none; } }
.header-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ← Back-to-welcome button */
.back-to-welcome {
  background: none; border: none; color: var(--purple);
  font-size: var(--fs-lg); cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm); font-family: inherit; line-height: 1; flex-shrink: 0;
  transition: background 0.15s;
}
.back-to-welcome:hover { background: var(--purple-light); }

/* Variant chip — labels the active form variant (♀/♂). Deliberately quiet:
   its job is labeling, so no button-like border/shadow; tapping returns to
   the welcome screen (never toggles sex in place). */
.variant-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--purple-light); color: var(--purple);
  border: none; border-radius: var(--radius-pill);
  padding: 4px 12px; font-size: var(--fs-xs); font-weight: 600;
  font-family: inherit; line-height: 1.4; cursor: pointer; flex-shrink: 0;
  transition: background 0.15s;
}
.variant-chip:hover { background: var(--purple-light-active); }
/* Inline SVG icons (Figtree has no ♀/♂ glyphs; system fallbacks render them
   hairline-thin and differently per OS). Stroke matches the semibold label. */
.variant-chip-icon {
  width: 15px; height: 15px; flex-shrink: 0;
  fill: none; stroke: currentcolor; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
}

/* mobile styles consolidated at end of file to avoid cascade conflicts */

/* ── Mobile header ───────────────────────────────────────────────────────── */
/* Hidden by default; shown on mobile when body.js-in-form (set by updateUI) */
#mobileHeader {
  display: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

/* Row 1 – identity bar */
.mh-identity {
  display: flex;
  align-items: center;
  /* 8px (not 10) keeps the CS title off the ellipsis on 375px-class devices;
     five elements share this row (mark, title, chip, save, language) */
  gap: 8px;
  padding: 8px 16px;
  min-height: 44px;
}
.mh-logo {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}
.mh-title {
  flex: 1;
  /* Matches the welcome header's mobile title size; at --fs-md the CS string
     ellipsized once the variant chip and actions took their width */
  font-size: var(--fs-ui);
  font-weight: 600;
  color: var(--purple);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mh-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.mh-save-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-size: var(--fs-xs);
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.mh-save-btn:hover { border-color: var(--purple); color: var(--purple); }

/* Language dropdown in mobile header */
.mh-lang-dropdown { position: relative; }
.mh-lang-trigger {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.mh-lang-trigger:hover { border-color: var(--purple); color: var(--purple); }
.mh-lang-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  overflow: hidden;
  min-width: 64px;
  z-index: 100;
}
.mh-lang-menu button {
  display: block;
  width: 100%;
  padding: 8px 14px;
  font-size: var(--fs-sm);
  font-weight: 600;
  font-family: inherit;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.mh-lang-menu button:hover { background: var(--purple-light); color: var(--purple); }

/* Row 2 – tappable step indicator row */
.mh-step-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}
.mh-step-row:hover { background: var(--gray-light); }
.mh-step-row:active { background: var(--purple-light); }
.mh-step-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.mh-step-name::after { content: ' ▾'; font-size: 10px; color: var(--muted); }
.mh-step-counter {
  font-size: var(--fs-xs);
  color: var(--muted);
  flex-shrink: 0;
  margin-left: 12px;
}

/* 9-segment progress bar */
.mh-segments {
  display: flex;
  gap: 3px;
  padding: 0 16px 8px;
}
.mh-segment {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.3s;
}
.mh-segment--filled { background: var(--purple); }
.mh-segment--error  { background: var(--error); }

/* Mobile toast (save feedback) */
.mh-toast {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  z-index: 500;
  transition: top 0.25s ease;
  pointer-events: none;
}
.mh-toast--visible { top: 12px; }

/* ── Bottom sheet — step picker ──────────────────────────────────────────── */
.step-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.step-sheet-backdrop--visible {
  opacity: 1;
  pointer-events: auto;
}
.step-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.step-sheet--open { transform: translateY(0); }
.step-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}
.step-sheet-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 16px 20px 8px;
}
.step-sheet-list {
  list-style: none;
  padding: 0 0 20px;
}
.step-sheet-item { border-bottom: 1px solid var(--border); }
.step-sheet-item:last-child { border-bottom: none; }
.step-sheet-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  min-height: 54px;
  transition: background 0.15s;
}
.step-sheet-btn:hover  { background: var(--gray-light); }
.step-sheet-btn:active { background: var(--purple-light); }
.step-sheet-name {
  flex: 1;
  font-size: var(--fs-ui);
  color: var(--text);
  line-height: 1.3;
}
.step-sheet-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--purple);
  flex-shrink: 0;
}

/* Progress runs along the header's full bottom edge: always-visible neutral
   track, purple fill (0% on welcome) */
.progress-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--track); }
.progress-fill { background: var(--purple); height: 100%; transition: width 0.4s ease; }

/* ── Content shell: desktop sidebar stepper + form column ────────────────── */
/* The sidebar and the mobile step sheet are two renderings of the same
   navigation model (rebuildTabNav / renderStepSheet in app.js).
   flex: 1 inside the body flex column makes the region fill the viewport
   (short steps don't collapse; the action bar stays at the bottom edge) —
   no hardcoded min-height needed. */
.content-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: var(--shell-gap);
  align-items: start;
  flex: 1 0 auto;
}
/* Welcome/success have no sidebar — single centered column */
body:not(.js-in-form) .content-shell { display: block; }
body:not(.js-in-form) .container { margin-inline: auto; }
.steps-nav {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 32px 0;
}
/* see consolidated @media block at end of file */
.step-tab {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 36px; padding: 7px 10px;
  background: none; border: none; border-radius: var(--radius-md);
  font-family: inherit; font-size: var(--fs-ui); color: var(--text);
  text-align: left; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.step-tab:hover { background: var(--bg); }
.step-tab.active { background: var(--purple-light); color: var(--purple); font-weight: 600; }
.step-tab:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.step-tab-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Step state circle — shared by the desktop sidebar and the mobile sheet.
   All states share identical geometry (diameter + border width); only fill,
   border color and glyph change. Visual weight: current (solid purple)
   strongest, error (red outline + !) next, completed recedes to the light
   purple tint, upcoming is a muted outline. */
.step-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  flex-shrink: 0;
}
.step-circle--current { background: var(--purple); border-color: var(--purple); color: var(--bg); }
.step-circle--warn    { background: var(--bg); border-color: var(--error); color: var(--error); }
.step-circle--done    { background: var(--purple-light); border-color: var(--purple-light); color: var(--purple); }
.step-circle--future  { background: none; border-color: var(--border); color: var(--muted); }

/* Error rows: red label, no background tint */
.step-tab--error .step-tab-name { color: var(--error); }
.step-sheet-btn--error .step-sheet-name { color: var(--error); }

.container { min-width: 0; max-width: var(--content-max); padding: 32px 0 48px; }

.section-card {
  background: var(--bg); border-radius: var(--radius-lg); border: 1px solid var(--border);
  padding: 32px; margin-bottom: 24px;
}
.privacy-notice {
  background: var(--teal-light);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 24px;
}
.privacy-notice-title {
  font-size: var(--fs-sm); font-weight: 600; color: var(--teal-dark);
  margin-bottom: 6px;
}
.privacy-notice-body {
  font-size: var(--fs-sm); color: var(--gray); line-height: 1.6; margin: 0;
}

/* ── Welcome / sex-selection screen ─────────────────────────────────────── */
.welcome-screen {
  max-width: 500px;
  margin: 40px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.welcome-screen .privacy-notice { width: 100%; margin-bottom: 0; }
.resume-card {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--purple);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.resume-card[hidden] { display: none; }
.resume-card-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.resume-card-meta  { font-size: var(--fs-meta); color: var(--muted); }
.resume-card-entry { display: flex; flex-direction: column; gap: 10px; }
.resume-card-entry + .resume-card-entry {
  margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--border);
}
.resume-card-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.resume-card-restart {
  padding: 9px 14px; font-size: var(--fs-sm);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--gray); cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.resume-card-restart:hover { border-color: var(--purple); color: var(--purple); }
.resume-card-restart:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.welcome-intro {
  display: flex; flex-direction: column; gap: 8px;
  text-align: center;
}
.welcome-subtitle {
  font-size: var(--fs-md); color: var(--muted); letter-spacing: 0.03em;
}
.welcome-hint {
  font-size: var(--fs-helper); color: var(--muted); line-height: 1.5;
}
.sex-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  width: 100%;
}
.sex-choice-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 32px 16px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.sex-choice-btn:hover  { border-color: var(--purple); background: var(--purple-light); }
.sex-choice-btn:active { border-color: var(--purple); background: var(--purple-light-active); }
.sex-choice-btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.sex-choice-icon  { font-size: 40px; line-height: 1; }
.sex-choice-label { font-size: var(--fs-md); font-weight: 600; letter-spacing: 0.01em; }
@media (max-width: 420px) {
  .sex-choice-btn { padding: 24px 8px; }
  .sex-choice-icon { font-size: 32px; }
  .sex-choice-label { font-size: var(--fs-md); }
}

/* Step heading — sentence case comes from the strings; no text-transform */
.section-title {
  font-size: var(--fs-step-title); font-weight: 500;
  color: var(--purple); margin-bottom: 20px; display: flex; align-items: center; gap: 12px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--purple-light); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.full-width { grid-column: 1 / -1; }

.required-legend { font-size: var(--fs-helper); color: var(--muted); margin: -12px 0 16px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: var(--fs-label); color: var(--gray); letter-spacing: 0.03em; }

/* ── Field helper text ───────────────────────────────────────────────────── */
/* Always-visible plain guidance between label and control (answer specs and
   examples from the source PDF). Per mobile-ux-guidelines §4–5 instructions
   live in visible text, never tooltips; plain muted text, no tinted box (that
   style is reserved for the welcome-screen privacy notice). */
.field-help {
  margin: 0; font-size: var(--fs-helper); color: var(--muted); line-height: 1.5;
}
.table-section > .field-help { margin: 0 0 8px; }
/* Record-section notes stay hidden until the section is answered "Ano". */
.record-notes-hidden { display: none; }
.field input, .field textarea, .field select,
.record-modal-fields input, .record-modal-fields select {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 44px; font-size: var(--fs-input);
  font-family: inherit; color: var(--text);
  background: var(--bg); transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-light);
}
.field textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.field .hint { font-size: var(--fs-helper); color: var(--muted); }

/* Inputs sized to expected content (see design-system.md): dates and other
   numeric-keyboard fields never need the full column; free-text, name and
   address fields stay full width */
.field input[inputmode="numeric"],
.field input.input-w-sm { max-width: 180px; }
.field input.input-w-md { max-width: 240px; }

.table-section { margin-top: 20px; }
/* Section question headings (7a, 10a, 12a …) — match the field-label size so
   every numbered question reads at the same weight across all steps. */
.table-label { font-size: var(--fs-label); letter-spacing: 0.03em; color: var(--gray); margin-bottom: 8px; }
.form-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.form-table th {
  background: var(--gray-light); color: var(--gray); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase; padding: 7px 8px;
  border: 1px solid var(--border); text-align: left;
}
.form-table td { border: 1px solid var(--border); padding: 3px; }
.form-table input {
  border: none; padding: 7px 8px; width: 100%; font-size: var(--fs-input);
  font-family: inherit; background: transparent; color: var(--text);
}
.form-table input:focus { outline: none; background: var(--purple-light); }
.add-row-btn {
  margin-top: 6px; font-size: var(--fs-sm); color: var(--purple); background: none; border: none;
  cursor: pointer; padding: 4px 0; font-family: inherit; display: flex; align-items: center; gap: 4px;
}
.add-row-btn:hover { text-decoration: underline; }

/* ── Record sections (card entry over hidden PDF tables) ─────────────────── */
/* !important: must beat later same-specificity display rules (e.g. .hormone-list) */
.record-table-hidden { display: none !important; }
.record-cards { display: flex; flex-direction: column; gap: 10px; }
.record-card {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--section-bg); padding: 12px 14px;
}
.record-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.record-card-title { font-size: var(--fs-sm); font-weight: 600; color: var(--purple); }
.record-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.record-card-btn {
  padding: 4px 10px; font-size: var(--fs-xs);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit; color: var(--text);
  transition: border-color 0.15s, color 0.15s;
}
.record-card-btn:hover { border-color: var(--purple); color: var(--purple); }
.record-card-btn--danger:hover { border-color: var(--error); color: var(--error); }
.record-card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px 14px; margin: 0;
}
.record-card-grid dt {
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted);
}
.record-card-grid dd { font-size: var(--fs-sm); color: var(--text); margin: 0; overflow-wrap: anywhere; }
.record-add-btn {
  display: block; width: 100%; margin-top: 10px; padding: 10px;
  background: none; border: 1.5px dashed var(--border); border-radius: var(--radius-md);
  font-size: var(--fs-sm); font-family: inherit; color: var(--purple); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.record-add-btn:hover { border-color: var(--purple); background: var(--purple-light); }
.record-yn-note { margin-top: 8px; font-size: var(--fs-helper); color: var(--muted); font-style: italic; }
.record-max-note { margin-top: 8px; font-size: var(--fs-helper); color: var(--muted); font-style: italic; }

/* ── Ne/Ano toggles over "write NE" free-text fields ─────────────────────── */
.yn-toggle { display: flex; gap: 8px; margin-bottom: 8px; max-width: 320px; }
.yn-btn {
  flex: 1; padding: 8px 16px; min-height: 40px;
  background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-md);
  font-family: inherit; font-size: var(--fs-ui); color: var(--text); cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.yn-btn:hover { border-color: var(--purple); color: var(--purple); }
.yn-btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.yn-btn--active {
  border-color: var(--purple); background: var(--purple-light);
  color: var(--purple); font-weight: 600;
}
/* !important: must beat .field input/textarea display rules */
.yn-hidden { display: none !important; }

/* Inline validation (border + icon + text — never colour alone) */
.field input.input-invalid, .field textarea.input-invalid { border-color: var(--error); }
.field-error, .yn-error {
  display: flex; align-items: baseline; gap: 5px;
  margin-top: 5px; font-size: var(--fs-ui); line-height: 1.4; color: var(--error);
}
.field-error::before, .yn-error::before { content: '⚠'; flex-shrink: 0; }
/* Unanswered Ne/Ano question flagged by the completion gate */
.yn-toggle--error .yn-btn { border-color: var(--error); }
.yn-error { margin-bottom: 8px; }
/* Incomplete-step marker (unmet required fields left behind) is the
   .step-circle--warn state, shared by sidebar and sheet */

/* Segmented buttons over a hidden select (marital status) */
.seg-hidden { display: none !important; }
.seg-group { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-group .yn-btn { flex: 0 1 auto; }

/* One-tap suggestion chips under a field (e.g. country) */
.field-suggest { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.suggest-chip {
  padding: 6px 14px; min-height: 32px;
  background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-pill);
  font-family: inherit; font-size: var(--fs-sm); color: var(--purple); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.suggest-chip:hover { border-color: var(--purple); background: var(--purple-light); }
.suggest-chip:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
/* Partner address chip carries a full address — left-align wrapped lines */
#partnerAddressSuggest .suggest-chip { text-align: left; }

/* Record add/edit modal */
.record-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 300;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.record-modal-backdrop--visible { opacity: 1; pointer-events: auto; }
.record-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.97);
  width: min(560px, calc(100vw - 32px)); max-height: 85vh;
  display: none; flex-direction: column;
  background: var(--bg); border-radius: var(--radius-lg); z-index: 301;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease;
}
.record-modal--open { display: flex; opacity: 1; transform: translate(-50%, -50%) scale(1); }
.record-modal-title {
  padding: 18px 20px 0; font-size: var(--fs-md); font-weight: 600; color: var(--purple);
}
.record-modal-fields {
  padding: 14px 20px; overflow-y: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.record-modal-actions {
  padding: 12px 20px 16px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* Completion summary (Dokončit with unanswered questions). Shares the record
   modal shell; the body lists the steps still missing answers. */
.completion-intro {
  padding: 8px 20px 0; margin: 0;
  font-size: var(--fs-sm); line-height: 1.5; color: var(--muted);
}
.completion-list {
  padding: 14px 20px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.completion-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px; min-height: 44px; text-align: left;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: inherit; font-size: var(--fs-ui); color: var(--text); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.completion-row:hover { border-color: var(--purple); background: var(--purple-light); }
.completion-row:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.completion-step-num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1.5px solid var(--error); color: var(--error);
  font-size: var(--fs-xs); font-weight: 600;
}
.completion-step-name { font-weight: 600; overflow-wrap: anywhere; }
.completion-step-count {
  margin-left: auto; flex-shrink: 0;
  font-size: var(--fs-sm); color: var(--error);
}
@media (max-width: 899px) {
  .record-modal {
    left: 0; right: 0; top: auto; bottom: 0; transform: translateY(8px);
    width: 100%; max-height: 85vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .record-modal--open { transform: translateY(0); }
  .record-modal-fields { grid-template-columns: 1fr; }
}

/* ── Bottom action bar ───────────────────────────────────────────────────── */
/* Same .shell container as the header, spanning its full width (wizard
   far-edge pattern): Zpět at the shell's left edge (aligned with the logo
   and sidebar), the draft cluster (save + ⋯ + status text) centered, the
   CTA at the shell's right edge (aligned with the header controls).
   Constant height across steps (Zpět hides via visibility, the ⋯ menu
   overlays, the status text reserves its width). */
.nav-footer {
  position: sticky; bottom: 0; background: var(--bg);
  border-top: 0.5px solid var(--border);
  margin-top: 32px;
}
.nav-footer-inner { padding-block: 14px; }
.nav-footer-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-footer-content .btn { white-space: nowrap; flex-shrink: 0; }
/* auto margins center the cluster between Zpět and the CTA */
.nav-footer-draft {
  display: flex; align-items: center; gap: 10px;
  margin-inline: auto; min-width: 0;
}
/* Fixed width fits the longest CS/EN status string (172px, EN saved) so
   no-draft↔saved and CS↔EN toggles shift no buttons; on narrow desktops
   (900–1024 grid) the box is the only element allowed to shrink, ellipsizing
   the text instead of pushing the CTA past the content column */
.draft-status-box {
  display: inline-flex; align-items: center; gap: 10px;
  margin-left: 2px; /* 12px from the ⋯ trigger (10px flex gap + 2px) */
  width: 180px; min-width: 0; flex-shrink: 1;
  font-size: var(--fs-meta); color: var(--muted);
}
.draft-status-box > span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Dokončit keeps the teal family but matches Pokračovat's geometry so the
   bar height never changes on the last step */
.nav-footer .btn-success { padding: 10px 24px; }

/* Draft ⋯ menu (load / delete) — opens upward from the bar */
.draft-menu { position: relative; }
.draft-menu-trigger { padding-inline: 14px; }
.draft-menu-list {
  position: absolute; bottom: calc(100% + 6px); left: 0;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  min-width: 190px; z-index: 100; overflow: hidden;
}
.draft-menu-list button {
  display: block; width: 100%; padding: 10px 14px;
  background: none; border: none; text-align: left; cursor: pointer;
  font-family: inherit; font-size: var(--fs-ui); color: var(--text);
  white-space: nowrap;
}
.draft-menu-list button:hover { background: var(--purple-light); color: var(--purple); }
.draft-menu-list .draft-menu-danger:hover { background: var(--error-bg); color: var(--error); }
/* CTA buttons: brand pill style (see docs/design-system.md → Components) */
.btn {
  padding: 10px 24px; border-radius: var(--radius-pill); font-size: var(--fs-ui); font-family: inherit;
  cursor: pointer; transition: all 0.15s; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.btn-outline { background: none; border: 1px solid var(--border); color: var(--gray); }
.btn-outline:hover { border-color: var(--purple); color: var(--purple); }
.btn-primary { background: var(--purple); border: 1px solid var(--purple); color: var(--bg); }
.btn-primary:hover { background: var(--purple-dark); }
.btn-success { background: var(--teal); border: 1px solid var(--teal); color: var(--bg); padding: 12px 28px; }
.btn-success:hover:not(:disabled) { background: var(--teal-dark); }
/* Work in progress (today only the PDF download's "Stahování…" state): reads as
   busy rather than clickable. */
.btn:disabled { opacity: 0.65; cursor: progress; }

.step-page { display: none; }
.step-page.active { display: block; }

.success-screen { text-align: center; padding: 48px 32px; }
.success-icon { font-size: 48px; margin-bottom: 16px; }
.success-screen h2 { font-size: var(--fs-xl); font-weight: 600; color: var(--purple); margin-bottom: 8px; }
.success-screen p { color: var(--muted); margin-bottom: 32px; font-size: var(--fs-base); }

/* Two send paths presented as cards, left-aligned within the centred screen */
.send-options {
  display: flex; flex-direction: column; gap: 16px;
  max-width: 460px; margin: 0 auto 24px; text-align: left;
}
.send-option {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg); padding: 20px;
}
.send-option--active { border-color: var(--teal); background: var(--teal-light); }
.send-option--soon { background: var(--section-bg); }
.send-option-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.send-option-icon { font-size: var(--fs-lg); line-height: 1; }
.send-option-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); margin: 0; }
.send-option--soon .send-option-title { color: var(--gray); }
.send-option-badge {
  margin-left: auto; font-size: var(--fs-xs); font-weight: 600;
  color: var(--purple); background: var(--purple-light);
  padding: 3px 10px; border-radius: var(--radius-pill); white-space: nowrap;
}
.send-option-desc { color: var(--muted); font-size: var(--fs-sm); margin: 0 0 14px; }
.send-option--soon .send-option-desc { margin-bottom: 0; }
.send-option .btn-success { width: 100%; }

/* Partner cross-CTA card: quieter than the active send path */
.send-option--partner { background: var(--section-bg); }
.send-option--partner .btn-outline { width: 100%; }
.send-option--partner .btn-outline:disabled { opacity: 0.5; cursor: not-allowed; }
.send-option-locked { color: var(--muted); font-size: var(--fs-xs); margin: 8px 0 0; }

/* Clinic-only PDF template plumbing, collapsed by default */
.template-settings { max-width: 460px; margin: 0 auto; text-align: left; }
.template-settings > summary {
  cursor: pointer; font-size: var(--fs-sm); color: var(--muted);
  text-align: center; list-style-position: inside; padding: 4px 0;
}
.template-settings > summary:hover { color: var(--gray); }
.template-settings-body { padding-top: 12px; }
.file-picker-hint { display: block; font-size: var(--fs-sm); color: var(--gray); margin-bottom: 8px; }
.file-picker-label {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  cursor: pointer; font-size: var(--fs-sm); color: var(--muted);
  transition: border-color 0.2s;
}
.template-settings .pdf-note { margin: 12px 0 0; font-size: var(--fs-meta); color: var(--muted); }

.hormone-list { display: flex; flex-direction: column; gap: 10px; }
.hormone-item {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--section-bg); padding: 10px 14px;
}
.hormone-name { font-size: var(--fs-sm); font-weight: 600; color: var(--gray); margin-bottom: 8px; }
.hormone-fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 899px) {
  .hormone-fields { grid-template-columns: 1fr 1fr; }
}

.lang-switcher { display: flex; gap: 3px; align-items: center; }
.lang-btn {
  padding: 4px 8px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em;
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit; color: var(--muted);
  transition: all 0.15s;
}
.lang-btn:hover { border-color: var(--purple); color: var(--purple); }
.lang-btn.active { background: var(--purple); border-color: var(--purple); color: var(--bg); }

.draft-info { color: var(--muted); }
.draft-status {
  font-weight: 600;
  transition: opacity 0.4s;
  opacity: 0;
}

/* Small laptops: narrower sidebar so the form column keeps room */
@media (min-width: 900px) and (max-width: 1024px) {
  :root { --sidebar-w: 220px; --shell-gap: 24px; }
}

/* ── Mobile (< 900px) ────────────────────────────────────────────────────── */
@media (max-width: 899px) {
  /* When inside the form: swap old header for new mobile header */
  body.js-in-form .header   { display: none; }
  body.js-in-form #mobileHeader { display: block; }

  .shell { padding-inline: 16px; }

  /* On the welcome screen (no js-in-form): keep old header compact */
  .header-inner {
    padding-block: 10px;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
  }
  /* Identity row: mark · title · CS/EN. The wordmark is dropped so the title
     — which is what actually tells the patient what this page is — fits on one
     line; the mark still carries the brand. Height stays 53px (10px padding
     block + 32px mark + 1px border), so the progress track below is unmoved. */
  .header-brand { gap: 10px; flex-shrink: 1; }
  .brand-logo      { display: none; }
  .brand-logo-mark { display: block; }
  .header-brand > div { border-left: none; padding-left: 0; min-width: 0; }
  .header h1 {
    display: block;
    font-size: var(--fs-ui);
    line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .header-badge { flex-shrink: 0; }

  /* Hide sidebar stepper — replaced by mobile header + bottom sheet */
  .content-shell { display: block; }
  .steps-nav { display: none; }

  /* Layout */
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .container  { padding: 16px 0 80px; }
  .section-card { padding: 16px; }

  /* Action bar: back/next only — drafts live in the mobile header (save)
     and the "Uloženo" timestamp has no room; sheet shows step state */
  .nav-footer-inner { display: block; padding-block: 12px; }
  .nav-footer-draft { display: none; }
  /* back at the left edge, CTA at the right — with the draft cluster gone,
     the desktop 3-column grid would auto-place the CTA into the middle track */
  .nav-footer-content { display: flex; justify-content: space-between; }

  /* Inputs are 16px (--fs-input) at every breakpoint — the iOS focus-zoom
     floor (docs/mobile-ux-guidelines.md) needs no mobile override */

  /* Touch targets ≥ 44px (docs/mobile-ux-guidelines.md) */
  .btn,
  .record-add-btn,
  .record-card-btn,
  .yn-btn,
  .suggest-chip,
  .resume-card-restart,
  .sex-choice-btn { min-height: 44px; }
  .yn-toggle { max-width: none; }
  .record-card-btn { padding: 8px 14px; }
  .mh-save-btn, .mh-lang-trigger { min-height: 40px; padding: 8px 12px; }
  #mobileHeader .variant-chip { min-height: 44px; padding: 8px 12px; }
  .mh-lang-menu button { min-height: 44px; }
}
