/*
 * Token names match bridge getTheme / window.__theme (Task 8 themeTokensFor).
 * :root + prefers-color-scheme hexes are the GistedColors light/dark values —
 * the same pins as apps/receiver theme_tokens_test. Update those first if the
 * shell palette changes; do not invent a second Contacts palette.
 */
:root {
  --surface: #FFFBF8;
  --surface-low: #FFF3EC;
  --ink: #2A1710;
  --muted: #8A5A1E;
  --primary: #A8412A;
  --outline: #8C756B;
  --line: #E0CFC6;
  --danger: #8C3A26;
  --danger-container: #FBE0DA;
  --on-primary: #FFFBF8;
  /* Message-delivery semantics (matches the finance-app sweep): reached =
     green, partial = amber, needs-attention = --danger. The shared
     GistedColors palette carries no success/warning hue, so both light and
     dark values live here, same as apps/finance. */
  /* #2E8B63 was 4.09:1 on --surface, under AA for the ledger's small bold
     text; this green is 5.83:1 on --surface, 5.51:1 on --surface-low. */
  --good: #23704F;
  /* #B4740E was 3.75:1 on --surface (3.54:1 on --surface-low); this amber is
     5.21:1 on --surface, 4.92:1 on --surface-low (styles_test.js). */
  --warn: #955F0B;
  /* Fixed "urgent" red for life-safety SOS surfaces — not the theme-varying
     --danger (whose dark value is a pale pink meant for on-dark text, not a
     button fill). Shared by the Home SOS block and Confirm & send. */
  --sos-strip: #8c3a26;
  --sos-strip-ink: #fffbf8;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;

  /* The receiver's five text roles (apps/receiver/lib/theme/gisted_theme.dart
     _gistedTextTheme), and nothing else: every font in this file is one of
     these (styles_test.js). The platform font stays. */
  --font-title: 600 30px/1.2 var(--font);
  --font-heading: 600 22px/1.25 var(--font);
  --font-row: 600 16px/1.3 var(--font);
  --font-body: 400 14px/1.45 var(--font);
  --font-label: 600 11px/1.2 var(--font);
  --label-tracking: 0.8px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  /* Distance from the viewport bottom to the top of the floating tab bar
     (its height, its 0.7rem lift and the safe area). syncTabbarClearance
     (app.js) measures the real value; this is the first-paint estimate. */
  --tabbar-h: calc(66px + 0.7rem + var(--safe-bottom));
  --tap: 44px;
  /* Pass 2 (the receiver's kit). The three container roles come over the
     bridge (getTheme / __theme); these are the shell's own values, for a
     page opened outside it. */
  --surface-container-low: #FFF3EC;
  --primary-container: #F6DCCF;
  --secondary-container: #F2E3DA;
  --card: var(--surface-container-low);
  --edge: var(--line);
  --tonal: var(--primary-container);
  --tonal-ink: var(--primary);
  --neutral-pill: var(--secondary-container);
  --glass: color-mix(in srgb, var(--surface) 70%, transparent);
  /* Glow only on heroes, primary CTAs and the tab bar. */
  --glow: 0 0 22px -4px color-mix(in srgb, var(--primary) 30%, transparent);
  /* One radius scale: cards and fields, sheet tops, heroes. */
  --r-card: 16px;
  --r-sheet: 20px;
  --r-hero: 24px;
  /* The tallest pinned sheet CTA stack (three buttons, gaps, padding): a
     focused field scrolls above it, never under it. */
  --sheet-actions-reserve: 180px;
}

/* Author .btn { display: inline-flex } would otherwise override the UA
   [hidden] rule and leave Discard (etc.) visible when skipped. */
[hidden] {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-container-low: #241B18;
    --primary-container: #3A2620;
    --secondary-container: #2E2320;
    --glow: 0 0 26px -6px color-mix(in srgb, var(--primary) 38%, transparent);
    --surface: #17110F;
    --surface-low: #241B18;
    --ink: #F7EDE8;
    --muted: #F0C08A;
    --primary: #E8845F;
    --outline: #8E7F79;
    --line: #3A2E2A;
    --danger: #F3B5A2;
    --danger-container: #3A211C;
    --on-primary: #17110F;
    --good: #4FB286;
    --warn: #E0A63A;
    --sos-strip: #6e2e1f;
    --sos-strip-ink: #fff3ec;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
  font: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* Native feel: no visible scrollbars; content still scrolls. */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-touch-callout: none;
}

/* App chrome is not text: no long-press callout, no selection — bars,
   buttons, the sheet handle and tappable rows (a long-press on a row is a
   press). Text people copy is listed below and left selectable. */
