/* Daacter — shared component layer.
   Everything here is surface-agnostic: reset, typography, controls, badges,
   forms, tables and feedback states. The staff shell lives in app.css and the
   public pages in site.css.

   Django renders bare <label>, <input> and <button> from forms, so elements
   are styled directly and the design's class names (.label, .input, .btn) are
   kept as aliases for hand-written markup. */

/* --- Reset ------------------------------------------------------------ */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-data);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

a { color: var(--accent-ink); text-decoration: none; }
a:hover { color: var(--teal-700); }

ul, ol { margin: 0; padding: 0; list-style: none; }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

/* [hidden] is a UA rule any element rule beats on specificity; screens are
   toggled with the attribute, so it has to win. */
[hidden] { display: none !important; }

.skip-link {
  position: absolute; inset-inline-start: var(--sp-4); top: -100px; z-index: 200;
  background: var(--surface); color: var(--accent-ink);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  box-shadow: var(--shadow-2); font-weight: 600;
  transition: top var(--t-fast) var(--ease);
}
.skip-link:focus { top: var(--sp-4); }

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

/* --- Typography ------------------------------------------------------- */

h1, h2, h3, h4, .display, .brand-name, .nav-link, .btn, .eyebrow, .tab {
  font-family: var(--font-display);
}

h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -0.02em; }

h1, .display { font-size: var(--fs-display); font-weight: 800; line-height: 1.02; letter-spacing: -0.038em; }
h2 { font-size: var(--fs-h2); font-weight: 700; line-height: 1.12; letter-spacing: -0.03em; }
h3 { font-size: var(--fs-h3); font-weight: 700; line-height: 1.25; }
h4 { font-size: var(--fs-body); font-weight: 700; line-height: 1.35; }

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-data);
  font-size: var(--fs-micro); font-weight: 600;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--sp-4);
}
.eyebrow::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: currentColor; opacity: .55; }
.eyebrow--gold { color: var(--gold-700); }

.lede { font-size: var(--fs-lede); line-height: 1.62; color: var(--ink-600); max-width: 54ch; }

.hl { color: var(--accent); }
.hl-gold { color: var(--gold-600); }

/* Data type: tabular, tight, unmistakable. Dosages and money must never be
   ambiguous, so they never render in the display face. */
.num, .money, .dose, .stamp, .metric {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv05" 1;
  letter-spacing: -0.01em;
}
.stamp { font-size: var(--fs-xs); color: var(--text-dim); }
.money { font-weight: 600; }

.muted, .helptext { color: var(--text-muted); font-size: var(--fs-sm); }
.dim   { color: var(--text-dim); }
.small { font-size: var(--fs-sm); }
.micro { font-size: var(--fs-micro); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); }

.share-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-xs); word-break: break-all; }

/* --- Layout primitives ------------------------------------------------ */

.container { width: 100%; max-width: var(--shell-max); margin-inline: auto; padding-inline: var(--sp-5); }
.container--narrow { max-width: 860px; }

