/* VaFL Mobile — the VaFL Toolkit look on any phone, tablet or Windows device.
   Light: the pale teal wash, white surfaces, deep-teal actions under white labels.
   Dark: warm charcoal surfaces, the shared accent #1f9fb2 as the teal foreground, deep
   teal only as a fill under a white label. Inter (bundled, fonts/) with the system faces behind it, a 4-point
   grid, 44 px touch targets (50 px for primary actions), brand-tinted glass on the bars,
   150/250 ms motion that respects reduced motion.
   Layouts: a phone (under 760 px) gets one task per screen and a bottom tab bar; a tablet
   or desktop gets the sections in the top bar and a list beside the open item. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/InterVariable.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/InterVariable-Italic.woff2') format('woff2');
}

:root {
  color-scheme: light dark;
  --bg: #effbfd;
  --chrome: rgba(246, 252, 254, 0.78);
  --surface: #ffffff;
  --surface-2: #f6fcfe;
  --raised: #ffffff;
  --text: rgba(0, 0, 0, 0.9);
  --muted: rgba(0, 0, 0, 0.6);
  --faint: rgba(0, 0, 0, 0.42);
  --hairline: #c0e4e9;
  --hairline-soft: rgba(31, 159, 178, 0.16);
  --accent: #1f9fb2;
  --teal: #006477;
  --action: #006477;
  --action-pressed: #00505f;
  --tint: rgba(31, 159, 178, 0.1);
  --tint-strong: rgba(31, 159, 178, 0.18);
  --success: #12704f;
  --success-tint: rgba(18, 112, 79, 0.1);
  --warn: #7a5200;
  --warn-tint: rgba(196, 140, 20, 0.14);
  --error: #b8261a;
  --error-tint: rgba(196, 41, 28, 0.09);
  --shadow: 0 1px 2px rgba(0, 100, 119, 0.06), 0 8px 24px rgba(0, 100, 119, 0.08);
  --shadow-lift: 0 2px 6px rgba(0, 100, 119, 0.1), 0 18px 40px rgba(0, 100, 119, 0.14);
  --page: #ffffff;
  --radius: 16px;
  --radius-sm: 12px;
  --tap: 44px;
  --tap-lg: 50px;
  --link-size: 15px;
  --link-pad: 8px;
  --link-radius: 6px;
  --link-press: color-mix(in srgb, currentColor 8%, transparent);
  --danger-fill: #b8261a;
  --bar: calc(env(safe-area-inset-top) + 60px);
  --tabbar: calc(env(safe-area-inset-bottom) + 62px);
  --actionbar: 70px;
  --fast: 150ms;
  --slow: 250ms;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  /* The tailed l everywhere. Tabular figures only where numbers line up (below): in Inter they
     also widen the hyphen, which spreads case numbers and "e-filed" out in a sentence. */
  font-feature-settings: 'cv05' 1;
}

/* The font shorthand (font: inherit on buttons and fields) would reset the features. */
button, input, select, textarea { font-feature-settings: inherit; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141310;
    --chrome: rgba(24, 23, 20, 0.8);
    --surface: #1f1e1b;
    --surface-2: #262521;
    --raised: #2b2a26;
    --text: #f0ede4;
    --muted: #c2bfb3;
    --faint: #8f8c82;
    --hairline: rgba(255, 255, 255, 0.12);
    --hairline-soft: rgba(255, 255, 255, 0.07);
    --teal: #1f9fb2;
    --tint: rgba(31, 159, 178, 0.14);
    --tint-strong: rgba(31, 159, 178, 0.24);
    --success: #4cc9a0;
    --success-tint: rgba(76, 201, 160, 0.13);
    --warn: #f0b45a;
    --warn-tint: rgba(240, 180, 90, 0.14);
    --error: #ff7a70;
    --danger-fill: #c4291c;
    --error-tint: rgba(255, 107, 97, 0.13);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.35), 0 18px 40px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--bar) + 12px); scroll-padding-bottom: calc(var(--tabbar) + var(--actionbar) + 16px); }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 16px; line-height: 1.45; min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 700; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; color: var(--teal); margin-top: 6px; }