.topbar,
.tabbar,
button,
.btn,
.sheet-handle,
.swipe-front.row {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Text people copy: the row sheet's title (a contact's name / username, a
   sent message's subject) — selectable, with its long-press menu. */
#row-action-title {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

button {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
}

p,
h1,
h2,
h3 {
  margin: 0;
}

/* Chromium (the Android WebView) gives a textarea a monospace face and other
   controls the system font unless they inherit; button's font: inherit
   above covers it. Controls keep 16px (the row role's size, regular
   weight): under 16px iOS zooms the page when a field takes focus. */
input,
textarea,
select {
  font-family: inherit;
  font: var(--font-row);
  font-weight: 400;
  -webkit-appearance: none;
  appearance: none;
  border-radius: var(--r-card);
}

/* One focus treatment app-wide: the clay accent, never the browser's blue
   (the same rule as apps/finance). :focus-visible so a tap on a button does
   not ring, but keyboard and text-field focus do. */
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

textarea {
  resize: none;
}

.app {
  height: 100%;
  max-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

/* ---- App bar: its title is the screen title (no in-page repeat) ----
   Spacing matches the receiver's native app bar (business_screen.dart:
   AppBar(titleSpacing: 0) — a 56dp leading slot, the title at 56dp): the
   44px back hit area starts 4px from the edge (16px padding, -12px margin),
   its chevron centred, and the title starts 8px after it, at 56px. */
.topbar {
  /* Its own transition group, which never animates (route transitions). */
  view-transition-name: topbar;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  /* Keep height stable when #nav-back is [hidden] on Home (display:none
     would otherwise collapse the bar below the 44px back control). No
     hairline now: the bar is glass over the page. */
  min-height: calc(var(--safe-top) + 44px + 1.1rem);
  padding: calc(0.55rem + var(--safe-top)) 16px 0.55rem;
  /* The capsule's reserve as the shell measured and injected it
     (--gisted-capsule-right); 5rem until it does. */
  padding-right: calc(16px + var(--gisted-capsule-right, 5rem) + env(safe-area-inset-right, 0px));
  border-bottom: 0;
  background: var(--glass);
  backdrop-filter: saturate(1.2) blur(12px);
  -webkit-backdrop-filter: saturate(1.2) blur(12px);
  z-index: 3;
}

/* Scrolled: the bar takes an edge, a hairline and a raised tint, so it
   reads apart from the page moving under it (2026-10-21). At the top of a
   screen it stays flat. */
.topbar.is-scrolled {
  /* An inset line, not a border: the bar keeps its height. */
  box-shadow: inset 0 -1px 0 var(--line);
  background: var(--card);
}

.topbar {
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
  .topbar {
    transition: none;
  }
}

/* The title is the row role and wraps to two lines before it ellipsizes, so
   a long group or contact name reads in full. Two 16/1.3 lines (41.6px) fit
   in the 44px back-button row; if text zoom makes them taller the bar grows
   (it is a flex: none item above the scroller, nothing assumes its height)
   and the back button stays centred. max-height is the no-line-clamp
   fallback: two lines, clipped. */
.topbar h1 {
  font: var(--font-heading);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--primary);
  margin: 0 0 0 -12px;
  padding: 0;
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.back-chevron {
  display: block;
  width: 0.78rem;
  height: 1.25rem;
}

/* Every scrolling view clears the floating tab bar: its measured height
   (with the safe area) plus 16px, so the last row sits fully above it. */
.main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  /* Vertical scrolling is the browser's; a horizontal drag (the edge-swipe
     Back) stays with the page's pointer handlers. */
  touch-action: pan-y;
  padding: 16px 16px calc(var(--tabbar-h) + 16px);
}

.app.tabbar-hidden .main {
  padding-bottom: calc(16px + var(--safe-bottom));
}

.view {
  position: relative;
}

.view[hidden] {
  display: none;
}

/* ---- Route transitions (Kit.navigate, document.startViewTransition) ----
   <html data-nav> carries the direction. Only the content moves: the top bar
   and the tab bar are their own groups with no animation, and the root
   snapshot is not animated either. */
#main-scroll {
  view-transition-name: content;
}

::view-transition-group(topbar),
::view-transition-old(topbar),
::view-transition-new(topbar),
::view-transition-group(tabbar),
::view-transition-old(tabbar),
::view-transition-new(tabbar),
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}

/* An un-animated old snapshot stays up for the whole transition; the bars'
   old snapshots would show the previous title through the gap the morphing
   title leaves, so they are not drawn. */
::view-transition-old(topbar),
::view-transition-old(tabbar),
::view-transition-old(root) {
  display: none;
}

html[data-nav='forward']::view-transition-old(content) {
  animation: vt-fade-out 250ms ease-out both;
}

html[data-nav='forward']::view-transition-new(content) {
  animation: vt-in-right 250ms ease-out both;
}

html[data-nav='back']::view-transition-old(content) {
  animation: vt-out-right 250ms ease-out both;
}

html[data-nav='back']::view-transition-new(content) {
  animation: vt-fade-in 250ms ease-out both;
}

/* Tab switches: the default crossfade, a touch quicker. */
html[data-nav='tab']::view-transition-old(content),
html[data-nav='tab']::view-transition-new(content) {
  animation-duration: 200ms;
}

/* The shared-element morphs (row title <-> app bar title, collection row
   <-> board hero). */
::view-transition-group(nav-title),
::view-transition-group(nav-hero) {
  animation-duration: 250ms;
  animation-timing-function: ease-out;
}

/* Reduced motion: Kit.navigate marks it 'fade' (no morphs); a plain, short
   crossfade. */
html[data-nav='fade']::view-transition-group(*),
html[data-nav='fade']::view-transition-old(*),
html[data-nav='fade']::view-transition-new(*) {
  animation-duration: 150ms;
}

@keyframes vt-in-right {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}

@keyframes vt-out-right {
  to {
    opacity: 0;
    transform: translateX(24px);
  }
}

@keyframes vt-fade-in {
  from {
    opacity: 0;
  }
}

@keyframes vt-fade-out {
  to {
    opacity: 0;
  }
}

/* Edge swipe Back (Kit.attachEdgeSwipe + makePeek): the view being swiped
   is opaque above the one Back goes to, casting a shadow on it; that one
   (.is-peek) sits under it at its remembered scroll, sliding in from -30%
   and brightening as --peek (0..1) grows. */
.main.is-peeking {
  position: relative;
}

.view.is-edge-swiping {
  position: relative;
  z-index: 1;
  background: var(--surface);
  /* A short page still covers the whole screen while it is swiped. */
  min-height: 100dvh;
  box-shadow: -12px 0 24px -12px rgba(0, 0, 0, 0.35);
}

.view.is-peek {
  position: absolute;
  left: 16px;
  right: 16px;
  z-index: 0;
  pointer-events: none;
  transform: translateX(calc(-30% * (1 - var(--peek, 0))));
  filter: brightness(calc(0.82 + 0.18 * var(--peek, 0)));
}

/* Without view transitions (Kit.navigate's fallback): the page enters
   with a light CSS slide; leave is instant. */
.view.pt-enter-fade {
  animation: pt-enter-fade 200ms ease-out both;
}

