/* The Southern Smiles app design system: the website's look (site/css/site.css) set for
   the admin dashboard and the patient portal. Edit it in shared/css/, then npm run sync.
   Each app adds its own file on top (admin/css/admin.css, portal/css/portal.css) and can
   turn the type and control sizes up or down with the --text / --control variables. */

/* Inter, served from this app (copied from shared/fonts). SIL OFL: /fonts/OFL.txt. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/inter-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;
}

/* The website's palette, copied as-is from :root in site/css/site.css. Change both together. */
:root {
  --ink: #0a1929;
  --ink-2: #10243a;
  --ink-3: #1a3a5c;
  --blue: #29abe2;
  --blue-2: #1a5fa8;
  --sky: #e0f4fc;
  --green: #7dc242;
  --green-2: #4e8a28;
  --gold: #f2b01e;
  --paper: #f4f2ef;
  --white: #fff;
  --dim: #9fb0c0;
  --mute: #4a6b8a;
  --line: #e3e0dc;
  /* App only. The website never deletes anything, so it has no red; here it marks
     deletes and errors and nothing else. --edge is ink, faded, for input borders. */
  --red: #b42318;
  --red-tint: #fdecea;
  --edge: rgb(10 25 41 / .16);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --gutter: clamp(16px, 3.4vw, 40px);
  /* Type and control sizes. The admin uses these; the portal turns them up for patients. */
  --text: 15px;
  --text-sm: 14px;
  --text-xs: 13px;
  --text-xxs: 12px;
  --control: 42px;
  --control-fs: 15px;
  --btn: 40px;
  --btn-fs: 14px;
  --icon-btn: 36px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text);
  line-height: 1.5;
  letter-spacing: -.006em;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
[hidden], .hidden, .role-hidden { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 2px; }
/* Headings that receive focus when a view changes, for screen readers; no ring needed. */
h1[tabindex="-1"], h2[tabindex="-1"] { outline: none; }

/* Icons come from the <symbol> sprite at the top of index.html: <svg class="i"><use href="#i-name"/></svg>. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* Injected by main.js on the portal. */
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 300; padding: 10px 16px; border-radius: 999px; background: var(--blue); color: var(--ink); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 10px; }

/* ---------- Sign in ---------- */
/* Set like the website's error pages: ink, the sunrise mark drawing in, one pill button. */

.signin {
  position: relative; min-height: 100vh; min-height: 100svh;
  background: radial-gradient(circle at 50% 30%, var(--ink-2) 0, var(--ink) 60%);
  color: var(--white); font-size: 17px; line-height: 1.47; letter-spacing: -.011em;
  color-scheme: dark; /* dark autofill and form controls */
}
.signin :focus-visible { outline-color: var(--blue); outline-offset: 3px; }
.signin-bar {
  position: absolute; inset: 0 0 auto; height: 108px; padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.signin-bar img { width: auto; height: 72px; filter: brightness(1.3) contrast(1.05); }
.signin-back { font-size: var(--text-sm); color: rgb(255 255 255 / .78); text-decoration: none; transition: color .2s; }
.signin-back:hover { color: var(--white); }
.signin-main {
  min-height: 100vh; min-height: 100svh; display: grid; place-content: center; justify-items: center;
  padding: 140px var(--gutter) 96px; text-align: center;
}
.signin-eyebrow { margin-bottom: 14px; font-weight: 600; letter-spacing: -.01em; color: var(--blue); }
.signin-title { font-size: clamp(44px, 7vw, 72px); line-height: 1.04; font-weight: 650; letter-spacing: -.045em; }
.signin-lede { max-width: 34em; margin: 18px auto 0; font-size: clamp(19px, 2vw, 22px); line-height: 1.36; font-weight: 500; letter-spacing: -.02em; color: var(--dim); }
.signin-form { display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); margin-top: 40px; text-align: left; }
.signin-form label { margin-top: 10px; font-size: var(--text-sm); font-weight: 500; color: var(--dim); }
.signin-form label:first-child { margin-top: 0; }
.signin-form input:not([type="checkbox"]) {
  height: 52px; padding: 0 18px; border: 0; border-radius: 14px; outline: none;
  background: rgb(255 255 255 / .06); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .14);
  color: var(--white); font-size: 17px; transition: box-shadow .2s, background-color .2s;
}
.signin-form input::placeholder { color: rgb(159 176 192 / .6); }
.signin-form input:not([type="checkbox"]):hover { box-shadow: inset 0 0 0 1px rgb(255 255 255 / .26); }
/* The blue ring is the focus indicator. */
.signin-form input:not([type="checkbox"]):focus { background: rgb(255 255 255 / .09); box-shadow: inset 0 0 0 2px var(--blue); }
.signin-form input:focus-visible { outline: none; }
.signin-error.notice { background: rgb(41 171 226 / .14); color: var(--sky); }
.signin-error { margin-top: 6px; padding: 12px 16px; border-radius: 14px; background: rgb(255 107 107 / .12); color: #ffb4ab; font-size: 15px; }
.signin-form .btn { min-height: 52px; margin-top: 18px; font-size: 17px; }

.draw { width: min(160px, 44vw); height: auto; margin-bottom: 40px; overflow: visible; }
.draw .arch, .draw .horizon { fill: none; stroke: var(--green); stroke-width: 26; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw-on 1.4s var(--ease) forwards; }
.draw .arch { animation-delay: .35s; }
.draw image { opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; animation: palm-in 1s 1.1s var(--ease) forwards; }
.rise { animation: rise-in 1s var(--ease) both; animation-delay: calc(var(--d, 0) * 120ms + 100ms); }
@keyframes draw-on { to { stroke-dashoffset: 0; } }
@keyframes palm-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(28px); filter: blur(6px); } }