p { margin: 0; }
b, strong { font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.error { color: var(--error); font-size: 15px; font-weight: 500; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal); }
.stack { display: flex; flex-direction: column; gap: 14px; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

/* ------------------------------------------------------------------ Top bar */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--bar);
  padding: calc(env(safe-area-inset-top) + 8px) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--chrome);
  -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  border-bottom: 1px solid var(--hairline-soft);
}
.bar__logo { border-radius: 9px; box-shadow: 0 1px 3px rgba(0, 100, 119, 0.2); }
.bar__title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar__title strong { font-size: 17px; line-height: 1.2; }
.bar__status { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__actions { display: flex; gap: 4px; }

.icon-button {
  width: var(--tap); height: var(--tap); border: 0; border-radius: 50%;
  display: grid; place-items: center; background: transparent; color: var(--teal); cursor: pointer;
  transition: background var(--fast);
}
.icon-button:hover { background: var(--tint); }
.icon-button:active { background: var(--tint-strong); }
.icon-button[aria-current='page'] { background: var(--tint-strong); }

.segment-nav {
  display: flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: var(--tint); border: 1px solid var(--hairline-soft);
}
.segment-nav button {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 0 18px; border: 0; border-radius: 999px;
  background: transparent; color: var(--teal); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background var(--fast), box-shadow var(--fast);
}
.segment-nav button svg { width: 18px; height: 18px; }
.segment-nav button[aria-current='page'] { background: var(--raised); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); color: var(--text); }
.segment-nav button[aria-current='page'] svg { color: var(--teal); }

.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-grid; place-items: center;
  background: var(--error); color: #fff; font-size: 12px; font-weight: 700; line-height: 1;
}