.view.pt-enter-forward {
  animation: pt-enter-forward 240ms ease-out both;
}

.view.pt-enter-back {
  animation: pt-enter-back 240ms ease-out both;
}

/* A transform would make the SOS view the containing block of its fixed
   action bar for the length of the slide, and the bar would jump. */
#view-sos.pt-enter-forward,
#view-sos.pt-enter-back {
  animation-name: pt-enter-fade;
}

@keyframes pt-enter-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pt-enter-forward {
  from {
    opacity: 0;
    transform: translateX(14%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pt-enter-back {
  from {
    opacity: 0;
    transform: translateX(-10%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ---- Sections ---- */
.view-section + .view-section,
.view > .view-section + .view-section {
  margin-top: 28px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--tap);
  margin-bottom: 4px;
}

.section-heading h2,
.view-section > h2 {
  font: var(--font-label);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--muted);
}

.section-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 4px;
  margin-right: -4px;
  font: var(--font-body);
  color: var(--primary);
}

/* The label above a grouped list (e.g. "Will be alerted", "Delivery"). */
.group-label {
  margin: 0 0 4px;
  font: var(--font-label);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--muted);
}

.icon-btn,
.section-action {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  min-width: var(--tap);
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--tonal);
  color: var(--tonal-ink);
  font: var(--font-label);
}

/* The 44px hit area around the 36px stadium. */
.icon-btn::after,
.section-action::after {
  content: "";
  position: absolute;
  inset: -4px 0;
}

.icon-btn .icon-plus {
  width: 18px;
  height: 18px;
  display: block;
}

/* ---- Rows: every list is one of these (rows.js) ----
   On the page surface, no per-row box: a hairline in --line between rows
   (not after the last), inset to the text. The group bleeds to the screen
   edge so the rows' 16px padding lines their text up with the headings. */
.row-group {
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--r-card);
  overflow: hidden;
}

/* An empty list draws nothing: otherwise its border alone shows as a thin
   bar above the empty state (Scheduled with nothing scheduled). */
.row-group:empty {
  display: none;
}

.row-group > li {
  position: relative;
  min-width: 0;
}

.row-group > li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 1px;
  background: var(--edge);
  z-index: 2;
  pointer-events: none;
}

/* Inset to the text when the row above leads with a 40px disc. */
.row-group > li.has-lead + li::before {
  left: 68px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 10px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: var(--font-body);
  text-align: left;
  text-decoration: none;
}

a.row,
button.row,
.swipe-front.row {
  cursor: pointer;
}

a.row:active,
button.row:active,
.swipe-front.row:active {
  background: color-mix(in srgb, var(--ink) 6%, var(--card));
}

.row:focus-visible {
  outline-offset: -2px;
}

