:root {
  --ink: #15181c; --ink-lede: #333333; --muted: #5b6570; --rule: #d9dee4;
  --field-border: #8a949e; --accent: #0f6b5c; --accent-soft: #e7f2ef;
  --accent-press: #0b5247; --ink-press: #2a2f36; --danger: #a33;
  --bg: #fbfbfa; --surface: #ffffff;
  --pill-neutral: #eef1f4; --pill-warning: #fdf3e3; --warning-ink: #8a5a12;
  --pill-danger: #fbeceb; --alert-border: #eccfcb; --warn-border: #efdcbb;
  --notice-border: #cfe3dd; --edge-warm: #e6e3dc;
}
* { box-sizing: border-box; }
/* a hidden control stays hidden: `.btn` and friends set display, and an author
   display rule beats the user-agent `[hidden] { display: none }` */
[hidden] { display: none !important; }
/* Thai type, self-hosted from our own origin (~113 KB, SIL OFL, see
   OFL-NotoSansThai.txt): the looped cut for anything read through, the loopless cut
   for display. No font CDN, so the page that takes a patient's consent does not hand
   their IP to a third party. `font-display: swap` keeps the form usable while the
   face loads; the OS stack behind it still renders Thai if the request fails. */
@font-face {
  font-family: "Noto Sans Thai Looped"; font-style: normal; font-weight: 400 700;
  font-display: swap; src: url("/assets/noto-sans-thai-looped-thai.woff2") format("woff2"); /* variable, wght 100-900 */
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Noto Sans Thai Looped"; font-style: normal; font-weight: 400 700;
  font-display: swap; src: url("/assets/noto-sans-thai-looped-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Noto Sans Thai"; font-style: normal; font-weight: 400 700;
  font-display: swap; src: url("/assets/noto-sans-thai-thai.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Noto Sans Thai"; font-style: normal; font-weight: 400 700;
  font-display: swap; src: url("/assets/noto-sans-thai-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Noto Sans Thai Looped", "Noto Sans Thai", "Thonburi", "Sathu", "Leelawadee UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.6;
}
/* display type stays loopless: headings are read at a glance, prose is read through */
h1, h2, h3, .brand, .hero-copy h1, .price, .rec-time {
  font-family: "Noto Sans Thai", "Thonburi", "Sathu", "Leelawadee UI", system-ui, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.3; margin: 0 0 .4rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3 { font-size: .98rem; margin: 0 0 .4rem; }
.top {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 6px 16px;
  padding: 14px 22px; background: #fff; border-bottom: 1px solid var(--rule);
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); letter-spacing: .01em; }
.top nav { display: flex; gap: 16px; align-items: center; font-size: .92rem; white-space: nowrap; }
.top nav > a, .top .brand { display: inline-flex; align-items: center; min-height: 44px; }
/* the patient's step belongs to the patient: the doctor's nav (and account menu) leaves
   the hand-off screen, the brand stays, and the back link in the sheet restores it */
body.patient-step .top nav { display: none; }

/* the shell: the next action is always one tap, the account folds away */
.nav-new {
  color: var(--ink); font-weight: 600; text-decoration: none;
  border-bottom: 2px solid var(--ink); padding-bottom: 1px;
}
.nav-new:hover { color: var(--accent); border-color: var(--accent); }
.acct { position: relative; }
.acct > summary {
  cursor: pointer; list-style: none; color: var(--muted);
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; max-width: 20rem;
}
.acct-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct > summary::-webkit-details-marker { display: none; }
.acct > summary::after {
  content: ""; display: inline-block; vertical-align: middle; margin-left: 6px;
  border: 4px solid transparent; border-top-color: currentColor;
}
.acct[open] > summary { color: var(--ink); }
.acct-menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 20;
  min-width: 190px; padding: 6px; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--rule); border-radius: 6px;
}
.acct-menu a, .acct-menu button {
  display: block; white-space: normal; padding: 9px 10px; border-radius: 4px;
  text-align: left; text-decoration: none; color: var(--ink); font-size: .92rem;
}
.acct-menu a:hover, .acct-menu button:hover { background: var(--bg); }
.acct-menu button { width: 100%; background: none; border: 0; font: inherit; cursor: pointer; }
@media (max-width: 560px) {
  .nav-new { display: none; }
  /* the shell's link rule out-specifies the bare class; the phone still hides it */
  .top nav > a.nav-new { display: none; }
}
main { max-width: 920px; margin: 0 auto; padding: 26px 20px 60px; }
main p, main li { text-wrap: pretty; }
.card {
  background: #fff; border: 1px solid var(--rule); border-radius: 6px;
  padding: 22px; margin: 0 0 16px;
}
.card.narrow { max-width: 440px; margin: 40px auto; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin: 10px 0 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
label { display: block; font-size: .92rem; margin: 10px 0; }
label input, label select {
  display: block; width: 100%; margin-top: 5px; padding: 11px 10px;
  border: 1px solid var(--field-border); border-radius: 4px; font: inherit; background: #fff;
}
label.check { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; }
label.check input { width: auto; margin: 5px 0 0; flex: none; }
/* a consent row is a thumb target on a phone, not a mouse target */
@media (max-width: 640px) {
  /* the tick stays aligned to the first line of a long Thai consent clause */
  label.check { min-height: 44px; align-items: flex-start; margin: 2px 0; padding: 10px 0; }
  label.check input { margin: 4px 0 0; }
}
/* one green means press this: the primary action is the accent on every screen */
.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 4px;
  padding: 10px 16px; min-height: 44px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-press); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.small { padding: 6px 11px; font-size: .85rem; }
/* a second action that is not the next step: ink, never a second green */
.btn.secondary { background: var(--ink); }
.btn.secondary:hover { background: var(--ink-press); }
/* the one destructive action: a brick, not a second green */
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #8a2c2c; }
/* LINE is a door, not the product's own accent: its brand green, with ink text so the
   label clears WCAG AA (white on #06c755 is about 2.3:1, which is not readable). */
.btn.line { background: #06c755; color: #08240f; }
.btn.line:hover { background: #05b04c; }
.btn.line:focus-visible { outline-color: var(--ink); }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.link.danger { color: var(--danger); }
.inline { display: inline; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.error { color: var(--danger); font-weight: 600; }
.empty { color: var(--muted); border: 1px dashed var(--rule); padding: 18px; text-align: center; }
.pill { font-size: .78rem; padding: 2px 9px; border-radius: 99px; background: var(--pill-neutral); white-space: nowrap; }
.pill.ready { background: var(--accent-soft); color: var(--accent); }
.pill.error, .pill.withdrawn { background: var(--pill-danger); color: var(--danger); }
.pill.transcribing, .pill.packing, .pill.draft, .pill.expired { background: var(--pill-warning); color: var(--warning-ink); }
table.list { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .94rem; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: .82rem; padding: 8px 6px; border-bottom: 1px solid var(--rule); }
table.list td { padding: 10px 6px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.right { text-align: right; }
.hero { padding: 20px 0 10px; }
.kicker { color: var(--accent); font-weight: 700; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; }
.lede { font-size: 1.06rem; max-width: 42rem; color: var(--ink-lede); }
.cta { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin: 20px 0 8px; }
/* the doorway's terms of entry: body size and ink, never a footnote */
.fact { font-size: 1rem; color: var(--ink); margin: 6px 0 0; }
.pricing { margin: 46px 0 10px; }
.pricing h2 { font-size: 1.45rem; line-height: 1.3; }
.pricing table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--rule); }
/* a two-column table, not a full-bleed grid: capped, and flush with the column's left edge */
@media (min-width: 760px) {
  .pricing table { max-width: 34rem; margin-left: 0; margin-right: auto; }
}
.pricing th, .pricing td { padding: 10px 12px; border-bottom: 1px solid var(--rule); text-align: left; }
/* a row label is a header for assistive tech, not a heading on the page */
.pricing tbody th { font-weight: 400; }
.sig canvas { border: 1px solid var(--rule); border-radius: 4px; background: #fff; touch-action: none; max-width: 100%; }
fieldset { border: 1px solid var(--rule); border-radius: 4px; padding: 8px 14px 12px; margin: 12px 0; }
legend { font-size: .86rem; color: var(--muted); padding: 0 6px; }
ul.scopes { list-style: none; padding: 0; margin: 4px 0; }
ul.scopes li { margin: 3px 0; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .86rem; }
.timeline li { padding: 5px 0; border-bottom: 1px dotted var(--rule); }
.foot { text-align: center; color: var(--muted); font-size: .86rem; padding: 18px; }
.ok { color: var(--accent); font-weight: 600; }
.price-row { display: flex; align-items: baseline; gap: 8px 16px; flex-wrap: wrap;
  margin: 10px 0 18px; padding: 16px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.price-row .price { flex: 0 0 auto; }
/* the annual prepay sits under the monthly price: one line of terms, one button */
.annual-offer { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px;
  flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
.annual-offer > div { display: grid; gap: 2px; min-width: 0; }
.price { font-size: 2.25rem; font-weight: 700; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.pay-qr { display: flex; gap: 20px; align-items: center; margin: 14px 0 18px; flex-wrap: wrap;
  padding: 16px; background: var(--bg); border: 1px solid var(--rule); border-radius: 6px; }
.pay-qr .qr { background: #fff; border: 1px solid var(--rule); padding: 8px; }
.pay-qr .qr svg { display: block; width: 180px; height: 180px; }

/* inviter page — a phone screen, not a dashboard */
.invite-row { padding: 16px; }
.share-field {
  display: block; width: 100%; margin: 8px 0; padding: 10px 11px;
  border: 1px dashed var(--rule); border-radius: 4px; font: inherit;
  font-size: .88rem; color: var(--muted); background: var(--bg);
}
.row-gap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1 1 200px; margin: 0; }
details summary { cursor: pointer; }
.qr.small svg { width: 150px; height: 150px; }
.notice {
  background: var(--accent-soft); border: 1px solid var(--notice-border);
  padding: 10px 12px; border-radius: 4px; margin: 12px 0 18px;
}

/* an invite link is read on a phone, never scanned on the sender's own screen */
.btn.wide { display: block; width: 100%; max-width: 26rem; text-align: center; min-height: 48px;
  padding: 13px 16px; font-size: 1rem; }
.invite-link-label { margin: 12px 0 4px; font-size: .86rem; color: var(--muted); }
.invite-link {
  display: block; padding: 10px 11px; border-radius: 4px; background: var(--bg);
  border: 1px solid var(--field-border); color: var(--ink); font-size: .92rem; line-height: 1.45;
  word-break: break-all; user-select: all; -webkit-user-select: all;
}
.invite-row .small { font-size: .95rem; }
.invite-row.fresh { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.invite-ok { background: var(--accent-soft); padding: 8px 10px; border-radius: 4px; }
.create-more { padding: 16px; }
.create-more summary { font-weight: 600; cursor: pointer; }

/* landing — the document is the argument, so it appears before any feature list */
.sample { margin: 46px 0 10px; }
.sample h2 { font-size: 1.45rem; line-height: 1.3; }
.sample .lede { margin-bottom: 22px; }
/* the set: page 1 is the hero; these are the pages behind it */
.doc-notes { max-width: 40rem; margin: 0 0 26px; }
.doc-strip-title { font-size: 1rem; margin: 0 0 10px; }
.doc-strip {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px; margin: 0; align-items: start;
}
.doc-page { margin: 0; min-width: 0; }
.doc-open { display: block; border-radius: 6px; }
.doc-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.doc-page .doc-open img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--rule); border-radius: 6px; background: #fff;
}
.doc-page figcaption { font-size: .86rem; color: var(--muted); padding-top: 9px; }
/* the transcript is a readable excerpt, not a full A4 page shrunk to a thumbnail */
.doc-transcript .transcript-card {
  background: #fff; border: 1px solid var(--rule); border-radius: 6px; padding: 16px;
}
.transcript-kicker { margin: 0 0 8px; color: var(--muted); font-size: .78rem; }
.transcript-lines { list-style: none; margin: 0; padding: 0; }
.transcript-lines li {
  display: grid; grid-template-columns: 42px 62px minmax(0, 1fr); gap: 8px;
  align-items: baseline; padding: 8px 0; border-top: 1px solid var(--rule);
  font-size: .92rem; line-height: 1.55;
}
.transcript-lines li:first-child { border-top: 0; }
.tx-time { color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; }
.tx-who { font-weight: 700; font-size: .86rem; }
.tx-text { min-width: 0; }
.transcript-more { margin: 10px 0 0; color: var(--muted); font-size: .86rem; }
.doc-swipe { display: none; }
@media (max-width: 759px) {
  .doc-swipe { display: block; margin: 8px 0 0; color: var(--muted); font-size: .86rem; }
}
@media (max-width: 560px) {
  .transcript-lines li { grid-template-columns: 42px minmax(0, 1fr); }
  .tx-who { grid-column: 2; }
  .tx-text { grid-column: 1 / -1; padding-left: 50px; }
}
.doc-notes h3 { font-size: 1rem; margin: 0 0 4px; }
.doc-notes dl { margin: 0; }
.doc-notes dl > div { padding: 14px 0; border-top: 1px solid var(--rule); }
.doc-notes dl > div:first-child { border-top: 0; padding-top: 6px; }
.doc-notes dt { font-weight: 700; font-size: .95rem; }
.doc-notes dd { margin: 3px 0 0; color: var(--muted); font-size: .95rem; line-height: 1.62; text-wrap: pretty; }
.doc-notes code, .chain code {
  font-family: ui-monospace, Menlo, monospace; font-size: .86em;
  background: var(--bg); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px;
}

/* the chain: four stops on one hairline, a green dot at each stop */
.chain { margin: 46px 0 10px; }
.chain h2 { font-size: 1.45rem; line-height: 1.3; margin-bottom: 6px; }
.chain-list {
  list-style: none; padding: 0; margin: 26px 0 12px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px;
}
.chain-list li { position: relative; padding-top: 20px; border-top: 1px solid var(--rule); }
.chain-list li::before {
  content: ""; position: absolute; top: -4px; left: 0;
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}
.chain-list .glyph { display: block; width: 26px; height: 26px; color: var(--ink); margin-bottom: 10px; }
.chain-list strong { display: block; font-size: .98rem; margin-bottom: 3px; }
.chain-list span { display: block; color: var(--muted); font-size: .86rem; line-height: 1.55; }
/* the chain ends on the action it describes: one line of ink, then the button */
.chain-cta { margin: 20px 0 0; }
.chain-ask { margin: 0 0 10px; color: var(--ink); font-size: 1rem; line-height: 1.6; }

/* on a phone the set is a strip: both pages stay legible and snap one at a time */
@media (max-width: 759.98px) {
  .doc-strip {
    display: flex; gap: 14px; overflow-x: auto;
    scroll-snap-type: x mandatory; scroll-padding-inline: 20px;
    -webkit-overflow-scrolling: touch;
    margin-inline: -20px; padding: 2px 20px 14px;
  }
  .doc-page { flex: 0 0 78vw; scroll-snap-align: start; }
}
/* the shell narrows its page padding here; the strip follows it edge to edge */
@media (max-width: 560px) {
  .doc-strip { margin-inline: -16px; padding-inline: 16px; scroll-padding-inline: 16px; }
}

/* where the data is: three facts on hairlines, no card, no shadow, no new accent */
.where { margin: 46px 0 10px; }
.where h2 { font-size: 1.45rem; line-height: 1.3; margin-bottom: 6px; }
.where-list { margin: 0; max-width: 46rem; }
.where-list > div { padding: 14px 0; border-top: 1px solid var(--rule); }
.where-list > div:first-child { border-top: 0; padding-top: 6px; }
.where-list dt { font-weight: 700; font-size: .95rem; }
.where-list dd { margin: 3px 0 0; color: var(--muted); font-size: .95rem; line-height: 1.62; text-wrap: pretty; max-width: 65ch; }
.where-ask { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--rule); font-size: 1rem; line-height: 1.6; max-width: 46rem; }
.where-pending { margin: 8px 0 0; font-size: .95rem; color: var(--muted); max-width: 46rem; }
.where-pending a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; }
@media (max-width: 760px) {
  .chain-list { grid-template-columns: 1fr; gap: 0; }
  .chain-list li { padding: 16px 0 16px 0; border-top: 1px solid var(--rule); }
  .chain-list li::before { top: 22px; left: -2px; }
  .chain-list li { padding-left: 18px; }
}

/* one authored moment: the chain stops arrive in reading order */
@media (prefers-reduced-motion: no-preference) {
  .chain-list li { animation: stop-in .5s cubic-bezier(.16,1,.3,1) both; }
  .chain-list li:nth-child(2) { animation-delay: .07s; }
  .chain-list li:nth-child(3) { animation-delay: .14s; }
  .chain-list li:nth-child(4) { animation-delay: .21s; }
  @keyframes stop-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  html { scroll-behavior: smooth; }
}

section[id] { scroll-margin-top: 24px; }

.closing { margin: 46px 0 8px; padding-top: 26px; border-top: 1px solid var(--rule); }
.closing h2 { font-size: 1.45rem; line-height: 1.3; margin-bottom: 6px; }
.closing .muted { margin: 0 0 16px; }
.closing .btn { margin-top: 4px; }
/* the last ask is the widest action on the page: the whole column, label at its edge */
.closing .btn.wide { max-width: none; min-height: 48px; text-align: left; }

/* the code a friend may hear over the phone, grouped for saying aloud */
.invite-code-line { margin: 0 0 12px; font-size: .92rem; color: var(--muted); }
.invite-code {
  font-family: ui-monospace, Menlo, monospace; font-size: 1rem; letter-spacing: .08em;
  color: var(--ink); background: var(--bg); border: 1px solid var(--rule);
  border-radius: 4px; padding: 2px 8px; margin-left: 4px;
}

/* recording inside the visit: one button, one timer, no file to move */
.recorder { margin: 14px 0 6px; }
.rec-stop { background: var(--danger); }
.rec-time {
  font-family: ui-monospace, Menlo, monospace; font-size: 2rem; letter-spacing: .08em;
  margin: 12px 0 0; color: var(--ink);
}
.rec-status { margin: 8px 0 0; min-height: 1.4em; font-size: .95rem; color: var(--muted); }
.rec-status[data-tone="error"] { color: var(--danger); }
.rec-status[data-tone="ok"] { color: var(--accent); }
.rec-status[data-tone="warn"] { color: var(--warning-ink); }
.record-fallback { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--rule); }

/* the document is the photograph: one artefact, one shadow, one crop */
.hero { padding: 34px 0 8px; }
.hero-copy h1 {
  font-size: clamp(2rem, 3.6vw, 3.1rem); line-height: 1.3;
  text-wrap: balance;
}
.hero-copy .lede { max-width: 34rem; font-size: 1.08rem; }
.hero-doc { margin: 28px 0 0; }
.hero-doc figcaption { font-size: .86rem; color: var(--muted); padding-top: 10px; }
@media (min-width: 900px) {
  .hero {
    display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, .82fr);
    grid-template-areas: "copy doc" "terms doc";
    gap: 0 56px; align-items: start; padding: 52px 0 18px;
  }
  .hero-copy { grid-area: copy; }
  .entry-terms { grid-area: terms; }
  .hero-doc { grid-area: doc; align-self: center; margin: 0; }
}
/* the proof is a strip, not a page: two decision rows, one hash, the draft stamp */
.hero-proof {
  background: #fff; border: 1px solid var(--edge-warm); border-radius: 4px;
  box-shadow: 0 28px 56px -28px rgba(21,24,28,.42);
  padding: 20px 22px 16px;
}
.hero-proof-kicker { margin: 0 0 12px; color: var(--muted); font-size: .86rem; letter-spacing: .04em; }
.hero-proof-hash {
  margin: 12px 0 0; padding: 10px 12px; min-width: 0;
  border: 1px solid var(--rule); background: var(--bg);
}
.hero-proof-hash span { display: block; margin-bottom: 2px; color: var(--muted); font-size: .86rem; }
.hero-proof-hash code {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); font-family: ui-monospace, Menlo, monospace;
  font-size: .86rem; line-height: 1.45;
}
.hero-proof-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px;
}
.hero-proof-foot .doc-stamp { margin: 0; }
.hero-proof-version { color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .hero-proof { padding: 16px 16px 12px; }
}
.doc-scopes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.doc-scope {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 7px 0; border-bottom: 1px solid var(--rule);
  font-size: 1.0625rem; line-height: 1.5;
}
.doc-mark { flex: none; width: 1.05em; color: var(--ink); }
.doc-scope.declined { color: var(--muted); }
/* The state is a column, not a sentence: every row says what was decided, so the
   unchecked box is not the only difference between "refused" and "granted". */