/* ------------------------------------------------------------------ Screens (pairing) */
.screen { min-height: calc(100dvh - var(--bar)); padding: 28px max(20px, env(safe-area-inset-left)) calc(env(safe-area-inset-bottom) + 32px); }
.screen--center { display: grid; place-items: center; }
.welcome { width: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.welcome__mark { border-radius: 20px; box-shadow: var(--shadow-lift); }
.welcome h1 { font-size: 34px; }
.lede { font-size: 18px; color: var(--muted); }
.steps { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 12px; counter-reset: step; }
.steps li { position: relative; padding-left: 46px; min-height: 34px; display: flex; flex-direction: column; justify-content: center; counter-increment: step; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--tint-strong); color: var(--teal); font-weight: 700; font-size: 15px;
}
.steps b { font-size: 16px; }
.steps span { color: var(--muted); font-size: 15px; }
.code-input { font-size: 22px; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.check-number { font-size: 52px; font-weight: 750; letter-spacing: 0.06em; text-align: center; margin: 18px 0 4px; font-variant-numeric: tabular-nums; color: var(--teal); }
.fineprint { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.fineprint svg { width: 16px; height: 16px; margin-top: 2px; color: var(--teal); }

/* ------------------------------------------------------------------ Cards, fields, controls */
.card {
  background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card__head { display: flex; align-items: center; gap: 10px; color: var(--teal); }
.card__head h2 { color: var(--text); }
.callout { border-radius: var(--radius-sm); padding: 14px 16px; background: var(--tint); border: 1px solid var(--hairline-soft); }
.callout[data-tone='error'] { background: var(--error-tint); border-color: transparent; }
.callout[data-tone='success'] { background: var(--success-tint); border-color: transparent; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row--title { grid-template-columns: 2fr 1fr; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { font-size: 14px; color: var(--muted); margin-top: -4px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field__label { font-size: 13px; font-weight: 650; color: var(--muted); letter-spacing: 0.01em; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  min-height: 48px; padding: 11px 13px; width: 100%;
  -webkit-appearance: none; appearance: none;
  transition: border-color var(--fast), box-shadow var(--fast);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); }
input[type='date'], input[type='time'] { min-width: 0; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 21px, calc(100% - 14px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px;
}
textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
#n-body { min-height: 300px; }
.item__text span, .facts dd, .actionbar__state, #t-hours, input[type='number'], input[type='date'], input[type='time'] { font-variant-numeric: tabular-nums; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); font-weight: 550; cursor: pointer; }
.switch input {
  order: 2; flex: none; width: 51px; height: 31px; min-height: 0; padding: 0; border: 0; border-radius: 16px; position: relative;
  background: color-mix(in srgb, var(--muted) 35%, transparent); transition: background var(--fast); cursor: pointer;
}
.switch input::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform var(--fast);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }
.switch input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 3px;
  border-radius: var(--radius-sm); background: var(--tint); border: 1px solid var(--hairline-soft);
}
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; opacity: 0; min-height: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: grid; place-items: center; min-height: 40px; padding: 0 8px; border-radius: 9px; text-align: center;
  font-size: 14px; line-height: 1.2; font-weight: 600; color: var(--teal); transition: background var(--fast), color var(--fast);
}
.segmented input:checked + span { background: var(--action); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }
.segmented input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }

.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check input { width: 24px; height: 24px; min-height: 0; padding: 0; flex: none; border-radius: 7px; position: relative; cursor: pointer; }
.check input:checked { background: var(--action); border-color: var(--action); }
.check input:checked::after { content: ''; position: absolute; left: 7px; top: 3px; width: 6px; height: 12px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }

/* ------------------------------------------------------------------ Buttons */
.btn {
  font: inherit; font-weight: 650; font-size: 16px; min-height: var(--tap-lg); padding: 0 22px; border-radius: 999px;
  border: 1.5px solid transparent; cursor: pointer; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; white-space: nowrap;
  transition: background var(--fast), transform var(--fast), box-shadow var(--fast);
}
.btn--inline { width: auto; }
.btn--small { min-height: var(--tap); padding: 0 16px; font-size: 15px; }
.btn__icon { width: 19px; height: 19px; }
.btn--primary { background: var(--action); color: #fff; box-shadow: 0 2px 8px rgba(0, 100, 119, 0.25); }
.btn--primary:hover { background: var(--action-pressed); }
.btn--danger-solid { background: var(--danger-fill); color: #fff; }
.btn--danger-solid:hover { background: color-mix(in srgb, var(--danger-fill) 82%, #000); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:active:not(:disabled) { transform: scale(0.98); }
/* The one text link every non-primary action uses: no fill, no border, teal (red when
   destructive), a 44 px hit box, underline on hover, a tint of its own colour while pressed. */
.link-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: var(--tap); min-height: var(--tap);
  padding: 0 var(--link-pad); border: 0; border-radius: var(--link-radius); background: none; color: var(--teal);
  font: inherit; font-size: var(--link-size); font-weight: 650; line-height: 1.2; white-space: nowrap; text-decoration: none; cursor: pointer;
}
.link-button:active:not(:disabled) { background: var(--link-press); }
.link-button:disabled { opacity: 0.5; cursor: default; }
.link-button--danger { color: var(--error); }
.stack > .link-button, .welcome > .link-button { align-self: flex-start; }
@media (hover: hover) { .link-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; } }
.link-inline { border: 0; background: none; padding: 0; color: var(--teal); font: inherit; font-weight: 650; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ------------------------------------------------------------------ App shell */
.shell { min-height: calc(100dvh - var(--bar)); }
.page { padding: 20px max(16px, env(safe-area-inset-left)) calc(var(--tabbar) + var(--actionbar) + 24px); }
.page-title { font-size: 30px; margin-bottom: 4px; }
.page-title--list { font-size: 28px; }
.form { display: flex; flex-direction: column; gap: 16px; max-width: 640px; margin: 0 auto; }
.form--wide { max-width: 980px; }
.form--settings { max-width: 640px; }

.banner {
  display: flex; align-items: center; gap: 12px; margin: 12px max(16px, env(safe-area-inset-left)) 0;
  padding: 12px 14px; border-radius: var(--radius-sm); background: var(--error-tint); color: var(--text);
}
.banner svg { color: var(--error); }
.banner p { flex: 1; font-size: 15px; }

/* Lists of items (drafts, sent, today) */
.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.item-list__empty { list-style: none; padding: 10px 2px; color: var(--muted); font-size: 15px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 12px;
  border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--hairline-soft);
  color: var(--text); font: inherit; text-align: left;
}
.item--button { cursor: pointer; transition: background var(--fast), border-color var(--fast), box-shadow var(--fast); }
.item--button:hover { border-color: var(--hairline); box-shadow: var(--shadow); }
.item--button:active { background: var(--tint); }
.item--button[aria-current='true'] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); box-shadow: 0 0 0 1px var(--accent); }
.item__icon { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--tint); color: var(--teal); }
.item__icon svg { width: 20px; height: 20px; }
.item__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.item__text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__text span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__text .item__status { color: var(--faint); }
.item[data-state='delivered'] .item__status { color: var(--success); }
.item[data-state='held'] .item__status, .item[data-state='failed'] .item__status { color: var(--error); }
.list-note, .list-intro { font-size: 14px; color: var(--muted); margin: 6px 2px 0; }
#sent-groups > .eyebrow { margin: 22px 2px 8px; }
#sent-groups > .eyebrow:first-child { margin-top: 18px; }

.chip {
  flex: none; display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap;
  background: var(--tint); color: var(--teal);
}
.chip--large { min-height: 30px; padding: 0 14px; font-size: 14px; }
.chip[data-state='delivered'] { background: var(--success-tint); color: var(--success); }
.chip[data-state='held'], .chip[data-state='failed'] { background: var(--error-tint); color: var(--error); }
.chip[data-state='queued'] { background: var(--warn-tint); color: var(--warn); }
.chip[data-state='unknown'] { background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); }