.row-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-title {
  display: block;
  font: var(--font-row);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.row-meta {
  display: block;
  font: var(--font-body);
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* A template's message preview: one line. */
.row-meta.is-clamped {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta.is-danger {
  color: var(--danger);
}

.row-title-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}

.row-trail {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  max-width: 45%;
  font: var(--font-body);
  color: var(--muted);
  text-align: right;
}

.row-trail-text {
  white-space: nowrap;
}

/* A send row's time over its pill. */
.row-trail-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.row-trail-text.is-warn {
  color: var(--warn);
}

.row-trail-text.is-danger {
  color: var(--danger);
}

.row-chevron {
  display: block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-top: 2px solid var(--outline);
  border-right: 2px solid var(--outline);
  transform: rotate(45deg);
}

.row-chevron-down {
  margin: 0 4px 4px 0;
  transform: rotate(135deg);
  transition: transform 0.18s ease;
}

.row-toggle[aria-expanded="true"] .row-chevron-down {
  margin: 4px 4px 0 0;
  transform: rotate(-45deg);
}

.row-monogram {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: var(--font-label);
  color: var(--tonal-ink);
  background: var(--tonal);
}

/* A row's 40px leading disc: initials or an icon on the tonal fill. */
.lead-disc {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: var(--font-label);
  background: var(--tonal);
  color: var(--tonal-ink);
}

.lead-disc.is-sos {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}

/* The person's picture laid over the initial; a failed one is removed. */
.row-monogram {
  position: relative;
  overflow: hidden;
}

.row-monogram img.avatar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ---- Pills: quiet sentence-case stadiums, a tone at 12-14% ---- */
.pill,
.badge,
.row-emergency-mark {
  display: inline-block;
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  font: var(--font-label);
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  background: var(--neutral-pill);
  white-space: nowrap;
}

/* Semantic delivery-status tones (mirrors apps/finance): reached = green,
   partial = amber, needs-attention = red. Clay (--primary) stays reserved
   for actions, never for status. */
.pill-ok,
.badge-ok {
  color: var(--good);
  background: color-mix(in srgb, var(--good) 14%, transparent);
}

.pill-warn,
.badge-warn {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}

.pill-danger,
.badge-danger {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.pill-neutral {
  color: var(--ink);
  background: var(--neutral-pill);
}

.row-emergency-mark {
  /* The theme's danger pair (injected by the shell), not the fixed
     --sos-strip fill: that dark red was 1.7:1 on the dark card. danger on
     dangerContainer is 6.10:1 light, 8.44:1 dark (styles_test.js). */
  color: var(--danger);
  background: var(--danger-container);
}

/* ---- Swipe rows: the actions behind the face; a tap on the face opens the
   same actions in the action sheet (rows.js, swipe_row.js) ---- */
.row-group > li.swipe-row {
  overflow: hidden;
  touch-action: pan-y;
}

.swipe-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  z-index: 0;
  /* Not painted at rest: a 1-2px strip of the action colours could show at
     the face's edge. The delay keeps them for the 180ms slide closed
     (swipe_row.js setSwipeOffset). */
  visibility: hidden;
  transition: visibility 0s linear 180ms;
}

.swipe-row.is-open .swipe-actions,
.swipe-row.is-dragging .swipe-actions {
  visibility: visible;
  transition-delay: 0s;
}

.swipe-action {
  border: 0;
  margin: 0;
  min-width: 76px;
  padding: 0 12px;
  font: var(--font-body);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.swipe-action-neutral {
  background: color-mix(in srgb, var(--primary) 82%, #1a1a1a);
}

.swipe-action-rename {
  background: var(--outline);
}

.swipe-action-remove {
  background: var(--danger);
}

.swipe-front {
  position: relative;
  z-index: 1;
  /* The card's own fill: the face covers the actions and reads as part of
     the GroupCard it sits in. */
  background: var(--card);
  touch-action: pan-y;
  will-change: transform;
}

.swipe-row.is-dragging .swipe-front {
  transition: none !important;
}

.swipe-row.is-open .swipe-front,
.swipe-row.is-dragging .swipe-front {
  box-shadow: -4px 0 12px color-mix(in srgb, var(--ink) 8%, transparent);
}

.row-group > li.row-enter {
  animation: row-enter 320ms ease-out;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 12px 16px;
  font: var(--font-row);
  text-align: center;
  transition: opacity 0.15s ease, transform 0.08s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
  opacity: 0.92;
}

.btn + .btn {
  margin-top: 8px;
}

.btn-primary {
  min-height: 52px;
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
  box-shadow: var(--glow);
}

.btn-ghost {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--edge);
}

/* A secondary action that is only words (Cancel under Confirm & send). */
.btn-text {
  min-height: var(--tap);
  background: transparent;
  border-color: transparent;
  color: var(--primary);
}

.btn-compact {
  width: auto;
  min-height: var(--tap);
  padding: 8px 14px;
}

.btn-compact + .btn-compact {
  margin-top: 0;
}

.btn-large {
  min-height: 56px;
}

/* A life-safety confirm action must read as unmistakably strong in both
   themes — --danger's dark value is a pale pink (meant for on-dark text, not
   a button fill), so this uses the fixed "urgent" red instead. Falls back to
   --danger/--on-primary if the sos-strip tokens are ever unset. */
.btn-sos {
  background: var(--sos-strip, var(--danger));
  color: var(--sos-strip-ink, var(--on-primary));
  border-color: var(--sos-strip, var(--danger));
}

.btn-sos.is-disabled,
.btn-sos:disabled {
  opacity: 0.42;
  filter: grayscale(0.35);
}

a.btn {
  text-decoration: none;
}

/* ---- Home ---- */
.setup-card {
  margin: 0 0 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-low);
  display: grid;
  gap: 12px;
}

.setup-card h2 {
  font: var(--font-heading);
}

.setup-card p {
  font: var(--font-body);
  color: var(--muted);
}

.setup-card .setup-card-title {
  font: var(--font-row);
  color: var(--ink);
}

.setup-card .btn + .btn {
  margin-top: 0;
}

.sos-setup {
  grid-template-columns: 1fr;
}

/* The SOS hero — the app's signature element, shown whole only when SOS
   can be sent; an empty Emergency group gets .sos-setup instead. A glass
   card with an error wash, an error hairline and an error glow. */
.sos-block {
  margin: 0 0 20px;
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--edge));
  border-radius: var(--r-hero);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--danger) 22%, transparent), transparent 60%),
    color-mix(in srgb, var(--danger) 8%, var(--card));
  box-shadow: 0 0 28px -8px color-mix(in srgb, var(--danger) 55%, transparent);
  color: var(--ink);
}

.sos-block h2 {
  margin: 0 0 4px;
  font: var(--font-heading);
  color: var(--danger);
}

.sos-block p {
  margin: 0 0 16px;
  font: var(--font-body);
  color: var(--muted);
}

/* Send SOS: a full-width error CTA with its own glow. The fixed urgent red
   (--sos-strip), not --danger: dark --danger is a pale text tint. */
.sos-block .btn-sos {
  min-height: 52px;
  background: var(--sos-strip);
  color: var(--sos-strip-ink);
  border-color: var(--sos-strip);
  box-shadow: 0 0 22px -4px color-mix(in srgb, var(--danger) 60%, transparent);
}

.sos-block .btn-sos.is-disabled,
.sos-block .btn-sos:disabled {
  /* Not live: no glow, and greyed like every disabled SOS action. */
  opacity: 0.55;
  filter: grayscale(0.35);
  box-shadow: none;
}

.home-live {
  margin: 0 0 16px;
}

.home-recent {
  margin-top: 24px;
}

/* Home fills the scroll area so the empty state can sit in the space a set-up
   book with no recent activity would otherwise leave blank. Scoped :not([hidden])
   so it never beats .view[hidden] { display: none } when another tab is active. */
#view-home:not([hidden]) {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* Home with no messages yet (owner-approved mock, 2026-10-21): an example
   message, marked Example, then the two ways in. The hero's clay and the
   path cards match the Finance welcome. */
.home-empty {
  display: grid;
  gap: 16px;
  margin: 8px 0 0;
  padding-bottom: 8px;
}