.doc-state {
  margin-left: auto; padding-left: 10px; flex: none;
  color: var(--muted); font-size: .82rem; line-height: 1.5; white-space: nowrap;
}
.doc-stamp {
  display: inline-block; margin: 12px 0 0; padding: 3px 9px;
  border: 1px dashed var(--warn-border); border-radius: 4px;
  background: var(--pill-warning); color: var(--warning-ink); font-size: .86rem;
}
.doc-hash-note { margin: 8px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.doc-hash-note code {
  font-family: ui-monospace, Menlo, monospace; font-size: .86em;
  background: var(--bg); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px;
}
.doc-full { display: inline-flex; align-items: center; min-height: 44px; white-space: nowrap; }
/* the terms of entry sit under the hero copy: on a phone before the proof, on a desk
   in the copy's second grid row with the document spanning both */
.entry-terms {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 24px;
  margin: 26px 0 8px; padding-top: 16px; border-top: 1px solid var(--rule);
}
.entry-terms .fact { margin: 0; font-size: 1rem; color: var(--ink); }
@media (max-width: 640px) {
  .entry-terms { grid-template-columns: 1fr; gap: 4px; }
}
/* the only action a doctor can complete today is a section, not a promo strip */
.kit-invite {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  margin: 46px 0 10px; padding-top: 26px; border-top: 1px solid var(--rule);
}
.kit-invite-copy { max-width: 42rem; }
.kit-invite h2 { font-size: 1.45rem; line-height: 1.3; margin: 0 0 4px; }
.kit-invite .lede { margin: 0; font-size: 1.06rem; }
.kit-invite .btn { flex: none; }
@media (max-width: 640px) {
  .kit-invite { display: block; }
  .kit-invite .btn { width: 100%; margin-top: 16px; min-height: 48px; text-align: center; }
}
@media (prefers-reduced-motion: no-preference) {
  .hero-doc { animation: sheet-in .7s cubic-bezier(.16,1,.3,1) both; }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
}

/* ---- app: the record list (dashboard) ---- */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; flex-wrap: wrap; margin: 6px 0 26px;
}
.page-head h1 { font-size: 1.6rem; line-height: 1.25; margin: 0; }
.page-meta { margin: 6px 0 0; color: var(--muted); font-size: .95rem; }
.page-head .btn { flex: 0 0 auto; }
/* one next action at the top: where a page-head carries it, the shell link yields */
body:has(.page-head) .nav-new { display: none; }
.page-foot-action { margin: 22px 0 0; font-size: .95rem; }

