/*
 * Whereabouts — application stylesheet
 * Raw CSS, no framework, no build step (Propshaft serves this file directly).
 * Loaded via stylesheet_link_tag :app in the layouts, which picks up every
 * file in app/assets/stylesheets (this one plus kiosk.css).
 *
 * Section order mirrors the page: tokens, base elements, nav, page shell,
 * flash, forms, buttons, tables, then the component vocabulary the views
 * rely on (person-card, task-card, banners, color-picker).
 */

/* ---------- Palette & tokens ---------- */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-sunken: #f9fafb;
  --text: #16202c;
  --text-muted: #667487;
  --border: #e3e8ef;
  --border-strong: #cfd6e0;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, 0.04), 0 12px 28px rgba(15, 23, 42, 0.09);

  --accent: #4f6ef7;
  --accent-hover: #3d5be0;
  --accent-soft: #eef1fe;
  --accent-fg: #ffffff;

  --status-planned: #2563eb;
  --status-planned-bg: #eff6ff;
  --status-planned-border: #bfdbfe;
  --status-in_progress: #b45309;
  --status-in_progress-bg: #fffbeb;
  --status-in_progress-border: #fde68a;
  --status-undone: #64748b;
  --status-undone-bg: #f1f5f9;
  --status-undone-border: #e2e8f0;
  --status-completed: #15803d;
  --status-completed-bg: #f0fdf4;
  --status-completed-border: #bbf7d0;

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-fg: #7f1d1d;
  --notice-fg: #14532d;

  --placeholder: #9aa5b4;
  --backdrop: rgba(15, 23, 42, 0.45);
  --crop-shade: rgba(255, 255, 255, 0.6);
  --swatch-ring: rgba(15, 23, 42, 0.08);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --tap: 44px;
  --shell: 1040px;
  --gutter: clamp(1rem, 4vw, 2rem);
  /* The gutter, widened to clear a notch or rounded corner where the
     installed app draws edge to edge (viewport-fit=cover, landscape). */
  --gutter-start: max(var(--gutter), env(safe-area-inset-left, 0px));
  --gutter-end: max(var(--gutter), env(safe-area-inset-right, 0px));

  /* QR codes stay dark-on-light in both themes: scanners expect it. */
  --qr-dark: #000000;
  --qr-light: #ffffff;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  /* Motion. A springy ease for things that pop, a calm one for the rest. */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 140ms;
  --medium: 260ms;

  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- Dark theme ----------
 * Follows the OS setting. Every component reads its colours from the tokens
 * above, so flipping them here is the whole theme — don't add colour rules
 * inside this block. `color-scheme` also switches the UA-drawn parts we don't
 * style: scrollbars, the datetime-local picker, checkbox/radio glyphs.
 *
 * The chip/danger backgrounds become translucent washes of their hue rather
 * than the light tints, which turn to mud on a dark surface.
 */
:root { color-scheme: light dark; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #171d26;
    --surface-sunken: #1e2531;
    --text: #e7edf5;
    --text-muted: #94a3b8;
    --border: #28313d;
    --border-strong: #3b4655;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 12px 28px rgba(0, 0, 0, 0.5);

    --accent: #8ba4ff;
    --accent-hover: #a3b7ff;
    --accent-soft: rgba(139, 164, 255, 0.16);
    --accent-fg: #0f141b;

    --status-planned: #93c5fd;
    --status-planned-bg: rgba(37, 99, 235, 0.18);
    --status-planned-border: rgba(147, 197, 253, 0.3);
    --status-in_progress: #fcd34d;
    --status-in_progress-bg: rgba(217, 119, 6, 0.2);
    --status-in_progress-border: rgba(252, 211, 77, 0.3);
    --status-undone: #cbd5e1;
    --status-undone-bg: rgba(100, 116, 139, 0.22);
    --status-undone-border: rgba(203, 213, 225, 0.25);
    --status-completed: #86efac;
    --status-completed-bg: rgba(22, 163, 74, 0.18);
    --status-completed-border: rgba(134, 239, 172, 0.3);

    --danger: #f87171;
    --danger-bg: rgba(220, 38, 38, 0.16);
    --danger-border: rgba(248, 113, 113, 0.32);
    --danger-fg: #fca5a5;
    --notice-fg: #86efac;

    --placeholder: #64748b;
    --backdrop: rgba(0, 0, 0, 0.6);
    --crop-shade: rgba(15, 20, 27, 0.65);
    --swatch-ring: rgba(255, 255, 255, 0.16);
  }
}

/* ---------- Reset-ish base ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* Room for the scrollbar always, so the page doesn't shift sideways when it
   comes and goes (a picker opening, a list growing). */
html { font-size: 16px; -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 0 0 0.5rem;
  letter-spacing: -0.015em;
  font-weight: 650;
}
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.875rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

small { font-size: 0.8125rem; color: var(--text-muted); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.15em 0.4em;
  word-break: break-all;
}

blockquote {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--border-strong);
  background: var(--surface-sunken);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}

:where(input, select, textarea, button, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* `button_to` wraps its button in a form. Inside flex/grid rows that extra
   element breaks the layout, so let the button itself be the flex item. */
.nav-user form,
.form-actions form,
.task-actions form,
.sched-actions form,
.who-row form,
.invite-actions form,
.checklist-header form,
.checklist-step form,
.header-actions form,
.history-item form,
.table-actions form { display: contents; }

/* ---------- Nav ---------- */
/* Only the top bar: a bare `nav` selector also caught the admin tabs (also
   a <nav>), making them sticky on the same layer and drawn over the
   account menu. Above everything on the page except dialogs. */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0.5rem var(--gutter-end) 0.5rem var(--gutter-start);
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 56px;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  min-height: 36px;
  padding: 0 0.75rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 550;
  white-space: nowrap;
  transition: color var(--fast) ease, background var(--fast) ease;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--surface-sunken);
  text-decoration: none;
}
.nav-links a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

/* The phone's tab bar (layouts/_tab_bar): the nav links, along the bottom.
   Low profile, translucent like the top bar, and it slides away while you
   scroll down (tab_bar_controller.js puts .tab-bar-hidden on <html>). The
   gesture bar below it is painted in --surface too (the manifest's
   theme_color), so the two read as one. Hidden above phone width. */
.tab-bar { display: none; }
@media (max-width: 719px) {
  :root { --tab-bar-h: 3.25rem; }
  .nav-links { display: none; }
  .tab-bar {
    position: fixed;
    z-index: 50;
    inset: auto 0 0;
    display: flex;
    padding: 0 var(--gutter-end) env(safe-area-inset-bottom, 0px) var(--gutter-start);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--border);
    transition: transform 260ms var(--ease-out);
  }
  .tab-bar-hidden .tab-bar:not(:focus-within) { transform: translateY(100%); }
  /* A page with its own bottom bar (Feed, Report where) keeps the bottom to it. */
  body:has(.sticky-actions) { --tab-bar-h: 0px; }
  body:has(.sticky-actions) .tab-bar { display: none; }
}
.tab-bar-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  height: var(--tab-bar-h);
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.tab-bar-link:hover { text-decoration: none; color: var(--text); }
.tab-bar-icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 1.75rem;
  border-radius: var(--radius-pill);
  transition: background var(--fast) ease, transform var(--medium) var(--ease-spring);
}
.tab-bar-icon .icon { width: 1.25rem; height: 1.25rem; }
.tab-bar-link:active .tab-bar-icon { transform: scale(0.9); }
.tab-bar-link[aria-current="page"] { color: var(--accent); }
.tab-bar-link[aria-current="page"] .tab-bar-icon { background: var(--accent-soft); }

/* Account menu: your avatar opens it. */
.user-menu { position: relative; }
.user-menu-button {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.375rem 0.1875rem 0.1875rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  transition: background var(--fast) ease, color var(--fast) ease;
}
.user-menu-button::-webkit-details-marker { display: none; }
.user-menu-button:hover,
.user-menu[open] .user-menu-button { background: var(--surface-sunken); color: var(--text); }
.user-menu-button .icon { width: 1rem; height: 1rem; }
.user-menu[open] .user-menu-button .icon-chevron-down { transform: rotate(180deg); }
.user-menu-button:hover .nav-avatar { transform: scale(1.08) rotate(-6deg); }
.user-menu-button[aria-current="page"] .nav-avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