.welcome-hero {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: var(--r-hero);
  color: #fff;
  background:
    radial-gradient(130% 90% at 85% 0%, rgba(255, 255, 255, 0.16), transparent 60%),
    linear-gradient(135deg, #a8412a 0%, #6e2a1a 100%);
  box-shadow: var(--glow);
  overflow: hidden;
}

.welcome-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.welcome-hero-cap {
  font: var(--font-body);
  color: rgba(255, 255, 255, 0.85);
}

/* On the clay: a light pill, not the neutral one. */
.welcome-hero .welcome-example {
  flex: none;
  padding: 5px 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.welcome-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  font: var(--font-label);
  background: rgba(255, 255, 255, 0.18);
  animation: welcome-rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.welcome-chip-disc {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font: var(--font-label);
  background: #fff;
  color: #a8412a;
}

.welcome-bubble {
  justify-self: end;
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 16px 16px 4px 16px;
  font: var(--font-body);
  background: #fff;
  color: #2a1710;
  animation: welcome-rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: 0.62s;
}

.welcome-meta {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 6px;
  font: var(--font-label);
  color: rgba(255, 255, 255, 0.8);
  animation: welcome-rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: 0.8s;
}

.welcome-meta svg {
  width: 14px;
  height: 14px;
}

/* One moment when the welcome appears: the people, then the message and
   its delivery, rise in. It plays each time [hidden] lifts, then sits
   still. */
@keyframes welcome-rise {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.welcome-chip:nth-child(1) {
  animation-delay: 0.2s;
}

.welcome-chip:nth-child(2) {
  animation-delay: 0.32s;
}

.welcome-chip:nth-child(3) {
  animation-delay: 0.44s;
}

@media (prefers-reduced-motion: reduce) {
  .welcome-chip,
  .welcome-bubble,
  .welcome-meta {
    animation: none;
  }
}

.home-welcome-title {
  font: var(--font-heading);
  color: var(--ink);
  text-wrap: balance;
}

.home-welcome-lede {
  margin-top: -10px;
  font: var(--font-body);
  color: var(--muted);
}

.welcome-paths {
  display: grid;
  gap: 10px;
}

.welcome-path {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: start;
  width: 100%;
  padding: 16px;
  border-radius: var(--r-card);
  border: 1px solid var(--edge);
  background: var(--card);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
}

.welcome-path-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary-container);
  color: var(--primary);
}

.welcome-path-icon svg {
  width: 22px;
  height: 22px;
}

.welcome-path-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.welcome-path-title {
  font: var(--font-row);
}

.welcome-path-meta {
  font: var(--font-body);
  color: var(--muted);
}

/* Compose leads: it is what Contacts is for. */
.welcome-path.is-lead {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.welcome-path.is-lead .welcome-path-icon {
  background: color-mix(in srgb, var(--on-primary) 16%, transparent);
  color: var(--on-primary);
}

.welcome-path.is-lead .welcome-path-meta {
  color: var(--on-primary);
  opacity: 0.85;
}

.welcome-cta {
  justify-self: start;
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  font: var(--font-row);
  background: var(--on-primary);
  color: var(--primary);
}

/* ---- Templates / Sent / Scheduled ---- */
.sent-row-btn {
  cursor: pointer;
}

.sent-row-detail {
  padding: 0 16px 16px;
}

.sent-row-body {
  margin: 0 0 12px;
  font: var(--font-body);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sent-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.sent-action-chip {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  font: var(--font-body);
}

.sent-row-detail .status {
  margin-top: 8px;
}

.ledger-block {
  margin-top: 20px;
}

.ledger-block .btn {
  margin-top: 12px;
}

.sent-row-detail .ledger-block {
  margin-top: 4px;
}

.sos-ledger-status {
  font: var(--font-body);
  color: var(--muted);
}

.sos-ledger-status.is-reached {
  /* Success is --good everywhere, as on the Sent badge (.badge-ok); clay
     (--primary) is for actions, not status. */
  color: var(--good);
}

.empty {
  margin: 8px 0 0;
  font: var(--font-body);
  color: var(--muted);
}

/* The lighter style for everyday empty lists (owner-approved mock,
   2026-10-21): a soft icon tile, a title, one line of help and, where there
   is an obvious next step, one button. */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 24px 16px;
  text-align: center;
}

.empty-state-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 2px;
  border-radius: 18px;
  background: var(--primary-container);
  color: var(--primary);
}

.empty-state-icon svg {
  width: 28px;
  height: 28px;
}

.empty-state-title {
  font: var(--font-row);
  color: var(--ink);
}

.empty-state-help {
  max-width: 30ch;
  font: var(--font-body);
  color: var(--muted);
}

.empty-state-cta {
  width: auto;
  margin-top: 8px;
  padding: 12px 20px;
}

/* ---- Confirm SOS ---- */
.sos-view #sos-ready {
  /* Room for the fixed action bar below the last row. */
  padding-bottom: calc(136px + var(--safe-bottom));
}

.sos-loc-line {
  margin: 8px 0 20px;
  font: var(--font-body);
  color: var(--muted);
}

.sos-loc-line.is-ok {
  color: var(--good);
}

/* Degraded, not failed: the SOS still sends. */
.sos-loc-line.is-bad {
  color: var(--warn);
}

.sos-attach-panel {
  padding: 0 0 4px;
}


/* One extra per block: what it is, then its buttons under it. */
.sos-attach-item {
  display: grid;
  gap: 8px;
  padding: 10px 16px 12px 32px;
}

.sos-attach-actions {
  flex: none;
  display: flex;
  gap: 4px;
  align-items: center;
}

.sos-audio-status {
  display: block;
  font: var(--font-body);
  color: var(--ink);
}

/* Confirm & send: always on screen, above the safe area. */
.sos-actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: grid;
  gap: 4px;
  padding: 12px 16px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.2) blur(12px);
  -webkit-backdrop-filter: saturate(1.2) blur(12px);
}

.sos-actionbar .btn + .btn {
  margin-top: 0;
}

.sos-view > .setup-card .btn-text {
  justify-self: center;
}

/* ---- Status lines ---- */
.hint {
  font: var(--font-body);
  color: var(--muted);
}

.status {
  margin: 0 0 12px;
  font: var(--font-body);
  color: var(--muted);
}

.status.is-error {
  color: var(--danger);
}

/* The retry a failed list read offers, inline after its error (list_load.js).
   The hit area is 44px tall without growing the line. */
.status-retry {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  margin: -12px 0;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  text-decoration: underline;
  vertical-align: middle;
  cursor: pointer;
}

.status-retry:disabled {
  opacity: 0.5;
  cursor: default;
}

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

/* ---- Forms ---- */
.stack-form {
  display: grid;
  gap: 16px;
  margin: 0 0 16px;
  min-width: 0;
}

#schedule-edit-fields,
#schedule-repeat-fields {
  display: grid;
  gap: 16px;
}