@media (max-width: 700px) {
  .signin-bar { height: 80px; }
  .signin-bar img { height: 56px; }
  .signin-main { padding-top: 112px; }
}

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none;
  min-height: var(--btn); padding: 0 18px; border: 0; border-radius: 999px;
  font-size: var(--btn-fs); font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: transform .2s var(--ease), background-color .2s, box-shadow .2s, color .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn .i { width: 16px; height: 16px; }
/* The one main action in a view: brand blue with ink text, as on the website. */
.btn-primary { background: var(--blue); color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: #5cc0ea; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge); }
.btn-ghost:hover:not(:disabled) { background: rgb(10 25 41 / .04); box-shadow: inset 0 0 0 1px rgb(10 25 41 / .3); }
.btn-danger { background: var(--red-tint); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: #fbd9d4; }
.btn-danger.solid { background: var(--red); color: var(--white); }
.btn-danger.solid:hover:not(:disabled) { background: #8f1c13; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: var(--text-xs); }
/* While a form saves, its button shows a spinner and can't be pressed twice. */
.btn[data-busy]::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn[data-busy] .i { display: none; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none; width: var(--icon-btn); height: var(--icon-btn); padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--mute); transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: rgb(10 25 41 / .06); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-tint); color: var(--red); }
.link-btn { padding: 0; border: 0; background: none; color: inherit; font-weight: 600; text-align: left; }
.link-btn:hover { color: var(--blue-2); }

@media (pointer: coarse) {
  .btn { min-height: max(var(--btn), 44px); }
  .btn-sm { min-height: 40px; }
  .icon-btn { width: 44px; height: 44px; }
}

/* ---------- Panels and rows ---------- */
/* One white panel per subject; its items sit on hairlines inside it, never in boxes of their own. */

.panel { background: var(--white); border-radius: 18px; box-shadow: 0 0 0 1px rgb(10 25 41 / .06), 0 1px 2px rgb(10 25 41 / .04); }
.panel + .panel, .panel + .section-gap { margin-top: 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 17px; line-height: 1.3; font-weight: 600; letter-spacing: -.02em; }
.panel-head p { margin-top: 2px; font-size: var(--text-sm); color: var(--mute); }
.panel-body { padding: 24px; }
.narrow { max-width: 760px; }

.rows > li, .row { display: flex; align-items: center; gap: 16px; padding: 16px 24px; border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-weight: 600; letter-spacing: -.015em; }
.row-meta { margin-top: 2px; font-size: var(--text-sm); color: var(--mute); }
.row-text { display: -webkit-box; margin-top: 4px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: var(--text-sm); color: var(--mute); }
.row-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.row-eyebrow { display: block; margin-bottom: 2px; font-size: var(--text-xs); font-weight: 600; color: var(--blue-2); }
.key { font: 500 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--mute); }
.thumb { flex: none; width: 48px; height: 48px; border-radius: 12px; object-fit: cover; background: var(--paper); }
.stars { color: var(--gold); letter-spacing: 1px; font-size: var(--text-xs); }