.nav-avatar { width: 2.125rem; height: 2.125rem; font-size: 0.75rem; }
/* Photos in the nav skip the card's colour ring; the button is ring enough. */
.nav-avatar:has(img) { box-shadow: none; }

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 30;
  min-width: 14rem;
  padding: 0.375rem;
  display: grid;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transform-origin: top right;
  animation: menu-in 200ms var(--ease-spring);
}
.user-menu-header {
  display: grid;
  padding: 0.5rem 0.625rem 0.625rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}
.user-menu-header strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-panel a,
.user-menu-panel button {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  min-height: 40px;
  padding: 0 0.625rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--fast) ease;
}
.user-menu-panel a:hover,
.user-menu-panel button:hover { background: var(--surface-sunken); text-decoration: none; }
.user-menu-panel a:hover .icon,
.user-menu-panel button:hover .icon { transform: translateX(2px); }
.user-menu-panel .icon { color: var(--text-muted); }
.user-menu-panel form { display: contents; }
.user-menu-panel form button { margin-top: 0.25rem; }

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
}

/* ---------- Page shell ---------- */
.container {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 2rem var(--gutter-end) max(4rem, env(safe-area-inset-bottom, 0px)) var(--gutter-start);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-header h1 { margin: 0; }
.page-header p { margin: 0.25rem 0 0; color: var(--text-muted); }

.page-intro {
  color: var(--text-muted);
  margin: -0.25rem 0 1.5rem;
}

/* ---------- Flash ----------
   Lives in .overlay-stack with the toasts (below), floating over the page. */
.flash-stack { display: grid; gap: 0.5rem; }
.flash-stack:empty { display: none; }

.flash,
.flash-notice,
.flash-alert {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 550;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  animation: slide-down 420ms var(--ease-spring) both;
}
.flash-notice > .icon,
.flash-alert > .icon { flex: none; width: 1.25rem; height: 1.25rem; }
.flash-notice { background: var(--status-completed-bg); border-color: var(--status-completed-border); color: var(--notice-fg); }
.flash-alert  { background: var(--danger-bg);           border-color: var(--danger-border);           color: var(--danger-fg); }

.flash-alert ul { margin: 0; padding-left: 1.125rem; }
.flash-alert li { margin: 0.125rem 0; }

/* ---------- Toasts (in-page notifications) ----------
   Notifier appends one per update into #notifications while the app is
   open (shared/_notification, toast_controller.js). A flash, floated in the
   bottom corner (.overlay-stack, with the flashes) so it doesn't push the
   page around. */
.overlay-stack {
  position: fixed;
  z-index: 60;
  right: var(--gutter-end);
  bottom: calc(max(1rem, env(safe-area-inset-bottom, 0px)) + var(--tab-bar-h, 0px));
  width: min(24rem, calc(100vw - var(--gutter-start) - var(--gutter-end)));
  display: grid;
  gap: 0.5rem;
  pointer-events: none;
}
.toast-stack { display: grid; gap: 0.5rem; }
.toast-stack:empty { display: none; }
.toast {
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
  padding: 0.625rem 0.5rem 0.625rem 0.875rem;
  font-weight: 500;
  animation: rise-in 420ms var(--ease-spring) backwards;
}
.toast > .icon { flex: none; width: 1.25rem; height: 1.25rem; color: var(--accent); }
/* The tints are see-through in dark mode: lay them over a solid surface so
   the page doesn't show through a floating flash. */
.flash-notice.toast { background: linear-gradient(var(--status-completed-bg), var(--status-completed-bg)), var(--surface); }
.flash-alert.toast  { background: linear-gradient(var(--danger-bg), var(--danger-bg)), var(--surface); }
.flash-notice.toast > .icon,
.flash-alert.toast > .icon { color: currentColor; }
.flash-notice.toast .btn-icon,
.flash-alert.toast .btn-icon { color: inherit; }
.toast-body { flex: 1; min-width: 0; display: grid; line-height: 1.35; overflow-wrap: anywhere; }
.toast-body small { font-weight: 600; }
.toast .btn-icon { min-height: 34px; width: 34px; }

/* ---------- Push notifications panel ---------- */
.push-panel .form-actions { margin-top: 1rem; }
.push-panel .flash-notice,
.push-panel .flash-alert { margin-top: 1rem; }
.push-steps { margin: 0 0 1rem; padding-left: 1.25rem; }
/* The push/email matrix on the Notifications page. Fits a 320px phone:
   the hint and any select wrap under the label, the checkbox columns stay
   narrow, and nothing scrolls sideways. */
.notification-matrix { table-layout: auto; }
.notification-matrix thead th { background: none; padding: 0 0.25rem 0.5rem; text-align: center; }
.notification-matrix thead th:first-child { text-align: left; padding-left: 0; }
.notification-matrix tbody th {
  text-align: left;
  font-weight: 400;
  padding: 0.75rem 0.5rem 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.notification-matrix tbody th strong { display: block; font-weight: 600; }
.notification-matrix tbody th small { display: block; margin-top: 0.125rem; }
.notification-matrix tbody td {
  width: 3.75rem;
  padding: 0.75rem 0.25rem;
  text-align: center;
}
.notification-matrix tbody td input { margin: 0; }
.notification-matrix tbody tr:hover { background: none; }
.notification-matrix tbody tr:last-child th { border-bottom: 0; }
.notification-matrix input:disabled { opacity: 0.4; cursor: not-allowed; }
.matrix-select { width: auto; max-width: 100%; margin-top: 0.5rem; min-height: 36px; padding: 0.25rem 0.625rem; font-size: 0.875rem; }
.matrix-hints { margin: 1rem 0 0; display: grid; gap: 0.25rem; }
.quiet-hours { margin-top: 0.5rem; }
/* Admin > Settings: what's true about push and email on this server. */
.setting-facts { display: grid; grid-template-columns: minmax(6rem, max-content) 1fr; gap: 0.75rem 1.25rem; margin: 0; }
.setting-facts dt { font-weight: 600; }
.setting-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.setting-facts small { display: block; margin-top: 0.375rem; }
@media (max-width: 480px) { .setting-facts { grid-template-columns: 1fr; gap: 0.25rem; } .setting-facts dd { margin-bottom: 0.75rem; } }

/* Quiet hours off: the times stay editable but read as not in effect. */
.form-field:has(#notifications_quiet_hours:not(:checked)) .quiet-hours { opacity: 0.55; }

.push-steps li { margin: 0.25rem 0; }

/* ---------- Household switcher ---------- */
.household-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.household-switch select {
  width: auto;
  min-width: 10rem;
  min-height: 36px;
  padding: 0.25rem 0.625rem;
  font-size: 0.9375rem;
  background: var(--surface-sunken);
}

/* ---------- Forms ---------- */
.form-card {
  --card-pad: clamp(1.25rem, 3vw, 1.75rem); /* .sticky-actions bleeds over it */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--card-pad);
  max-width: 520px;
}

.form-field { margin-bottom: 1.125rem; display: block; border: 0; padding: 0; }
.form-field:last-of-type { margin-bottom: 0; }

.form-field > label,
.form-field > legend {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  padding: 0;
  color: var(--text);
}

.form-field small { display: block; margin-top: 0.375rem; }

details.form-field,
fieldset.form-field {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  margin-top: 1.5rem;
  background: var(--surface-sunken);
}
details.form-field > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
details.form-field[open] > summary { margin-bottom: 1rem; }

fieldset.form-field + .form-field,
details.form-field + .form-field { margin-top: 1.125rem; }

fieldset.form-field > legend {
  margin: 0;
  padding: 0 0.375rem;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="datetime-local"],
input[type="date"],
input[type="time"],
input[type="number"],
textarea,
select {
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
textarea { min-height: 0; resize: vertical; line-height: 1.5; }

input::placeholder, textarea::placeholder { color: var(--placeholder); }

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

input[readonly] { background: var(--surface-sunken); color: var(--text-muted); }

/* Checkboxes and radios drawn from the theme tokens, so they match in
   light and dark instead of the browser's own grey boxes. The tick and dot
   are clip-paths in currentColor, no images. Inputs hidden inside chips and
   tiles (opacity 0) are unaffected. */
input[type="checkbox"], input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  display: inline-grid;
  place-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0 0.5rem 0 0;
  vertical-align: -0.2em;
  color: var(--accent-fg);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--fast) ease, border-color var(--fast) ease, box-shadow var(--fast) ease;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::before,
input[type="radio"]::before {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  background: currentColor;
  transform: scale(0);
  transition: transform var(--medium) var(--ease-spring);
}
input[type="checkbox"]::before { clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
input[type="radio"]::before { width: 0.5rem; height: 0.5rem; border-radius: 50%; }
input[type="checkbox"]:checked,
input[type="radio"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::before,
input[type="radio"]:checked::before { transform: scale(1); }
input[type="checkbox"]:hover,
input[type="radio"]:hover { border-color: var(--accent); }
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"]:disabled,
input[type="radio"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* Checkboxes read as one inline row, not a stacked label-over-control.
   Two shapes occur: a label that wraps its own checkbox (settings/setup) and
   a checkbox with a sibling label (Devise's "remember me"). */
.form-field > label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  font-weight: 500;
  margin-bottom: 0;
  min-height: var(--tap);
}

.form-field:has(> input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
}
.form-field:has(> input[type="checkbox"]) > input[type="checkbox"] { margin: 0; }
.form-field:has(> input[type="checkbox"]) > label {
  margin-bottom: 0;
  font-weight: 500;
}

.field_with_errors { display: contents; }
.field_with_errors input,
.field_with_errors select,
.field_with_errors textarea { border-color: var(--danger); }

/* ---------- Buttons ---------- */
.form-actions {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: var(--tap);
  padding: 0.5rem 1.125rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background var(--fast) ease,
    border-color var(--fast) ease,
    color var(--fast) ease,
    box-shadow var(--fast) ease,
    transform var(--medium) var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover {
  background: var(--surface-sunken);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn:active {
  transform: translateY(0) scale(0.96);
  box-shadow: var(--shadow-sm);
  transition-duration: 60ms;
}

.btn-primary {
  color: var(--accent-fg);
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* Finishing a task: the one green button in the app. */
.btn-success {
  color: var(--surface);
  background: var(--status-completed);
  border-color: var(--status-completed);
}
.btn-success:hover {
  background: color-mix(in srgb, var(--status-completed) 88%, var(--text));
  border-color: transparent;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--status-completed) 35%, transparent);
}

.btn-danger {
  color: var(--danger);
  background: var(--surface);
  border-color: var(--danger-border);
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-quiet {
  color: var(--text-muted);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.btn-quiet:hover { color: var(--text); background: var(--surface-sunken); box-shadow: none; }

/* Square icon-only button (Edit / Delete on task cards). */
.btn-icon { padding: 0; width: 36px; min-height: 36px; }
.btn-icon-danger:hover { color: var(--danger); background: var(--danger-bg); }

.btn-small {
  min-height: 34px;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

/* ---------- Error explanation (Devise) ---------- */
#error_explanation {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  max-width: 520px;
}
#error_explanation h2 { font-size: 0.9375rem; color: var(--danger-fg); margin-bottom: 0.375rem; }
#error_explanation ul { margin: 0; padding-left: 1.125rem; color: var(--danger-fg); }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.form-card + h2,
.table-wrap + h2,
.form-card + .table-wrap { margin-top: 2.5rem; }
h2 + .table-wrap { margin-top: 1rem; }
.form-card + .form-card { margin-top: 1rem; }
/* A select in a table row (who lives where) keeps room for a name: the
   table scrolls sideways on a phone rather than squeezing it to a letter. */
td select { min-width: 10rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

thead th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-sunken);
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-sunken); }

/* Stays a table-cell: `display: flex` on a <td> drops it out of the table
   layout and breaks the row's bottom border. */
.table-actions {
  text-align: right;
  white-space: nowrap;
}
.table-actions .btn { margin-left: 0.375rem; vertical-align: middle; }

/* ---------- Dashboard ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
  align-items: start;
}

.person-card {
  --user-color: #6366f1;
  --user-fg: #ffffff;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  overflow: hidden;
  transition: transform var(--medium) var(--ease-out), box-shadow var(--medium) ease;
}
.person-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
/* Colour band drawn as a pseudo-element so it can't shift the box model. */
.person-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--user-color);
  transition: width var(--medium) var(--ease-out);
}
.person-card:hover::before { width: 8px; }

.person-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.person-avatar {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-pill);
  background: var(--user-color);
  color: var(--user-fg);
  display: grid;
  place-items: center;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform var(--medium) var(--ease-spring);
}
/* A profile photo fills the disc; the user's colour shows as a thin ring. */
.person-avatar:has(img) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--user-color); }
.person-avatar img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  display: block;
}
.person-card:hover .person-avatar { transform: scale(1.08) rotate(-6deg); }
/* Someone who's busy gets a soft ring pulsing out of their avatar. */
.person-card.is-busy .person-avatar { animation: ring-pulse 2.4s ease-out infinite; }