#schedule-edit-fields[hidden],
#schedule-repeat-fields[hidden] {
  display: none;
}

.stack-form label,
.field-label {
  display: grid;
  gap: 6px;
  min-width: 0;
  font: var(--font-body);
  color: var(--muted);
}

.field-block {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.stack-form input,
.stack-form textarea,
.stack-form select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px 14px;
}

.stack-form textarea {
  min-height: 5.5rem;
}

.stack-form > .hint {
  margin-top: -8px;
}

.compose-actions {
  display: grid;
  gap: 4px;
}

.compose-actions .btn + .btn {
  margin-top: 0;
}

/* Send later: the lighter second action under Send now, with a clock. */
.compose-later {
  gap: 8px;
}

.compose-later svg {
  flex: none;
}

/* ---- Compose: the To field (people and one group, as chips) ---- */
.compose-to {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.compose-to-chips {
  display: contents;
}

.compose-to-add {
  flex: 1 1 auto;
  min-height: 34px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font: var(--font-row);
  font-weight: 400;
}

.compose-chip,
.compose-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 34px;
  padding: 0 0 0 12px;
  border-radius: 999px;
  background: var(--tonal);
  color: var(--ink);
  font: var(--font-body);
}

.compose-chip.has-disc {
  padding-left: 4px;
}

.compose-chip-disc {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--tonal-ink);
  font: var(--font-label);
}

.compose-chip-name,
.compose-attach-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The glyph stays small; the button is 44x44 and overhangs the chip. */
.compose-chip button,
.compose-file-chip button {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  margin: -5px -6px -5px -10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: var(--font-row);
}

.compose-file-chip {
  justify-self: start;
}

.compose-file-chip[hidden] {
  display: none;
}

.hint.is-error {
  color: var(--danger);
}

/* ---- Compose: Attach and the count, inside the Message box ---- */
.compose-message {
  position: relative;
  min-width: 0;
}

.stack-form .compose-message textarea {
  min-height: 8rem;
  padding-bottom: 52px;
}

.compose-attach-pick {
  position: absolute;
  left: 4px;
  bottom: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: var(--font-body);
}

.compose-attach-pick.is-disabled {
  opacity: 0.45;
}

.compose-count {
  position: absolute;
  right: 14px;
  bottom: 14px;
  font: var(--font-body);
  color: var(--muted);
  pointer-events: none;
}

/* ---- Compose: the Send to sheet ---- */
.compose-to-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.compose-to-head h2 {
  flex: 1 1 auto;
  margin: 0;
  padding-right: 0;
}

/* The title takes focus when the sheet opens, so Done does not; it is not
   a control and draws no ring. */
#compose-to-title:focus-visible {
  outline-color: transparent;
}

/* Done closes this sheet: the chrome's X would be a second close. */
#compose-to-sheet .sheet-x {
  display: none;
}

.compose-to-done {
  flex: none;
  min-height: var(--tap);
  padding: 0 12px;
  margin-right: -8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  font: var(--font-row);
}

