/* JEFF hosted web app. Tokens follow extension/panel.css (brief §3). */
:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --shade: #eff0f2;
  --line: #dfe2e7;
  --field-line: #7d8794;
  --ink: #252b35;
  --muted: #606874;
  --accent: #325bc7;
  --accent-hover: #294ca9;
  --accent-tint: #edf1fb;
  --accent-tint-hover: #e2e9fa;
  --accent-tint-line: #ccd5ef;
  --accent-tint-line-hover: #acbbe3;
  --success: #286040;
  --success-tint: #edf4ee;
  --signal: #795b20;
  --signal-tint: #faf3e3;
  --danger: #a52820;
  --danger-tint: #fdeceb;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --t-display: 2.25rem;
  --t-title: 1.75rem;
  --t-heading: 1.375rem;
  --t-lead: 1.25rem;
  --t-body: 1.125rem;
  --t-small: 1.0625rem;
  --t-label: 0.9375rem;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;
  --gutter: 32px;
  --r-control: 6px;
  --r-panel: 8px;
  --r-chip: 4px;
  --e-pop: 0 8px 24px oklch(0.288 0.02 261 / 0.12);
  --e-dialog: 0 24px 64px oklch(0.288 0.02 261 / 0.18);
  --backdrop: oklch(0.288 0.02 261 / 0.45);
  --z-sticky: 10; --z-pop: 20; --z-dialog: 30; --z-toast: 40;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); font-size: var(--t-body); }