.person-meta { min-width: 0; display: flex; flex-direction: column; gap: 0.125rem; }

/* Names wrap rather than being cut off. */
.person-name {
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}


.person-status {
  display: grid;
  justify-items: start;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}
.person-status .task-meta { margin: 0; }

/* ---------- Status chips ---------- */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  max-width: 100%;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-chip .icon { width: 1em; height: 1em; }
/* "Doing" has no icon: a live dot that breathes instead. */
.status-chip.status-in_progress::before {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-pill);
  background: currentColor;
  animation: live-dot 1.8s ease-in-out infinite;
}
.person-card:hover .status-completed .icon-sun { animation: spin 6s linear infinite; }

.status-planned     { color: var(--status-planned);     background: var(--status-planned-bg);     border-color: var(--status-planned-border); }
.status-in_progress { color: var(--status-in_progress); background: var(--status-in_progress-bg); border-color: var(--status-in_progress-border); }
.status-undone      { color: var(--status-undone);      background: var(--status-undone-bg);      border-color: var(--status-undone-border); }
.status-completed   { color: var(--status-completed);   background: var(--status-completed-bg);   border-color: var(--status-completed-border); }

/* ---------- Task meta (shared small print) ---------- */
.task-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.75rem;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0 0 0.75rem;
}

.task-meta > span:not(.status-chip) { display: inline-flex; align-items: center; gap: 0.3125rem; }
.task-meta .icon { width: 0.9375rem; height: 0.9375rem; }

.task-recurrence {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-pill);
}

/* Action rows on cards (pet cards). */
.task-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
}
.task-actions .btn { min-height: 36px; padding: 0.25rem 0.875rem; font-size: 0.875rem; }
.task-actions .btn-icon { padding: 0; }

/* ---------- Banners ---------- */
.invite-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.invite-banner p { margin: 0; flex: 1 1 16rem; color: var(--text-muted); }
.banner-icon {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
}
.banner-icon .icon { animation: bell-ring 3.2s ease-in-out 0.6s infinite; transform-origin: 50% 10%; }

.invite-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.invite-actions .btn { min-height: 38px; padding: 0.375rem 1rem; font-size: 0.875rem; }

/* ---------- Color picker ---------- */
.color-picker { display: grid; gap: 1rem; }

.palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 0.5rem;
}

.swatch {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px var(--swatch-ring);
  cursor: pointer;
  transition: transform var(--medium) var(--ease-spring), box-shadow var(--fast) ease;
}
.swatch:hover { transform: scale(1.1); }