/* Starting a note */
.starters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 18px; }
.starter {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-height: 108px; padding: 14px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--hairline-soft); box-shadow: var(--shadow);
  color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: transform var(--fast), box-shadow var(--fast);
}
.starter:hover { box-shadow: var(--shadow-lift); }
.starter:active { transform: scale(0.98); }
.starter__icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--action); color: #fff; }
.starter__icon svg { width: 20px; height: 20px; }
.starter strong { display: block; font-size: 15px; }
.starter small { display: block; font-size: 13px; color: var(--muted); }

/* Matter picker */
.picker__chosen {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px;
  padding: 10px 8px 10px 14px; border-radius: var(--radius-sm); background: var(--surface);
  border: 1px solid var(--hairline); box-shadow: inset 4px 0 0 var(--accent);
}
.picker__chosen-text { min-width: 0; display: flex; flex-direction: column; }
.picker__name { font-size: 16px; }
.picker__meta { font-size: 13px; color: var(--muted); }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 42px; min-height: var(--tap-lg); border-radius: 999px; background: var(--surface); }
.picker__list {
  list-style: none; margin: 8px 0 0; padding: 4px; max-height: 44vh; overflow-y: auto; overscroll-behavior: contain;
  border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--hairline-soft);
}
.picker__list li[role='option'] { display: flex; flex-direction: column; justify-content: center; min-height: 54px; padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.picker__list li[role='option']:hover, .picker__list li[role='option']:focus { background: var(--tint); outline: none; }
.picker__row-name { font-weight: 600; }
.picker__row-meta { font-size: 13px; color: var(--muted); }
.picker__group { padding: 10px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal); }
.picker__empty { padding: 14px 12px; color: var(--muted); font-size: 15px; }

