/*
 * HelloScout: the setup site.
 *
 * The site is a calm, neutral control panel; the playfulness lives on the TV. Color
 * appears only inside the TV preview, as a faithful miniature of the dashboard.
 *
 * Everything below reads from these tokens. Light and dark are both first-class.
 */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f2f4;           /* icon wells, segmented track */
  --ink: #0b0b0c;
  --ink-2: #5f5f66;               /* secondary text */
  --ink-3: #9a9aa1;               /* tertiary text, chevrons */
  --line: rgba(11, 11, 12, 0.08);
  --line-strong: rgba(11, 11, 12, 0.16);
  --primary: #0b0b0c;
  --on-primary: #ffffff;
  --focus: #0a66ff;
  --positive: #1f9d55;
  --danger: #d13438;
  --danger-bg: #fdf1f1;
  --notice-bg: #eef7f1;

  --tv-bezel: #0d0d0f;
  --tv-screen: #121316;
  --tv-tile: #1c1d21;
  --tv-ink: #f4f4f6;
  --tv-ink-2: #8c8d93;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --control: 48px;
  --shadow: 0 1px 2px rgba(11, 11, 12, 0.04), 0 8px 24px -12px rgba(11, 11, 12, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --surface: #161618;
    --surface-2: #232326;
    --ink: #f4f4f6;
    --ink-2: #a3a3aa;
    --ink-3: #6c6c73;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --primary: #f4f4f6;
    --on-primary: #0b0b0c;
    --focus: #4c8dff;
    --danger: #ff6b6b;
    --danger-bg: rgba(255, 107, 107, 0.1);
    --notice-bg: rgba(52, 199, 89, 0.1);
    --tv-bezel: #000000;
    --shadow: 0 0 0 1px var(--line);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

a { color: inherit; text-decoration: none; }
p { margin: 0; }
.icon { flex-shrink: 0; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Type scale ---------- */
h1, .h1 {
  font-family: var(--font-display);
  font-size: 30px; line-height: 1.12; font-weight: 650; letter-spacing: -0.025em;
  margin: 0;
}
h2, .h2 { font-size: 17px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.lede { font-size: 17px; line-height: 1.5; color: var(--ink-2); }
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); }
.small { font-size: 14px; line-height: 1.45; }
.caption { font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.eyebrow { font-size: 13px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.mono { font-family: var(--font-mono); font-feature-settings: normal; }
.tnum { font-variant-numeric: tabular-nums; }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.link:hover { text-decoration-color: currentColor; }

/* ---------- Page shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.topbar-inner {
  max-width: 640px; margin: 0 auto; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-4);
}
.wordmark { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 17px; letter-spacing: -0.02em; }
.wordmark-mark {
  width: 22px; height: 22px; border-radius: 7px; background: var(--ink); position: relative; display: inline-block;
}
.wordmark-mark::after {
  /* a tiny screen: the mark is a TV with one lit pixel */
  content: ""; position: absolute; width: 6px; height: 6px; border-radius: 2px;
  background: var(--bg); right: 5px; bottom: 5px;
}
.topbar-link { font-size: 15px; font-weight: 500; color: var(--ink-2); padding: 8px 4px; }
.topbar-link:hover { color: var(--ink); }

.page { max-width: 640px; margin: 0 auto; padding: var(--space-4) var(--space-4) 120px; }
.page-narrow { max-width: 440px; }
.stack > * + * { margin-top: var(--space-5); }
.stack-sm > * + * { margin-top: var(--space-3); }
.stack-lg > * + * { margin-top: var(--space-7); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.page-header { padding-top: var(--space-4); }
.page-header > * + * { margin-top: var(--space-2); }

/* ---------- Flash ---------- */
.flash {
  display: flex; gap: var(--space-2); align-items: flex-start;
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: var(--space-4);
  font-size: 15px; line-height: 1.4;
}
.flash .icon { margin-top: 1px; }
.flash-alert { background: var(--danger-bg); color: var(--danger); }
.flash-notice { background: var(--notice-bg); color: var(--positive); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control); padding: 0 20px;
  border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px; font-weight: 550; letter-spacing: -0.01em;
  cursor: pointer; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease, opacity .15s ease;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { opacity: .88; border-color: var(--primary); }
.btn-apple { background: #000; color: #fff; border-color: #000; }
.btn-apple:hover { opacity: .88; border-color: #000; }
@media (prefers-color-scheme: dark) { .btn-apple { background: #fff; color: #000; border-color: #fff; } }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { color: var(--ink); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 15px; border-radius: 10px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn:disabled { opacity: .35; cursor: default; transform: none; }
form.button_to { display: contents; }
.button-stack { display: flex; flex-direction: column; gap: var(--space-3); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.text-button {
  background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px;
}
.text-button:hover { color: var(--ink); }
.text-button.danger { color: var(--danger); text-decoration-color: currentColor; }

.icon-button {
  width: 36px; height: 36px; display: inline-grid; place-items: center; flex-shrink: 0;
  border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.icon-button:hover { background: var(--surface-2); color: var(--ink); }
.icon-button[disabled] { opacity: .25; cursor: default; background: transparent; }

.divider { display: flex; align-items: center; gap: var(--space-3); color: var(--ink-3); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Forms ---------- */
.field > * + * { margin-top: 6px; }
.label { display: block; font-size: 14px; font-weight: 550; color: var(--ink); }
.hint { font-size: 13px; color: var(--ink-2); }
.input {
  width: 100%; height: var(--control); padding: 0 14px;
  font: inherit; font-size: 16px; color: var(--ink);    /* 16px stops iOS zooming on focus */
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); }
.input-with-icon { position: relative; }
.input-with-icon .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-with-icon .input { padding-left: 42px; }
.errors {
  background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-sm);
  padding: 12px 14px 12px 34px; margin: 0; font-size: 15px;
}

/* ---------- Grouped lists (the iOS Settings idiom) ---------- */
.section > * + * { margin-top: var(--space-2); }
.section-title { font-size: 13px; font-weight: 500; color: var(--ink-2); padding: 0 var(--space-4); }
.section-footer { font-size: 13px; color: var(--ink-2); padding: 0 var(--space-4); }
.group {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
  list-style: none; padding: 0;
}
:where(ul.group, ol.group) { margin: 0; }   /* zero specificity, so stack spacing still applies */
.group > * + * { box-shadow: inset 0 1px 0 var(--line); }  /* hairline between rows */
.cell {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 56px; padding: 10px var(--space-4);
  width: 100%; background: none; border: 0; font: inherit; color: inherit; text-align: left;
}
a.cell, button.cell, label.cell { cursor: pointer; transition: background-color .12s ease; }
a.cell:hover, button.cell:hover, label.cell:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.cell-title { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; }
.cell-detail { font-size: 14px; color: var(--ink-2); line-height: 1.35; }
.cell-value { font-size: 15px; color: var(--ink-2); white-space: nowrap; }
.cell .chevron { color: var(--ink-3); margin-right: -4px; }
.cell-body { flex: 1; min-width: 0; }
.cell-body > * { overflow: hidden; text-overflow: ellipsis; }
.cell-block { display: block; padding: var(--space-4); }

.well {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink);
}

/* Switches */
.switch { position: relative; width: 51px; height: 31px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong);
  transition: background-color .2s ease; pointer-events: none;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s cubic-bezier(.3,.7,.4,1);
}
.switch input:checked + span { background: var(--positive); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Round checkboxes */
.check { position: relative; width: 24px; height: 24px; flex-shrink: 0; }
.check input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.check span {
  position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--line-strong);
  display: grid; place-items: center; color: transparent; pointer-events: none;
  transition: background-color .15s ease, border-color .15s ease;
}
.check input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.check input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Segmented control */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px; border-radius: 10px; background: var(--surface-2);
}
.segmented .seg {
  height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.segmented .seg:hover { color: var(--ink); }
.segmented .seg[aria-pressed=true] {
  background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 .5px var(--line);
}
@media (prefers-color-scheme: dark) { .segmented .seg[aria-pressed=true] { background: #3a3a3e; } }
.segmented-block { display: flex; }
.segmented-block .seg { flex: 1; }

/* Color dots for calendars (only shown once a calendar is chosen) */
.swatches { display: none; gap: 10px; padding: 0 var(--space-4) 14px 52px; flex-wrap: wrap; }
.cal-item:has(input[type=checkbox]:checked) .swatches { display: flex; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span { display: block; width: 22px; height: 22px; border-radius: 50%; pointer-events: none; transition: box-shadow .15s ease; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.swatch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Status */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.status.is-online::before { background: var(--positive); box-shadow: 0 0 0 3px color-mix(in srgb, var(--positive) 18%, transparent); }

/* ---------- TV code ---------- */
.code-boxes { display: flex; gap: 8px; align-items: center; }
.code-boxes input {
  width: 100%; max-width: 52px; aspect-ratio: 52 / 64; min-width: 0; padding: 0; text-align: center;
  font-family: var(--font-mono); font-size: 26px; font-weight: 600; color: var(--ink); text-transform: uppercase;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.code-boxes input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); }
.code-boxes .dash { width: 10px; height: 2px; border-radius: 1px; background: var(--ink-3); flex-shrink: 0; }
.code-display {
  display: inline-flex; font-family: var(--font-mono); font-size: 22px; font-weight: 600; letter-spacing: 0.12em;
  padding: 8px 14px; border-radius: 10px; background: var(--surface-2);
}

/* ---------- Setup progress ---------- */
.progress { display: flex; align-items: center; gap: var(--space-3); }
.progress-track { flex: 1; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; background: var(--ink); border-radius: 2px; transition: width .3s ease; }

.sticky-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  box-shadow: inset 0 1px 0 var(--line);
}
.sticky-actions .inner { max-width: 640px; margin: 0 auto; display: flex; gap: var(--space-2); justify-content: flex-end; }
.sticky-actions .inner .btn-primary { min-width: 140px; }
@media (max-width: 480px) { .sticky-actions .inner > .btn-primary { flex: 1; } }

/* ---------- TV preview ---------- */
.tv {
  background: var(--tv-bezel); border-radius: var(--radius-lg); padding: 7px;
  box-shadow: var(--shadow);
}
.tv-screen {
  aspect-ratio: 16 / 9; background: var(--tv-screen); border-radius: 14px; overflow: hidden;
  display: grid; grid-template-rows: auto 1fr; gap: 3.2%; padding: 3.2% 3.6%;
  container-type: inline-size;
}
.tv-header { display: flex; justify-content: space-between; align-items: baseline; color: var(--tv-ink); }
.tv-day { font-family: var(--font-display); font-weight: 700; font-size: 4.6cqw; letter-spacing: -0.02em; line-height: 1; }
.tv-time { font-size: 2.6cqw; color: var(--tv-ink-2); font-variant-numeric: tabular-nums; }
.tv-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(3, 1fr); gap: 1.4cqw; min-height: 0; }
.tv-slot { border-radius: 1.2cqw; border: 1px dashed rgba(255,255,255,0.08); }
.tile {
  position: relative; min-width: 0; min-height: 0; overflow: hidden;
  border-radius: 1.2cqw; background: var(--tv-tile); color: var(--tv-ink);
  display: flex; flex-direction: column; justify-content: space-between; padding: 1.6cqw;
}
.tile::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 0.45cqw; background: var(--tile-color); }
.tile-icon { color: var(--tile-color); width: 3.2cqw; height: 3.2cqw; }
.tile-agenda { display: grid; gap: 1.3cqw; align-content: start; flex: 1; padding: 1.8cqw 0; }
.tile-agenda i { display: block; height: 0.8cqw; border-radius: 1cqw; background: rgba(255,255,255,0.14); }
.tile-agenda i:first-child { background: color-mix(in srgb, var(--tile-color) 70%, transparent); }
.tile { justify-content: flex-start; }
.tile:not(:has(.tile-agenda)) .tile-icon { width: 5.2cqw; height: 5.2cqw; margin: auto; opacity: .95; }
.tile-name { font-size: 1.9cqw; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.tv-header-right { display: inline-flex; align-items: baseline; gap: 2.4cqw; }
.tv-weather { display: inline-flex; align-items: center; gap: 0.8cqw; font-size: 2.6cqw; font-weight: 600; color: var(--tv-ink); }
.tv-weather-icon { width: 2.8cqw; height: 2.8cqw; color: #F5B83D; align-self: center; }
.tile-agenda.is-wide { grid-template-columns: 1fr 1fr; column-gap: 3cqw; }
.tile-week { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.8cqw; min-height: 0; }
.tile-week-day { display: flex; flex-direction: column; gap: 0.8cqw; min-width: 0; }
.tile-week-day b { font-size: 1.6cqw; font-weight: 600; color: var(--tv-ink-2); text-align: center; text-transform: uppercase; }
.tile-week-day.is-today b { color: var(--tv-ink); }
.tile-week-col { position: relative; flex: 1; border-radius: 0.6cqw; background: rgba(255,255,255,0.03); }
.tile-week-day.is-today .tile-week-col { background: rgba(255,255,255,0.07); }
.tile-week-col i { position: absolute; left: 6%; right: 6%; border-radius: 0.5cqw; background: color-mix(in srgb, var(--tile-color) 55%, #1c1d21); }
.tile-forecast { flex: 1; display: grid; grid-template-columns: 0.8fr 1.2fr; grid-template-rows: 1.4fr 0.8fr 0.8fr; gap: 1.2cqw; min-height: 0; }
.tf-now { display: flex; align-items: center; gap: 1.2cqw; }
.tf-now b { font-size: 6cqw; font-weight: 700; letter-spacing: -0.03em; color: var(--tv-ink); }
.tf-icon { width: 6cqw; height: 6cqw; color: #F5B83D; }
.tf-details { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8cqw; }
.tf-details i, .tf-days i { border-radius: 0.8cqw; background: rgba(255,255,255,0.06); }
.tf-strip { grid-column: 1 / -1; display: flex; align-items: flex-end; gap: 0.8cqw; padding: 0 0.4cqw; }
.tf-strip i { flex: 1; border-radius: 0.6cqw 0.6cqw 0 0; background: color-mix(in srgb, #F5B83D 45%, #1c1d21); }
.tf-days { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.8cqw; }
.tv-empty { grid-column: 1 / -1; grid-row: 1 / -1; display: grid; place-items: center; color: var(--tv-ink-2); font-size: 2.2cqw; }

/* ---------- Layout editor ---------- */
.editor-list { list-style: none; margin: 0; padding: 0; }
.editor-row { padding: 12px var(--space-4) 14px; background: var(--surface); }
.editor-row > * + * { margin-top: 10px; }
.editor-row .grip { color: var(--ink-3); cursor: grab; touch-action: none; margin-left: -6px; }
.editor-row .grip:active { cursor: grabbing; }
.editor-row .controls { display: flex; gap: 2px; margin-right: -8px; }
.editor-row .segmented { margin-left: 26px; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: var(--shadow); position: relative; z-index: 1; }

/* ---------- Templates ---------- */
.template-switcher { display: flex; align-items: center; gap: var(--space-2); }
.template-switcher .icon-button { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); color: var(--ink); }
.template-label { flex: 1; min-width: 0; text-align: center; }
.template-label .cell-title { display: block; }
.template-dots { display: flex; justify-content: center; gap: 6px; }
.template-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); transition: background-color .2s ease, width .2s ease; }
.template-dots span.is-current { width: 18px; border-radius: 3px; background: var(--ink); }
.device-card > details + .cell-block { box-shadow: inset 0 1px 0 var(--line); }
.device-card > details[open] + .cell-block { box-shadow: inset 0 1px 0 var(--line); }
.look-option { display: block; cursor: pointer; transition: box-shadow .15s ease; }
.look-option:has(input:checked) { box-shadow: 0 0 0 2px var(--ink); }

/* ---------- Landing ---------- */
.hero { padding-top: var(--space-6); }
.hero h1 { font-size: 40px; line-height: 1.05; letter-spacing: -0.035em; }
@media (min-width: 600px) { .hero h1 { font-size: 52px; } }
.feature-list { display: grid; gap: var(--space-5); }
@media (min-width: 600px) { .feature-list { grid-template-columns: repeat(3, 1fr); } }
.feature > * + * { margin-top: 6px; }
.feature .well { margin-bottom: var(--space-3); }
.site-footer { padding-top: var(--space-7); font-size: 13px; color: var(--ink-3); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 13px; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.photo-remove:hover { background: rgba(0, 0, 0, .75); }
.tile.is-photos { padding: 0; }
.tile.is-photos::before { display: none; }
.tile-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile-photo.is-empty { background: linear-gradient(135deg, color-mix(in srgb, var(--tile-color) 35%, var(--tv-tile)), var(--tv-tile)); }
.tile.is-photos .tile-icon { position: relative; }
.segmented-block form .seg { width: 100%; padding: 0 4px; white-space: nowrap; }
.source-head { align-items: flex-start; }
.source-head .cell-detail { display: block; margin-top: 2px; }
.source-tv + .source-tv { border-top: 1px solid var(--line); }
select.input {
  -webkit-appearance: none; appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9aa1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}

/* ---------- Little Kids preview ---------- */
.tv-screen.is-headerless { grid-template-rows: 1fr; }
.tile.is-little_kid { padding: 0; background: linear-gradient(135deg, #4b2fc9, #6a3fe0 45%, #2f6fe6); }
.tile.is-little_kid::before { display: none; }
.tile-little { position: absolute; inset: 0; display: grid; grid-template-columns: 30% 1fr; grid-template-rows: 1fr auto; padding: 4% 5%; gap: 4%; color: #fff; }
.tl-stars { position: absolute; inset: 0; pointer-events: none; }
.tl-stars i { position: absolute; width: .45cqw; height: .45cqw; border-radius: 50%; background: #fff; opacity: .6; }
.tl-stars i:nth-child(1) { left: 12%; top: 10%; } .tl-stars i:nth-child(2) { left: 46%; top: 6%; } .tl-stars i:nth-child(3) { left: 70%; top: 14%; }
.tl-stars i:nth-child(4) { left: 88%; top: 8%; } .tl-stars i:nth-child(5) { left: 30%; top: 22%; } .tl-stars i:nth-child(6) { left: 92%; top: 40%; }
.tl-stars i:nth-child(7) { left: 6%; top: 55%; } .tl-stars i:nth-child(8) { left: 60%; top: 30%; } .tl-stars i:nth-child(9) { left: 80%; top: 62%; }
.tl-mascot { align-self: center; justify-self: center; font-size: 9cqw; width: 15cqw; height: 15cqw; border-radius: 50%; background: rgba(255,255,255,.92); display: grid; place-items: center; }
.tl-main { display: flex; flex-direction: column; justify-content: center; gap: 1.2cqw; }
.tl-pill { align-self: flex-start; font-size: 1.5cqw; font-weight: 800; letter-spacing: .1em; color: #2b1d6b; background: #FECA57; border-radius: 99px; padding: .3cqw 1cqw; }
.tl-day { font-size: 7cqw; font-weight: 900; line-height: 1; letter-spacing: -0.02em; }
.tl-week { display: flex; gap: 1cqw; }
.tl-week i { width: 2.4cqw; height: 2.4cqw; border-radius: 50%; background: rgba(255,255,255,.25); }
.tl-week i.is-today { background: #FECA57; box-shadow: 0 0 0 .4cqw rgba(254,202,87,.35); }
.tl-cards { grid-column: 1 / -1; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2cqw; }
.tl-cards i { font-style: normal; font-size: 4cqw; height: 9cqw; border-radius: 1.6cqw; background: rgba(255,255,255,.14); display: grid; place-items: center; }

/* ---------- Kids ---------- */
.kid-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 22px;
  background: color-mix(in srgb, var(--kid-color) 22%, var(--surface)); box-shadow: inset 0 0 0 2px var(--kid-color);
}
.kid-avatar.is-large { width: 88px; height: 88px; font-size: 48px; box-shadow: inset 0 0 0 3px var(--kid-color); }
.kid-preview { display: flex; justify-content: center; }
.kid-choices { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.kid-choice { position: relative; }
.kid-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.kid-choice span {
  display: grid; place-items: center; aspect-ratio: 1; border-radius: 12px; font-size: 24px;
  background: var(--surface-2); pointer-events: none; transition: box-shadow .15s ease;
}
.kid-choice input:checked + span { box-shadow: 0 0 0 2px var(--ink); background: var(--surface); }
.kid-choice input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.kid-colors { display: flex; gap: 14px; flex-wrap: wrap; padding: 4px 0; }
.kid-colors .swatch span { width: 32px; height: 32px; }
fieldset.field { border: 0; padding: 0; margin-inline: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: 8px; }

/* ---------- Chores ---------- */
.segmented-block a.seg { flex: 1; display: grid; place-items: center; text-decoration: none; }
.seg-radio { flex: 1; position: relative; display: grid; place-items: center; }
.seg-radio input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-radio:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 .5px var(--line); }
.chore-card .kid-avatar { background: color-mix(in srgb, var(--kid-color) 22%, var(--surface)); box-shadow: inset 0 0 0 2px var(--kid-color); }
.chore-stars { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chore-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 0; }
.chore-btn {
  width: 100%; min-height: 64px; display: flex; align-items: center; gap: 10px; text-align: left; position: relative;
  padding: 10px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2);
  font: inherit; font-size: 15px; font-weight: 550; color: var(--ink); cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.chore-btn:active { transform: scale(0.97); }
.chore-emoji { font-size: 26px; line-height: 1; }
.chore-name { flex: 1; min-width: 0; line-height: 1.2; }
.chore-check {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  border: 1.5px solid var(--line-strong, var(--line)); color: transparent;
}
.chore-btn.is-done { background: color-mix(in srgb, var(--kid-color) 20%, var(--surface)); border-color: var(--kid-color); }
.chore-btn.is-done .chore-check { background: var(--kid-color); border-color: var(--kid-color); color: #fff; }
.chore-well { font-size: 18px; }

.tile.is-chores { padding: 2.2cqw; }
.tile.is-chores::before { display: none; }
.tile-chores { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1.6cqw; }
.tc-kid { display: flex; flex-direction: column; align-items: center; gap: 1.2cqw; padding: 1.4cqw 1cqw; border-radius: 1.2cqw; background: rgba(255,255,255,.05); }
.tc-avatar { width: 6cqw; height: 6cqw; border-radius: 50%; display: grid; place-items: center; font-size: 3.4cqw; box-shadow: inset 0 0 0 .3cqw var(--kid-color); }
.tc-items { display: grid; grid-template-columns: 1fr 1fr; gap: .8cqw; width: 100%; }
.tc-items i { font-style: normal; font-size: 2.6cqw; aspect-ratio: 1; display: grid; place-items: center; border-radius: .9cqw; background: rgba(255,255,255,.07); opacity: .55; }
.tc-items i.is-done { opacity: 1; background: color-mix(in srgb, var(--kid-color) 45%, transparent); }
.jar-row { display: flex; align-items: center; gap: 16px; border-top: 1px solid var(--line); }
.star-jar { flex-shrink: 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,.08)); }
.jar-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.jar-buttons { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.jar-buttons .btn[disabled] { opacity: .4; cursor: default; }
.drop-star { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; transform-origin: center; filter: drop-shadow(0 4px 6px rgba(0,0,0,.18)); }
.drop-sparkle { position: fixed; z-index: 50; pointer-events: none; font-size: 16px; color: #F5B83D; }

/* ---------- Main menu: sidebar on wide screens, drawer on phones ---------- */
.app-nav { display: flex; flex-direction: column; gap: var(--space-4); flex: 1; min-height: 0; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 0 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; padding: 0 12px;
  border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 500; color: var(--ink-2); text-decoration: none;
  transition: background-color .12s ease, color .12s ease;
}
.nav-item .icon { flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current=page] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 0 0 .5px var(--line); }
@media (prefers-color-scheme: dark) { .nav-item[aria-current=page] { background: #2a2a2e; } }
.nav-account { margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.nav-account-who { display: flex; align-items: center; gap: 10px; padding: 6px 12px 8px; min-width: 0; }
.nav-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 14px; font-weight: 650; background: var(--ink); color: var(--bg); }
.nav-account-text { display: flex; flex-direction: column; min-width: 0; }
.nav-account-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.nav-account-email { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-signout { color: var(--ink-2); }

.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: 248px;
  display: flex; flex-direction: column; gap: var(--space-5); padding: 18px 12px 16px; overflow-y: auto;
  background: var(--bg); border-right: 1px solid var(--line);
}
.sidebar-brand { padding: 4px 12px 0; }
.menu-button { margin-left: -8px; }
.menu-button-spacer { width: 36px; }
.mobile-bar .topbar-inner { justify-content: space-between; }

dialog.drawer {
  margin: 0; inset: 0 auto 0 0; width: min(86vw, 320px); height: 100dvh; max-height: none; max-width: none;
  border: 0; padding: 14px 12px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); color: var(--ink);
  box-shadow: 8px 0 40px rgba(0,0,0,.18);
}
dialog.drawer[open] { display: flex; flex-direction: column; gap: var(--space-4); animation: drawer-in .26s cubic-bezier(.2,.8,.2,1); }
dialog.drawer::backdrop { background: rgba(0,0,0,.32); animation: fade-in .2s ease; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 2px 12px; }
@keyframes drawer-in { from { transform: translateX(-100%); } }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog.drawer[open], dialog.drawer::backdrop { animation: none; } }

@media (min-width: 960px) {
  body.has-app-nav { padding-left: 248px; }
  body.has-app-nav .mobile-bar { display: none; }
  body.has-app-nav .page { padding-top: var(--space-6); }
}
@media (max-width: 959px) {
  .sidebar { display: none; }
}
.drop-puff { position: fixed; z-index: 50; pointer-events: none; width: 16px; height: 16px; border-radius: 50%; background: color-mix(in srgb, var(--ink-3) 45%, white); }
.drop-minus { position: fixed; z-index: 50; pointer-events: none; font-size: 15px; font-weight: 800; color: var(--danger); }

/* ---------- Linking another app (Alexa) ---------- */
.link-apps { display: inline-flex; align-items: center; gap: 14px; margin-bottom: var(--space-3); }
.link-app { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); }
.link-app .wordmark-mark { transform: scale(1.4); }
.link-app.is-alexa { background: #00a8e1; color: #fff; }
.link-dots { color: var(--ink-3); letter-spacing: 2px; }
.prose h2 { font-size: 18px; font-weight: 650; margin-bottom: var(--space-2); }
.prose p, .prose li { font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.prose ul { padding-left: 1.2em; display: grid; gap: 6px; }