.compose-to-search {
  width: 100%;
  min-height: 48px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.compose-to-count {
  margin: 0 0 12px;
}

.compose-to-list {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.compose-pick.is-selected .row-title {
  color: var(--primary);
}

.compose-pick[aria-disabled="true"] {
  opacity: 0.45;
}

/* A round tick on the right: an empty ring, filled with a check when on. */
.compose-tick {
  flex: none;
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--outline);
  border-radius: 50%;
  background: var(--surface);
}

.compose-pick.is-selected .compose-tick {
  border-color: var(--primary);
  background: var(--primary);
}

/* The check: a short L turned 45deg, in the on-primary ink. */
.compose-pick.is-selected .compose-tick::after {
  content: '';
  display: block;
  width: 6px;
  height: 11px;
  margin: 3px auto 0;
  border-right: 2.5px solid var(--on-primary);
  border-bottom: 2.5px solid var(--on-primary);
  transform: rotate(45deg);
}

/* iOS-style confirm toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.toggle-copy {
  flex: 1 1 auto;
  min-width: 0;
  font: var(--font-body);
  color: var(--ink);
}

.stack-form label.toggle {
  position: relative;
  flex: none;
  display: inline-flex;
  width: 51px;
  height: 31px;
  margin: 0;
}

/* The input spans past the switch so the hit area is 45px tall. */
.toggle input {
  position: absolute;
  inset: -7px -4px;
  opacity: 0;
  width: auto;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  z-index: 1;
}

.toggle-ui {
  display: block;
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.18s ease;
  pointer-events: none;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.toggle input:checked + .toggle-ui {
  background: var(--primary);
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(20px);
}

.toggle input:focus-visible + .toggle-ui {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Searchable multi-select */
.ms {
  position: relative;
  min-width: 0;
}

.ms-search {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 12px 14px;
}

.ms-options {
  max-height: 12rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ms-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 12px 14px;
  font: var(--font-body);
}

.ms-option:last-child {
  border-bottom: 0;
}

.ms-option.is-selected {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

.ms-option .ms-check {
  flex: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--outline);
  border-radius: 4px;
  background: var(--surface);
}

.ms-option.is-selected .ms-check {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: inset 0 0 0 2px var(--surface);
}

.ms-option-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ms-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.ms-chips:empty {
  display: none;
}

.ms-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  min-height: 34px;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
  padding: 0 0 0 12px;
  font: var(--font-body);
}

.ms-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The glyph stays small; the button is 44x44 and overhangs the chip. */
.ms-chip button {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  margin: -5px -6px -5px -8px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font: var(--font-row);
  padding: 0;
}

.ms-empty {
  padding: 14px;
  color: var(--muted);
  font: var(--font-body);
}

/* ---- Sheets ---- */
.sheet {
  width: 100%;
  max-width: 100%;
  max-height: 88dvh;
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--edge);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 -8px 40px -12px rgba(0, 0, 0, 0.35);
}

/* A dark scrim in both themes — must NOT key off --ink, which is the light
   text colour in dark mode and would wash the backdrop lighter instead of
   dimming it. Same value and reasoning as apps/finance/styles.css. */
.sheet::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

/* Sheets move like native ones: up from the bottom on a spring-like curve
   while the scrim fades in; down and out (Kit.closeSheet adds .is-closing,
   then closes the dialog when it has played). A drag sets the transform
   inline (Kit.attachSheetDrag). */
.sheet[open] {
  animation: sheet-in 320ms cubic-bezier(.2, .9, .25, 1) both;
}

.sheet[open]::backdrop {
  animation: scrim-in 320ms ease-out both;
}

.sheet.is-closing {
  animation: sheet-out 220ms ease-in both;
  /* On its way out: a tap must not land on a sheet that is leaving. */
  pointer-events: none;
}

.sheet.is-closing::backdrop {
  animation: scrim-out 220ms ease-in both;
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-out {
  to {
    transform: translateY(100%);
  }
}

@keyframes scrim-in {
  from {
    opacity: 0;
  }
}

@keyframes scrim-out {
  to {
    opacity: 0;
  }
}

/* Sheets under reduced motion: a short fade, no travel. */
@media (prefers-reduced-motion: reduce) {
  .sheet[open],
  .sheet[open]::backdrop {
    animation: scrim-in 150ms ease-out both;
  }
}

.sheet.is-closing.is-fade,
.sheet.is-closing.is-fade::backdrop {
  animation: scrim-out 120ms ease-out both;
}

/* While it slides away a closing sheet is no longer modal (Kit.closeSheet
   closes it at once, so the page behind is live — a tap on Send SOS is not
   lost) and is re-shown non-modally just to animate: kept where the modal
   sheet was, above the page, taking no taps. Its scrim is a separate
   overlay, fading on its own. */
.sheet.is-closing:not(:modal) {
  position: fixed;
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  margin: 0;
  z-index: 1001;
  pointer-events: none;
}

.sheet-scrim-out {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.62);
  pointer-events: none;
  animation: scrim-out 220ms ease-in both;
}

.sheet-scrim-out.is-fade {
  animation-duration: 120ms;
}

.sheet-form {
  /* The sheet's own scroll never rubber-bands the page behind it. */
  overscroll-behavior: contain;
  padding: 24px 16px 16px;
  scroll-padding-bottom: var(--sheet-actions-reserve);
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 88dvh;
}

.sheet-form h2 {
  margin: 0 0 4px;
  padding-right: var(--tap);
  font: var(--font-heading);
}

/* The sheet's own chrome (kit.js sheetChrome): a drag handle and an X. */
/* Dragging a sheet down (Kit.attachSheetDrag) starts on its handle or
   header: those take the whole gesture, so the browser does not claim it
   for scrolling and cancel the drag. */
.sheet-handle,
.sheet-form > h2 {
  touch-action: none;
}

/* The 4px handle's grab area: a finger-sized box around it. */
.sheet-handle::after {
  content: '';
  position: absolute;
  inset: -16px -48px;
}

.sheet-handle {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ink) 35%, transparent);
}

.sheet-x {
  position: absolute;
  top: 12px;
  right: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

/* The close button is a bare X, never ringed or bordered (owner,
   2026-10-21; Finance has the same rule): keyboard focus shows as a quiet
   disc behind the X instead of an outline. */
.sheet-x:focus,
.sheet-x:focus-visible {
  outline-color: transparent;
  box-shadow: none;
}

.sheet-x:focus-visible {
  background: color-mix(in srgb, var(--ink) 10%, transparent);
}

.sheet-x:active {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

/* A sheet takes focus when it opens (so its X does not) and draws no ring. */
dialog.sheet:focus,
dialog.sheet:focus-visible {
  outline-color: transparent;
}

.sheet-sub {
  margin: 0 0 16px;
  font: var(--font-body);
  color: var(--muted);
}

.sheet-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding: 12px 0 calc(8px + var(--safe-bottom));
  background: linear-gradient(to bottom, transparent, var(--card) 30%);
}

.sheet-actions .btn + .btn {
  margin-top: 0;
}

.action-sheet .sheet-form {
  padding: 12px 16px calc(12px + var(--safe-bottom));
}

.action-sheet-title {
  padding: 4px var(--tap) 12px 0;
  font: var(--font-heading);
  color: var(--ink);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The actions as one card; the X closes (there is no Close row). */
.action-sheet-list {
  display: grid;
  margin: 0 0 12px;
  border: 1px solid var(--edge);
  border-radius: var(--r-card);
  overflow: hidden;
  background: var(--surface);
}

.action-sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: var(--font-body);
  text-align: left;
}

.action-sheet-item + .action-sheet-item {
  border-top: 1px solid var(--edge);
}

.action-sheet-item:active {
  background: color-mix(in srgb, var(--ink) 6%, var(--surface));
}

/* The 32px icon disc; the icon is a mask over the tone, from data-icon. */
.action-sheet-disc {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
}

.action-sheet-disc[data-icon="edit"] {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='16' fill='%23000' fill-opacity='.14'/%3E%3Cpath d='M11 21l.7-3.2 7.6-7.6 2.5 2.5-7.6 7.6zM18.2 11.3l2.5 2.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") center / 32px 32px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='16' fill='%23000' fill-opacity='.14'/%3E%3Cpath d='M11 21l.7-3.2 7.6-7.6 2.5 2.5-7.6 7.6zM18.2 11.3l2.5 2.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") center / 32px 32px no-repeat;
}

.action-sheet-disc[data-icon="trash"] {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='16' fill='%23000' fill-opacity='.14'/%3E%3Cpath d='M11 12h10M14 12v-1.5h4V12M12.5 12l.8 9.5h5.4l.8-9.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") center / 32px 32px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='16' fill='%23000' fill-opacity='.14'/%3E%3Cpath d='M11 12h10M14 12v-1.5h4V12M12.5 12l.8 9.5h5.4l.8-9.5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") center / 32px 32px no-repeat;
}

.action-sheet-disc[data-icon="action"] {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='16' fill='%23000' fill-opacity='.14'/%3E%3Cpath d='M13 11l5 5-5 5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 32px 32px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='16' fill='%23000' fill-opacity='.14'/%3E%3Cpath d='M13 11l5 5-5 5' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 32px 32px no-repeat;
}

.action-sheet-item.is-destructive .action-sheet-disc {
  background: var(--danger);
}

/* The title takes focus only so no action does (tabindex=-1, never
   tabbable); it is not a control and draws no ring. */
.action-sheet-title:focus-visible {
  outline-color: transparent;
}

.action-sheet-item:focus-visible {
  outline-offset: -2px;
}

.action-sheet-item.is-destructive {
  color: var(--danger);
}

/* A group's lead icon sits centred in its disc. */
.lead-disc svg {
  display: block;
}

/* ---- Bottom tab bar: floating pill ---- */
.app.tabbar-hidden .tabbar {
  view-transition-name: tabbar;
  display: none;
}

.tabbar {
  flex: none;
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--safe-bottom) + 0.7rem);
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 28px;
  border: 1px solid var(--edge);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  backdrop-filter: saturate(1.7) blur(26px);
  -webkit-backdrop-filter: saturate(1.7) blur(26px);
  box-shadow: var(--glow), inset 0 1px 0 color-mix(in srgb, var(--surface) 70%, transparent);
  transition: transform 0.24s ease, opacity 0.24s ease;
  will-change: transform;
}