/* Bottom bars */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px max(8px, env(safe-area-inset-left)) calc(env(safe-area-inset-bottom) + 6px);
  background: var(--chrome); -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  border-top: 1px solid var(--hairline-soft);
}
.tabbar button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 50px;
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; font-weight: 650; cursor: pointer;
}
.tabbar button svg { width: 24px; height: 24px; padding: 0; transition: color var(--fast); }
.tabbar button[aria-current='page'] { color: var(--teal); }
.tabbar button[aria-current='page'] svg { stroke-width: 2.3; }
.tabbar .badge { position: absolute; top: 2px; left: calc(50% + 6px); }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: var(--tabbar); z-index: 15;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: var(--actionbar);
  padding: 10px max(16px, env(safe-area-inset-left));
  background: var(--chrome); -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  border-top: 1px solid var(--hairline-soft);
}
.actionbar__spacer { flex: 1; }
.actionbar__state { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actionbar .btn { padding: 0 18px; }

/* Empty states and details */
.empty-state { max-width: 460px; margin: 10vh auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 0 12px; }
.empty-state__icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--tint); color: var(--teal); }
.empty-state__icon svg { width: 30px; height: 30px; }
.empty-state h2 { font-size: 22px; }
.editor-head { display: flex; align-items: center; gap: 6px; min-height: var(--tap); }
.icon-button--back { margin-left: -10px; }
.detail { display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 0 auto; }
.detail__title { font-size: 26px; }
.detail__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.detail__actions .btn { width: auto; }
.timeline { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { position: relative; padding: 0 0 18px 34px; display: flex; flex-direction: column; }
.timeline li::before { content: ''; position: absolute; left: 7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--hairline); background: var(--surface); }
.timeline li::after { content: ''; position: absolute; left: 12px; top: 22px; bottom: 0; width: 2px; background: var(--hairline); }
.timeline li:last-child::after { display: none; }
.timeline li[data-done='true']::before { background: var(--accent); border-color: var(--accent); }
.timeline li[data-tone='error']::before { background: var(--error); border-color: var(--error); }
.timeline strong { font-size: 15px; }
.timeline span { font-size: 13px; color: var(--muted); }
.timeline li[data-done='false'] strong { color: var(--muted); font-weight: 550; }