.visit-list { border-top: 2px solid var(--ink); }
.visit-head, .visit-row {
  display: grid; grid-template-columns: minmax(0, 1.6fr) 150px 150px 104px;
  gap: 16px; align-items: center;
}
.visit-head { padding: 10px 0 8px; color: var(--muted); font-size: .86rem; }
.visit-head span:last-child { text-align: right; }
.visit-rows { list-style: none; margin: 0; padding: 0; }
.visit-row { position: relative; padding: 16px 0; border-top: 1px solid var(--rule); }
.visit-id { display: block; text-decoration: none; color: var(--ink); }
/* the whole row is the target; the download link sits above it */
.visit-id::after { content: ""; position: absolute; inset: 0; }
.visit-row:hover .visit-name { color: var(--accent); }
.visit-name { display: block; font-weight: 600; font-size: 1.0625rem; line-height: 1.4; }
.visit-sub { display: block; margin-top: 2px; color: var(--muted); font-size: .86rem; }
.visit-date { color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.visit-status { min-width: 0; }
.visit-action { text-align: right; }
.row-action { position: relative; z-index: 1; display: inline-flex; align-items: center; min-height: 44px; padding: 8px 0 8px 12px; font-size: .92rem; }

.empty-state { padding: 26px 0 10px; }
.empty-title { font-size: 1.15rem; margin: 0 0 6px; }
.empty-state .muted { margin: 0; max-width: 34rem; }
/* the first screen is a first lesson: one green action inside it, then the same four
   steps the landing sells, in one compact row that opens to a 2x2 grid on a phone */
.empty-lede .btn { display: inline-flex; margin-top: 14px; }
.empty-chain { margin: 28px 0 0; padding-top: 20px; border-top: 1px solid var(--rule); }
.empty-chain-title { font-size: 1.05rem; margin: 0 0 14px; }
.chain-list--compact { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0; }
.chain-list--compact li { padding-top: 14px; }
.chain-list--compact strong { font-size: .92rem; margin: 0; }
@media (min-width: 701px) {
  .empty-lede .btn { margin: 0 0 0 8px; vertical-align: middle; }
}
@media (max-width: 759.98px) {
  .chain-list--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 14px; }
  .chain-list--compact li { padding: 10px 0 0; }
}
@media (max-width: 700px) {
  .empty-lede .btn {
    display: block; width: 100%; margin-top: 14px; text-align: center; min-height: 48px;
  }
}