.stack > * + * { margin-top: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.row--top { align-items: flex-start; }
.spacer, .grow { flex: 1; min-width: 0; }

.divider { height: 1px; background: var(--line-soft); border: 0; margin-block: var(--sp-4); }

/* --- Buttons ---------------------------------------------------------- */
/* Bare <button> gets the primary look so Django-rendered submits land right
   without a class on every template. */

.btn, button {
  --btn-bg: var(--accent);
  --btn-fg: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 0.72rem 1.15rem;
  border: 0; border-radius: var(--r-md);
  background: var(--btn-bg); color: var(--btn-fg);
  font-family: var(--font-display);
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: -0.01em;
  box-shadow: var(--shadow-teal);
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  /* Wrap rather than run off the edge: a long submit label ("Prescribe and
     send to the pharmacy") on a narrow column must stay inside the button. */
  white-space: normal;
  max-width: 100%;
  text-align: center;
}
.btn:hover, button:hover { background: var(--teal-700); color: #fff; transform: translateY(-1px); }
.btn:active, button:active { transform: translateY(0); box-shadow: var(--shadow-1); }
.btn[disabled], button[disabled] { opacity: .5; pointer-events: none; }

.btn--lg { padding: 0.9rem 1.5rem; font-size: var(--fs-body); border-radius: var(--r-lg); }
.btn--sm { padding: 0.45rem 0.8rem; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn--full { width: 100%; }

.btn--ghost, button.ghost {
  --btn-bg: transparent; --btn-fg: var(--ink-700);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn--ghost:hover, button.ghost:hover {
  background: var(--surface); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--ink-300), var(--shadow-1);
}

.btn--quiet, button.quiet { --btn-bg: var(--ink-100); --btn-fg: var(--ink-700); box-shadow: none; }
.btn--quiet:hover, button.quiet:hover { background: var(--ink-200); color: var(--text); }

.btn--gold { --btn-bg: var(--gold-600); box-shadow: var(--shadow-gold); }
.btn--gold:hover { background: var(--gold-700); }

/* Destructive: the pharmacy sending a prescription back, and nothing else. */
.btn--danger, button.danger { --btn-bg: var(--rose-600); box-shadow: 0 1px 2px rgba(190,18,60,.18), 0 8px 20px -6px rgba(190,18,60,.26); }
.btn--danger:hover, button.danger:hover { background: var(--rose-700); }

.btn--onink { --btn-bg: var(--pristine-white); --btn-fg: var(--ink-900); box-shadow: 0 8px 24px -8px rgba(0,0,0,.6); }
.btn--onink:hover { background: var(--teal-100); color: var(--teal-900); }

/* A button that reads as a link — log out, and other low-stakes verbs. */
.btn--link, button.link {
  --btn-bg: transparent; --btn-fg: var(--accent-ink);
  box-shadow: none; padding: 0.25rem 0.4rem;
  font-family: var(--font-data); font-weight: 600;
}
.btn--link:hover, button.link:hover { background: var(--ink-100); color: var(--accent-ink); transform: none; }

.icon-btn, button.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: 0 0 36px; padding: 0;
  border: 0; border-radius: var(--r-md);
  background: var(--ink-100); color: var(--ink-600);
  box-shadow: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover, button.icon-btn:hover { background: var(--teal-100); color: var(--teal-800); transform: none; }
.icon-btn svg { width: 17px; height: 17px; }

a.button-link {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 0.72rem 1.15rem;
  border-radius: var(--r-md);
  background: var(--accent); color: #fff;
  font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 700;
  box-shadow: var(--shadow-teal);
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
a.button-link:hover { background: var(--teal-700); color: #fff; transform: translateY(-1px); }

/* --- Badges, dots, avatars -------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.22rem 0.6rem 0.24rem;
  border-radius: var(--r-pill);
  background: var(--ink-100); color: var(--ink-600);
  font-family: var(--font-data);
  font-size: var(--fs-micro); font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap;
}
.badge--teal    { background: var(--teal-100); color: var(--teal-800); }
.badge--gold    { background: var(--gold-050); color: var(--gold-700); box-shadow: inset 0 0 0 1px var(--gold-200); }
.badge--rose    { background: var(--rose-050); color: var(--rose-700); }
.badge--ink     { background: var(--ink-900); color: #CBD5E1; }
.badge--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-600); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-300); flex: 0 0 7px; }
.dot--teal   { background: var(--teal-600); }
.dot--gold   { background: var(--gold-600); }
.dot--urgent { background: var(--urgent); box-shadow: 0 0 0 3px var(--rose-100); }
.dot--live   { background: var(--teal-600); animation: pulse-dot 2.2s var(--ease) infinite; }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(13,148,136,.34); }
  50%      { box-shadow: 0 0 0 6px rgba(13,148,136,0); }
}

.avatar {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: var(--r-md);
  background: var(--teal-100); color: var(--teal-800);
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-sm);
  letter-spacing: -0.01em; text-transform: uppercase;
}
.avatar--sm { width: 30px; height: 30px; flex-basis: 30px; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.avatar--lg { width: 52px; height: 52px; flex-basis: 52px; font-size: var(--fs-body); border-radius: var(--r-lg); }
.avatar--gold { background: var(--gold-050); color: var(--gold-700); }
.avatar--ink  { background: var(--ink-900); color: var(--teal-300); }

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

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: var(--sp-5);
}
.card--flat { box-shadow: var(--shadow-1); }
.card--lift { box-shadow: var(--shadow-3); }
.card--sunk { background: var(--surface-sunk); box-shadow: inset 0 0 0 1px var(--line-soft); }

.card-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h3, .card-head h4 { margin: 0; }

.mini-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface-sunk);
  font-size: var(--fs-sm);
}
.mini-row strong { font-weight: 650; }

/* --- Forms ------------------------------------------------------------ */
/* Bare elements first, so `{{ form.as_p }}` output is styled as-is. */

form p { margin: 0 0 var(--sp-4); }

label, .label {
  display: block;
  font-family: var(--font-data);
  font-size: var(--fs-xs); font-weight: 650; color: var(--ink-700);
  letter-spacing: -0.005em;
  margin-bottom: var(--sp-2);
}

input, select, textarea, .input, .select, .textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 0; border-radius: var(--r-md);
  background: var(--surface-sunk);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: var(--fs-sm);
  transition: box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
input:focus, select:focus, textarea:focus,
.input:focus, .select:focus, .textarea:focus {
  outline: none; background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--accent), var(--ring);
}
textarea, .textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.input--num, input[type="number"], input[inputmode="numeric"] { font-variant-numeric: tabular-nums; }

input[type="checkbox"], input[type="radio"] { width: auto; box-shadow: none; accent-color: var(--accent); }
input[type="file"] { padding: var(--sp-3); background: var(--surface-sunk); }

.field { display: grid; gap: var(--sp-2); }
.field label, .field .label { margin-bottom: 0; }
.field + .field { margin-top: var(--sp-4); }
.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.field-row .field + .field { margin-top: 0; }

.hint, .helptext { display: block; font-size: var(--fs-micro); color: var(--text-dim); margin-top: var(--sp-1); }

/* Errors are rose, never gold — gold means money on this platform. */
.errorlist {
  list-style: none; margin: 0 0 var(--sp-3); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--rose-050); color: var(--rose-700);
  font-size: var(--fs-xs); font-weight: 600;
}

/* --- Tables ----------------------------------------------------------- */

table, .ledger { width: 100%; border-collapse: collapse; }
th, .ledger th {
  text-align: start; padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-data);
  font-size: var(--fs-micro); font-weight: 650; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-dim);
  box-shadow: inset 0 -1px 0 var(--line-soft);
  white-space: nowrap;
}
td, .ledger td {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  box-shadow: inset 0 -1px 0 var(--line-soft);
  vertical-align: top;
}
.ledger td { vertical-align: middle; }
tbody tr:last-child td { box-shadow: none; }
tbody tr { transition: background var(--t-fast) var(--ease); }
tbody tr:hover { background: var(--surface-sunk); }
.t-right { text-align: end; }
.case-ref { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: var(--fs-xs); }

/* --- Definition lists (case facts) ------------------------------------ */

dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); }
dt { font-size: var(--fs-xs); font-weight: 650; color: var(--text-muted); }
dd { margin: 0; font-size: var(--fs-sm); color: var(--ink-700); }

