/* Jaalam — the staff-facing tool's stylesheet.
 *
 * Every screen behind sign-in loads this file. It holds the design system —
 * tokens, type, controls, cards, tables, badges — and the components the
 * capture tool's own pages use. shell.css layers the sidebar and the account
 * pages on top; the OPD, desk, encounter and protocol pages each add a small
 * file of their own that only says what is new there.
 *
 * The patient's phone screens do not use this file (patient.css).
 *
 * THEME. `data-theme` on <html> is the single switch, and it is always set:
 * `_theme.html` stamps "light" or "dark" from an inline script in <head>,
 * before the first paint, resolving the stored choice — or, when that choice
 * is "system", `prefers-color-scheme`. One block per theme, one source of
 * truth; see the note in `_theme.html` for why there is no media query here.
 */

/* --- Tokens -------------------------------------------------------------- */

:root {
  /* Surfaces, from the canvas up. `--surface-2` is an inset — a table head,
     a well inside a card, a hover on a plain row. */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #e9ebef;
  --rail-bg: #eef0f3;
  --raised: #ffffff;
  --field: #ffffff;

  --border: #e4e6ea;
  --border-strong: #cfd3da;

  --text: #111418;
  --text-2: #3b4250;
  --muted: #6b7280;
  --faint: #9aa1ad;

  /* The accent is the one saturated thing on a staff screen. Used on the
     action to take, the row that is live, the item that is on. */
  --accent: #0f766e;
  --accent-hover: #0b5f59;
  --accent-soft: #e3f4f1;
  --accent-soft-2: #c9e9e3;
  --accent-text: #0b5c56;
  --accent-contrast: #ffffff;

  --info: #2563eb;
  --info-soft: #e5edff;
  --info-text: #1e4fc4;

  --warn: #b45309;
  --warn-soft: #fdf1dc;
  --warn-text: #92400e;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fee7e7;
  --danger-text: #b42318;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-xs: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-sm: 0 1px 3px rgb(16 24 40 / 0.07), 0 1px 2px -1px rgb(16 24 40 / 0.05);
  --shadow-md: 0 6px 16px -4px rgb(16 24 40 / 0.12), 0 2px 6px -2px rgb(16 24 40 / 0.06);
  --shadow-lg: 0 24px 56px -12px rgb(16 24 40 / 0.28), 0 8px 20px -8px rgb(16 24 40 / 0.12);

  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  --ring-danger: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent);

  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Malayalam", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.2, 0, 0, 1);
  --fast: 120ms;
}

:root[data-theme="dark"] {
  /* Wider steps between layers than the light theme needs: on a dark screen
     the eye separates surfaces by lightness alone, so the canvas, a card, a
     dialog and a field each get a clear step, and the hairlines are drawn a
     shade brighter than the surface they edge. */
  --bg: #0e1115;
  --surface: #171b21;
  --surface-2: #1f242c;
  --surface-3: #2a303a;
  --rail-bg: #12161b;
  --raised: #1d2229;
  --field: #111519;

  --border: #2c333d;
  --border-strong: #3d4652;

  --text: #eceef1;
  --text-2: #c3c9d3;
  --muted: #98a1ae;
  --faint: #6b7482;

  --accent: #2ec4ae;
  --accent-hover: #4dd3bf;
  --accent-soft: #163a35;
  --accent-soft-2: #1e5049;
  --accent-text: #7fe3d3;
  --accent-contrast: #06201c;

  --info: #7aa7f7;
  --info-soft: #1c2a48;
  --info-text: #a9c4fb;

  --warn: #eaa93f;
  --warn-soft: #3e2d12;
  --warn-text: #f5cd80;

  --danger: #f26b60;
  --danger-hover: #f6867c;
  --danger-soft: #42201d;
  --danger-text: #f9a39b;

  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.45);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.55), 0 0 0 1px rgb(255 255 255 / 0.04);
  --shadow-md: 0 8px 24px -6px rgb(0 0 0 / 0.65), 0 0 0 1px rgb(255 255 255 / 0.06);
  --shadow-lg: 0 32px 72px -16px rgb(0 0 0 / 0.85), 0 0 0 1px rgb(255 255 255 / 0.08);
}

/* --- Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

/* Any author `display` beats the UA stylesheet's [hidden] rule, so hiding an
   element that has one silently does nothing. State this once. */