.av {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: var(--sky); color: var(--blue-2); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0;
}
.av.md { width: 44px; height: 44px; font-size: 15px; }
.av.lg { width: 64px; height: 64px; font-size: 22px; }
img.av { object-fit: cover; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who > div { min-width: 0; }
.who .row-meta { margin-top: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { display: grid; justify-items: center; gap: 6px; padding: 48px 24px; text-align: center; color: var(--mute); }
.empty b { color: var(--ink); font-weight: 600; }
.empty .i { width: 28px; height: 28px; margin-bottom: 6px; color: var(--dim); }
.rows .empty { border-top: 0; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 24px; color: var(--mute); font-size: var(--text-sm); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--blue-2); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }

/* A list's own toolbar: how many, search or filters, and its main action on the right. */
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.toolbar .tally { margin-right: auto; font-size: var(--text-sm); color: var(--mute); }
.search { position: relative; }
.search .i { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--mute); pointer-events: none; }
.search .input { width: min(300px, 100%); padding-left: 40px; border-radius: 999px; }
@media (max-width: 640px) { .toolbar .search { flex: 1 1 100%; } .search .input { width: 100%; } }

/* Filter pills: radio buttons, so arrow keys move between them. */
.seg { display: inline-flex; gap: 2px; max-width: 100%; overflow-x: auto; padding: 4px; border-radius: 999px; background: rgb(10 25 41 / .06); scrollbar-width: none; }
.seg label { position: relative; flex: none; }
.seg input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 14px; border-radius: 999px; font-size: var(--text-xs); font-weight: 500; color: var(--mute); white-space: nowrap; transition: background-color .15s, color .15s; }
.seg label:hover span { color: var(--ink); }
.seg input:checked + span { background: var(--white); color: var(--ink); box-shadow: 0 1px 3px rgb(10 25 41 / .14); }
.seg input:focus-visible + span { outline: 2px solid var(--blue-2); outline-offset: 1px; }