/* --- Chart list (dated facts) ----------------------------------------- */

.chart-list { display: grid; }
.chart-item {
  display: grid; grid-template-columns: 72px 1fr; gap: var(--sp-3);
  padding: var(--sp-3) 0;
  box-shadow: inset 0 -1px 0 var(--line-soft);
  font-size: var(--fs-sm);
}
.chart-item:last-child { box-shadow: none; }
.chart-item .when { font-size: var(--fs-micro); color: var(--text-dim); font-variant-numeric: tabular-nums; padding-top: 2px; }
.chart-item .what strong { display: block; font-weight: 650; font-size: var(--fs-sm); }
.chart-item .what span { color: var(--text-muted); font-size: var(--fs-xs); }

/* --- Prescription lines ----------------------------------------------- */

.rx-list { display: grid; gap: var(--sp-3); }
.rx-card {
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  padding: var(--sp-4);
  display: grid; gap: var(--sp-3);
}
.rx-head { display: flex; align-items: flex-start; gap: var(--sp-3); }
.rx-lines { display: grid; gap: var(--sp-2); }
.rx-line {
  display: grid; grid-template-columns: 1fr auto; gap: var(--sp-3);
  align-items: baseline;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--surface-sunk);
}
.rx-line .drug { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-sm); letter-spacing: -0.012em; }
.rx-line .sig { font-variant-numeric: tabular-nums; font-size: var(--fs-xs); color: var(--ink-600); display: block; margin-top: 1px; }
.rx-line .qty { font-variant-numeric: tabular-nums; font-weight: 650; font-size: var(--fs-sm); color: var(--ink-700); white-space: nowrap; }
/* A line the patient buys from the market, not from the named pharmacy. */
.rx-line--market { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.rx-line--market .qty { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: var(--fs-micro); letter-spacing: .06em; }

.rx-strip {
  display: grid; gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--teal-050);
  box-shadow: inset 0 0 0 1px rgba(13,148,136,.14);
}
.rx-drug { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-sm); letter-spacing: -0.01em; }
.rx-dose { font-variant-numeric: tabular-nums; font-size: var(--fs-xs); color: var(--teal-800); font-weight: 550; }