[hidden] { display: none !important; }

/* 15px, not the browser's 16: this is an application, read in rows and
   panels, not a document read in paragraphs. Every size below is in rem, so
   the one number here sets the density of the whole tool. */
html {
  font-size: 15px;
  /* Keep the scrollbar's room whether or not there is a scrollbar (founder,
     2026-09-08): a short page and a long one otherwise sit at different
     widths, so every navigation between them shifts the layout sideways. */
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01", "calt";
}

body.centered {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* Thin, quiet scrollbars where the platform lets us. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

/* One focus treatment for the whole tool: a soft ring in the accent, drawn
   outside the control, and only for keyboard focus. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

code, kbd, samp, pre {
  font-family: var(--mono);
  font-size: 0.86em;
}

code {
  padding: 0.1em 0.4em;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
}

pre code { padding: 0; background: none; color: inherit; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

h1, h2, h3, h4 {
  margin: 0 0 0.35rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  text-wrap: balance;
}

h1 { font-size: 1.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin-bottom: 0.6rem; }
h3 { font-size: 0.95rem; }

p { margin: 0 0 0.75rem; }

strong { font-weight: 600; }

svg.icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* --- Text utilities ------------------------------------------------------- */

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.warn { color: var(--warn-text); }
.error { color: var(--danger-text); font-size: 0.9rem; }

.lede {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 64ch;
}

.note {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.section-heading {
  margin: 2rem 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-lede { margin: 0 0 1rem; max-width: 64ch; font-size: 0.92rem; }

/* A line of links above a title — "← Home", "← Protocols". */
.crumb {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  font-size: 0.88rem;
}

.crumb a, .crumb .link { color: var(--muted); font-weight: 500; }
.crumb a:hover, .crumb .link:hover { color: var(--text); text-decoration: none; }

.inline-form { display: inline; margin: 0; }
.empty { padding: 1rem 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- Top bar --------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  min-height: 3.5rem;
  padding: 0.5rem 1.25rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand:hover { text-decoration: none; }

.brand span {
  margin-left: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.topbar nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-left: auto;
  font-size: 0.9rem;
}

.topbar nav > a { color: var(--text-2); font-weight: 500; }

.who-box {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.who { color: var(--text); font-weight: 600; }

/* --- Cards ----------------------------------------------------------------- */

.card {
  margin-bottom: 1.25rem;
  padding: 1.25rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.card > :last-child { margin-bottom: 0; }

.card-title { margin: 0 0 0.9rem; font-size: 1rem; }

/* --- Landing page ---------------------------------------------------------- */

.home-title { margin: 0.25rem 0 0.2rem; font-size: 1.75rem; }
.home-lede { margin: 0 0 1.75rem; max-width: 62ch; color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

/* Each tile is a link wrapping a .card, so the whole panel is the target
   rather than a word inside it. */
.cards .card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 1.25rem 1.35rem 1.15rem;
  color: inherit;
  text-decoration: none;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
    transform var(--fast) var(--ease);
}

.cards .card:hover {
  text-decoration: none;
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.cards .card:hover .card-go { color: var(--accent-text); }

.cards .card h2 { margin: 0; font-size: 1rem; }
.cards .card p { margin: 0; font-size: 0.88rem; line-height: 1.5; color: var(--muted); }

.cards .card-go {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-text);
}

/* The tile's icon, in the top corner: drawn from the same set the sidebar
   uses, so the tile and the link that leads to it look like the same thing. */
.tile-icon {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  margin-bottom: 0.35rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.tile-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cards-primary { margin-bottom: 0.5rem; }
.cards-primary .card h2 { font-size: 1.05rem; }

/* A card that submits rather than navigates: starting an encounter creates
   one, and a GET would mint a conversation on every refresh and prefetch. */
.cards .card-action { text-align: left; cursor: pointer; }

.card-go.as-link {
  background: none;
  border: 0;
  padding: 0.5rem 0 0;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-text);
  cursor: pointer;
  text-align: left;
  box-shadow: none;
}

.card-go.as-link:hover { background: none; }

/* The whole tile submits, not just the words at the bottom: the button's box
   is stretched over the card, so there is one target and no nested
   interactive elements. */
.cards .card-action .card-go.as-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card-note {
  font-size: 0.78rem !important;
  color: var(--faint) !important;
  margin: 0.25rem 0 0 !important;
}

/* --- Forms ------------------------------------------------------------------ */

label {
  display: block;
  margin-bottom: 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.75rem;
  min-height: 2.4rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text);
  background-color: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

input::placeholder, textarea::placeholder { color: var(--faint); }

input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--muted)); }

input:focus, select:focus, textarea:focus,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

input:disabled, select:disabled, textarea:disabled {
  color: var(--muted);
  background-color: var(--surface-3);
  border-color: transparent;
  box-shadow: none;
  cursor: not-allowed;
}

textarea { resize: vertical; min-height: 4.5rem; }

/* Our own chevron on selects: the UA arrow sits hard against the corner. Two
   declarations, one per theme, because a background image cannot take
   `currentColor`. Data URIs so no select waits on a request to look finished. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3e%3cpath d='M1 1.75 6 6.25 11 1.75' fill='none' stroke='%236b7280' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 0.65rem auto;
}

:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3e%3cpath d='M1 1.75 6 6.25 11 1.75' fill='none' stroke='%238b939f' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
}

select[multiple] {
  appearance: auto;
  -webkit-appearance: auto;
  padding-right: 0.75rem;
  background-image: none;
}

input[type="file"] { padding: 0.4rem; background: transparent; box-shadow: none; }

input[type="checkbox"], input[type="radio"] {
  width: 1rem;
  height: 1rem;
  min-height: 0;
  margin: 0;
  padding: 0;
  box-shadow: none;
  accent-color: var(--accent);
}

input[type="range"] { box-shadow: none; border: 0; padding: 0; min-height: 0; accent-color: var(--accent); }

label.checkbox {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-weight: 400;
  line-height: 1.45;
  color: var(--text);
}

label.checkbox input { width: 1rem; margin: 0.2rem 0 0; flex: none; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row label { flex: 1 1 200px; }

/* --- Buttons ---------------------------------------------------------------- */

/* ONE BUTTON FORMAT (founder, 2026-09-09): a pill, with the icon for what
   the button does sitting in a disc at its left end. Held throughout the
   tool, in two weights and one alarm:

     primary    filled in the accent — the thing to do on this screen
     secondary  the surface with a hairline — every other thing
     danger     filled red — the one destructive thing, when there is one

   The bare <button> is primary, because most buttons in the tool's forms are
   the one thing that form does. `.btn` is the same system by class, for <a>
   elements and for the quiet variants. A button that leads with an `.icon`
   gets the disc automatically; one without an icon is a plain pill. */

button,
.btn,
a.button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* One height sets the whole shape: the disc is the height less a 4px
     inset all round, and the glyph sits centred in the disc. Change --h and
     every proportion follows, so the small button is the same button. */
  --h: 38px;
  --glyph: 16px;
  /* THE RULE THAT KEEPS A RESIZED BUTTON LOOKING RIGHT (founder): the space
     between the disc and the pill's edge is the same on the left as above
     and below, and the same at every size. Everything below derives from
     this one number; nothing else may move the disc. */
  --inset: 4px;
  gap: 0.55rem;
  height: var(--h);
  min-height: var(--h);
  padding: 0 calc(var(--h) * 0.42);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--accent-contrast);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 999px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgb(255 255 255 / 0.12);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

button:hover, .btn:hover, a.button:hover, .button:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

button:active, .btn:active { transform: translateY(0.5px); }

button:disabled, .btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* The icon, in its disc. Only a LEADING icon is the function mark; a
   trailing one (the chevron on "More") stays a plain glyph. */
/* Low specificity, on purpose: a component that draws its own button — a
   tab, a menu row, the theme switch — keeps its own padding and its own
   icon, because anything it says about them outranks this. Only a button
   that says nothing gets the disc. */
/* Specificity (0,1,0) and (0,2,0): above the bare element and `svg.icon`,
   below anything a component says about its own button. */
:is(button, .btn):where(:has(> .icon:first-child:not(.trail))) { padding-left: calc(var(--inset) - 1px); }

:where(button, .btn) > .icon:first-child {
  flex: none;
  width: calc(var(--h) - 2 * var(--inset));
  height: calc(var(--h) - 2 * var(--inset));
  padding: calc((var(--h) - 2 * var(--inset) - var(--glyph)) / 2);
  margin-left: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.2);
  box-sizing: border-box;
}

/* A trailing glyph — the arrow after "Start a patient", the chevron on
   "More" — is not the function mark and gets no disc. `:first-child` cannot
   see the text before it, so it is said with a class (`.trail`) or, for the
   menu button, by name. */
button > .icon:not(:first-child), .btn > .icon:not(:first-child),
button > .icon.trail, .btn > .icon.trail,
:where(.modal-close, .btn-icon, .nav-toggle, .nav-open, .theme-choice button, .menu-body button,
       .menu-body a, .strip-go, .tab, .picker > summary, button.link, .btn.link) > .icon:first-child {
  width: 1rem;
  height: 1rem;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: inherit;
}

/* `.btn-end` — a button whose function mark is at the END (founder,
   2026-09-09). For the controls whose glyph is a DIRECTION rather than a
   thing: "More", whose chevron says there is a menu below, and "Open next",
   whose arrow says forward, to the next patient. A direction set in front of
   the label points at the label.

   THE INSET RULE, MIRRORED. The disc sits `--inset` from the right edge, so
   its centre lands at `--h / 2` from that edge, which is the centre of the
   pill's right cap. Same one number, same two concentric circles; only the
   side changes. Below the trailing-glyph reset above, so it wins on order at
   equal specificity.

   BOTH paddings are set, and the left one is why this needs a class at all:
   when the glyph is the button's only ELEMENT child — a text-node label does
   not count for `:first-child` — the leading-disc rule matches it and strips
   the left padding to the inset. The label then sat 4px from the pill's edge. */
.btn-end {
  padding-left: calc(var(--h) * 0.42);
  padding-right: calc(var(--inset) - 1px);
}

.btn-end > .icon:last-child {
  flex: none;
  width: calc(var(--h) - 2 * var(--inset));
  height: calc(var(--h) - 2 * var(--inset));
  padding: calc((var(--h) - 2 * var(--inset) - var(--glyph)) / 2);
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 50%;
  color: var(--accent-text);
  background: var(--accent-soft);
  box-sizing: border-box;
}

/* Filled: the disc is a tint alone and the hairline goes, exactly as it does
   on the leading side — against the accent a tinted border is a smudge. */
:is(button.primary, .btn.btn-primary, .btn.primary).btn-end > .icon:last-child {
  color: inherit;
  background: rgb(255 255 255 / 0.2);
  border-color: transparent;
}

/* Open, the chevron points the other way. */
details[open] > .btn-end > .icon:last-child { transform: rotate(180deg); }

/* Secondary: the surface, a hairline, and the function mark tinted. */
button.secondary, .btn.secondary,
.btn:not(.btn-primary):not(.danger):not(.link):not(.primary):not(.secondary):not(.quiet-danger) {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

button.secondary:hover, .btn.secondary:hover,
.btn:not(.btn-primary):not(.danger):not(.link):not(.primary):not(.secondary):not(.quiet-danger):hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--border-strong) 60%, var(--muted));
}