/* Status tags. The dot and the word carry the meaning together, never colour alone. */
.tag {
  display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 3px 10px; border-radius: 999px;
  background: var(--paper); color: var(--mute); font-size: var(--text-xxs); font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.plain::before { display: none; }
.tag.ok { background: #dcf3d0; color: #2f6512; }
.tag.wait { background: #fdf0c8; color: #6b5200; }
.tag.info { background: var(--sky); color: #174f8a; }
.tag.bad { background: var(--red-tint); color: var(--red); }
.tag.ink { background: var(--ink); color: var(--white); }

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

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; font-size: var(--text-xxs); font-weight: 600; color: var(--mute); white-space: nowrap; }
.table td { padding: 14px 16px; border-top: 1px solid var(--line); color: var(--mute); vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child, .table td:last-child { padding-right: 24px; }
.table td.strong { color: var(--ink); font-weight: 500; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .end { text-align: right; white-space: nowrap; }
.table tr[data-action] { cursor: pointer; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: var(--paper); }
/* On phones only the columns that identify a row stay; the rest is one tap away. */
@media (max-width: 760px) {
  .table .opt { display: none; }
  .table .row-meta { display: none; }
}

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

.stack { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; align-content: start; }
.field > label, .label { font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); }
.optional { font-weight: 400; color: var(--mute); }
.hint { font-size: var(--text-xs); color: var(--mute); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.input {
  width: 100%; min-height: var(--control); padding: 9px 14px; border: 0; border-radius: 12px;
  background: var(--white); box-shadow: inset 0 0 0 1px var(--edge); color: var(--ink);
  font-size: var(--control-fs); line-height: 1.4; transition: box-shadow .15s;
}
.input::placeholder { color: var(--mute); opacity: .75; }
.input:hover { box-shadow: inset 0 0 0 1px rgb(10 25 41 / .3); }
.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--blue-2), 0 0 0 4px rgb(41 171 226 / .2); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.55; }
select.input {
  appearance: none; padding-right: 40px; cursor: pointer;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a6b8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 14px center / 16px no-repeat;
}
.input-sm { min-height: 36px; padding: 6px 12px; font-size: var(--text-sm); border-radius: 10px; }
.input.auto { width: auto; }
select.input-sm { padding-right: 34px; background-position: right 10px center; }
input[type="file"].input { padding: 6px; cursor: pointer; }
input[type="file"].input::file-selector-button {
  margin-right: 12px; padding: 7px 14px; border: 0; border-radius: 999px; background: var(--paper);
  color: var(--ink); font: 500 13px/1 var(--font); cursor: pointer;
}
.check { display: flex; align-items: center; gap: 10px; font-size: var(--text-sm); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue-2); }

/* Settings-style sections: what it is on the left, the fields on the right. */
.form-section { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 16px 48px; padding: 28px 24px; border-top: 1px solid var(--line); }
.form-section:first-child { border-top: 0; }
.form-section h2 { font-size: 16px; font-weight: 600; letter-spacing: -.02em; }
.form-section > div:first-child p { margin-top: 6px; font-size: var(--text-sm); color: var(--mute); }
@media (max-width: 900px) { .form-section { grid-template-columns: 1fr; } }
.pairs { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); gap: 10px 14px; align-items: center; }
.pairs .label { padding-bottom: 0; }

/* The save bar stays in reach at the bottom of a long form, and says when there are unsaved edits. */
.savebar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 16px;
  padding: 14px 24px; border-top: 1px solid var(--line); border-radius: 0 0 18px 18px;
  background: rgb(255 255 255 / .92); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.savebar .dirty { display: none; margin-right: auto; font-size: var(--text-sm); font-weight: 500; color: #6b5200; }
form[data-dirty] .savebar .dirty { display: flex; align-items: center; gap: 8px; }
form[data-dirty] .savebar .dirty::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

.callout { padding: 12px 16px; border-radius: 12px; background: var(--sky); color: #174f8a; font-size: var(--text-sm); font-weight: 500; }
.callout.ok { background: #dcf3d0; color: #2f6512; }
.callout.wait { background: #fdf0c8; color: #6b5200; }
.callout.error { background: var(--red-tint); color: var(--red); }

/* The website's provider badge, previewed. */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: var(--paper); font-size: var(--text-sm); font-weight: 600; }
.pill .i { color: var(--blue-2); }

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

.modal {
  width: min(560px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 0; border: 0; border-radius: 22px;
  background: var(--white); color: var(--ink); box-shadow: 0 40px 120px rgb(10 25 41 / .35); overflow: hidden;
}
/* Never set display on .modal itself: it would override the closed dialog's display: none. */
.modal[open] { display: flex; flex-direction: column; animation: modal-in .3s var(--ease) both; }
.modal::backdrop { background: rgb(10 25 41 / .5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal > form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.modal-lg { width: min(980px, calc(100% - 32px)); height: calc(100% - 64px); }
.modal-sm { width: min(440px, calc(100% - 32px)); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 20px 0 24px; flex: none; }
.modal-head h2 { padding-top: 4px; font-size: 20px; line-height: 1.25; font-weight: 650; letter-spacing: -.025em; }
.modal-head p { margin-top: 4px; font-size: var(--text-sm); color: var(--mute); }
.modal-head .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.modal-body { display: grid; gap: 18px; align-content: start; flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex: none; padding: 16px 24px; border-top: 1px solid var(--line); }
.modal-lg .modal-head { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.modal-lg .modal-head > div:first-child { min-width: 0; }
.confirm-title { padding-top: 6px; font-size: 20px; line-height: 1.25; font-weight: 650; letter-spacing: -.025em; }
.confirm-text { color: var(--mute); }
.preview-img { width: 100%; max-height: 200px; object-fit: cover; border-radius: 12px; }
.modal-lg .modal-body { background: var(--paper); }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }

/* ---------- Toasts ---------- */

.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 200; display: grid; justify-items: end; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: min(440px, calc(100vw - 48px)); padding: 12px 18px 12px 14px;
  border-radius: 14px; background: var(--ink); color: var(--white); font-size: var(--text-sm); font-weight: 500;
  box-shadow: 0 20px 60px rgb(10 25 41 / .3); pointer-events: auto; cursor: pointer; animation: toast-in .35s var(--ease) both;
}
.toast .i { color: var(--green); }
.toast.error .i { color: #ffb4ab; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@media (max-width: 640px) { .toasts { left: 16px; right: 16px; bottom: 16px; justify-items: stretch; } }

/* ---------- Registration form (registration-renderer.js) ---------- */
/* One panel per part of the form; answers are big tappable chips, not tiny radio dots. */

.reg-sections { display: grid; gap: 20px; }
.reg-sections > .panel + .panel { margin-top: 0; }
.reg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 18px; }
.reg-grid > .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .reg-grid { grid-template-columns: 1fr; } }
.req { color: var(--red); }
fieldset.field { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.field > legend { padding: 0; margin-bottom: 8px; font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 8px; }
.chip { position: relative; display: inline-flex; }
.chip-grid .chip { display: flex; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip span {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--control); padding: 8px 16px 8px 14px;
  border-radius: 12px; background: var(--white); box-shadow: inset 0 0 0 1px var(--edge);
  font-size: var(--control-fs); line-height: 1.3; transition: background-color .15s, box-shadow .15s, color .15s;
}
.chip span::before { content: ""; flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--white); box-shadow: inset 0 0 0 1.5px rgb(10 25 41 / .3); }
.chip input[type="checkbox"] + span::before { border-radius: 5px; }
.chip:hover span { box-shadow: inset 0 0 0 1px rgb(10 25 41 / .32); }
.chip input:checked + span { background: var(--sky); box-shadow: inset 0 0 0 2px var(--blue-2); color: #174f8a; font-weight: 500; }
.chip input[type="radio"]:checked + span::before { background: radial-gradient(circle, var(--white) 0 3px, var(--blue-2) 3.5px); box-shadow: none; }
.chip input[type="checkbox"]:checked + span::before {
  box-shadow: none;
  background: var(--blue-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 13px no-repeat;
}
.chip input:focus-visible + span { outline: 2px solid var(--blue-2); outline-offset: 2px; }
.scale .chip span { justify-content: center; width: var(--control); padding: 0; font-weight: 600; }
.scale .chip span::before { display: none; }
/* A consent you tick, with its full wording beside the box. */
.ack { display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px; border-radius: 14px; background: var(--paper); font-size: var(--text-sm); line-height: 1.5; cursor: pointer; }
.ack input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--blue-2); cursor: pointer; }
.input.signature { font-size: calc(var(--control-fs) + 5px); font-style: italic; letter-spacing: -.01em; }

/* Submit stays in reach the whole way down, next to how much is left. */
.reg-bar {
  position: sticky; bottom: 16px; z-index: 10; display: flex; align-items: center; flex-wrap: wrap; gap: 14px 24px;
  margin-top: 20px; padding: 14px 14px 14px 24px; border-radius: 22px; background: var(--ink); color: var(--white);
  box-shadow: 0 20px 60px rgb(10 25 41 / .3);
}
.reg-bar :focus-visible { outline-color: var(--blue); outline-offset: 3px; }
.reg-progress { display: grid; gap: 8px; flex: 1; min-width: 200px; font-size: var(--text-xs); font-weight: 500; color: var(--dim); }
.reg-progress .progress { background: rgb(255 255 255 / .14); }
.reg-progress .progress > div { background: var(--blue); }
.reg-note { color: var(--mute); font-size: var(--text-xs); }
@media (max-width: 640px) { .reg-bar { gap: 10px; padding: 12px; border-radius: 18px; } .reg-bar .btn { width: 100%; } }

/* ---------- Shared pieces: facts, files, previews, chat ---------- */

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px 24px; padding: 20px 24px; border-top: 1px solid var(--line); }
.facts dt { font-size: var(--text-xxs); font-weight: 600; color: var(--mute); }
.facts dd { margin-top: 2px; overflow-wrap: anywhere; font-weight: 500; }
.facts.inline { display: flex; flex-wrap: wrap; gap: 6px 28px; padding: 0; border: 0; }
.facts.inline dd { font-size: var(--text-sm); }
.ftype { color: var(--blue-2); }
.ftype.pdf { color: var(--red); }
.ftype.img { color: #2f6512; }
.progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; width: 0; border-radius: inherit; background: var(--blue-2); transition: width .3s var(--ease); }
.preview { display: grid; place-items: center; min-height: 100%; }
.preview iframe { width: 100%; height: 100%; min-height: 60vh; border: 0; border-radius: 12px; background: var(--white); }
.preview img { max-height: 70vh; object-fit: contain; border-radius: 12px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; overflow-y: auto; padding: 20px; background: var(--paper); }
.bubble { align-self: flex-start; max-width: min(560px, 82%); padding: 10px 14px; border-radius: 18px 18px 18px 6px; background: var(--white); box-shadow: 0 0 0 1px var(--line); overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.me { align-self: flex-end; border-radius: 18px 18px 6px 18px; background: var(--blue); color: var(--ink); box-shadow: none; }
.bubble-meta { display: block; margin-top: 4px; font-size: var(--text-xxs); color: var(--mute); white-space: normal; }
.bubble.me .bubble-meta { color: rgb(10 25 41 / .7); text-align: right; }
.bubble-from { display: block; margin-bottom: 2px; font-size: var(--text-xxs); font-weight: 600; color: var(--mute); }
.bubble.me .bubble-from { color: rgb(10 25 41 / .7); }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 14px 16px 10px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 44px; max-height: 160px; resize: none; }
.composer .btn { min-height: 44px; }
.composer-hint { padding: 0 16px 12px; font-size: var(--text-xxs); color: var(--mute); }
.chat-closed { padding: 14px 20px; border-top: 1px solid var(--line); background: var(--paper); font-size: var(--text-sm); color: var(--mute); text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { padding: 2px 10px; border-radius: 999px; background: var(--sky); color: #174f8a; font-size: var(--text-xs); font-weight: 500; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .spinner, .btn[data-busy]::before { animation: spin 1.4s linear infinite !important; }
}