/* --- Case spine -------------------------------------------------------
   A case is measured by when each stage happened, not by step number, so the
   timestamp is the left-hand column and the labels of stages not yet reached
   stay dim. */

.spine { position: relative; display: grid; }

.spine-step {
  position: relative;
  display: grid;
  grid-template-columns: 76px 20px 1fr;
  align-items: start;
  gap: var(--sp-3);
  padding-block: var(--sp-3);
}
.spine-step::before {
  content: "";
  position: absolute;
  left: calc(76px + var(--sp-3) + 9px);
  top: calc(var(--sp-3) + 16px);
  bottom: calc(-1 * var(--sp-3));
  width: 2px;
  background: var(--line);
  border-radius: 2px;
}
.spine-step:last-child::before { display: none; }
.spine-step.is-done::before { background: var(--teal-100); }

.spine-t {
  font-family: var(--font-data);
  font-size: var(--fs-xs); font-variant-numeric: tabular-nums; font-weight: 600;
  color: var(--text-dim); text-align: end; padding-top: 1px; letter-spacing: -0.01em;
}
.spine-step.is-done .spine-t { color: var(--teal-700); }
.spine-step.is-money .spine-t { color: var(--gold-700); }

.spine-dot {
  position: relative; z-index: 1;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--pristine-white);
  box-shadow: inset 0 0 0 2px var(--line);
  display: grid; place-items: center;
  margin-top: 1px;
}
.spine-dot::after {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-300);
  transition: background var(--t-mid) var(--ease), transform var(--t-mid) var(--ease-out);
}
.spine-step.is-done .spine-dot { box-shadow: inset 0 0 0 2px var(--teal-300); }
.spine-step.is-done .spine-dot::after { background: var(--teal-600); }
.spine-step.is-money.is-done .spine-dot { box-shadow: inset 0 0 0 2px var(--gold-200); }
.spine-step.is-money.is-done .spine-dot::after { background: var(--gold-600); }
.spine-step.is-active .spine-dot::after { transform: scale(1.25); animation: pulse-dot 2s var(--ease) infinite; }
.spine-step.is-blocked .spine-dot { box-shadow: inset 0 0 0 2px var(--rose-100); }
.spine-step.is-blocked .spine-dot::after { background: var(--rose-600); }
.spine-step.is-blocked .spine-t { color: var(--rose-700); }

.spine-body { min-width: 0; }
.spine-label {
  display: block;
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-sm);
  color: var(--ink-400); letter-spacing: -0.01em;
  transition: color var(--t-slow) var(--ease);
}
.spine-step.is-done .spine-label, .spine-step.is-active .spine-label { color: var(--text); }
.spine-who { display: block; margin-top: 1px; font-size: var(--fs-xs); color: var(--text-muted); }

/* Horizontal variant — the public "how it works" rail. */
.spine--rail { grid-template-columns: repeat(4, 1fr); gap: var(--sp-5); }
.spine--rail .spine-step { display: block; padding: var(--sp-6) 0 0; }
.spine--rail .spine-step::before {
  content: ""; left: 0; right: 0; top: 9px; bottom: auto;
  width: auto; height: 2px; background: var(--line);
}
.spine--rail .spine-step:last-child::before {
  display: block; background: linear-gradient(90deg, var(--teal-100), rgba(204,251,241,0));
}
.spine--rail .spine-dot { position: absolute; top: 0; left: 0; margin: 0; }
.spine--rail .spine-t { text-align: left; display: block; margin-bottom: var(--sp-3); font-size: var(--fs-sm); }
.spine--rail .spine-label { font-size: var(--fs-h3); font-weight: 700; margin-bottom: var(--sp-2); }
.spine--rail .spine-who {
  font-size: var(--fs-micro); font-weight: 650; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: var(--sp-2);
}
.spine--rail .spine-step.is-money .spine-who { color: var(--gold-700); }
.spine--rail .spine-note { display: block; font-size: var(--fs-sm); color: var(--ink-600); line-height: 1.55; }