button.secondary > .icon:first-child, .btn.secondary > .icon:first-child,
.btn:not(.btn-primary):not(.danger):not(.link):not(.primary):not(.secondary):not(.quiet-danger) > .icon:first-child {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

button.primary, .btn.btn-primary, .btn.primary {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: transparent;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgb(255 255 255 / 0.12);
}

button.primary:hover, .btn.btn-primary:hover, .btn.primary:hover { background: var(--accent-hover); }

/* The filled button's disc is a tint alone: the hairline is the secondary's,
   where the disc would otherwise vanish into the surface (founder). */
button.primary > .icon:first-child, .btn.btn-primary > .icon:first-child, .btn.primary > .icon:first-child {
  color: inherit;
  background: rgb(255 255 255 / 0.2);
  border-color: transparent;
}

button.danger, .btn.danger {
  color: #fff;
  background: var(--danger);
  border-color: transparent;
}

button.danger:hover, .btn.danger:hover { background: var(--danger-hover); }

/* Dark mode lifts the secondary a step off the canvas: the surface it shares
   with cards sits too close to the page there, and the softest accent tint is
   nearly black. A lighter fill, a firmer hairline, and the disc in the second
   tint with the accent itself for the mark. */
:root[data-theme="dark"] button.secondary,
:root[data-theme="dark"] .btn.secondary,
:root[data-theme="dark"] .btn:not(.btn-primary):not(.danger):not(.link):not(.primary):not(.secondary):not(.quiet-danger) {
  background: var(--surface-3);
  border-color: #414a57;
}

:root[data-theme="dark"] button.secondary:hover,
:root[data-theme="dark"] .btn.secondary:hover,
:root[data-theme="dark"] .btn:not(.btn-primary):not(.danger):not(.link):not(.primary):not(.secondary):not(.quiet-danger):hover {
  background: #2c323b;
  border-color: #4d5665;
}

:root[data-theme="dark"] button.secondary > .icon:first-child,
:root[data-theme="dark"] .btn.secondary > .icon:first-child,
:root[data-theme="dark"] .btn:not(.btn-primary):not(.danger):not(.link):not(.primary):not(.secondary):not(.quiet-danger) > .icon:first-child {
  color: var(--accent);
  background: var(--accent-soft-2);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

/* A quiet button whose action takes something away: secondary, with the
   mark in red. Not filled — that is for the one destructive thing on a
   screen. */
.btn.quiet-danger, button.quiet-danger {
  color: var(--danger-text);
  background: var(--surface);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border-strong));
}