/* The radio is the accessible control; the label is the visible swatch. */
.swatch input[type="radio"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.swatch:has(input:checked) {
  animation: pop var(--medium) var(--ease-spring);
  border-color: var(--text);
  box-shadow: inset 0 0 0 2px var(--surface);
}
.swatch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.custom-color { max-width: 220px; }

/* ---------- Profile photo ---------- */
.avatar-picker { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.avatar-preview {
  width: 5rem;
  height: 5rem;
  font-size: 1.5rem;
  transition: background var(--medium) ease, color var(--medium) ease, box-shadow var(--medium) ease;
}
.avatar-preview.is-new { animation: pop 420ms var(--ease-spring); }
.avatar-controls { flex: 1 1 14rem; min-width: 0; display: grid; gap: 0.5rem; }
.avatar-controls small { margin: 0; }
.avatar-controls .inline-check { margin: 0; }
.avatar-controls .btn { justify-self: start; }

/* Crop dialog: the photo on a canvas under a round window. */
.crop-dialog {
  width: min(22rem, calc(100vw - 2rem));
  padding: 1.5rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.crop-dialog[open] { animation: pop 320ms var(--ease-spring); }
.crop-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.crop-dialog h2 { margin-bottom: 0.25rem; }
.crop-hint { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1rem; }
.crop-stage {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  /* The shade outside the circle is drawn on the canvas, in --crop-shade. */
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage:focus { outline: none; }
.crop-stage:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.crop-dialog .crop-stage { box-shadow: 0 0 0 1px var(--border); }
.crop-zoom {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-top: 1rem;
  color: var(--text-muted);
}
.crop-zoom input[type="range"] { flex: 1; accent-color: var(--accent); }
.crop-dialog .form-actions { margin-top: 1.25rem; }

input[type="file"] {
  max-width: 100%;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text-muted);
}
input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  min-height: 36px;
  padding: 0.25rem 0.875rem;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background var(--fast) ease, transform var(--medium) var(--ease-spring);
}
input[type="file"]::file-selector-button:hover { background: var(--surface-sunken); transform: translateY(-1px); }
input[type="file"]::file-selector-button:active { transform: scale(0.96); }
.custom-color summary {
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}
.custom-color[open] summary { margin-bottom: 0.5rem; }
.custom-color label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

/* ---------- Devise screens ---------- */
.devise-links {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  display: grid;
  gap: 0.375rem;
}
.devise-links p { margin: 0; }

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
[hidden] { display: none !important; }

a.nav-brand { color: var(--text); text-decoration: none; }

.btn-block { width: 100%; }

.empty-hint {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
}
.empty-hint .icon { flex: none; color: var(--accent); width: 1.25rem; height: 1.25rem; }
.section-title { margin-top: 2.5rem; display: flex; align-items: center; gap: 0.5rem; }
.section-title .icon { color: var(--status-completed); }

/* ---------- Passkeys & sign-in ---------- */
.passkey-signin { display: grid; gap: 0.75rem; }
.passkey-signin:has(.btn:not([hidden])) {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.passkey-choice { margin-bottom: 1.125rem; }
.passkey-hint {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
}
.passkey-add { margin-top: 1rem; }

.code-input {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  letter-spacing: 0.15em;
  max-width: 16rem;
}

.help-details { margin-top: 1rem; font-size: 0.9375rem; }
.help-details summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.help-details[open] summary { margin-bottom: 0.5rem; }

/* Backups: Admin > Backup, and restoring one on the setup page. */
.restore-card { margin-top: 1.5rem; }
.restore-card > summary { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 650; color: var(--accent); }
.restore-card[open] > summary { margin-bottom: 0.75rem; }
.restore-card p { color: var(--text-muted); font-size: 0.9375rem; }
.form-card > h2 { display: flex; align-items: center; gap: 0.5rem; font-size: 1.0625rem; margin-top: 0; }
.form-card > h2 .icon { color: var(--accent); }
.backup-notes { margin: 0 0 1rem; padding-left: 1.25rem; color: var(--text-muted); font-size: 0.9375rem; }
.backup-notes li { margin: 0.25rem 0; }
.help-details ul { padding-left: 1.125rem; margin: 0; display: grid; gap: 0.375rem; }

.inline-form { display: flex; align-items: center; gap: 0.5rem; }
.inline-form input { min-width: 8rem; }
.inline-check { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; font-weight: 500; }

/* ---------- Account & admin pages ---------- */
.account-section { margin-bottom: 2.75rem; }
.account-section > h2 { margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.account-section > h2 .icon { color: var(--accent); }
.account-section .page-intro { display: block; }
.account-section .table-wrap { margin-bottom: 1rem; }

.admin-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.admin-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.5rem 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9375rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--fast) ease, border-color var(--medium) var(--ease-out);
}
.admin-tabs a:hover { color: var(--text); text-decoration: none; }
.admin-tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

.copy-field { display: flex; gap: 0.5rem; align-items: stretch; flex-wrap: wrap; }
.copy-field input { flex: 1 1 16rem; font-family: var(--font-mono); font-size: 0.875rem; }
.copy-field + .form-actions { margin-top: 1rem; }

/* ---------- Two-step verification ---------- */
.setup-steps { margin: 0; padding-left: 1.25rem; display: grid; gap: 1.5rem; }
.setup-steps > li > strong { display: block; margin-bottom: 0.25rem; }
.setup-steps > li > small { display: block; margin-bottom: 0.75rem; }
.qr-frame { width: min(240px, 100%); }
.qr-code { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); }
.qr-code .qr-light { fill: var(--qr-light); }
.qr-code .qr-dark { fill: var(--qr-dark); }
.secret-key { font-size: 1rem; letter-spacing: 0.08em; word-break: break-all; }

.recovery-codes {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.5rem;
}
.recovery-codes code { display: block; text-align: center; font-size: 1rem; padding: 0.5rem; }

/* ---------- Getting started checklist ---------- */
.checklist {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.checklist-header { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.checklist-header h2 { margin: 0; font-size: 1.0625rem; display: flex; align-items: center; gap: 0.5rem; }
.checklist-header h2 .icon { color: var(--accent); animation: twinkle 2.8s ease-in-out infinite; }
.checklist-progress {
  height: 6px;
  margin-bottom: 0.875rem;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}
.checklist-progress::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--status-completed));
  animation: grow-x 900ms var(--ease-out) both;
  transform-origin: left;
}
.checklist-header .task-meta { margin: 0; }
.checklist-header .btn { margin-left: auto; }
.checklist-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.checklist-step {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.625rem 0;
  border-top: 1px solid var(--border);
}
.checklist-mark {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 0.8125rem;
  font-weight: 700;
}
.checklist-mark .icon { width: 0.875rem; height: 0.875rem; stroke-width: 3; animation: pop 400ms var(--ease-spring) both; }
.checklist-step.is-done .checklist-mark {
  border-color: var(--status-completed);
  background: var(--status-completed-bg);
  color: var(--status-completed);
}
.checklist-step.is-done strong { color: var(--text-muted); font-weight: 500; }
.checklist-step.is-skipped .checklist-mark { border-color: var(--border-strong); background: var(--surface-sunken); color: var(--text-muted); }
.checklist-body { flex: 1; min-width: 0; display: grid; }
.checklist-actions { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; justify-content: flex-end; }


/* ---------- Pets, locations & profiles ----------
 * The pets feature is the pattern for the rest of the app: every card says
 * what's true now and puts the next action one tap away; anything done to
 * several things at once is "pick tiles, then confirm" (pick-grid), and the
 * confirm button says exactly what will happen ("Feed 2 pets").
 */
.header-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.section-title .icon-paw,
.section-title .icon-clock { color: var(--accent); }

.empty-state {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty-state h2 { margin: 0.5rem 0 0; }
.empty-state p { color: var(--text-muted); max-width: 32rem; margin-bottom: 0.75rem; }
.empty-state .banner-icon .icon { animation: none; }

/* Pet cards */
.pet-grid,
.place-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
}

.pet-card {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.125rem 1.25rem;
  transition: transform var(--medium) var(--ease-out), box-shadow var(--medium) ease;
}
.pet-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.pet-card .task-actions { padding-top: 0.75rem; margin-top: auto; }
.pet-card .task-actions .btn { flex: 1; }