[hidden] { display: none !important; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
h1 { font-size: var(--t-display); line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: var(--t-title); line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; }
h3 { font-size: var(--t-heading); line-height: 1.3; font-weight: 700; }
p { margin: 0; max-width: 68ch; text-wrap: pretty; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1:focus, h2:focus, [tabindex="-1"]:focus { outline: none; }
/* Headings and summaries receive focus programmatically only; they are not controls, so no ring. */
h1:focus-visible, h2:focus-visible, p[tabindex="-1"]:focus-visible { outline: none; }
.error-summary:focus-visible, .banner:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: var(--t-small); line-height: 1.5; }
.lead { font-size: var(--t-lead); line-height: 1.5; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.skip-link { position: absolute; left: var(--s4); top: -100px; z-index: var(--z-toast); background: var(--surface); padding: var(--s3) var(--s4); border-radius: var(--r-control); font-weight: 600; }
.skip-link:focus { top: var(--s4); }

/* ---------- Shell ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: var(--s6); padding: 0 var(--gutter); min-height: 72px; }
.wordmark { font-size: 26px; font-weight: 800; letter-spacing: -0.8px; line-height: 1; color: var(--ink); padding: var(--s3) 0; }
.wordmark:hover { text-decoration: none; }
.wordmark::after { content: "."; color: var(--accent); }
.mainnav { display: flex; gap: var(--s5); align-self: stretch; }
.mainnav a { display: flex; align-items: center; min-height: 44px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; padding-top: 3px; transition: color 150ms var(--ease), border-color 150ms var(--ease); }
.mainnav a:hover { color: var(--ink); text-decoration: none; }
.mainnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.account { margin-left: auto; }
.account-button { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s2); margin-right: calc(var(--s2) * -1); background: transparent; border: 0; border-radius: var(--r-control); font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; }
.account-button:hover { background: var(--shade); }
.chevron { width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.menu { position: absolute; inset: 64px var(--gutter) auto auto; margin: 0; min-width: 260px; padding: var(--s2) 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--e-pop); color: var(--ink); opacity: 1; transform: none; transition: opacity 200ms var(--ease), transform 200ms var(--ease), display 200ms allow-discrete, overlay 200ms allow-discrete; }
@starting-style { .menu:popover-open { opacity: 0; transform: translateY(-4px); } }
.menu-email { padding: var(--s3) var(--s4); font-size: var(--t-small); color: var(--muted); overflow-wrap: anywhere; border-bottom: 1px solid var(--line); margin-bottom: var(--s2); }
.menu button { display: flex; align-items: center; width: 100%; min-height: 48px; padding: 0 var(--s4); background: transparent; border: 0; font: inherit; font-size: var(--t-body); color: var(--ink); text-align: left; cursor: pointer; }
.menu button:hover { background: var(--shade); }
.menu button:focus-visible { outline-offset: -2px; }

.page { max-width: 760px; margin: 0 auto; padding: var(--s7) var(--gutter) var(--s9); }
.page.wide { max-width: 1120px; }

/* ---------- Buttons ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 48px; padding: 0 20px; border: 1px solid transparent; border-radius: var(--r-control); font: inherit; font-size: var(--t-body); font-weight: 600; line-height: 1.2; text-align: center; cursor: pointer; white-space: nowrap; transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease); }
.button:hover { text-decoration: none; }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-hover); }
.button.secondary { background: var(--accent-tint); border-color: var(--accent-tint-line); color: var(--accent-hover); }
.button.secondary:hover { background: var(--accent-tint-hover); border-color: var(--accent-tint-line-hover); }
.button.danger { background: var(--danger); color: #fff; }
.button.danger:hover { background: #8c2019; }
.button.quiet { min-height: 44px; padding: 0 var(--s1); background: transparent; color: var(--accent); }
.button.quiet:hover { text-decoration: underline; }
.button:active { transform: translateY(1px); }
.button:disabled, .button[aria-disabled="true"] { background: var(--shade); border-color: var(--shade); color: var(--muted); cursor: not-allowed; transform: none; }
.button.quiet:disabled { background: transparent; }
.button[aria-busy="true"] { cursor: progress; }
.button.full { width: 100%; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); }

/* ---------- Forms ---------- */
.field { margin: 0 0 var(--s5); }
.field > label, .field > .label, fieldset > legend { display: block; font-weight: 600; margin-bottom: var(--s2); padding: 0; }
.hint { display: block; font-size: var(--t-small); line-height: 1.5; color: var(--muted); margin-top: var(--s2); max-width: 68ch; }
.hint.met { color: var(--success); }
.hint.met::before { content: ""; display: inline-block; width: 6px; height: 11px; margin: 0 10px 0 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], textarea {
  display: block; width: 100%; min-height: 52px; padding: 12px 14px; margin: 0;
  font: inherit; font-size: var(--t-body); line-height: 1.4; color: var(--ink);
  background: var(--surface); border: 1px solid var(--field-line); border-radius: var(--r-control);
}
textarea { min-height: 128px; resize: vertical; line-height: 1.55; }
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border: 2px solid var(--danger); padding: 11px 13px; }
.field-error { display: flex; gap: var(--s2); align-items: baseline; color: var(--danger); font-weight: 600; margin-top: var(--s2); max-width: 68ch; }
.bang { flex: 0 0 auto; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: currentColor; transform: translateY(3px); }
.bang::before { content: "!"; color: #fff; font-size: 14px; font-weight: 800; line-height: 1; }
.error-summary .bang, .field-error .bang { color: var(--danger); }
fieldset { border: 0; margin: 0 0 var(--s5); padding: 0; min-width: 0; }
.password { display: flex; }
.password input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.password .toggle { flex: 0 0 auto; min-width: 76px; min-height: 52px; border: 1px solid var(--field-line); border-left: 0; border-radius: 0 var(--r-control) var(--r-control) 0; background: var(--surface); color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.password .toggle:hover { background: var(--accent-tint); }
.password input[aria-invalid="true"] + .toggle { border: 2px solid var(--danger); border-left: 0; }

.stepper { display: inline-flex; align-items: stretch; }
.stepper button { width: 48px; min-height: 52px; border: 1px solid var(--field-line); background: var(--surface); color: var(--ink); font: inherit; font-size: 22px; font-weight: 600; cursor: pointer; }
.stepper button:first-child { border-radius: var(--r-control) 0 0 var(--r-control); }
.stepper button:last-child { border-radius: 0 var(--r-control) var(--r-control) 0; }
.stepper button:hover { background: var(--shade); }
.stepper button:disabled { color: var(--muted); background: var(--shade); cursor: not-allowed; }
.stepper input { width: 84px; border-radius: 0; border-left: 0; border-right: 0; text-align: center; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.inline-field { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.card-radio { position: relative; display: flex; gap: var(--s3); align-items: flex-start; min-height: 76px; padding: 14px 16px; border: 1px solid var(--field-line); border-radius: var(--r-panel); background: var(--surface); cursor: pointer; transition: background-color 150ms var(--ease), border-color 150ms var(--ease); }
.card-radio:hover { background: var(--shade); }
.card-radio input { flex: 0 0 auto; width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--accent); }
.card-radio:has(input:checked) { border: 2px solid var(--accent); padding: 13px 15px; background: var(--accent-tint); }
.card-radio:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.card-radio input:focus-visible { outline: none; }
.card-radio strong { display: block; font-weight: 600; }
.card-radio span span { display: block; font-variant-numeric: tabular-nums; }

.summary-box { padding: var(--s4) 20px; border: 1px solid var(--accent-tint-line); border-radius: var(--r-panel); background: var(--accent-tint); color: var(--ink); font-variant-numeric: tabular-nums; max-width: none; }

/* ---------- Banners, errors, status ---------- */
.banner { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4) 20px; border-radius: var(--r-panel); margin: 0 0 var(--s6); color: var(--ink); }
.banner p { max-width: none; }
.banner.success { background: var(--success-tint); }
.banner.error { background: var(--danger-tint); }
.banner.info { background: var(--accent-tint); }
.banner .icon { flex: 0 0 auto; margin-top: 4px; }
.icon-check { display: inline-block; width: 20px; height: 20px; border-radius: 50%; background: var(--success); position: relative; }
.icon-check::after { content: ""; position: absolute; left: 7px; top: 4px; width: 5px; height: 9px; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg); }
.icon-info { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); }
.icon-info::before { content: "i"; color: #fff; font-size: 14px; font-weight: 800; line-height: 1; font-family: Georgia, serif; }
.error-summary { padding: 20px; border: 2px solid var(--danger); border-radius: var(--r-panel); background: var(--danger-tint); margin: 0 0 var(--s6); }
.error-summary h2 { font-size: var(--t-heading); line-height: 1.3; display: flex; gap: var(--s3); align-items: baseline; }
.error-summary ul { margin: var(--s3) 0 0; padding: 0 0 0 32px; }
.error-summary li + li { margin-top: var(--s1); }
.error-summary a { color: var(--danger); font-weight: 600; text-decoration: underline; }
.error-summary p { margin-top: var(--s2); }
.inline-status { margin-top: var(--s3); }
.inline-status.ok { color: var(--success); font-weight: 600; }
.inline-status.bad { color: var(--danger); font-weight: 600; }

.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: var(--r-chip); font-size: var(--t-label); font-weight: 600; line-height: 1.2; white-space: nowrap; }
.chip::before { content: ""; flex: 0 0 auto; }
.chip.active { color: var(--success); background: var(--success-tint); }
.chip.active::before { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.paused { color: var(--ink); background: var(--shade); }
.chip.paused::before { width: 8px; height: 10px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.chip.signal { color: var(--signal); background: var(--signal-tint); }
.chip.signal::before { width: 10px; height: 9px; background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.chip.off { color: var(--muted); background: var(--shade); }
.chip.off::before { width: 9px; height: 9px; border: 2px solid currentColor; border-radius: 50%; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.signal-text { color: var(--signal); }

/* ---------- Sections ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s4) var(--s5); }
.page-head + .lead, .page-head + p { margin-top: var(--s3); }
.intro { margin-top: var(--s3); color: var(--muted); }
.block { margin-top: var(--s8); padding-top: var(--s8); border-top: 1px solid var(--line); }
.block.first { margin-top: var(--s7); padding-top: 0; border-top: 0; }
.block-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3) var(--s4); margin-bottom: var(--s5); }
.block-head h2 { font-size: var(--t-title); }
.back { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; font-weight: 600; margin-bottom: var(--s4); }
.back::before { content: ""; width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }

/* Scoring and Recent changes keep the wide page (so the section tabs stay put) but a readable column. */
#view-scoring, #view-changes { max-width: 760px; }
.subnav { display: flex; flex-wrap: wrap; gap: var(--s5); border-bottom: 1px solid var(--line); margin-bottom: var(--s7); }
.subnav a { display: flex; align-items: center; min-height: 44px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--ink); text-decoration: none; }
.subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.list-head { display: grid; background: var(--shade); font-size: var(--t-small); font-weight: 600; padding: 12px 20px; }
.row { display: grid; gap: var(--s1) var(--s5); align-items: start; padding: var(--s4) 20px; }
.row-sub { font-size: var(--t-small); line-height: 1.5; color: var(--muted); margin-top: 2px; }
.row-sub.signal-text { color: var(--signal); }
.row-name { font-weight: 600; overflow-wrap: anywhere; }
.row-email { overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--s2) var(--s3); }
.confirm { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); padding-top: var(--s2); animation: fade 200ms var(--ease); }
.confirm p { flex: 1 1 320px; }
.row.confirming { background: var(--shade); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Agencies list */
.agency-cols { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.4fr) minmax(0, 1.2fr) minmax(0, 1.5fr) 20px; gap: var(--s5); }
.agency-link { display: grid; align-items: start; min-height: 80px; padding: var(--s4) 20px; color: var(--ink); transition: background-color 150ms var(--ease); }
.agency-link:hover { background: var(--shade); text-decoration: none; }
.agency-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: var(--r-panel); }
.agency-name { font-size: var(--t-body); font-weight: 700; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell-label { display: none; }
.go { align-self: center; width: 10px; height: 10px; border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg); }
.list-foot { margin-top: var(--s4); }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s4) var(--s5); margin: var(--s6) 0 var(--s5); }
.toolbar .search { flex: 1 1 320px; }
.toolbar .search label { display: block; font-weight: 600; margin-bottom: var(--s2); }
.segmented { display: flex; flex-wrap: wrap; gap: var(--s2); border: 0; margin: 0; padding: 0; }
.segmented legend { font-weight: 600; margin-bottom: var(--s2); float: left; width: 100%; }
.segmented label { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s4); border: 1px solid var(--field-line); border-radius: var(--r-control); background: var(--surface); font-weight: 600; cursor: pointer; }
.segmented label:hover { background: var(--shade); }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:checked) { background: var(--accent-tint); border: 2px solid var(--accent); padding: 0 15px; color: var(--accent-hover); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }

/* People rows */
/* Fixed action column (fits a "Disabled" label plus a button) so the email column lines up on every row. */
.person { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) 13rem; }
.invite-row { grid-template-columns: minmax(0, 1fr) auto; }
.empty { padding: var(--s6) 20px; }
.empty h2, .empty h3 { margin-bottom: var(--s2); }
.empty p + .actions { margin-top: var(--s4); }

.inline-form { margin-top: var(--s5); padding: var(--s5); border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
.inline-form h3 { margin-bottom: var(--s4); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s4); }

/* Skeleton */
.skeleton { display: none; }
.skeleton.show { display: block; }
.skeleton .bar { height: 80px; background: var(--shade); border-radius: var(--r-panel); margin-bottom: var(--s2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* Save bar */
.savebar { position: sticky; bottom: 0; z-index: var(--z-sticky); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); margin: var(--s6) calc(var(--s5) * -1) 0; padding: var(--s4) var(--s5); padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--e-pop); transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
@starting-style { .savebar { opacity: 0; transform: translateY(16px); } }
.savebar p { flex: 1 1 200px; font-weight: 600; }

/* Changes */
.day { margin-top: var(--s6); }
.day:first-child { margin-top: 0; }
.day h2 { font-size: var(--t-heading); line-height: 1.3; letter-spacing: 0; margin-bottom: var(--s3); }
.danger-text { color: var(--danger); font-weight: 600; }
.change { grid-template-columns: 72px minmax(0, 1fr); }
.change time { font-variant-numeric: tabular-nums; color: var(--muted); }
.change .diff { margin-top: 2px; font-size: var(--t-small); overflow-wrap: anywhere; }

/* Key/value rows (scoring) */
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: var(--s5); padding: var(--s5) 0; border-top: 1px solid var(--line); }
.kv:first-of-type { border-top: 0; padding-top: 0; }
.kv dt { font-weight: 600; }
.kv dd { margin: 0; }
.status-line { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: center; }