@media (max-width: 700px) {
  .page-head { margin-bottom: 22px; align-items: stretch; }
  .page-head .btn { width: 100%; text-align: center; min-height: 48px; padding: 13px 16px; }
  .visit-head { display: none; }
  .visit-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "id status" "date action";
    gap: 2px 12px; padding: 14px 0;
  }
  .visit-id { grid-area: id; }
  .visit-date { grid-area: date; font-size: .86rem; }
  .visit-status { grid-area: status; justify-self: end; align-self: start; }
  .visit-action { grid-area: action; justify-self: end; }
  .row-action { padding: 6px 0 0 12px; }
}

/* ---- app: the case file (visit) ---- */
.backlink {
  display: inline-flex; align-items: center; min-height: 44px;
  margin: 0 0 10px; color: var(--muted);
  text-decoration: none; font-size: .92rem;
}
.backlink:hover { color: var(--ink); }
/* the case masthead: whose case, and is it signed — the two questions the doctor asks */
.case-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap;
  margin: 0 0 26px; padding-bottom: 18px; border-bottom: 1px solid var(--rule);
}
.case-head h1 { font-size: clamp(1.6rem, 3.4vw, 2rem); line-height: 1.22; margin: 0; }
.case-head .pill { margin-top: 6px; }
.case-meta { margin: 8px 0 0; color: var(--muted); font-size: .95rem; }

/* the pack card is the one object on the page that behaves like a document */
.sheet {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
  padding: 24px 24px 22px; margin: 0 0 34px;
}
.sheet h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 2px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.action-lead { margin: 8px 0 18px; color: var(--ink-lede); font-size: 1rem; line-height: 1.6; max-width: 42rem; }
.sheet-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
/* the draft's way to the confirmation is a route, not the action: ink, never the green
   that means "press this" — the one green on the page is the confirm button itself */
.sheet-actions .ink-link {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--ink); text-decoration: underline;
}
.sheet-actions [data-share-status] { flex: 1 1 100%; margin: 0; }
.sheet-actions [data-share-status]:empty { display: none; }
/* the acknowledgement gets its own row: it is read before the button is pressed */
.confirm-form { flex: 1 1 100%; }
.confirm-form label.check { margin: 0 0 12px; max-width: 42rem; font-size: 1.0625rem; line-height: 1.5; }
.confirm-form .btn { margin-top: 2px; }
/* the review dock: on a phone, the way to the confirmation at the end of the evidence.
   A surface and a hairline, not a second green button — the row is a link, never a submit. */
.case-review-dock { display: none; }
@media (max-width: 1099.98px) {
  .case-review-dock {
    display: block;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--rule);
  }
  .case-review-dock-link {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 48px; text-decoration: none; color: var(--ink);
  }
  .case-review-dock-counts {
    display: flex; flex-wrap: wrap; gap: 2px 10px;
    color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums;
  }
  .case-review-dock-action {
    flex: none; color: var(--accent); font-size: .95rem; font-weight: 600; white-space: nowrap;
  }
  /* the fixed row must never sit over the timeline it follows, or over the footer */
  body:has(.case-review-dock:not([hidden])) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  /* the hidden attribute has to beat the class's display, or the dock never leaves */
  .case-review-dock[hidden] { display: none; }
}
.sheet .recorder, .sheet .notes-form { max-width: 460px; }
/* a machine value reads as a receipt line, not as prose */
.hash-line {
  margin: 18px 0 0; padding: 12px 14px;
  background: var(--bg); border: 1px dashed var(--rule); border-radius: 4px;
  color: var(--muted); font-size: .86rem;
}
.hash-line .mono { font-family: ui-monospace, Menlo, monospace; color: var(--ink); }
.hash-title { margin: 0 0 2px; }
.hash-full { margin: 0 0 6px; font-size: .86rem; line-height: 1.5; word-break: break-all; user-select: all; }
.utt-legend { margin: 8px 0 0; }
.notes-input {
  display: block; width: 100%; padding: 11px 10px; margin: 0 0 12px;
  border: 1px solid var(--field-border); border-radius: 4px; background: #fff;
  font: inherit; font-size: .95rem; line-height: 1.55; resize: vertical;
}
/* the clinic's template editor: same field contract as the note, one per word block */
.template-edit textarea, .template-review input[type="text"] {
  display: block; width: 100%; padding: 11px 10px; margin-top: 5px;
  border: 1px solid var(--field-border); border-radius: 4px; background: #fff;
  font: inherit; font-size: 1rem; line-height: 1.55; resize: vertical;
}
.template-edit label { margin: 12px 0; }
.template-edit .btn, .template-review .btn { margin-top: 8px; }
.template-preview .patient-facts { margin-top: 4px; }

.banner { margin: 0 0 24px; padding: 13px 15px; border-radius: 6px; font-size: .95rem; font-weight: 600; }
.banner.alert { background: var(--pill-danger); border: 1px solid var(--alert-border); color: var(--danger); }
.banner.warn { background: var(--pill-warning); border: 1px solid var(--warn-border); color: var(--warning-ink); }

