/* Ally: phone-first. The phone's own font (SF Pro on iPhone), sized like Luma's iOS app: 17px body,
   15px details, bold titles. Nothing to download (the CSP allows no third-party requests anyway). */

:root {
  --ink: #111111;
  --gray-lg: #8a8a8a;   /* large gray: headline second half (3:1 at 24px+) */
  --gray: #6e6e6e;      /* small gray text (4.5:1) */
  --gray-mid: #555555;
  --pill: #1d1a1a;
  --chip: #f2f2f2;
  --panel: #f6f6f6;
  --line: #ebebeb;
  --mint: #ddf6ec;
  --mint-ink: #0b7a55;
  --mint-soft: #effaf5;
  --mint-line: #bdebd8;
  --peach: #fff0e5;
  --peach-ink: #a1450f;
  --skip-fill: #ffe3d0;
  --rec: #ff5a36;
  --radius-card: 24px;
  --radius-row: 20px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink);
  background: #fff;
}
a { color: var(--ink); }
a:hover { color: var(--gray-mid); }
p { margin: 0; }
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #3b82f6; outline-offset: 2px; }
/* `hidden` must win over the flex/grid display of classes like .stack and .pill. */
[hidden] { display: none !important; }
/* What a patient or the team typed can be one long unbroken string (a pasted link): wrap it anywhere. */
.need blockquote, .bubble-in, .inset, .msg, .exchange p, .pre, .note-list li, .who { overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Small helpers (the CSP forbids inline style attributes, so everything is a class). */
.ink { color: var(--ink); }
.fw-600 { font-weight: 600; }
.center { text-align: center; }
.card-title { font-size: 17px; font-weight: 600; }
.note-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 17px; }
.pre { white-space: pre-wrap; font-size: 16px; line-height: 1.55; margin: 0; font-family: inherit; }
.screen-pad { padding: 12px 16px 0; }