.btn.quiet-danger:hover, button.quiet-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.quiet-danger > .icon:first-child, button.quiet-danger > .icon:first-child {
  color: var(--danger-text);
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

/* A button that reads as a link: no box, no fill, no disc. */
button.link, .btn.link {
  min-height: 0;
  padding: 0;
  gap: 0.35rem;
  color: var(--accent-text);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  box-shadow: none;
  font-weight: 500;
}

button.link:hover, .btn.link:hover { background: none; text-decoration: underline; text-underline-offset: 2px; }
button.link.danger { color: var(--danger-text); background: none; }
button.link > .icon:first-child, .btn.link > .icon:first-child {
  width: 1rem;
  height: 1rem;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: inherit;
}

/* The page's own action — "New patient", "Add someone" — is this same
   button, `.btn.primary`, at the right of the page head; nothing about it is
   its own. `.opd-new` and `.opd-cta-quiet` are hooks for opd.js only. */

/* A button the width of its form. THE DISC STAYS WHERE THE INSET PUTS IT
   (founder, 2026-09-09: "circle center and the pill left radius center has to
   align"). At the inset the disc's centre is `--inset + (--h - 2*--inset) / 2`
   = `--h / 2`, which is exactly the centre of the pill's left cap — the two
   circles are concentric, and that is the whole reason the inset is one
   number. Centring disc and label together as one group, which is what a
   plain full-width button does, floats the disc into the middle of the pill
   instead and loses that.

   So: the disc is taken out of the flow and pinned at the inset, and the label
   centres on the pill. The padding reserves the disc's width at BOTH ends, so
   the label is centred against the pill and not against what is left of it. */
.btn-block,
.modal-foot button,
.add-foot button {
  position: relative;
  width: 100%;
}

/* The padding is the disc's width reserved at both ends, so only a button
   that HAS a disc pays for it — `.btn-block` on the sign-in button, which is
   a label alone, must not gain 2 × --h of padding it has no use for. Same
   `:has()` test as the base rule above, so the two cannot disagree about what
   counts as a leading icon. */
:is(.btn-block, .modal-foot button, .add-foot button):where(:has(> .icon:first-child:not(.trail))) {
  padding-left: var(--h);
  padding-right: var(--h);
}

/* `- 1px` for the button's own border: absolute positions are from the
   padding box, and the inset is measured from the outer edge. Same
   subtraction the `padding-left` above the icon rules makes. */
.btn-block > .icon:first-child,
.modal-foot button > .icon:first-child,
.add-foot button > .icon:first-child {
  position: absolute;
  top: calc(var(--inset) - 1px);
  left: calc(var(--inset) - 1px);
}

/* Sizes. Small is for a row's own buttons — "Open note", "Refresh". */
.btn-small, button.small { --h: 30px; --glyph: 14px; font-size: 0.82rem; gap: 0.4rem; }
.btn-large, button.large { --h: 44px; --glyph: 18px; font-size: 1rem; gap: 0.65rem; }

.actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.actions form { margin: 0; }

.login { width: min(380px, 100%); }
.login h1 { font-size: 1.75rem; }

/* A button that is only its icon: quiet until the pointer finds it. */
.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  min-height: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: none;
  cursor: pointer;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

.btn-icon:hover { color: var(--text); background: var(--surface-3); }
.btn-icon .icon { width: 1.05rem; height: 1.05rem; }


/* --- Badges ----------------------------------------------------------------- */

/* A soft tint with strong text, and no border: the modern mark for a state.
   Anything that wants a hairline instead says so. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
  white-space: nowrap;
}

.badge.state { color: var(--muted); background: var(--surface-2); }
.badge.source { color: var(--warn-text); background: var(--warn-soft); }
.badge.lead { color: var(--accent-text); background: var(--accent-soft); }
.status-failed .badge.state { color: var(--danger-text); background: var(--danger-soft); }

/* A pill is a badge beside a name: the state of a person or a version. Soft
   tint, strong text, no border. Tones: neutral | accent | info | warn | danger. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.4rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-2);
  background: var(--surface-3);
  white-space: nowrap;
  vertical-align: middle;
}

.pill-neutral { color: var(--muted); background: var(--surface-3); }
.pill-accent, .pill.live { color: var(--accent-text); background: var(--accent-soft); }
.pill-info { color: var(--info-text); background: var(--info-soft); }
.pill-warn, .pill.warn { color: var(--warn-text); background: var(--warn-soft); }
.pill-danger { color: var(--danger-text); background: var(--danger-soft); }

/* --- Page head ---------------------------------------------------------------- */

/* Title and lede on the left, the page's actions on the right (`_ui.html`
   page_head). The same head on every screen is most of what makes them one
   product. */
.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.page-head-text { flex: 1 1 20rem; min-width: 0; }
.page-head h1 { margin: 0 0 0.2rem; font-size: 1.6rem; }
.page-head .lede, .page-head .muted { margin: 0; font-size: 0.95rem; }
.page-actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-left: auto; }
.page-head .crest { width: 3.5rem; height: 3.5rem; }