.case-section { padding: 28px 0 6px; border-top: 1px solid var(--rule); }
/* the 44px floor applies to text controls too, not only to buttons */
.case-section .link, .sheet-actions .link, .withdraw .link, .consent-meta .link,
.utt-actions .link {
  display: inline-flex; align-items: center; min-height: 44px;
}
.case-section h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { margin-bottom: 0; }

/* the episode timeline (#333): one hairlined row per procedure, never nested cards */
.case-episodes { padding-top: 0; border-top: 0; padding-bottom: 10px; }
/* a confirmed case with nothing to add: the section is one hairline line after the pack */
.case-episodes-empty { margin: 0; padding-top: 12px; border-top: 1px solid var(--rule); }
.episode-list { margin: 6px 0 18px; border-top: 1px solid var(--rule); }
.episode { padding: 16px 0 18px; border-bottom: 1px solid var(--rule); }
.episode-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.episode-letter {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 1px solid var(--rule); border-radius: 4px;
  font-family: "Noto Sans Thai", "Thonburi", "Sathu", system-ui, sans-serif;
  font-weight: 700; font-size: .95rem; color: var(--muted);
}
.episode-heading { flex: 1 1 12rem; min-width: 0; }
.episode-name { font-size: 1.15rem; margin: 0 0 2px; line-height: 1.35; }
.episode-meta { margin: 0; }
.episode-head .pill { margin-top: 4px; }
.episode-times { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 10px 0 0; padding: 0; list-style: none; }
.episode-times li {
  display: inline-flex; gap: 6px; align-items: baseline; margin: 0;
  padding: 2px 8px; border-radius: 4px; background: var(--pill-neutral); font-size: .95rem;
}
.episode-time-label { color: var(--muted); font-size: .86rem; }
.episode-order { margin: 10px 0 0; font-size: .95rem; line-height: 1.5; }
.episode-order.ok { color: var(--accent); }
.episode-order.warn { color: var(--warning-ink); }
.episode-order.muted { color: var(--muted); }
.episode-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.episode-actions .btn, .episode-actions .link {
  display: inline-flex; align-items: center; min-height: 44px;
}
.patient-card { margin-top: 12px; }
.patient-card > summary {
  display: flex; align-items: center; min-height: 44px; padding: 4px 0;
  color: var(--muted); font-size: .92rem; cursor: pointer;
}
.patient-card > summary { list-style: none; }
.patient-card > summary::-webkit-details-marker { display: none; }
.patient-card > summary::after {
  content: "⌄"; display: inline-block; margin-left: 6px; flex: none;
  color: var(--muted); font-size: .95em; line-height: 1;
}
.patient-facts { margin: 10px 0 0; }
.patient-facts > div { padding: 10px 0; border-top: 1px solid var(--rule); }
.patient-facts > div:first-child { border-top: 0; padding-top: 0; }
.patient-facts dt { font-size: .86rem; font-weight: 700; color: var(--muted); }
/* the patient's decision lines stay above the 17px floor */
.patient-facts dd { margin: 4px 0 0; font-size: 1.0625rem; line-height: 1.6; }
.card-list { margin: 4px 0 0; padding-left: 1.2rem; }
.card-list li { margin: 2px 0; }
.card-draft { margin: 0 0 8px; color: var(--warning-ink); }
.episode-add {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  margin: 14px 0 4px; padding-top: 14px; border-top: 1px solid var(--rule);
}
.episode-add label { flex: 1 1 18rem; margin: 0; }
.episode-add .btn { min-height: 44px; }
.episode-card-full {
  margin: 18px 0; padding: 16px 0;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.episode-refuse { margin-top: 22px; border-top: 1px solid var(--rule); }
.episode-refuse > summary {
  display: flex; align-items: center; min-height: 44px; color: var(--muted); font-size: .92rem;
  list-style: none;
}
.episode-refuse > summary::-webkit-details-marker { display: none; }
.episode-refuse > summary::after {
  content: "⌄"; display: inline-block; margin-left: 6px; flex: none;
  color: var(--muted); font-size: .95em; line-height: 1;
}
.episode-refuse .link { display: inline-flex; align-items: center; min-height: 44px; }
.episode-refuse-inline { margin: 0; }
.episode-refuse-inline > summary {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--danger); text-decoration: underline; cursor: pointer; font-size: .92rem;
  list-style: none;
}
.episode-refuse-inline > summary::-webkit-details-marker { display: none; }
.episode-refuse-inline > summary::after {
  content: "⌄"; display: inline-block; margin-left: 6px; flex: none;
  font-size: .95em; line-height: 1;
}
.episode-refuse-inline form { margin-top: 4px; }
.episode-refuse-inline .link { display: inline-flex; align-items: center; min-height: 44px; }
.agree-line { font-size: 1.0625rem; line-height: 1.6; }
/* the patient's one decision line gets a visible tick, not a 13px browser default */
label.check.agree-line input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
@media (max-width: 640px) {
  .episode-add { display: block; }
  .episode-add .btn { width: 100%; margin-top: 10px; }
  .episode-actions { gap: 10px; }
}

.consent-state { margin: 0 0 10px; font-size: 1.0625rem; font-weight: 600; line-height: 1.5; }
.consent-state.full { color: var(--accent); }
.consent-state.partial { color: var(--warning-ink); }
.consent-state.revoked { color: var(--muted); }
.consent-details summary {
  display: flex; align-items: center; min-height: 44px;
  padding: 4px 0; color: var(--muted); font-size: .92rem;
}
/* A disclosure that reads as a caption is not a control: the chevron is the affordance,
   and it turns when the clause opens. The native marker is removed for the same reason
   the row is a flex line. */
.consent-details > summary { list-style: none; }
.consent-details > summary::-webkit-details-marker { display: none; }
.consent-details > summary::after {
  content: "⌄"; display: inline-block; margin-left: 6px; flex: none; color: var(--muted);
  font-size: .95em; line-height: 1;
}
.consent-details[open] > summary::after { transform: rotate(180deg); }
.consent-details[open] summary { margin-bottom: 4px; }
.scope-list { list-style: none; margin: 0 0 14px; padding: 0; }
.scope-list li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--rule); font-size: .97rem;
}
.scope-list li:first-child { border-top: 0; }
.scope-mark { flex: none; width: 16px; display: inline-flex; justify-content: center; color: var(--accent); }
.scope-mark svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.refused { color: var(--ink); }
/* #5b6570 on #fbfbfa is 5.7:1 — not a faint grey. A refused scope is a state the record
   relies on: WCAG 1.4.11 asks 3:1 of an indicator, and the mark is text too, so 1.4.3 asks
   4.5:1. Both are measured by tests/ui-tokens.test.js (#35). */
.refused .scope-mark { color: var(--muted); }
.scope-state { margin-left: auto; color: var(--muted); font-size: .86rem; white-space: nowrap; }
.consent-meta { margin: 0 0 4px; color: var(--muted); font-size: .86rem; }
.withdraw { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--rule); }
.withdraw .small { margin: 6px 0 0; }
/* the case's destructive acts, after the evidence and the history, under one heading */
.case-manage { margin: 34px 0 0; padding-top: 20px; border-top: 2px solid var(--ink); }
.case-manage h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 4px; }
.case-manage .withdraw:first-of-type { margin-top: 8px; border-top: 0; padding-top: 0; }