/* Settings */
.facts { margin: 0; display: grid; gap: 10px; }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--hairline-soft); }
.facts div:last-child { border-bottom: 0; padding-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }
.computer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.computer { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.computer svg { color: var(--teal); }
.computer span { display: flex; flex-direction: column; }
.computer small { color: var(--muted); font-size: 13px; }

/* Home visit, handwriting and files */
.section-index {
  position: sticky; top: var(--bar); z-index: 5; display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; margin: 0 -2px;
  background: var(--bg); scrollbar-width: none;
}
.section-index::-webkit-scrollbar { display: none; }
.section-index a {
  flex: none; display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--hairline-soft); color: var(--teal); font-size: 14px; font-weight: 600; text-decoration: none;
}
.hv-section, #sec-ink, #sec-files { scroll-margin-top: calc(var(--bar) + 64px); }
.sub-card { border: 1px solid var(--hairline-soft); border-radius: var(--radius-sm); padding: 14px; background: var(--surface-2); }
.sub-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.ink { display: flex; flex-direction: column; gap: 10px; }
.ink__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.ink__group { display: flex; align-items: center; gap: 4px; }
.ink__pages { margin-left: auto; }
.ink__count { font-size: 14px; color: var(--muted); min-width: 84px; text-align: center; }
.ink__btn, .ink__swatch { width: var(--tap); height: var(--tap); border-radius: 50%; border: 1.5px solid transparent; background: transparent; display: grid; place-items: center; color: var(--teal); cursor: pointer; }
.ink__btn[aria-pressed='true'], .ink__swatch[aria-pressed='true'] { border-color: var(--accent); background: var(--tint); }
.ink__btn:disabled { opacity: 0.35; }
.ink-icon { width: 22px; height: 22px; }
.ink__dot { width: 22px; height: 22px; border-radius: 50%; display: block; }
.ink__dot--black { background: #1b1b1b; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5); }
.ink__dot--blue { background: #1d4fbf; }
.ink__dot--red { background: #c4291c; }
.ink__dot--highlight { background: rgba(255, 212, 0, 0.75); border-radius: 4px; width: 14px; }
.ink__finger { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); min-height: var(--tap); }
.ink__finger input { width: 22px; height: 22px; min-height: 0; padding: 0; border-radius: 6px; position: relative; }
.ink__finger input:checked { background: var(--action); border-color: var(--action); }
.ink__page { width: 100%; max-width: 860px; margin: 0 auto; }
.ink__page canvas {
  display: block; background: var(--page); border-radius: 8px; touch-action: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 8px 22px rgba(0, 100, 119, 0.12);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.file-buttons { display: flex; flex-wrap: wrap; gap: 4px; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-row { display: flex; align-items: center; gap: 14px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--hairline-soft); }
.file-row__thumb { width: 60px; height: 60px; flex: none; border-radius: 10px; background: var(--tint); overflow: hidden; display: grid; place-items: center; font-size: 12px; font-weight: 650; color: var(--teal); text-align: center; }
.file-row__thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-row__text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row__text span { font-size: 13px; color: var(--muted); }

/* Toast and sheets */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(var(--tabbar) + var(--actionbar) + 12px); width: min(92vw, 520px);
  padding: 13px 16px; border-radius: 14px; background: color-mix(in srgb, var(--text) 92%, transparent); color: var(--bg);
  font-size: 15px; font-weight: 500; box-shadow: var(--shadow-lift); animation: rise var(--slow) ease-out;
}
.toast { display: flex; align-items: center; gap: 10px; }
.toast::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.toast[data-tone='error']::before { background: var(--error); }
.toast[data-tone='neutral']::before { background: color-mix(in srgb, var(--bg) 60%, transparent); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.sheet { border: 0; border-radius: 20px; padding: 24px; width: min(92vw, 460px); background: var(--raised); color: var(--text); box-shadow: var(--shadow-lift); }
.sheet::backdrop { background: rgba(0, 0, 0, 0.42); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sheet h2 { font-size: 20px; margin-bottom: 8px; }
/* A sheet opens with its heading focused, so no action shows a focus ring until the keyboard moves to it. */
.sheet h2:focus { outline: none; }
/* The link and the filled button share one row: the button takes the room the link leaves. They
   stack only when both labels cannot fit side by side. */
.sheet__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 20px; }
.sheet__actions .btn { flex: 1 1 0; width: auto; min-width: max-content; padding: 0 14px; }

/* ------------------------------------------------------------------ Phone: one task per screen */
@media (max-width: 759px) {
  .segment-nav { display: none !important; }
  #settings-button { display: none; }
  h1 { font-size: 28px; }
  .split__list, .split__detail { min-width: 0; }
  /* Time: the form; today's entries live in Sent. */
  #tab-time .split__list { display: none; }
  /* Notes and Sent: the list, or the open item. */
  #tab-notes[data-open] .split__list, #tab-sent[data-open] .split__list { display: none; }
  #tab-notes:not([data-open]) .split__detail #note-empty, #tab-sent:not([data-open]) .split__detail #sent-empty { display: none; }
  #tab-notes:not([data-open]) .split__detail, #tab-sent:not([data-open]) .split__detail { display: none; }
  /* Only the open page's action bar shows, and none on lists. */
  #tab-notes:not([data-open]) .actionbar { display: none; }
  #tab-notes:not([data-open]), #tab-sent, #tab-settings { padding-bottom: calc(var(--tabbar) + 24px); }
  .starters { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .starter { min-height: 104px; padding: 12px; }
  .starter small { display: none; }
  .row, .grid2, .row--title, .checklist { grid-template-columns: 1fr; }
  .row:has(input[type='time']), .row:has(#t-hours) { grid-template-columns: 1fr 1fr; }
  .actionbar .btn { flex: 1; padding: 0 10px; font-size: 15px; }
  .actionbar__spacer { display: none; }
  #editor-actions .actionbar__state { display: none; }
  .toast { bottom: calc(var(--tabbar) + var(--actionbar) + 12px); }
  body[data-tab='sent'] .toast, body[data-tab='settings'] .toast { bottom: calc(var(--tabbar) + 12px); }
}

/* Inter is wider than the system faces: on the narrowest phones the date and time fields give
   up a little padding so a whole date still fits beside its pair, and a long placeholder ends
   in an ellipsis rather than being cut. */
@media (max-width: 359px) {
  input[type='date'], input[type='time'] { padding-inline: 9px; }
}
input { text-overflow: ellipsis; }

/* ------------------------------------------------------------------ Tablet and desktop: list beside the open item */
@media (min-width: 760px) {
  :root { --side: 320px; }
  body { font-size: 17px; }
  .tabbar { display: none; }
  html { scroll-padding-bottom: calc(var(--actionbar) + 24px); }
  .bar { gap: 16px; padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .bar__title { flex: 0 1 auto; margin-right: auto; }
  .segment-nav { position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; }
  .page { padding: 0; }
  .split { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: calc(100dvh - var(--bar)); }
  .split__list {
    position: sticky; top: var(--bar); height: calc(100dvh - var(--bar)); overflow-y: auto; overscroll-behavior: contain;
    padding: 22px 18px 32px; border-right: 1px solid var(--hairline-soft); background: color-mix(in srgb, var(--surface) 45%, transparent);
    display: flex; flex-direction: column; gap: 8px;
  }
  .split__list .eyebrow { margin-top: 10px; }
  .split__detail { min-width: 0; padding: 26px 32px calc(var(--actionbar) + 32px); }
  .starters { grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
  .starter { flex-direction: row; align-items: center; min-height: 64px; padding: 10px 14px; }
  .icon-button--back { display: none; }
  .detail .icon-button--back { display: none; }
  .actionbar { left: var(--side); bottom: 0; padding: 12px 32px calc(env(safe-area-inset-bottom) + 12px); min-height: calc(var(--actionbar) + env(safe-area-inset-bottom)); }
  .toast { left: calc(50% + var(--side) / 2); bottom: calc(var(--actionbar) + env(safe-area-inset-bottom) + 16px); }
  #tab-settings { padding: 28px 32px 48px; }
  #pairing-banner { margin: 14px 20px 0; }
}
/* Narrow tablets (an 11-inch iPad in portrait): a slimmer list, whose rows show their state
   as coloured status text instead of a chip, so names have room. */
@media (min-width: 760px) and (max-width: 900px) {
  :root { --side: 280px; }
  .segment-nav button { padding: 0 12px; }
  .split__list .item .chip { display: none; }
  .split__detail { padding: 22px 22px calc(var(--actionbar) + 28px); }
  .actionbar { padding-left: 22px; padding-right: 22px; }
}
/* Large tablets and desktops (a 14.6-inch Galaxy Tab or a Windows laptop): more room. */
@media (min-width: 1300px) {
  :root { --side: 360px; }
}
/* The top-bar segments need room beside the title: below 1000 px they follow the title, and
   below 820 px they show icons only. */
@media (min-width: 760px) and (max-width: 1000px) {
  .segment-nav { position: static; transform: none; }
  .bar__title { margin-right: 0; flex: 1; }
}
@media (min-width: 760px) and (max-width: 819px) {
  .segment-nav button span { display: none; }
  .segment-nav button { padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (hover: none) {
  .item--button:hover, .starter:hover, .icon-button:hover { box-shadow: none; }
}