/* The rail variant loses columns before the vertical one loses its gutter. */
@media (max-width: 1024px) {
  .spine--rail { grid-template-columns: repeat(2, 1fr); row-gap: var(--sp-6); }
}
@media (max-width: 720px) {
  .spine--rail { grid-template-columns: 1fr; }
  .spine--rail .spine-step::before { display: none; }
  .spine-step { grid-template-columns: 62px 20px 1fr; }
  .spine-step::before { left: calc(62px + var(--sp-3) + 9px); }
}

/* A money figure stated as the point of its panel, not as a table cell. */
.money-figure {
  font-family: var(--font-data);
  font-size: 1.75rem; font-weight: 700;
  letter-spacing: -0.035em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.money-figure .cur {
  font-size: .5em; font-weight: 650; color: var(--gold-700);
  vertical-align: .42em; margin-right: .18em; letter-spacing: 0;
}

/* --- Voice note -------------------------------------------------------
   A styled player wrapped around a real <audio> element (voicenote.js).
   The waveform is a deterministic silhouette drawn from the clip's id — it
   is a scrubbing surface, not a true amplitude read — and the played bars
   track the audio's own currentTime, so nothing here fakes playback. */

.voicenote {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--teal-050);
  box-shadow: inset 0 0 0 1px rgba(13,148,136,.14);
  transition: box-shadow var(--t-mid) var(--ease), background var(--t-mid) var(--ease);
}
.voicenote.is-playing {
  background: var(--pristine-white);
  box-shadow: inset 0 0 0 1px rgba(13,148,136,.28), var(--shadow-2);
}
.voicenote > audio { display: none; }

.vn-play {
  display: grid; place-items: center;
  width: 46px; height: 46px; flex: 0 0 46px;
  border: 0; border-radius: var(--r-md);
  background: var(--accent); color: #fff;
  box-shadow: var(--shadow-teal);
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.vn-play:hover { background: var(--teal-700); transform: scale(1.04); }
.vn-play:active { transform: scale(.97); }
/* max-width:none defeats the global `img, svg { max-width: 100% }`, which
   otherwise caps the icon's width to its shrink-to-fit grid cell (~9px) while
   height stays 18px, squishing the play triangle. */
.vn-play svg { width: 18px; height: 18px; max-width: none; }
.vn-play .ico-pause { display: none; }
.voicenote.is-playing .vn-play .ico-play { display: none; }
.voicenote.is-playing .vn-play .ico-pause { display: block; }

.vn-body { flex: 1; min-width: 0; }

.vn-wave {
  display: flex; align-items: center; justify-content: space-between; gap: 3px;
  height: 36px; width: 100%;
  cursor: pointer;
  padding-block: 2px;
}
.vn-bar {
  flex: 1 1 auto; min-width: 3px; max-width: 7px;
  border-radius: 2px;
  background: var(--teal-100);
  transform-origin: center;
  transition: background var(--t-fast) linear, transform var(--t-fast) var(--ease);
}
.vn-bar.is-played { background: var(--accent); }
.vn-bar.is-cursor { background: var(--teal-800); animation: vn-pulse .62s var(--ease) infinite; }

@keyframes vn-pulse {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(1.42); }
}