.pet-identity { display: flex; align-items: center; gap: 0.75rem; color: var(--text); min-width: 0; }
.pet-identity:hover { text-decoration: none; }
.pet-identity:hover .person-name { color: var(--accent); }
.pet-identity:hover .person-avatar { transform: scale(1.08) rotate(-6deg); }
.pet-identity .person-avatar { width: 3rem; height: 3rem; }
.person-avatar .icon-paw { width: 55%; height: 55%; }
.pet-sub { font-size: 0.8125rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pet-facts { display: grid; gap: 0.5rem; }
/* Inside / outside / penned up (PetsHelper#spot_chip), on the wall and the
   dashboard's pet cards, where the section already names the place. */
.spot-chip { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.spot-chip.is-outside { color: var(--text); background: transparent; border-color: var(--border-strong); }
.spot-chip.is-penned { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); }
.spot-chip .icon { width: 1.15em; height: 1.15em; }

.pet-where,
.person-where {
  display: flex;
  align-items: center;
  gap: 0.375rem 0.5rem;
  flex-wrap: wrap;
  margin: 0;
  font-weight: 600;
}
.pet-where > .icon,
.person-where > .icon { color: var(--accent); }
.pet-where small,
.person-where small { font-weight: 500; }
.pet-where-name.is-unknown { color: var(--text-muted); font-weight: 500; }
.person-where { margin-top: 0.75rem; font-size: 0.9375rem; }

.report-comment {
  display: flex;
  align-items: flex-start;
  gap: 0.4375rem;
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.report-comment .icon { margin-top: 0.15em; width: 0.9375rem; height: 0.9375rem; }
.person-card .report-comment { margin-top: 0.375rem; }

.pet-fed { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0; }

/* One pip per meal of the day, filled as they're eaten. */
.meal-pips { display: inline-flex; gap: 3px; margin-left: 0.125rem; }
.meal-pips span {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid currentColor;
  opacity: 0.6;
}
.meal-pips span.is-fed { background: currentColor; opacity: 1; animation: pop 320ms var(--ease-spring) backwards; }

.birthday-cake { color: var(--status-in_progress); margin-left: 0.375rem; animation: twinkle 2.8s ease-in-out infinite; }
.person-identity .birthday-cake { margin-left: auto; }

/* Person names on cards link to profiles. */
a.person-name { color: inherit; }
a.person-name:hover { color: var(--accent); text-decoration: none; }

/* Profiles (pets and people) */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}
.profile-avatar { width: 5.5rem; height: 5.5rem; font-size: 1.75rem; animation: pop 420ms var(--ease-spring) backwards; }
.profile-heading { flex: 1 1 14rem; min-width: 0; }
.profile-heading h1 { margin-bottom: 0.375rem; display: flex; align-items: center; }
.profile-heading .task-meta { margin: 0; }

.profile-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 1rem;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(1.125rem, 3vw, 1.5rem);
  animation: rise-in 480ms var(--ease-out) backwards;
}
.panel + .panel { animation-delay: 60ms; }
.panel > h2 { display: flex; align-items: center; gap: 0.5rem; font-size: 1.0625rem; margin-bottom: 1rem; }
.panel > h2 .icon { color: var(--accent); }
.panel .form-actions { margin-top: 1.25rem; }
.panel .empty-hint { margin-top: 0; }

.place-now { display: flex; align-items: center; gap: 1rem; }
.place-now > div { display: grid; gap: 0.125rem; min-width: 0; }
.place-now strong { font-size: 1.125rem; }
.place-now .place-photo { width: 4.5rem; }

.feeding-notes {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-left: 3px solid var(--status-completed);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
}
.feeding-notes p { margin-bottom: 0.375rem; }
.feeding-notes strong { display: block; margin-bottom: 0.25rem; }
.pet-fed + .feeding-notes { margin-top: 0.875rem; }
.feeding-notes-list { display: grid; gap: 0.5rem; }
.form-subtitle { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; margin: 0 0 0.25rem; }
.form-subtitle .icon { color: var(--status-completed); }

/* History timeline */
.history { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; }
.history-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}
.history-item:first-child { border-top: 0; }
.history-mark {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
}
.history-body { flex: 1; min-width: 0; display: grid; gap: 0.125rem; }
.history-body small { margin-left: 0.375rem; }
.history-item .btn-icon { opacity: 0.55; }
.history-item:hover .btn-icon,
.history-item .btn-icon:focus-visible { opacity: 1; }
.btn:hover .icon-undo { transform: rotate(-30deg); }

/* Place pictures: rounded squares (round discs are for faces). */
.place-photo {
  flex: none;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--accent);
  background: var(--accent-soft);
}
.place-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.place-photo > .icon { width: 40%; height: 40%; }
.place-photo.avatar-preview { width: 6rem; height: 6rem; }

.place-card {
  display: flex;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1rem;
  transition: transform var(--medium) var(--ease-out), box-shadow var(--medium) ease;
}
.place-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.place-card > .place-photo { width: 5.5rem; }
.place-body { flex: 1; min-width: 0; }
.place-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.place-title h2 { font-size: 1.0625rem; margin: 0.25rem 0 0.25rem; }
.place-body .task-meta { margin-bottom: 0.5rem; }
.here-now { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.375rem; }
.here-now a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.1875rem 0.625rem 0.1875rem 0.1875rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.here-now a:hover { border-color: var(--accent); text-decoration: none; }
.here-now .person-avatar { width: 1.5rem; height: 1.5rem; font-size: 0.5625rem; box-shadow: none; }

/* Tile pickers: big tap targets, the input covers the tile (like .swatch). */
.form-card-wide { max-width: 760px; }
.picker-field { position: relative; }
fieldset.picker-field { margin-top: 0; margin-bottom: 1.25rem; }
.pick-group + .pick-group { margin-top: 1rem; }
.pick-group-title { margin: 0 0 0.5rem; font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); }
.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 7.5rem), 1fr));
  gap: 0.625rem;
  margin-top: 0.5rem;
}
.pick-tile {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 0.375rem;
  padding: 0.875rem 0.5rem 0.75rem;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--fast) ease, background var(--fast) ease, transform var(--medium) var(--ease-spring);
}
.pick-tile:hover { border-color: var(--border-strong); text-decoration: none; transform: translateY(-1px); }
.pick-tile:active { transform: scale(0.97); }
.pick-tile input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.pick-tile:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pick-tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick-tile .person-avatar { width: 3.25rem; height: 3.25rem; }
.pick-name { font-weight: 600; font-size: 0.9375rem; line-height: 1.25; overflow-wrap: anywhere; }
.pick-meta { font-size: 0.75rem; color: var(--text-muted); line-height: 1.3; }
.pick-check {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  color: var(--accent-fg);
  background: var(--accent);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity var(--fast) ease, transform var(--medium) var(--ease-spring);
}
.pick-check .icon { width: 0.875rem; height: 0.875rem; stroke-width: 3; }
.pick-tile:has(input:checked) .pick-check { opacity: 1; transform: none; }
.pick-place .place-photo { width: 100%; max-width: 6rem; }
.pick-add { border-style: dashed; color: var(--text-muted); }

/* "New place" in a picker or select reveals its name box, no JS needed. */
.new-place-field { display: none; margin-top: 0.875rem; }
.new-place-host:has(input[value="new"]:checked) .new-place-field,
.new-place-host:has(option[value="new"]:checked) .new-place-field { display: block; animation: slide-down 320ms var(--ease-out); }
.new-place-field > label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.375rem; }
.pick-add .place-photo { background: var(--surface-sunken); color: var(--text-muted); }
.pick-add:hover .icon-plus { transform: rotate(90deg); }

/* The confirm button stays in reach while scrolling a long picker. */
.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-inline: calc(-1 * var(--card-pad));
  margin-bottom: calc(-1 * var(--card-pad));
  padding: 0.875rem var(--card-pad);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.btn-wide { min-width: 12rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* Location kind: icon chips as radios */
.kind-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.kind-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  min-height: 40px;
  padding: 0 0.875rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--fast) ease, border-color var(--fast) ease, background var(--fast) ease;
}
.kind-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.kind-option:has(input:checked) { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.kind-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: 0 1rem; }
.form-row .form-field:last-of-type { margin-bottom: 1.125rem; }
.number-input { max-width: 7rem; }
.danger-zone { margin-top: 2rem; }