/* ---- app: the transcript editor, one row per utterance ---- */
.utt-list { margin: 10px 0 0; border-top: 1px solid var(--rule); }
.utt { border-bottom: 1px solid var(--rule); }
.utt > summary {
  list-style: none; cursor: pointer; display: grid; align-items: baseline; gap: 4px 10px;
  grid-template-columns: 20mm 30mm minmax(0, 1fr) auto;
  grid-template-areas: "time who text act"; padding: 12px 0;
}
.utt > summary::-webkit-details-marker { display: none; }
.utt[open] > summary { padding-bottom: 6px; }
.utt-time { grid-area: time; font-family: ui-monospace, Menlo, monospace; font-size: .86rem; color: var(--muted); }
.utt-who { grid-area: who; font-weight: 700; font-size: .95rem; overflow-wrap: anywhere; }
.utt-text { grid-area: text; font-size: .95rem; overflow-wrap: anywhere; }
.utt-mark { color: var(--warning-ink); font-weight: 700; }
.utt > summary::after { grid-area: act; content: "แก้"; color: var(--accent); font-size: .86rem; justify-self: end; }
.utt[open] > summary::after { content: "ปิด"; }
.utt-body { padding: 0 0 16px 17mm; }
.utt-original { margin: 0 0 8px; line-height: 1.5; }
.utt-audio { display: block; width: 100%; margin: 0 0 12px; }
.speaker-id { margin-left: 6px; font-size: .78rem; color: var(--muted); }
.utt-was { display: block; margin-top: 3px; color: var(--muted); font-size: .86rem; font-weight: 400; overflow-wrap: anywhere; }
.utt-field { display: block; margin: 0 0 10px; }
.utt-textarea {
  display: block; width: 100%; padding: 10px; margin: 0;
  border: 1px solid var(--field-border); border-radius: 4px; background: #fff;
  font: inherit; font-size: .95rem; line-height: 1.6; resize: vertical;
}
.utt-reason { margin: 0 0 12px; font-size: .86rem; color: var(--muted); }
.utt-reason input {
  display: block; width: 100%; margin-top: 5px; padding: 8px 10px;
  border: 1px solid var(--field-border); border-radius: 4px; font: inherit; font-size: .92rem;
}
.utt-actions { display: flex; align-items: center; gap: 12px 14px; flex-wrap: wrap; }
.utt-actions .muted { font-size: .86rem; }
@media (max-width: 640px) {
  .utt > summary {
    grid-template-columns: 20mm minmax(0, 1fr) auto;
    grid-template-areas: "time who act" "text text text";
  }
  .utt-body { padding-left: 0; }
}

.speaker-list { margin: 0 0 16px; border-top: 1px solid var(--rule); }
.speaker-row {
  display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 14px;
  align-items: center; margin: 0; padding: 10px 0; border-bottom: 1px solid var(--rule);
}
.speaker-tag { font-size: .92rem; font-weight: 600; color: var(--ink); }
.speaker-field { display: block; }
.speaker-named { display: block; margin-top: 4px; font-size: .86rem; color: var(--muted); }
.speaker-row input { margin: 0; max-width: 380px; }
@media (max-width: 640px) {
  .speaker-row { grid-template-columns: 1fr; gap: 4px; }
}

.summary-body { max-width: 44rem; }
.summary-body h3 { font-size: .95rem; margin: 18px 0 4px; }
.summary-body .cc { margin: 4px 0 8px; font-size: 1.06rem; line-height: 1.6; color: var(--ink-lede); }
.summary-body ul.sum { margin: 4px 0 0; padding-left: 1.15rem; }
.summary-body ul.sum li { padding: 2px 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid; grid-template-columns: 156px minmax(0, 1fr);
  gap: 16px; align-items: baseline;
  padding: 9px 0; border-top: 1px solid var(--rule); font-size: .86rem;
}
.timeline li:first-child { border-top: 0; }
.timeline time { color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; }
.timeline-detail { color: var(--muted); font-size: .86rem; }
.event-type {
  font-family: ui-monospace, Menlo, monospace; font-size: .86rem; color: var(--ink);
}
@media (max-width: 640px) {
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
}

/* a processing state is the one animated moment on the case file */
.progress-rule {
  position: relative; overflow: hidden; height: 2px; margin: 4px 0 2px;
  background: var(--rule); border-radius: 2px;
}
@media (prefers-reduced-motion: no-preference) {
  .progress-rule::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 32%;
    background: var(--accent); animation: sweep 1.5s cubic-bezier(.45,0,.25,1) infinite;
  }
  @keyframes sweep { from { transform: translateX(-110%); } to { transform: translateX(360%); } }
}

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

/* focus belongs to the system, not the browser default */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:focus-visible { outline-color: var(--accent); outline-offset: 3px; }
.btn.secondary:focus-visible { outline-color: var(--accent); }

@media (max-width: 560px) {
  .acct > summary { max-width: 7rem; }
  .top { padding: 12px 16px; }
  main { padding: 20px 16px 48px; }
  /* the primary action gets the width; the text links get a 44px thumb row, and
     enough air between them that they do not read as one control */
  .cta { flex-direction: column; align-items: stretch; gap: 12px; margin-top: 18px; }
  .cta .btn { width: 100%; text-align: center; }
  .cta .link { display: inline-flex; align-items: center; min-height: 44px; padding: 0; }
}

/* ---- consent capture: one decision per line, the next action always in reach ---- */
.crumb { margin: 0 0 10px; font-size: .92rem; }
.crumb a { text-decoration: none; color: var(--muted); display: inline-flex; align-items: center; min-height: 44px; }
.crumb a:hover { color: var(--accent); }

.consent-sheet { padding: 26px 24px 0; }
/* The hand-off is the patient's screen: the clinic's masthead and the "back to the
   dashboard" crumb belong to the doctor's step and leave with it. The step heading
   below is the page's h1 in that state, so the patient's screen opens on their own
   title instead of "เก็บความยินยอมก่อนบันทึก". */
.consent-sheet.patient-step .consent-head { display: none; }
.consent-sheet.patient-step .consent-step[data-step="2"] {
  border-top: 0; margin-top: 0; padding-top: 0;
}
body.patient-step .crumb { display: none; }
/* Thai stacks vowels and tone marks above the baseline: negative tracking collides them */
.consent-head h1 { font-size: 1.6rem; line-height: 1.28; margin-bottom: .25rem; }
.consent-intro { margin: 4px 0 16px; max-width: 42rem; font-size: 1.0625rem; line-height: 1.6; }
.consent-meta {
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline;
  margin: 0; padding-top: 14px; border-top: 1px solid var(--rule);
  font-size: .86rem; color: var(--muted);
}

/* The notice at the decision: who controls the data, what is stored where, what leaves
   the country under which tick, for how long, and how to reach the clinic. It is a
   visible block, never a disclosure the patient has to open (#245). */
.consent-notice {
  margin: 0 0 22px; padding: 18px 20px 14px;
  border: 1px solid var(--rule); border-radius: 4px; background: var(--surface);
}
.notice-title { font-size: 1.125rem; line-height: 1.4; margin: 0 0 12px; }
.notice-facts { margin: 0; padding: 0; display: grid; gap: 9px; }
.notice-facts > div { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 12px; align-items: baseline; }
.notice-facts dt { color: var(--muted); font-size: .92rem; }
.notice-facts dd { margin: 0; font-size: 1.0625rem; line-height: 1.55; }
.notice-facts dd .link { display: inline-flex; align-items: center; min-height: 44px; }
.notice-foot { margin: 12px 0 0; }
@media (max-width: 480px) {
  .notice-facts > div { grid-template-columns: 1fr; gap: 2px; }
}

/* a fieldset is a section of the sheet, not a box drawn around it */
fieldset.form-section { border: 0; padding: 0; margin: 30px 0 0; min-width: 0; }
/* Thai is not an upper-case script and has no letter-spacing to give: the label is
   set by weight and a rule, not by tracked-out capitals. */
fieldset.form-section > legend {
  font-size: 1.0625rem; font-weight: 700; color: var(--ink);
  padding: 0; margin: 0 0 10px;
}