/* --- Notices ----------------------------------------------------------------- */

.notice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.9rem;
  --notice-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='12' cy='12' r='9'/%3e%3cpath d='M12 16v-4M12 8h.01'/%3e%3c/svg%3e");
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
  color: var(--text-2);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* The mark before a notice, drawn with a mask so it takes the text colour —
   a background image cannot. */
.notice::before {
  content: "";
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.1rem;
  background-color: var(--accent);
  -webkit-mask: var(--notice-icon) center / contain no-repeat;
  mask: var(--notice-icon) center / contain no-repeat;
}

.notice.warn::before { background-color: var(--warn); }
.notice.danger::before, .notice.error::before { background-color: var(--danger); }

.notice.warn {
  border-color: color-mix(in srgb, var(--warn) 30%, var(--border));
  background: color-mix(in srgb, var(--warn-soft) 60%, var(--surface));
}

.notice.danger, .notice.error {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
  background: color-mix(in srgb, var(--danger-soft) 60%, var(--surface));
  color: var(--danger-text);
}

/* --- Dialogs ------------------------------------------------------------------- */

/* A native <dialog> over the page: Escape closes it and focus stays inside
   without a line of script. `.opd-modal` is the same thing under the name the
   list page's script and stylesheet know it by. */
.modal,
.opd-modal {
  width: min(92vw, 44rem);
  max-height: 88vh;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.modal[open],
.opd-modal[open] {
  display: flex;
  flex-direction: column;
  animation: modal-in 160ms var(--ease);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.modal::backdrop,
.opd-modal::backdrop {
  background: rgb(8 10 14 / 0.45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* Round, like every control in the tool, and on the title's line: the head
   pads 1.4rem and its title is about 1.6rem tall, so the button's centre
   sits at the title's centre. */
.modal-close {
  position: absolute;
  top: 1.2rem;
  right: 1.6rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  min-height: 0;
  padding: 0;
  color: var(--text-2);
  background: var(--raised);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-xs);
}

.modal-close:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.modal-close .icon { width: 1.1rem; height: 1.1rem; }

.modal-body { min-height: 0; overflow: auto; }
.modal-pad { padding: 1.4rem 1.6rem 1.5rem; }

/* A dialog's form is one column: the fields stack, and the one button that
   saves them sits at the right of its own row, where a dialog keeps its
   commit. */
.modal-pad .form-grid { grid-template-columns: 1fr; gap: 1rem; margin-top: 0; }
.modal-pad .form-grid button.primary { grid-column: 1 / -1; justify-self: end; margin-top: 0.5rem; }
.modal-pad label { margin: 0; }

/* A second part of a dialog, under a rule: the account's access under its
   details, the archive under the roster. */
.modal-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.modal-section .section-heading { margin-top: 0; margin-bottom: 0.75rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.row-actions form { margin: 0; }



/* A form that is the whole dialog: its head, its fields, its one button. */
.modal-form {
  max-width: none;
  margin: 0;
  padding: 1.4rem 1.6rem 1.2rem;
  overflow: auto;
}

.modal-head, .add-head { margin-bottom: 1rem; padding-right: 2.5rem; }
.modal-head h2, .add-head h2 { margin: 0 0 0.2rem; font-size: 1.3rem; }
.modal-head .muted, .add-head .muted { margin: 0; }

.modal-foot, .add-foot { margin-top: 1rem; }
.modal-foot button, .add-foot button { --h: 44px; --glyph: 18px; font-size: 1rem; }
.modal-form .note { margin: 0.9rem 0 0; }

/* --- Recording list ----------------------------------------------------------- */

.recordings { list-style: none; margin: 0; padding: 0; }

.recording {
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.recording:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

.recording a {
  display: block;
  padding: 0.85rem 1rem;
  color: var(--text);
  text-decoration: none;
}

.line1 {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.line2 { display: block; margin-top: 0.25rem; font-size: 0.85rem; }

.asked {
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.asked q { font-style: italic; }

/* --- Transcripts ------------------------------------------------------------ */

.player-card audio { width: 100%; margin-top: 0.5rem; }

.player-card {
  position: sticky;
  top: 0.5rem;
  z-index: 5;
  box-shadow: var(--shadow-md);
}

.notes {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.meta { margin-top: -0.35rem; }

.config summary { font-size: 0.85rem; color: var(--muted); cursor: pointer; }

.config pre, .error-block {
  overflow-x: auto;
  padding: 0.75rem;
  font-size: 0.8rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.error-block { color: var(--danger-text); white-space: pre-wrap; }

.segments { list-style: none; margin: 0.8rem 0; padding: 0; }

.segment {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
}

.segment.playing { background: var(--accent-soft); }

.seek {
  flex: none;
  min-height: 0;
  padding: 0.05rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 0;
  box-shadow: none;
}

.seek:hover { background: var(--accent-soft-2); }

.fulltext { padding: 0.75rem; background: var(--surface-2); border-radius: var(--radius-sm); }

.alternatives > summary {
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  list-style-position: outside;
}

.alternatives > summary .muted { font-weight: 400; }
.alternatives[open] > summary { margin-bottom: 0.6rem; }
.fold-note { margin: 0 0 0.4rem; }

.alternatives .transcript.alt {
  margin: 0.9rem 0 0;
  padding: 0.9rem 0 0;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

/* --- Code-switch merge (experiment 006) ------------------------------------ */

.codeswitch { line-height: 2; }

.cs {
  padding: 0.05rem 0.3rem;
  border-radius: 5px;
  cursor: help;
  font-size: 0.85em;
  letter-spacing: 0.02em;
}

.cs-parakeet { background: var(--accent-soft); color: var(--accent-text); }
.cs-xlit { background: var(--warn-soft); color: var(--warn-text); }
.cs-legend { cursor: default; margin-left: 0.35rem; }
.cs-intro { margin-bottom: 0.4rem; }

/* --- Reference editor ------------------------------------------------------- */

.reference-row {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin-bottom: 0.4rem;
}

.reference-row textarea { margin-top: 0; overflow: hidden; min-height: 2.4rem; }

.history summary { cursor: pointer; font-size: 0.9rem; }
.history ul { padding-left: 1.1rem; }
.history li { margin-bottom: 0.7rem; font-size: 0.9rem; }
.history p { margin: 0.2rem 0 0; }

/* --- Placeholder screens ----------------------------------------------------- */

.placeholder-panel { max-width: 62ch; }

.placeholder-steps {
  margin: 0.75rem 0 1rem;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.placeholder-steps li { margin-bottom: 0.6rem; }
.placeholder-steps strong { color: var(--text); }

/* --- Motion ----------------------------------------------------------------- */

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