/* ---------- Schedule ----------
 * Availability is the first thing a card says: green "Free", amber
 * "Text only", red "Do not disturb". Built from the status/danger tokens.
 */
.avail-free { color: var(--status-completed);   background: var(--status-completed-bg);   border-color: var(--status-completed-border); }
.avail-text { color: var(--status-in_progress); background: var(--status-in_progress-bg); border-color: var(--status-in_progress-border); }
.avail-busy { color: var(--danger);             background: var(--danger-bg);             border-color: var(--danger-border); }

.person-now { margin: 0; color: var(--text); font-weight: 600; font-size: 0.9375rem; line-height: 1.35; }
.person-next {
  display: flex;
  align-items: center;
  gap: 0.4375rem;
  margin: 0.625rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.person-next .icon { color: var(--status-planned); width: 0.9375rem; height: 0.9375rem; }
.person-card.is-busy::before { width: 8px; }

/* The form's availability choice: neutral until picked, then its colour. */
.avail-options .kind-option:not(:has(input:checked)) { color: var(--text-muted); background: var(--surface); border-color: var(--border-strong); }
.avail-options .kind-option:has(input:checked) { border-width: 1.5px; }
.avail-options .kind-option.avail-free:has(input:checked) { color: var(--status-completed);   background: var(--status-completed-bg);   border-color: var(--status-completed); }
.avail-options .kind-option.avail-text:has(input:checked) { color: var(--status-in_progress); background: var(--status-in_progress-bg); border-color: var(--status-in_progress); }
.avail-options .kind-option.avail-busy:has(input:checked) { color: var(--danger);             background: var(--danger-bg);             border-color: var(--danger); }

/* Whose schedule */
.people-switch {
  display: flex;
  gap: 0.375rem;
  margin: -0.25rem 0 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0.25rem;
}
.people-switch::-webkit-scrollbar { display: none; }
.people-switch a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
  min-height: 40px;
  padding: 0.25rem 0.875rem 0.25rem 0.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: color var(--fast) ease, border-color var(--fast) ease, background var(--fast) ease;
}
.people-switch a:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.people-switch a[aria-current="page"] { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.people-switch .person-avatar { width: 2rem; height: 2rem; font-size: 0.6875rem; box-shadow: none; }
.family-avatar { --user-color: var(--accent); --user-fg: var(--accent-fg); }
.family-avatar .icon { width: 55%; height: 55%; }

/* Quick add */
.quick-add {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 0.75rem;
  margin-bottom: 1.25rem;
}
.quick-add:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.quick-add-row { display: flex; gap: 0.5rem; }
.quick-add-row input { flex: 1; min-width: 0; border-color: transparent; font-size: 1.0625rem; background: var(--surface-sunken); }
.quick-add-row input:focus { box-shadow: none; border-color: transparent; }
.quick-add-more { margin-top: 0.5rem; }
.quick-add-more > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
}
.quick-add-more > summary::-webkit-details-marker { display: none; }
.quick-add-more > summary:hover { color: var(--accent); background: var(--accent-soft); }
.quick-add-more[open] > summary { color: var(--accent); margin-bottom: 0.75rem; }
.quick-add-more[open] { padding: 0 0.25rem 0.25rem; animation: slide-down 260ms var(--ease-out); }
.form-row-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); }
.form-hint { margin: -0.5rem 0 1rem; }
.form-hint small { display: block; }

/* Now banner */
.now-banner {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-wrap: wrap;
  padding: 0.875rem 1.125rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--status-in_progress-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  animation: rise-in 420ms var(--ease-out) backwards;
}
.now-banner > div { flex: 1 1 12rem; display: grid; }
.now-banner .banner-icon { color: var(--status-in_progress); background: var(--status-in_progress-bg); }
.now-banner .banner-icon .icon { animation: none; }
.now-banner.is-busy { border-color: var(--danger-border); }
.now-banner.is-busy .banner-icon { color: var(--danger); background: var(--danger-bg); }
.now-banner.is-free { border-color: var(--status-completed-border); }

/* Schedule columns and rows */
.schedule-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 1rem;
  align-items: start;
}
.panel > h2 .count,
.section-title .count {
  margin-left: auto;
  min-width: 1.5rem;
  padding: 0 0.4375rem;
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-sunken);
}

.sched-list { list-style: none; margin: 0; padding: 0; display: grid; }
ul.sched-list.panel { padding: 0.25rem clamp(1.125rem, 3vw, 1.5rem); }
.sched-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}
.sched-item:first-child { border-top: 0; }
.sched-item.is-completed .sched-title,
.sched-item.is-undone .sched-title { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.sched-item.is-past { opacity: 0.6; }
.sched-item.is-now .sched-time { color: var(--status-in_progress); }

.sched-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  margin-top: 0.0625rem;
  padding: 0;
  color: transparent;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color var(--fast) ease, color var(--fast) ease, background var(--fast) ease, transform var(--medium) var(--ease-spring);
}
.sched-check .icon { width: 1rem; height: 1rem; stroke-width: 3; }
.sched-check:hover { color: var(--status-completed); border-color: var(--status-completed); transform: scale(1.1); }
.sched-check:active { transform: scale(0.9); }
.sched-check.is-checked { color: var(--status-completed); background: var(--status-completed-bg); border-color: var(--status-completed); cursor: default; }
.is-undone .sched-check.is-checked { color: var(--text-muted); background: var(--surface-sunken); border-color: var(--border-strong); }
.sched-item form:has(.sched-check) { display: contents; }

.sched-time {
  flex: none;
  min-width: 5.5rem;
  padding-top: 0.125rem;
  font-size: 0.8125rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--status-planned);
  white-space: nowrap;
}
.sched-body { flex: 1; min-width: 0; display: grid; gap: 0.3125rem; }
.sched-title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.sched-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem 0.625rem; font-size: 0.8125rem; color: var(--text-muted); }
.sched-meta:empty { display: none; }
.sched-meta > span:not(.status-chip):not(.task-recurrence) { display: inline-flex; align-items: center; gap: 0.25rem; }
.sched-meta .icon { width: 0.875rem; height: 0.875rem; }
.sched-meta .status-chip { font-size: 0.75rem; padding: 0.125rem 0.5rem; }
.sched-notes { font-size: 0.875rem; color: var(--text-muted); white-space: pre-line; }
.sched-actions { flex: none; display: flex; gap: 0.125rem; opacity: 0.6; transition: opacity var(--fast) ease; }
.sched-item:hover .sched-actions,
.sched-actions:focus-within { opacity: 1; }
.sched-actions .btn-icon { width: 34px; min-height: 34px; }

.private-mark { margin-left: 0.375rem; width: 0.875rem; height: 0.875rem; color: var(--text-muted); vertical-align: -0.1em; }
.sched-item.is-private .sched-title { display: inline-flex; align-items: center; gap: 0.375rem; color: var(--text-muted); }
.family-day .icon-lock { width: 0.8125rem; height: 0.8125rem; margin-left: 0.25rem; color: var(--text-muted); vertical-align: -0.1em; }
/* Availability and Private sit right under "For". */
.status-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.375rem 0.625rem; margin-top: 0.5rem; }
.status-row .kind-option { min-height: 34px; padding: 0 0.75rem; font-size: 0.8125rem; }
.private-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--fast) ease, border-color var(--fast) ease, background var(--fast) ease;
}
.private-chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.private-chip span { display: inline-flex; align-items: center; gap: 0.3125rem; }
.private-chip:hover { color: var(--text); border-color: var(--accent); }
.private-chip:has(input:checked) { color: var(--text); background: var(--surface-sunken); border-style: solid; border-color: var(--text-muted); }
.private-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.visitor-check { margin: -0.375rem 0 1.125rem; }

/* An admin managing someone else's details */
.managing-banner { border-color: var(--accent); }
.managing-banner .banner-icon { color: var(--accent); background: var(--accent-soft); }