/* recording mode: two full-width rows, the choice is a row and not a radio dot */
ul.choice { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
ul.choice li { margin: 0; }
ul.choice label.check {
  display: flex; gap: 10px; align-items: flex-start;
  min-height: 56px; padding: 14px 16px; margin: 0;
  border: 1px solid var(--field-border); border-radius: 4px; background: #fff;
  font-size: 1.0625rem; line-height: 1.45;
}
ul.choice label.check:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
ul.choice label.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }

/* five purposes: each a line you can refuse without it turning into an error.
   `.purpose*`, not `.scope-*`: the visit page already owns `.scope-list li`. */
ul.purposes { list-style: none; margin: 0; padding: 0; }
.purpose { border-top: 1px solid var(--rule); }
.purpose:last-child { border-bottom: 1px solid var(--rule); }
.purpose[hidden] { display: none; }
/* two columns, not a flex row: the box owns 24px and the label wraps under itself in
   the second column at every width, so a long Thai label never runs under the checkbox.
   The `(จำเป็น)` marker is inline inside the label, so it stays at the end of the
   sentence instead of taking a line of its own. */
.purpose label.check {
  display: grid; grid-template-columns: 24px 1fr; column-gap: 11px; align-items: start;
  min-height: 56px; padding: 15px 2px; margin: 0; font-size: 1.0625rem; line-height: 1.5;
}
/* a 20px box on a 25.5px first line: 3px down puts its centre on the text's centre */
.purpose label.check input {
  width: 20px; height: 20px; margin-top: 3px; accent-color: var(--accent);
}
.purpose-label { display: block; grid-column: 2; min-width: 0; }
/* the (จำเป็น) marker is a status pill, not a word shrunk below its row: the pill's
   own class carries the size (the Thai-Size Rule allows 0.78rem for a pill), so the
   marker only needs the gap that keeps it off the label's last word */
.purpose .req { margin-left: 6px; }
/* the cross-border row is an ordinary hairline row: the consequence is a tag under the
   label, never a tint or an inset that reads as already chosen */
.purpose-tag { display: block; margin-top: 6px; font-size: .86rem; line-height: 1.45; color: var(--muted); }
/* the explanation is a rule for the whole list, so it sits above the list */
.purpose-note { margin: 0 14px 15px 35px; font-size: 1.0625rem; line-height: 1.5; color: var(--muted); }
.purpose-note--rule { margin: 0 0 14px; }
/* each purpose states its own consequence in place, so a refusal is a decision, not a
   mode switch; the recording row's escape control is a thumb target inside that note */
.purpose > .purpose-note { margin: 0 14px 12px 35px; }
.purpose-note .link { display: inline-flex; align-items: center; min-height: 44px; font-size: .95rem; text-align: left; }