/* ── Frame: a phone column, centered on bigger screens ── */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.app.wide { max-width: 960px; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 20px 16px 26px; }
.screen.roomy { gap: 18px; }
.dev-banner { background: #fff7d6; color: #6b5200; font-size: 12px; font-weight: 600; text-align: center; padding: 4px 8px; }
.dev-banner a { color: inherit; }

/* ── Top bar ── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding-right: 8px; font-size: 17px; font-weight: 600; text-decoration: none; color: var(--ink); }
.brand { font-weight: 700; font-size: 20px; letter-spacing: -0.02em; text-decoration: none; }
/* The logo at the top center of the sign-in page, in the row a top bar would use. */
.auth-logo { align-self: center; flex-shrink: 0; width: auto; height: 36px; margin: 4px 0; }

/* ── Type ── */
.display { font-weight: 700; font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; }
.display.xl { font-size: 36px; line-height: 1.1; }
/* A screen's status sits under its title as one chip (Ready, Approved…), never as a second half of the title. */
.title-block { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.display .soft { color: var(--gray-lg); }
.sub { font-size: 15px; color: var(--gray); }
.fine { font-size: 13px; color: var(--gray); line-height: 1.5; }
.lead { font-size: 17px; line-height: 1.5; }
.lead .soft { color: #5e5e5e; }
.h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.h3 { font-size: 15px; font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-sm { display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ── Buttons: black pills and gray pills ── */
.btn, .pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 999px; font-weight: 600; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn { min-height: 54px; padding: 0 20px; font-size: 17px; }
.pill { min-height: 44px; padding: 0 16px; font-size: 15px; background: var(--chip); color: var(--ink); }
.btn-primary { background: var(--pill); color: #fff; }
.btn-primary:hover { color: #fff; background: #000; }
.btn-secondary { background: var(--chip); color: var(--ink); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: 0.5; pointer-events: none; }
.btn[data-wait] { font-variant-numeric: tabular-nums; } /* "Send a new code in 0:27" holds still as it counts */
.actions { display: flex; gap: 10px; }
.actions > .grow { flex: 1; }
.actions.wrap { flex-wrap: wrap; }
form.inline { display: inline; }

/* ── Chips ── */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--chip); }
.chip-mint { background: var(--mint); color: var(--mint-ink); }
.chip-peach { background: var(--peach); color: var(--peach-ink); }
.chip-dark { background: #111; color: #fff; }
.tag-added { padding: 1px 8px; border-radius: 999px; background: var(--mint); color: var(--mint-ink); font-size: 13px; font-weight: 600; }
.tag-stopped { padding: 1px 8px; border-radius: 999px; background: var(--peach); color: var(--peach-ink); font-size: 13px; font-weight: 600; }

/* ── Surfaces ── */
.panel { background: var(--panel); border-radius: var(--radius-card); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.panel.tight { padding: 16px 18px; gap: 12px; }
.card-line { border: 1px solid var(--line); border-radius: var(--radius-row); padding: 14px 16px; }
.inset { background: #fff; border-radius: 16px; padding: 12px 14px; }
.section-title { font-size: 17px; font-weight: 700; }
.empty { color: var(--gray); font-size: 15px; }
.visit-row { display: flex; align-items: flex-start; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); -webkit-tap-highlight-color: transparent; }
a.visit-row:active { opacity: 0.55; }
.visit-row .time { width: 74px; flex-shrink: 0; font-size: 16px; font-weight: 500; color: var(--gray); font-variant-numeric: tabular-nums; }
.visit-row .ampm { font-size: 12px; }
.visit-row .who { font-size: 17px; font-weight: 600; line-height: 1.3; }
.visit-row .what { font-size: 15px; color: var(--gray); }
.status { align-self: center; flex-shrink: 0; font-size: 15px; font-weight: 600; color: var(--gray); }
.status.review { color: var(--peach-ink); }
.status.done { display: inline-flex; color: var(--mint-ink); }
.needs { display: flex; flex-direction: column; gap: 10px; }
.need { border-radius: var(--radius-row); background: var(--peach); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.need .reason { font-size: 14px; font-weight: 700; color: var(--peach-ink); }
.need blockquote { margin: 0; font-size: 17px; }
.need .actions { flex-wrap: wrap; gap: 8px; }
.need .pill { background: #fff; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: 50px; z-index: 20; min-width: 220px; background: #fff; border-radius: 18px; box-shadow: 0 12px 32px rgba(17, 17, 17, 0.16); padding: 8px; display: flex; flex-direction: column; }
.menu-list a, .menu-list button { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 12px; text-decoration: none; font-size: 17px; font-weight: 500; background: none; border: none; text-align: left; cursor: pointer; width: 100%; }
.menu-list a:hover, .menu-list button:hover { background: var(--chip); color: var(--ink); }

/* ── Voice screens: pastel wash, black listening pill ── */
.voice {
  background: radial-gradient(90% 55% at 85% 12%, #ffe3d3 0%, rgba(255, 227, 211, 0) 62%),
    radial-gradient(95% 60% at 8% 88%, #dce8ff 0%, rgba(220, 232, 255, 0) 66%), #f4f6fa;
}
.voice .screen { gap: 18px; padding-top: 32px; }

/* ── Night strips: one bar per night ── */
.strip { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 5px; }
.strip.mini { gap: 3px; }
.bar { display: flex; align-items: center; justify-content: center; height: 30px; border-radius: 6px; }
.strip.mini .bar { height: 18px; border-radius: 3px; }
.strip.small .bar { height: 18px; border-radius: 4px; }
.bar.done { background: var(--mint-ink); }
.bar.skipped { background: var(--skip-fill); border: 1.5px solid var(--peach-ink); color: var(--peach-ink); }
.bar.no_reply { background: #fff; border: 1.5px dashed #8a8a8a; color: var(--gray); }
.bar.waiting { background: #fff; border: 1.5px solid #cfcfcf; }
.bar.rest { background: #e6e6e6; }
.markers { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 5px; min-height: 14px; }
.markers span { display: flex; justify-content: center; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--gray-mid); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 14px; border-radius: 3px; }
.legend .swatch.done { background: var(--mint-ink); }
.legend .swatch.skipped { background: var(--skip-fill); border: 1.5px solid var(--peach-ink); }
.legend .swatch.no_reply { background: #fff; border: 1.5px dashed #8a8a8a; }
.legend .swatch.rest { background: #e6e6e6; }

/* ── Past visits ── */
details.visit-card { border: 1px solid var(--line); border-radius: var(--radius-row); }
details.visit-card > summary { list-style: none; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px; cursor: pointer; }
details.visit-card > summary::-webkit-details-marker { display: none; }
details.visit-card > summary .chev { transition: transform 0.2s; flex-shrink: 0; }
details.visit-card[open] > summary .chev { transform: rotate(180deg); }
details.visit-card .body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; font-size: 16px; }
details.visit-card ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.nights { display: flex; flex-direction: column; gap: 8px; padding: 4px 18px 2px; }
.exchange { background: #fff; border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.exchange .meta { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--gray); }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.empty-state { align-items: center; text-align: center; gap: 8px; padding: 28px 20px; }
details.notes { border-radius: var(--radius-row); background: var(--panel); padding: 4px 18px; }
details.notes > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 44px; font-size: 15px; font-weight: 600; color: var(--gray-mid); cursor: pointer; }
details.notes > summary::-webkit-details-marker { display: none; }
details.notes[open] > summary svg { transform: rotate(180deg); }
details.notes .note-list { padding-bottom: 14px; font-size: 16px; color: var(--gray-mid); }
.check-row { background: var(--peach); border-radius: 16px; padding: 12px 14px; font-size: 15px; display: flex; flex-direction: column; gap: 4px; }
.check-row strong { color: var(--peach-ink); }
.bubble-in { padding: 10px 14px; border-radius: 18px 18px 18px 6px; background: var(--chip); font-size: 16px; line-height: 1.45; }
.proposal { padding: 16px; border-radius: 20px; background: var(--mint-soft); border: 1px solid var(--mint-line); display: flex; flex-direction: column; gap: 6px; }
.proposal .label { font-size: 14px; font-weight: 600; color: var(--mint-ink); }

/* ── Forms ── */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; font-weight: 600; color: var(--gray-mid); }
input[type='text'], input[type='email'], input[type='password'], input[type='tel'], input[type='date'], input[type='time'], input[type='number'], input:not([type]), select, textarea {
  font-size: 17px; min-height: 50px; padding: 12px 16px; border-radius: 14px; border: 1px solid #e0e0e0; background: #fff; width: 100%;
}
textarea { min-height: 120px; line-height: 1.45; resize: vertical; }
textarea.transcript { min-height: 260px; font-size: 16px; }
.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: 16px; }
.checkline input { width: 22px; height: 22px; margin-top: 1px; flex-shrink: 0; }
.chips-choose { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-choose label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px; background: var(--chip); font-size: 16px; font-weight: 500; cursor: pointer; }
.chips-choose input { width: 16px; height: 16px; }
.error { background: var(--peach); color: var(--peach-ink); border-radius: 14px; padding: 12px 14px; font-size: 15px; font-weight: 600; }
.notice { background: var(--mint); color: var(--mint-ink); border-radius: 14px; padding: 12px 14px; font-size: 15px; font-weight: 600; }
.field-error { color: var(--peach-ink); font-size: 14px; font-weight: 600; }

/* ── Tables (audit log, admin) ── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--gray); font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* ── Patient's phone (dev fake phone, looks like Messages) ── */
.phone { display: flex; flex-direction: column; flex: 1; }
.phone-head { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 16px 12px; border-bottom: 1px solid #f0f0f0; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: #111; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 600; }
.thread { flex: 1; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; font-size: 17px; line-height: 1.4; }
.msg { max-width: 290px; padding: 10px 14px; border-radius: 20px 20px 20px 6px; background: var(--chip); align-self: flex-start; white-space: pre-wrap; }
.msg.in { align-self: flex-end; background: #111; color: #fff; border-radius: 20px 20px 6px 20px; }
.msg-time { align-self: center; font-size: 13px; font-weight: 500; color: var(--gray); padding-top: 6px; }
.composer { display: flex; gap: 10px; align-items: center; padding: 10px 14px 20px; border-top: 1px solid #f0f0f0; }
.composer input { border-radius: 999px; background: var(--chip); border: none; }
.quick { display: flex; gap: 8px; padding: 0 14px 20px; }
.quick button { flex: 1; min-height: 44px; border-radius: 999px; border: none; background: var(--chip); font-weight: 700; cursor: pointer; }
fieldset.stack { border: none; padding: 0; margin: 0; min-width: 0; }
fieldset.stack legend { padding: 0; margin-bottom: 8px; }
.moment { position: absolute; animation: moment-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
/* The sign-in card rises into place, like Luma's sign-in sheet. */
.sheet-rise { animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes moment-in { from { opacity: 0; translate: 0 70px; scale: 0.82; } }
@keyframes field { to { translate: -12px -14px; } }
@keyframes rise { from { opacity: 0; translate: 0 18px; } }
@media (prefers-reduced-motion: reduce) {
  .moment, .sheet-rise { animation: none; }
}