/* Inside/outside: only once a house is picked. */
.spot-field { display: none; }
form:has(.pick-house input:checked) .spot-field { display: block; animation: slide-down 260ms var(--ease-out); }
/* Penned up: only outside at a house. */
.pen-field { display: none; }
form:has(.pick-house input:checked):has(.spot-field input[value="outside"]:checked) .pen-field { display: block; animation: slide-down 260ms var(--ease-out); }

/* Pets that are away for now */
.section-title.away-title .count { margin-left: 0.25rem; }
.away-title .icon { color: var(--text-muted); }
.away-list .pet-identity { flex: 1; }
.away-list .person-avatar { opacity: 0.6; }
.away-list .sched-actions { opacity: 1; align-self: center; }
.away-banner { border-color: var(--border-strong); }
.away-banner .banner-icon { color: var(--text-muted); background: var(--surface-sunken); }

/* The board, by house */
.board-tools { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.board-tools > span { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.875rem; font-weight: 650; color: var(--text-muted); margin-right: 0.25rem; }
.board-tools > span .icon { color: var(--accent); }
.house-groups { display: grid; gap: 2rem; }
.house-group { display: grid; gap: 1rem; }
.house-title { display: flex; align-items: center; gap: 0.625rem; margin: 0; font-size: 1.125rem; }
.house-title .place-photo { width: 2rem; border-radius: var(--radius-sm); }
.house-title .place-photo > .icon { width: 55%; height: 55%; }
.family-grid + .house-title { margin-top: 2rem; }
.house-title + .family-grid { margin-top: 0.875rem; }

/* Who it's for */
.who-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.375rem 0.625rem; margin-top: 0.625rem; }
.who-label { font-size: 0.8125rem; font-weight: 650; color: var(--text-muted); padding-left: 0.25rem; }
.who-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.who-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 34px;
  padding: 0.1875rem 0.75rem 0.1875rem 0.1875rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--fast) ease, border-color var(--fast) ease, background var(--fast) ease;
}
.who-chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.who-chip .person-avatar { width: 1.625rem; height: 1.625rem; font-size: 0.625rem; box-shadow: none; opacity: 0.55; transition: opacity var(--fast) ease; }
.who-chip:has(input:checked) { color: var(--text); border-color: var(--user-color); background: color-mix(in srgb, var(--user-color) 14%, var(--surface)); }
.who-chip:has(input:checked) .person-avatar { opacity: 1; }
.who-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Follow up: a toggle chip, shown only once someone else is picked. */
.follow-up-check {
  position: relative;
  display: none;
  align-items: center;
  gap: 0.375rem;
  min-height: 34px;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--fast) ease, border-color var(--fast) ease, background var(--fast) ease;
}
.follow-up-check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.follow-up-check span { display: inline-flex; align-items: center; gap: 0.3125rem; }
.follow-up-check:hover { color: var(--text); border-color: var(--accent); }
.follow-up-check:has(input:checked) { color: var(--accent); background: var(--accent-soft); border-style: solid; border-color: var(--accent); }
.follow-up-check:has(input:checked) .icon { animation: bell-ring 700ms ease-in-out; }
.follow-up-check:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.who-row:has(.who-other input:checked) .follow-up-check { display: inline-flex; }
.form-field > .who-row,
.form-field > .status-row { margin-top: 0; }

.who-list { display: inline-flex; align-items: center; gap: 0.25rem; }
.who-list .person-avatar { width: 1.375rem; height: 1.375rem; font-size: 0.5625rem; box-shadow: 0 0 0 2px var(--surface); }
.who-list .person-avatar + .person-avatar { margin-left: -0.5rem; }
.who-list .person-avatar.is-waiting { opacity: 0.45; outline: 1.5px dashed var(--border-strong); outline-offset: 1px; }
.sched-conflict { display: inline-flex; align-items: center; gap: 0.3125rem; font-size: 0.8125rem; font-weight: 600; color: var(--status-in_progress); }
.sched-conflict .icon { width: 0.875rem; height: 0.875rem; }
.waiting-panel { margin-bottom: 1.25rem; border-color: var(--status-in_progress-border); }
.waiting-panel > h2 .icon { color: var(--status-in_progress); }
.sched-actions.invite-actions { opacity: 1; margin: 0; width: auto; gap: 0.375rem; }

/* Work hours and days off */
.sched-work .sched-title,
.sched-day-off .sched-title { display: inline-flex; align-items: center; gap: 0.4375rem; }
.sched-work .sched-title .icon { color: var(--accent); }
.sched-day-off .sched-title .icon { color: var(--status-completed); }
.sched-day-off .sched-time { color: var(--status-completed); }
.person-now .icon-briefcase,
.family-day .icon-briefcase { width: 0.9375rem; height: 0.9375rem; margin-right: 0.3125rem; color: var(--accent); vertical-align: -0.15em; }
.day-off-banner .banner-icon { color: var(--status-completed); background: var(--status-completed-bg); }
.day-header .header-actions { align-self: flex-start; }

.work-days { display: grid; gap: 0.5rem; margin-top: 0.5rem; }
.work-day {
  display: grid;
  grid-template-columns: 7.75rem 9rem auto 9rem minmax(8rem, 1fr);
  align-items: center;
  gap: 0.5rem;
  transition: opacity var(--fast) ease;
}
.work-day:not(:has(input[type="checkbox"]:checked)) > input { opacity: 0.4; }
.work-day input[type="time"] { padding-inline: 0.625rem; }
.work-day-place { display: grid; gap: 0.375rem; min-width: 0; }
.work-day-place .new-place-field { margin-top: 0; }
.work-day:not(:has(input[type="checkbox"]:checked)) .work-day-place { opacity: 0.4; }
form:has(.work-days) { max-width: 860px; }
.work-day-name { display: flex; align-items: center; gap: 0.25rem; font-weight: 600; cursor: pointer; }
.work-day-to { font-size: 0.875rem; color: var(--text-muted); }
.work-week-tools { margin-top: 0.75rem; }
.days-off-section { margin-top: 2.5rem; }
.days-off-section .section-title { margin-top: 0; }
.days-off-section .section-title .icon { color: var(--status-completed); }
.days-off-list { margin-top: 1rem; max-width: 760px; }

.done-today { margin-top: 2rem; }
.done-today > summary { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 600; color: var(--text-muted); }
.done-today > summary .icon { color: var(--status-completed); }
.done-today[open] > summary { margin-bottom: 0.5rem; }

/* Family day */
.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
  align-items: start;
}
.family-column { border-top: 4px solid var(--user-color); }
.family-person { display: flex; align-items: center; gap: 0.625rem; color: var(--text); margin-bottom: 0.75rem; }
.family-person:hover { text-decoration: none; }
.family-person:hover .person-name { color: var(--accent); }
.family-now { display: grid; justify-items: start; gap: 0.375rem; margin-bottom: 0.875rem; }
.family-day { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.5rem; font-size: 0.9375rem; }
.family-day li { display: flex; gap: 0.625rem; }
.family-day li.is-past { opacity: 0.55; }
.family-day li.is-now { font-weight: 650; }
.family-day .sched-time { min-width: 6.5rem; }
.family-todos { margin: 0; }
.family-todos small { display: inline-flex; align-items: center; gap: 0.375rem; }


/* A person's day: profile header and the one-tap "I'm at" chips. */
.day-header { margin-bottom: 1.25rem; }
.day-header .profile-avatar { width: 4.5rem; height: 4.5rem; font-size: 1.375rem; }
/* Its own line, so a long place name doesn't wrap it on and off the
   date's line and move everything below. */
.day-where { flex-basis: 100%; color: var(--text); font-weight: 600; }
.day-where .icon { color: var(--accent); }
.profile-heading .report-comment { margin-top: 0.375rem; }