.vn-meta {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-top: 2px;
  font-size: var(--fs-micro);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.vn-meta .vn-total { margin-left: auto; }

.vn-speed {
  border: 0; border-radius: var(--r-pill);
  padding: 0.1rem 0.5rem;
  background: rgba(13,148,136,.1); color: var(--teal-800);
  font-size: var(--fs-micro); font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background var(--t-fast) var(--ease);
}
.vn-speed:hover { background: rgba(13,148,136,.2); }

@media (prefers-reduced-motion: reduce) {
  .vn-bar.is-cursor { animation: none; }
}

/* --- Recorded media ---------------------------------------------------
   The patient's video and the physician's voice reply. Real media elements
   with the browser's own controls: the recording is evidence, so nothing
   here dresses it up or gets between the clinician and the playhead. */

.media {
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--ink-900);
  box-shadow: var(--shadow-1);
}
.media video { width: 100%; display: block; max-height: 60vh; background: #000; }
.media audio { width: 100%; display: block; }
.media--audio { background: var(--surface-sunk); padding: var(--sp-3); box-shadow: inset 0 0 0 1px var(--line); }
.media-note {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: var(--sp-2);
  font-size: var(--fs-micro); color: var(--text-dim);
}
video, audio { max-width: 100%; }

/* The payment screenshot the patient uploaded. */
.proof { border-radius: var(--r-md); box-shadow: var(--shadow-1); max-width: 22rem; }

/* --- Alerts and feedback ---------------------------------------------- */

.alert {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--rose-050);
  box-shadow: inset 0 0 0 1px var(--rose-100);
  font-size: var(--fs-sm); color: var(--rose-700); line-height: 1.55;
}
.alert svg { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 2px; }
.alert b { font-weight: 700; }
.alert--gold { background: var(--gold-050); box-shadow: inset 0 0 0 1px var(--gold-200); color: var(--gold-700); }
.alert--teal { background: var(--teal-050); box-shadow: inset 0 0 0 1px rgba(13,148,136,.18); color: var(--teal-800); }
/* The base alert is already rose (blocked/wrong); named for intent at the call site. */
.alert--rose { background: var(--rose-050); box-shadow: inset 0 0 0 1px var(--rose-100); color: var(--rose-700); }

.confirm {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--teal-050);
  box-shadow: inset 0 0 0 1px rgba(13,148,136,.18);
  font-size: var(--fs-sm); font-weight: 600; color: var(--teal-800);
  animation: confirm-in var(--t-slow) var(--ease-out) both;
}
.confirm svg { width: 17px; height: 17px; flex: 0 0 17px; }
.confirm--gold { background: var(--gold-050); box-shadow: inset 0 0 0 1px var(--gold-200); color: var(--gold-700); }

@keyframes confirm-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Django's messages framework, in the same language as .alert. */
.messages { display: grid; gap: var(--sp-3); margin: 0 0 var(--sp-5); }
.messages li {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-sunk);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-700);
  overflow-wrap: anywhere;
}
.messages li.success { background: var(--teal-050); box-shadow: inset 0 0 0 1px rgba(13,148,136,.18); color: var(--teal-800); }
.messages li.error   { background: var(--rose-050); box-shadow: inset 0 0 0 1px var(--rose-100); color: var(--rose-700); }
.messages li.warning { background: var(--gold-050); box-shadow: inset 0 0 0 1px var(--gold-200); color: var(--gold-700); }

/* Why the pharmacy sent a prescription back. */
.decline-reason {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--rose-050);
  box-shadow: inset 0 0 0 1px var(--rose-100);
  color: var(--rose-700); font-size: var(--fs-sm);
}

/* An empty screen should say what to do next, not just that it is empty. */
.empty {
  display: grid; place-items: center; gap: var(--sp-3);
  padding: var(--sp-7) var(--sp-5);
  text-align: center;
}
.empty svg { width: 28px; height: 28px; color: var(--ink-300); }
.empty h3 { font-size: var(--fs-body); }
.empty p { font-size: var(--fs-sm); color: var(--text-muted); max-width: 40ch; }
.empty p + p { margin-top: calc(-1 * var(--sp-1)); }

/* --- htmx request state ----------------------------------------------- */

.htmx-indicator { opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request .btn-label { opacity: .55; }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.swap-in { animation: swap-in var(--t-mid) var(--ease-out) both; }
@keyframes swap-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* --- Scroll reveal ---------------------------------------------------- */

.reveal { opacity: 0; transform: translateY(14px); }
.reveal.is-in { opacity: 1; transform: none; transition: opacity 620ms var(--ease-out), transform 620ms var(--ease-out); }
.reveal-d1 { transition-delay: 80ms; }
.reveal-d2 { transition-delay: 160ms; }
.reveal-d3 { transition-delay: 240ms; }

/* --- Motion and print ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  body { background: #fff; }
  .panel, .card { box-shadow: none; border: 1px solid var(--line); }
}