/* who was in the room: chips, because it is a set, not a list of decisions */
ul.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
ul.chips li { margin: 0; }
ul.chips label.chip {
  display: inline-flex; gap: 7px; align-items: center;
  min-height: 44px; padding: 8px 14px; margin: 0; cursor: pointer;
  border: 1px solid var(--field-border); border-radius: 99px; background: #fff;
  font-size: 1rem; line-height: 1.3;
}
ul.chips label.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
ul.chips label.chip input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* the signature is the consent: give it a frame, and the clear action a quieter place */
.sig { border: 1px solid var(--rule); border-radius: 4px; background: #fff; padding: 14px; }
.sig canvas { display: block; width: 100%; height: auto; touch-action: none; background: #fff; }
.sig-foot {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--rule);
}
.sig-foot .link { display: inline-flex; align-items: center; min-height: 44px; }
/* WCAG 2.5.7: the typed path must not depend on script. The chosen method decides which
   block is visible, in CSS, so a browser with JS off still has a path that works — the
   canvas is script-driven, typing is not. Both blocks are in the markup, never hidden. */
.sig-methods:has(#sig-typed:checked) ~ [data-sig="drawn"],
.sig-methods:not(:has(#sig-typed:checked)) ~ [data-sig="typed"] { display: none; }

/* the next action reaches the thumb: docked while the sheet scrolls, above the safe area */
.consent-actions {
  position: sticky; bottom: 0; z-index: 5;
  margin: 28px -24px 0; padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--rule);
}
.consent-actions .btn { max-width: none; min-height: 48px; font-size: 1.0625rem; }
/* a dock action that is not ready is not a green button with the light off: it is a
   hairline slot that says "not yet", so the only green in view still means press this.
   Scoped to the dock — the global .btn:disabled keeps the rest of the app's contract. */
.consent-actions .btn:disabled {
  background: var(--surface); color: var(--muted); border: 1px solid var(--rule); opacity: 1;
}
/* the withdrawal reason is the record of why, not a note field: full width, body type */
.withdraw-reason {
  display: block; box-sizing: border-box; width: 100%; min-height: 96px; padding: 11px 10px;
  border: 1px solid var(--field-border); border-radius: 4px; background: var(--surface);
  font: inherit; font-size: 1rem; line-height: 1.6; resize: vertical;
}
/* the explicit cancel is not the phone hint: it stays beside the destructive submit */
.consent-cancel { margin: 6px 0 0; font-size: .86rem; color: var(--muted); }
.consent-cancel .link { display: inline-flex; align-items: center; min-height: 44px; }
.consent-actions .small { margin: 6px 0 0; }
/* the dock says what is still missing before it offers the signature; it is the dock's
   reason, so it reads at the 17px Patient Floor, not as a caption */
.consent-progress { margin: 0 0 8px; font-size: 1.0625rem; line-height: 1.5; color: var(--muted); }

/* the sheet is two states — the doctor's chart, then the patient's purposes. The one
   not in use is `hidden` (the global rule above), so no submit can cover the first
   field; the noscript style inside the form unhides both when there is no script. */
.consent-step { border-top: 1px solid var(--rule); margin-top: 18px; padding-top: 18px; }
.consent-step > .step-head { font-size: 1.25rem; line-height: 1.3; margin: 0 0 6px; }
/* The sheet moves focus to the step heading for a screen reader. The heading is
   tabindex="-1" — never in the tab ring — so the ring would only ever draw a box
   around a line of display type, reading as an empty field. */
.consent-step > .step-head:focus-visible {
  outline: none; text-decoration: underline 2px var(--accent); text-underline-offset: 6px;
}
.step-lede { margin: 4px 0 18px; max-width: 42rem; font-size: 1.0625rem; line-height: 1.6; }
.step-bundle { margin: -10px 0 20px; max-width: 42rem; font-size: 1.0625rem; line-height: 1.5; }
/* one visible way out of the "(จำเป็น)" bundle: a full-width 48px second action, not a
   14px link repeated under three rows */
.refuse-audio { margin: 22px 0 20px; padding-top: 16px; border-top: 1px solid var(--rule); }
.refuse-audio .btn { margin-top: 10px; max-width: none; }
.step-next { margin-top: 26px; }
/* the patient's own identity on the patient's step: the sheet names who is signing */
.patient-id { margin: 0 0 14px; font-size: 1.0625rem; line-height: 1.5; color: var(--muted); }
.patient-id strong { color: var(--ink); }

/* ---- the patient's receipt: one record and one action before the device goes back ---- */
.receipt main { max-width: 720px; }
.receipt-kicker { margin: 0 0 2px; color: var(--muted); font-size: .92rem; }
.receipt-sheet h1 { font-size: 1.7rem; line-height: 1.25; margin: 0 0 8px; }
.receipt-lead { margin: 0 0 18px; max-width: 42rem; font-size: 1.0625rem; line-height: 1.6; }
.receipt-facts { margin: 0 0 24px; }
.receipt-scopes { margin-bottom: 18px; }
.receipt-withdraw { margin: 0; padding-top: 16px; border-top: 1px solid var(--rule); font-size: .97rem; }
.receipt-handback { margin-top: 18px; }
.receipt-handback .btn { max-width: none; }
/* the way back to the chart, and manual mode naming itself above the purpose list */
.step-back { margin: 0 0 2px; }
.manual-line { margin: 0 0 14px; font-size: 1.0625rem; line-height: 1.5; color: var(--muted); }
.step-back .link, .manual-line .link { display: inline-flex; align-items: center; min-height: 44px; font-size: .95rem; text-align: left; }

@media (max-width: 640px) {
  .consent-sheet { padding: 20px 16px 0; }
  .consent-actions { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  /* on a phone the dock is the action: the hint repeats the button and pushes the
     dock well past the 48px the Thumb Rule allows. The hint is still read on a desk. */
  .consent-actions .small { display: none; }
  /* the progress line is the dock's reason, not a repeated hint: it stays */
  .consent-actions .consent-progress { display: block; }
}

/* on a desk the sheet reads as one column of paper; the docked action is a phone device */
@media (min-width: 900px) {
  .consent-sheet { max-width: 760px; margin-left: auto; margin-right: auto; }
  .consent-actions { position: static; margin: 26px 0 0; }
}

/* on a desk the case file splits the way a case file does: the proof stays in
   front of you while the transcript is worked on. DOM order is unchanged, so a
   phone still reads record → consent → transcript → history. */
@media (min-width: 1100px) {
  .case-grid {
    display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    column-gap: 44px; align-items: start; grid-auto-flow: row;
  }
  /* visual order matches DOM order, so the tab ring does not cross columns:
     sheet(s) → consent → the rest → history, left to right */
  .case-sheets { grid-column: 1; grid-row: 1; }
  .case-consent { grid-column: 2; grid-row: 1; border-top: 0; padding-top: 0; }
  .case-rest { grid-column: 1; grid-row: 2; }
  .case-timeline { grid-column: 2; grid-row: 2; }
  /* a ready draft has no sheet in the first column: the work column takes the top row
     and spans both, so the page still leads with the work while consent keeps column
     two (and history stays under it) */
  .case-grid--work-first .case-sheets { display: none; }
  .case-grid--work-first .case-rest { grid-row: 1 / span 2; }
}

/* ---- the first thirty seconds: a form, and the document it produces ---- */
.auth {
  display: grid; gap: 28px; max-width: 1040px;
  margin: 22px auto 40px; padding: 0 20px;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 6px; padding: 26px 24px;
}
.auth-eyebrow { margin: 0 0 8px; color: var(--muted); font-size: .86rem; }
.auth-card h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 10px; text-wrap: balance; }
.auth-lede {
  margin: 0 0 20px; color: var(--ink-lede);
  font-size: 1rem; line-height: 1.6;
}
.line-door { margin: 4px 0 0; }
.line-door .muted { margin: 8px 0 0; }
/* a divider that says "one of two doors", so the email form is not the only path */
.auth-or {
  display: flex; align-items: center; gap: 12px; margin: 18px 0;
  color: var(--muted); font-size: .86rem;
}
.auth-or::before, .auth-or::after {
  content: ""; flex: 1; border-top: 1px solid var(--rule);
}
.auth-facts {
  list-style: none; padding: 0; margin: 20px 0 0;
  border-top: 1px solid var(--rule);
  font-size: .95rem; line-height: 1.6; color: var(--muted);
}
.auth-facts li { padding: 11px 0; border-bottom: 1px solid var(--rule); }
.auth-facts strong { color: var(--ink); font-weight: 600; }
/* the low-risk door beside the request form: ink, never a second green, and a full
   thumb target on a phone */
.gate-kit { margin: 22px 0; padding-top: 18px; border-top: 1px solid var(--rule); }
.gate-kit p { margin: 0 0 12px; font-size: .95rem; line-height: 1.6; color: var(--muted); }
.gate-kit strong { color: var(--ink); font-weight: 600; }
.gate-kit .btn { width: 100%; text-align: center; }
.auth-aside { display: none; }
@media (min-width: 980px) {
  .auth { grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 56px; align-items: start; }
  .auth-aside { display: block; }
  .auth-doc { margin: 0; }
  .auth-doc img {
    display: block; width: 100%; height: auto;
    border: 1px solid var(--rule); border-radius: 4px; background: #fff;
    box-shadow: 0 28px 56px -28px rgba(21, 24, 28, .42);
  }
  .auth-doc figcaption { padding-top: 12px; font-size: .86rem; color: var(--muted); text-wrap: pretty; }
}
.remember { margin: 0 0 10px; font-size: .95rem; color: var(--muted); }

/* ---- the funnel pages: invite, kit, doctor name ---- */
.invite-head { margin: 6px 0 26px; padding-bottom: 18px; border-bottom: 1px solid var(--rule); }
.invite-head h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 10px; text-wrap: balance; }
.invite-row { padding: 18px 0; border-top: 1px solid var(--rule); }
.invite-row:last-of-type { border-bottom: 1px solid var(--rule); }
.invite-row .invite-code-line { margin: 12px 0 10px; }
.invite-row .btn.wide { max-width: none; }
.create-more { margin-top: 22px; padding: 4px 0 0; border-top: 1px solid var(--rule); }
.create-more summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; }

.kit { max-width: 1040px; margin: 22px auto 40px; padding: 0 20px; }
.kit-head { max-width: 640px; margin-bottom: 30px; }
.kit-head h1 { font-size: clamp(2rem, 4vw, 2.6rem); line-height: 1.2; margin: 0 0 12px; text-wrap: balance; }
.kit-grid { display: grid; gap: 18px; }
@media (min-width: 780px) { .kit-grid { grid-template-columns: 1fr 1fr; gap: 24px; } }
.kit-sheet {
  display: block; padding: 22px 22px 18px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
  color: var(--ink); text-decoration: none;
  transition: border-color .15s ease;
}
.kit-sheet:hover { border-color: var(--accent); }
.kit-kicker { margin: 0 0 8px; font-size: .86rem; color: var(--muted); }
.kit-sheet h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 8px; }
.kit-sheet p { margin: 0 0 14px; color: var(--ink-lede); font-size: .97rem; line-height: 1.6; }
.kit-link { color: var(--accent); font-weight: 600; font-size: .95rem; }
.kit-actions { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 26px; }

/* The clinic switcher: a person may hold a door into more than one clinic. */
.clinic-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.clinic-chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--ink); font-size: 15px;
  text-decoration: none; }
.clinic-chip.current { border-color: var(--green); font-weight: 600; }

/* The three documents a clinic accepts before paying: a readable measure and no
   marketing furniture. They are pages, so the links must work unauthenticated. */
.legal { max-width: 46rem; margin: 34px 0 20px; }
.legal h1 { font-size: 1.65rem; line-height: 1.3; margin: 2px 0 8px; }
.legal h2 { font-size: 1.1rem; margin: 28px 0 6px; }
.legal p, .legal li { color: var(--muted); font-size: .95rem; line-height: 1.72; }
.legal p { margin: 0 0 8px; }
.legal ul, .legal ol { margin: 0 0 8px; padding-left: 1.15rem; display: grid; gap: 5px; }
.legal .lede { color: var(--ink-lede); font-size: 1rem; }
.legal-meta { margin: 0; font-size: .84rem; color: var(--muted); }
.legal-note { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--rule); }
/* The DPIA's registers are wide; on a phone they scroll inside their own box rather
   than squeezing six columns into the viewport. */
.dpia-scroll { margin: 12px 0 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dpia-scroll table.list { margin-top: 0; min-width: 40rem; }
.foot-links { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 8px; }
.foot-links a { color: inherit; display: inline-flex; align-items: center; min-height: 44px; }