.where-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1.25rem;
}
.where-label { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.875rem; font-weight: 650; color: var(--text-muted); }
.where-label .icon { color: var(--accent); }
.where-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.where-chips form { display: contents; }
.where-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 36px;
  padding: 0 0.875rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color var(--fast) ease, background var(--fast) ease, transform var(--medium) var(--ease-spring);
}
.where-chip .icon { color: var(--accent); width: 1rem; height: 1rem; }
.where-chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.where-chip:active { transform: scale(0.95); }
.where-chip.is-current { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
/* "I'm" free / text only / do not disturb: each chip's icon in its own
   colour, and the one in force filled with it. */
.status-bar .where-chip.avail-free .icon { color: var(--status-completed); }
.status-bar .where-chip.avail-text .icon { color: var(--status-in_progress); }
.status-bar .where-chip.avail-busy .icon { color: var(--danger); }
.status-bar .where-chip.avail-free.is-current { color: var(--status-completed); background: var(--status-completed-bg); border-color: var(--status-completed); }
.status-bar .where-chip.avail-text.is-current { color: var(--status-in_progress); background: var(--status-in_progress-bg); border-color: var(--status-in_progress); }
.status-bar .where-chip.avail-busy.is-current { color: var(--danger); background: var(--danger-bg); border-color: var(--danger); }
.status-until { flex-basis: 100%; }
.where-more { flex-basis: 100%; }
/* A dashed chip, so it reads as one more thing to tap after the places. */
.where-more > summary { list-style: none; width: fit-content; color: var(--accent); border-style: dashed; background: transparent; }
.where-more > summary::-webkit-details-marker { display: none; }
.where-more > summary .where-more-chevron { width: 0.875rem; height: 0.875rem; transition: transform var(--medium) var(--ease-spring); }
.where-more[open] > summary { margin-bottom: 0.75rem; border-style: solid; background: var(--accent-soft); border-color: var(--accent); }
.where-more[open] > summary .where-more-chevron { transform: rotate(180deg); }
.where-more > form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.5rem);
  max-width: 760px;
  animation: slide-down 260ms var(--ease-out);
}

/* ---------- Icons & motion ----------
 * Icons come from IconsHelper as inline SVG stroked in currentColor, so they
 * take the colour of whatever text they sit in. Sized in em so they scale
 * with the text (the kiosk's bigger chips get bigger icons for free).
 */
.icon {
  flex: none;
  width: 1.125em;
  height: 1.125em;
  vertical-align: -0.2em;
  transition: transform var(--medium) var(--ease-spring);
}

.nav-brand .icon { color: var(--accent); width: 1.375rem; height: 1.375rem; }
.nav-brand:hover .icon { transform: rotate(-10deg) scale(1.12); }
.nav-brand[aria-current="page"] .icon { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 55%, transparent)); }
.nav-links a:hover .icon { transform: translateY(-1px) scale(1.12); }

/* Each button icon has its own little gesture on hover. */
.btn:hover .icon-plus       { transform: rotate(90deg); }
.btn:hover .icon-play,
.btn:hover .icon-arrow-right,
.btn:hover .icon-log-in     { transform: translateX(3px); }
.btn:hover .icon-log-out    { transform: translateX(2px); }
.btn:hover .icon-check      { transform: scale(1.25); }
.btn:hover .icon-pause      { transform: scaleY(0.8); }
.btn:hover .icon-skip       { transform: translateX(2px); }
.btn:hover .icon-pencil     { transform: rotate(-14deg) translateY(-1px); }
.btn:hover .icon-trash      { animation: wiggle 400ms ease-in-out; }
.btn:hover .icon-zap        { animation: wiggle 400ms ease-in-out; color: var(--status-in_progress-border); }
.btn:hover .icon-bell       { animation: bell-ring 700ms ease-in-out; }
.btn:hover .icon-user-plus,
.btn:hover .icon-key,
.btn:hover .icon-save       { transform: scale(1.15); }
.btn:hover .icon-map-pin    { animation: hop 500ms var(--ease-spring); }
.btn:hover .icon-utensils   { animation: wiggle 400ms ease-in-out; }
.btn:hover .icon-send,
.btn:hover .icon-external   { transform: translate(2px, -2px); }

/* While Turbo submits a form it marks it aria-busy: dim the button and
   let it breathe so a slow tap still feels acknowledged. */
form[aria-busy="true"] .btn {
  cursor: progress;
  animation: busy 900ms ease-in-out infinite;
}

/* Cards rise in, one after another. A card replaced by a live broadcast
   (someone started a task) rises in again, which reads as "this changed". */
.dashboard-grid > *,
.sched-list > *,
.pet-grid > *,
.place-grid > *,
.pick-grid > *,
.checklist,
.invite-banner {
  animation: rise-in 480ms var(--ease-out) backwards; /* not "both": a held end frame would block the hover lift */
}
.dashboard-grid > :nth-child(2), .sched-list > :nth-child(2) { animation-delay: 40ms; }
.dashboard-grid > :nth-child(3), .sched-list > :nth-child(3) { animation-delay: 80ms; }
.dashboard-grid > :nth-child(4), .sched-list > :nth-child(4) { animation-delay: 120ms; }
.dashboard-grid > :nth-child(5), .sched-list > :nth-child(5) { animation-delay: 160ms; }
.dashboard-grid > :nth-child(n+6), .sched-list > :nth-child(n+6) { animation-delay: 200ms; }

/* Confetti from the Done button (celebrate_controller.js). */
.confetti {
  position: fixed;
  z-index: 100;
  width: 7px;
  height: 10px;
  margin: -5px 0 0 -3px;
  border-radius: 2px;
  pointer-events: none;
  animation: confetti 800ms var(--ease-out) forwards;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes pop {
  0%   { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes live-dot {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); }
  50%      { box-shadow: 0 0 0 4px transparent; transform: scale(1.15); }
}
@keyframes ring-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--user-color) 55%, transparent); }
  70%  { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40%      { transform: translateY(-4px); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25%      { transform: rotate(-12deg); }
  75%      { transform: rotate(12deg); }
}
@keyframes bell-ring {
  0%, 20%, 100% { transform: rotate(0); }
  4%  { transform: rotate(14deg); }
  8%  { transform: rotate(-12deg); }
  12% { transform: rotate(8deg); }
  16% { transform: rotate(-4deg); }
}
@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0); }
  50%      { transform: scale(1.15) rotate(12deg); }
}
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes busy { 50% { opacity: 0.65; } }
@keyframes confetti {
  0%   { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 40px)) rotate(var(--spin)) scale(0.6); opacity: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 719px) {
  .nav-inner {
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
  }
  .nav-user { gap: 0.25rem; }
  .household-switch { order: 4; width: 100%; }
  .household-switch select { width: 100%; }

  /* iOS zooms into any field under 16px when it's focused: the compact
     ones (table selects, copy fields, inline forms) go full size here. */
  html :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"]), select, textarea) { font-size: 1rem; }

  .container { padding-top: 1.5rem; padding-bottom: calc(3rem + var(--tab-bar-h, 0px) + env(safe-area-inset-bottom, 0px)); }

  /* A phone has no width to spare for boxes in boxes: a slimmer card, and
     the fieldsets in it lose their own box (the legend still heads them). */
  .form-card { max-width: none; --card-pad: 1rem; }
  .form-card fieldset.form-field { border: 0; border-radius: 0; padding: 0; background: none; }
  .form-card fieldset.form-field > legend { padding: 0; margin-bottom: 0.5rem; }

  .invite-actions { margin-left: 0; width: 100%; }
  .invite-actions .btn { flex: 1; }

  .page-header .header-actions { width: 100%; }
  .page-header .header-actions .btn { flex: 1; }
  .sticky-actions .btn-wide { flex: 1; min-width: 0; }
  .pick-grid { grid-template-columns: repeat(auto-fill, minmax(6.25rem, 1fr)); }
  .quick-add-row .btn span { display: none; }
  /* Wraps (a day before the time) rather than squeezing the title. */
  .sched-time { flex: 0 0 5rem; min-width: 0; white-space: normal; }
  .sched-actions { opacity: 1; }
  .work-day { grid-template-columns: 1fr 1fr; }
  .work-day-name { grid-column: 1 / -1; }
  .work-day-to { display: none; }
  .work-day-place { grid-column: 1 / -1; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .btn:hover, .person-card:hover, .pet-card:hover, .place-card:hover, .pick-tile:hover { transform: none; }
}