/* Steps (recruiter) */
.steps { margin: var(--s5) 0 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--s3); padding: var(--s3) 0; }
/* Keep an email address on one line when it fits, instead of breaking at its hyphen. */
.steps strong, .row-name .row-email { display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-tint); color: var(--accent-hover); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Auth ---------- */
.auth { max-width: 440px; margin: 0 auto; padding: 15vh var(--gutter) var(--s9); }
.auth .wordmark { display: inline-block; margin-bottom: var(--s6); }
.auth h1 { margin-bottom: var(--s3); }
.auth .lead { color: var(--muted); margin-bottom: var(--s6); }
.auth form { margin-top: var(--s6); }
.auth .lead + form { margin-top: 0; }
.auth .after { margin-top: var(--s5); }
.auth-foot { margin-top: var(--s7); color: var(--muted); font-size: var(--t-small); }

/* ---------- Dialog ---------- */
dialog { width: min(560px, 100vw - 32px); max-height: calc(100vh - 32px); padding: var(--s6); border: 0; border-radius: var(--r-panel); background: var(--surface); color: var(--ink); box-shadow: var(--e-dialog); opacity: 1; transform: none; transition: opacity 160ms var(--ease), transform 160ms var(--ease), display 160ms allow-discrete, overlay 160ms allow-discrete; }
dialog[open] { transition-duration: 240ms; }
@starting-style { dialog[open] { opacity: 0; transform: scale(0.98); } }
dialog:not([open]) { opacity: 0; }
dialog::backdrop { background: var(--backdrop); transition: opacity 240ms var(--ease), display 240ms allow-discrete, overlay 240ms allow-discrete; opacity: 1; }
@starting-style { dialog[open]::backdrop { opacity: 0; } }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); }
.dialog-head h2 { font-size: var(--t-heading); line-height: 1.3; padding-top: 8px; }
.close { flex: 0 0 auto; position: relative; width: 44px; height: 44px; margin: 0 -10px 0 0; border: 0; border-radius: var(--r-control); background: transparent; cursor: pointer; }
.close:hover { background: var(--shade); }
.close::before, .close::after { content: ""; position: absolute; left: 12px; top: 21px; width: 20px; height: 2px; background: var(--ink); transform: rotate(45deg); }
.close::after { transform: rotate(-45deg); }
dialog .actions { margin-top: var(--s5); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: var(--s5); z-index: var(--z-toast); max-width: min(520px, calc(100vw - 32px)); padding: 14px 20px; border-radius: var(--r-panel); background: var(--ink); color: #fff; font-weight: 600; box-shadow: var(--e-pop); transform: translateX(-50%); transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
@starting-style { .toast { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  :root { --gutter: 16px; }
  h1 { font-size: 2rem; }
  h2, .block-head h2 { font-size: 1.5rem; }
  .topbar-inner { flex-wrap: wrap; gap: 0 var(--s4); padding: 0 var(--gutter); min-height: 64px; }
  .mainnav { order: 3; flex: 1 1 100%; gap: 0; border-top: 1px solid var(--line); margin: 0 calc(var(--gutter) * -1); }
  .mainnav a { flex: 1 1 0; justify-content: center; }
  .menu { inset: 60px var(--gutter) auto auto; }
  .page { padding: var(--s6) var(--gutter) var(--s8); }
  .auth { padding: 10vh var(--gutter) var(--s8); }
  .block { margin-top: var(--s7); padding-top: var(--s7); }
  .page-head > .button, .block-head > .button { width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
  .list-head { display: none; }
  .agency-link { grid-template-columns: minmax(0, 1fr) 20px; gap: var(--s1) var(--s3); }
  .agency-link > .cell-name { grid-column: 1; }
  .agency-link > .go { grid-column: 2; grid-row: 1; align-self: start; margin-top: 8px; }
  .agency-link > .cell { grid-column: 1; }
  .agency-name { font-size: var(--t-heading); }
  .cell .row-sub { display: none; }
  .agency-link > .cell-status { margin-top: var(--s2); }
  .person, .invite-row { grid-template-columns: minmax(0, 1fr); }
  .row-actions { justify-content: stretch; margin-top: var(--s2); }
  .row-actions .button { flex: 1 1 auto; }
  .row-actions .button.quiet { flex: 0 0 auto; }
  .confirm .button { flex: 1 1 auto; }
  .toolbar .segmented { width: 100%; }
  .kv { grid-template-columns: 1fr; gap: var(--s2); }
  .change { grid-template-columns: 1fr; gap: 0; }
  .savebar { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; border-width: 1px 0 0; }
  .savebar .actions { flex: 1 1 100%; }
  .savebar .button { flex: 1 1 0; }
  .inline-form { padding: var(--s4); }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 12px 12px 0 0; padding: var(--s5) var(--gutter) calc(var(--s5) + env(safe-area-inset-bottom)); }
  @starting-style { dialog[open] { opacity: 0; transform: translateY(24px); } }
  dialog .actions .button { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 100ms !important; animation: none !important; }
  .menu, dialog, .savebar, .toast, .button:active { transform: none !important; }
  @starting-style { .menu:popover-open, dialog[open], .savebar { transform: none !important; } .toast { transform: translateX(-50%) !important; } }
  .toast { transform: translateX(-50%) !important; }
}

.mobile-only { display: none; }
@media (max-width: 720px) {
  .desktop-only { display: none; }
  .mobile-only { display: block; }
}