/* Scroll-away: slide the bar out while scrolling down, back on scroll up.
   Content padding is unchanged (it tracks --tabbar-h), so nothing reflows —
   only the floating bar moves. Distinct from tabbar-hidden, which removes it
   entirely for full-screen flows. */
.app.tabbar-collapsed .tabbar {
  transform: translateY(calc(100% + var(--safe-bottom) + 1.2rem));
  opacity: 0;
  pointer-events: none;
}

/* Without backdrop-filter the glass can't frost the content behind it, so
   fall back to a near-opaque bar to keep the labels legible. */
@supports not (
  (-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))
) {
  .tabbar {
    background: color-mix(in srgb, var(--surface) 93%, transparent);
  }
}

.tabbar a {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  min-width: var(--tap);
  padding: 6px 0 5px;
  border-radius: 22px;
  font: var(--font-label);
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  overflow: hidden;
  text-align: center;
  transition: color 0.24s ease;
}

/* At 320px and 1.3x text a label is wider than its tab: it ellipsizes
   inside the tab rather than running into the next one. */
.tabbar a > span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabbar .tab-icon {
  width: 22px;
  height: 22px;
  flex: none;
  display: block;
}

.tabbar a[aria-current="page"] {
  color: var(--primary);
}

/* The moving highlight: one pill that glides to the active tab. JS sizes it
   to the active tab (offset box) and translates it; CSS animates the move. */
.tabbar-thumb {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-radius: 22px;
  background: var(--tonal);
  box-shadow: none;
  transform: translate(0, 0);
  pointer-events: none;
  z-index: 0;
  transition:
    transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.tabbar a[aria-current="page"] .tab-icon {
  transform: translateY(-0.5px);
}

/* ---- Motion ---- */
.sos-block.is-sent-pulse,
#sos-send.is-sent-pulse {
  animation: sos-sent-pulse 700ms ease-out;
}

@keyframes row-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes sos-sent-pulse {
  0% { filter: brightness(1); }
  35% { filter: brightness(1.12); }
  100% { filter: brightness(1); }
}

@media (prefers-reduced-motion: reduce) {
  .row-group > li.row-enter,
  .sos-block.is-sent-pulse,
  #sos-send.is-sent-pulse,
  .view.pt-enter-fade,
  .view.pt-enter-forward,
  .view.pt-enter-back {
    animation: none;
  }

  .swipe-front,
  .tabbar,
  .tabbar a,
  .tabbar-thumb,
  .row-chevron-down {
    transition: none !important;
  }
}

/* ---- kit.js: list skeletons, busy buttons, the Signal meter ---- */
/* The first home load, before it settles: the placeholder alone, and
   never after (the sections would otherwise appear one by one). */
#view-home.is-starting > :not(#home-start) {
  display: none !important;
}

#view-home:not(.is-starting) > #home-start {
  display: none;
}

.home-start {
  display: grid;
  gap: 16px;
  margin-top: 8px;
}

.home-start-hero {
  height: 156px;
  border-radius: var(--r-hero);
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.home-start-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 16px;
}

.skeleton-disc {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-line {
  height: 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.skeleton-line.is-short {
  width: 55%;
}

.btn.is-busy {
  cursor: progress;
}

/* Sits where the label was; setBusy holds the button at its width. */
.btn-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

/* The Signal meter: segments, the lit ones in --good (or --primary), the
   last lit one glowing. */
.meter {
  display: flex;
  gap: 2px;
  height: 6px;
  margin-top: 8px;
}

.meter-seg {
  flex: 1;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
}

.meter-seg.on {
  background: var(--good);
}

.meter-seg.tip {
  box-shadow: 0 0 6px color-mix(in srgb, var(--good) 70%, transparent);
}

.meter.is-primary .meter-seg.on {
  background: var(--primary);
}

.meter.is-primary .meter-seg.tip {
  box-shadow: 0 0 6px color-mix(in srgb, var(--primary) 70%, transparent);
}

/* Shimmer and spin only for people who have not asked for less motion. */
@media (prefers-reduced-motion: no-preference) {
  .skeleton-line,
  .skeleton-disc {
    animation: kit-shimmer 1.4s ease-in-out infinite;
  }

  .btn-spinner {
    animation: kit-spin 0.8s linear infinite;
  }
}

@keyframes kit-shimmer {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

@keyframes kit-spin {
  to {
    transform: rotate(360deg);
  }
}
