/* Family Dashboard - warm kitchen theme with automatic night mode */

:root {
  --bg: #F5F1EA;
  --surface: #FFFFFF;
  --surface-2: #FAF7F2;
  --ink: #1F2430;
  --ink-2: #3C4250;
  --muted: #6B6F7B;
  --faint: #A3A6AE;
  --line: #ECE6DC;
  --line-strong: #DCD4C6;
  --primary: #1F2430;
  --on-primary: #FFFFFF;
  --accent: #D9572B;
  --accent-soft: #FBE9E1;
  --cold: #2563C9;
  --cold-soft: #E3EDFC;
  --danger: #C2362B;
  --danger-soft: #FCE9E7;
  --ok: #1E8A5A;
  --ok-soft: #E2F4EA;
  --warn: #B7791F;
  --warn-soft: #FBF1DC;

  --p-family: #D98A1E;
  --p-bruce: #2F6FDB;
  --p-nupuur: #0E9384;
  --p-adira: #D6407A;
  --adira-soft: #FDECF3;
  --sky: #DDEBFA;

  --shadow: 0 1px 2px rgba(31, 36, 48, 0.05), 0 4px 16px rgba(31, 36, 48, 0.05);
  --shadow-lg: 0 24px 60px rgba(31, 36, 48, 0.22);
  --radius: 20px;
  --radius-sm: 12px;
  --tap: 48px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0F131A;
  --surface: #181E27;
  --surface-2: #1E252F;
  --ink: #EEF0F4;
  --ink-2: #C9CED8;
  --muted: #8E97A6;
  --faint: #5D6676;
  --line: #262E3A;
  --line-strong: #344050;
  --primary: #EEF0F4;
  --on-primary: #0F131A;
  --accent: #F08A5D;
  --accent-soft: #3A2620;
  --cold: #7FAEF5;
  --cold-soft: #1D2A40;
  --danger: #F26B5E;
  --danger-soft: #3A2222;
  --ok: #4CC38A;
  --ok-soft: #1B3328;
  --warn: #E6B24A;
  --warn-soft: #3A3020;
  --adira-soft: #3A2030;
  --sky: #1D2A40;
  --shadow: none;
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { font-size: 18px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}

button { font: inherit; color: inherit; }
svg { display: block; }

/* ---------- Header ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 0.9rem 1.5rem 0.4rem;
}
.clock {
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.clock .ampm { font-size: 1.2rem; font-weight: 700; color: var(--muted); margin-left: 0.25rem; letter-spacing: 0; }
.today-date { margin-top: 0.3rem; font-size: 1rem; font-weight: 600; color: var(--ink-2); }

.wx-header { display: flex; align-items: center; justify-content: center; gap: 0.9rem; min-width: 0; }
.wx-addie {
  flex: 0 0 auto; width: 96px; height: 96px; padding: 0; border: 0;
  border-radius: 22px; overflow: hidden; cursor: pointer;
  background: var(--sky); box-shadow: var(--shadow);
}
.wx-addie:empty { display: none; }
.wx-addie svg { width: 100%; height: 100%; display: block; }
.wx-now-block { display: flex; align-items: center; justify-content: center; gap: 1rem; min-width: 0; }
.weather-loading { color: var(--muted); font-size: 0.9rem; }
.wx-now-main { display: flex; align-items: center; gap: 0.5rem; }
.wx-now-main .wx-icon { width: 56px; height: 56px; }
.wx-temp { font-size: 2.8rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.wx-now-meta { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.wx-cond { font-weight: 700; font-size: 0.95rem; }
.wx-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.wx-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow);
  font-size: 0.82rem; font-weight: 700; white-space: nowrap;
}
.wx-chip.chill { background: var(--cold-soft); color: var(--cold); box-shadow: none; }
.wx-chip.chill.strong { background: var(--cold); color: #fff; }
.wx-chip.windy { background: var(--warn-soft); color: var(--warn); box-shadow: none; }
.wx-chip .arrow { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.top-actions { display: flex; align-items: center; gap: 0.6rem; }
.sync { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.sync.live .sync-dot { background: var(--ok); }
.sync.stale .sync-dot { background: var(--warn); }
.sync.down .sync-dot { background: var(--danger); }
.icon-btn {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow);
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.add-btn {
  display: flex; align-items: center; gap: 0.4rem;
  height: 52px; padding: 0 1.3rem 0 1rem;
  border: 0; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-weight: 800; font-size: 1rem;
  box-shadow: 0 6px 18px rgba(217, 87, 43, 0.3);
  cursor: pointer;
}
.add-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; fill: none; }
.add-btn:active { transform: scale(0.97); }

/* Weather icon strokes */
.wx-icon { width: 30px; height: 30px; flex: 0 0 auto; }
.wx-icon * { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wx-icon .sun { stroke: #E9A23B; }
.wx-icon .sun-fill { fill: #FBD38D; stroke: #E9A23B; }
.wx-icon .moon { fill: #E4E7F0; stroke: #8A94A6; }
.wx-icon .cloud { fill: var(--surface); stroke: #8A94A6; }
.wx-icon .rain { stroke: #3B82F6; }
.wx-icon .snow { stroke: #7CB7E8; }
.wx-icon .bolt { stroke: #E9A23B; fill: #FBD38D; }
.wx-icon .fog { stroke: #8A94A6; }

/* ---------- Error ---------- */
.error-line {
  margin: 0.4rem 1.5rem 0;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- Countdowns ---------- */
.countdowns {
  display: flex; gap: 0.6rem;
  padding: 0.5rem 1.5rem 0.2rem;
  overflow-x: auto; scrollbar-width: none;
  flex: 0 0 auto;
}
.countdowns::-webkit-scrollbar { display: none; }
.countdowns:empty { display: none; }
.countdown {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.4rem 1rem 0.4rem 0.4rem;
  background: var(--surface); border-radius: 999px; box-shadow: var(--shadow);
  border: 0; cursor: pointer; text-align: left;
  min-height: var(--tap);
}
.countdown .days {
  display: grid; place-items: center;
  min-width: 44px; height: 44px; padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 800; font-size: 1.05rem; line-height: 1;
}
.countdown .days small { display: block; font-size: 0.55rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }
.countdown .what { font-weight: 700; font-size: 0.88rem; max-width: 18ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.countdown .when { font-size: 0.74rem; color: var(--muted); }
.countdown.unconfirmed { opacity: 0.6; }
.countdown.unconfirmed .days { background: var(--surface-2); color: var(--muted); }

/* ---------- Board ---------- */
.board {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr;
  gap: 1rem;
  padding: 0.7rem 1.5rem 1.2rem;
  align-items: start;
}
.col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem 0.5rem;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; gap: 0.4rem;
  margin-bottom: 0.3rem; min-height: 32px;
}
.panel-head h2 {
  margin: 0; font-size: 1.1rem; font-weight: 800; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 0.5rem;
}
.panel-head .sub { color: var(--muted); font-size: 0.78rem; font-weight: 500; }
.ph-title { display: flex; align-items: baseline; gap: 0.6rem; margin-right: auto; min-width: 0; overflow: hidden; }
.ph-title h2 { white-space: nowrap; }
.ph-title .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pending-pill, .link-btn, .count { white-space: nowrap; flex: 0 0 auto; }
@media (max-width: 1400px) { .ph-title .sub.opt { display: none; } }
.add-mini {
  flex: 0 0 auto;
  width: 40px; height: 40px; margin: -4px -4px -4px 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 1.5rem; font-weight: 700; line-height: 1;
  cursor: pointer; touch-action: manipulation;
}
.add-mini:active { transform: scale(0.94); }
.panel-adira .add-mini { background: var(--adira-soft); color: var(--p-adira); }
.panel-meals .add-mini { background: var(--ok-soft); color: var(--ok); }
.count {
  min-width: 28px; height: 28px; padding: 0 0.5rem;
  display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--surface-2); color: var(--muted);
  font-size: 0.8rem; font-weight: 700;
}
.count:empty { display: none; }
.link-btn {
  min-height: 40px; padding: 0 0.8rem;
  border: 1.5px solid var(--line-strong); border-radius: 999px;
  background: transparent; color: var(--muted);
  font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.pending-pill {
  padding: 0.15rem 0.6rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  font-size: 0.75rem; font-weight: 700; border: 1.5px dashed var(--line-strong);
}

.panel-today { border-top: 5px solid var(--accent); }
.panel-adira { background: linear-gradient(180deg, var(--adira-soft), var(--surface) 70%); }
.panel-adira h2 { color: var(--p-adira); }
.panel-meals h2 { color: var(--ok); }
.meal-icon { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }

/* ---------- Weather panel ---------- */
.panel-weather { padding-bottom: 0.8rem; }
.wx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
.wx-grid + .wx-grid { margin-top: 0.45rem; }
.wx-tile {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 0.4rem;
  align-items: center;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  min-width: 0;
}
.wx-tile .lbl { grid-column: 1 / -1; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-tile .wx-icon { width: 28px; height: 28px; }
.wx-tile .t { font-size: 1.05rem; font-weight: 800; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: clip; min-width: 0; }
.wx-grid-days .wx-tile .t { font-size: 0.92rem; }
.wx-tile .d { grid-column: 1 / -1; margin-top: 0.1rem; font-size: 0.72rem; color: var(--muted); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-tile .d .c { color: var(--cold); }
.wx-tile .d .p { color: var(--p-bruce); }
.wx-tile .d .w { color: var(--warn); }
.wx-grid-days .wx-tile { background: transparent; border: 1.5px solid var(--line); }

/* ---------- Items ---------- */
.item-list { list-style: none; margin: 0; padding: 0; }
.empty { color: var(--muted); font-size: 0.88rem; padding: 0.5rem 0 0.7rem; }
.empty.locked { display: flex; align-items: center; gap: 0.7rem; color: var(--ink-2); font-weight: 600; }
.empty.locked span { flex: 1 1 auto; min-width: 0; }
.btn-small-lock {
  flex: 0 0 auto; min-height: 44px; padding: 0 1rem;
  border: 0; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 0.9rem; cursor: pointer;
}
#errorLine.tappable { cursor: pointer; }
.item {
  position: relative;
  border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item > .row {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 0.25rem;
}

/* Swipe to complete */
.item.swipeable { overflow: hidden; border-radius: 4px; }
.item.swipeable > .row {
  background: var(--surface);
  touch-action: pan-y;
  -webkit-user-select: none; user-select: none;
  will-change: transform;
}
.swipe-bg {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.1rem;
  background: var(--ok-soft); color: var(--ok);
  font-weight: 800; font-size: 0.95rem;
  opacity: 0; transition: background-color 0.15s, color 0.15s;
}
.item.dragging .swipe-bg { opacity: 1; }
.swipe-bg.armed { background: var(--ok); color: #fff; }
.swipe-label { display: flex; align-items: center; gap: 0.4rem; transition: transform 0.15s; }
.swipe-label svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.swipe-bg .swipe-label:last-child { visibility: hidden; }
.swipe-bg:not(.to-right) .swipe-label:first-child { visibility: hidden; }
.swipe-bg:not(.to-right) .swipe-label:last-child { visibility: visible; }
.swipe-bg.armed .swipe-label { transform: scale(1.12); }
.item.collapsing { transition: height 0.2s ease-in, opacity 0.2s; opacity: 0; border-top-color: transparent; }

/* Rows that can't be ticked off (events, meals, Adira, notes) get a small type icon instead of a circle */
.type-mark { flex: 0 0 var(--tap); height: 54px; display: grid; place-items: center; }
.type-mark svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.type-mark.m-event { color: var(--p-bruce); }
.type-mark.m-meal { color: var(--ok); }
.type-mark.m-adira { color: var(--p-adira); }
.type-mark.m-note { color: #7C5CC4; }
.item.unconfirmed .type-mark { color: var(--faint); }

/* Calendar (read-only) rows */
.cal-mark { flex: 0 0 var(--tap); height: 54px; display: grid; place-items: center; color: var(--p-bruce); }
.cal-mark svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cal-item .item-body { cursor: default; }
.t-cal { color: var(--p-bruce); background: var(--cold-soft); text-transform: none; letter-spacing: 0; font-size: 0.7rem; }
.error-line.warn { background: var(--warn-soft); color: var(--warn); }
.cal-status { display: flex; flex-direction: column; gap: 0.2rem; margin-top: -0.4rem; font-size: 0.8rem; font-weight: 600; }
.cal-status:empty { display: none; }
.cal-status .ok { color: var(--ok); }
.cal-status .bad { color: var(--danger); }
#sCalendars { font-size: 0.85rem; font-family: ui-monospace, Consolas, monospace; }

/* Addie: daily scene in Adira's box, and the play-time wanderer */
.adira-scene {
  flex: 0 0 auto; margin: 0.1rem 0 0.4rem;
  aspect-ratio: 2 / 1; max-height: 190px; width: 100%;
  border-radius: 14px; overflow: hidden; background: var(--adira-soft);
}
.adira-scene:empty { display: none; }
.adira-scene svg { width: 100%; height: 100%; display: block; }
.roamer {
  position: fixed; left: 0; z-index: 25;
  width: 66px; cursor: pointer;
  filter: drop-shadow(0 6px 6px rgba(31, 36, 48, 0.18));
  will-change: transform;
}
.roamer svg { width: 66px; height: 124px; display: block; }
.roamer.flip svg { transform: scaleX(-1); }

.confetti { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

.check {
  flex: 0 0 var(--tap); height: 54px;
  display: grid; place-items: center;
  border: 0; background: none; cursor: pointer; padding: 0;
}
.check .ring {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  display: grid; place-items: center;
  transition: background-color 0.15s, border-color 0.15s;
}
.check .ring svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; fill: none; opacity: 0; stroke-linecap: round; stroke-linejoin: round; }
.item.done .check .ring { background: var(--ok); border-color: var(--ok); }
.item.done .check .ring svg { opacity: 1; }
.check:disabled { opacity: 0.5; }

.item-body {
  flex: 1 1 auto; min-width: 0;
  display: block; text-align: left;
  padding: 0.55rem 0.25rem 0.55rem 0;
  border: 0; background: none; cursor: pointer;
  border-radius: var(--radius-sm);
}
.item-title { font-weight: 700; font-size: 0.98rem; line-height: 1.3; overflow-wrap: anywhere; }
.item.done .item-title { text-decoration: line-through; color: var(--muted); font-weight: 600; }
.item-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.55rem;
  margin-top: 0.2rem; font-size: 0.78rem; color: var(--muted);
}
.item-meta .when { font-weight: 700; color: var(--ink-2); }
.item-meta .soon { color: var(--accent); font-weight: 800; }
.item-meta .overdue { color: var(--danger); font-weight: 800; }
.item-notes {
  margin-top: 0.2rem; font-size: 0.83rem; color: var(--ink-2);
  white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.who { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 600; }

/* Unconfirmed (added by Muse / AI, not yet checked) */
.item.unconfirmed .item-title,
.item.unconfirmed .item-meta .when,
.item.unconfirmed .item-notes { color: var(--faint); }
.item.unconfirmed .check .ring { border-style: dashed; border-color: var(--faint); }
.item.unconfirmed .person-dot { opacity: 0.45; }
.tbc-tag {
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 0.1rem 0.45rem; border-radius: 6px;
  border: 1.5px dashed var(--line-strong); color: var(--muted);
}
.confirm-btn {
  flex: 0 0 auto;
  min-height: 44px; padding: 0 0.7rem; margin-left: 0.1rem;
  border: 1.5px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--ink-2);
  font-size: 0.8rem; font-weight: 800; cursor: pointer;
}
.confirm-btn:active { background: var(--ok-soft); }
.unconfirmed-note {
  padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line-strong); background: var(--surface-2);
  color: var(--ink-2); font-size: 0.88rem; font-weight: 600;
}

.person-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--p-family); flex: 0 0 auto; }
.p-family { background: var(--p-family); }
.p-bruce { background: var(--p-bruce); }
.p-nupuur { background: var(--p-nupuur); }
.p-adira { background: var(--p-adira); }

.type-tag {
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.1rem 0.45rem; border-radius: 6px; background: var(--surface-2); color: var(--muted);
}
.t-event { color: var(--p-bruce); }
.t-meal { color: var(--ok); }
.t-reminder { color: var(--warn); }
.t-adira { color: var(--p-adira); }
.t-note { color: #7C5CC4; }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.day { display: grid; grid-template-columns: 52px 1fr; gap: 0.5rem; padding: 0.45rem 0; border-top: 1px solid var(--line); }
.day:first-child { border-top: 0; }
.day-badge { display: flex; flex-direction: column; align-items: center; padding-top: 0.5rem; }
.day-badge .dow { font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.day-badge .dnum { font-size: 1.5rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.day-badge .rel { font-size: 0.62rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.day .item-list .item:first-child { border-top: 0; }

/* ---------- Buttons ---------- */
.btn {
  min-height: var(--tap); padding: 0 1.2rem;
  border-radius: var(--radius-sm); border: 1.5px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 0.95rem; cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); min-width: 120px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

.chip {
  min-height: 40px; padding: 0 0.9rem;
  border-radius: 999px; border: 1.5px solid var(--line-strong);
  background: var(--surface); font-weight: 600; font-size: 0.85rem; cursor: pointer;
}

/* ---------- Sheets ---------- */
dialog.sheet {
  border: 0; padding: 0;
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border-radius: 24px;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog.sheet-small { width: min(480px, calc(100vw - 32px)); }
dialog.sheet[open] { animation: rise 0.22s ease-out; }
dialog::backdrop { background: rgba(15, 19, 26, 0.45); }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet form, .sheet-body { display: flex; flex-direction: column; gap: 0.9rem; padding: 1.25rem 1.4rem 1.2rem; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sheet-head h2 { margin: 0; font-size: 1.35rem; font-weight: 800; }
.sheet-actions { display: flex; align-items: center; gap: 0.5rem; padding-top: 0.3rem; }
.spacer { flex: 1; }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > span, .field > legend { font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 0; margin-bottom: 0.35rem; }
.field input[type="text"], .field input[type="password"], .field input[type="url"],
.field input[type="date"], .field input[type="time"], .field textarea {
  min-height: var(--tap); width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 1rem;
}
.field textarea { resize: vertical; }
.field input:focus-visible, .field textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: -0.3rem; }

.seg { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: 44px; padding: 0 1rem;
  border-radius: 999px; border: 1.5px solid var(--line-strong);
  font-weight: 600; font-size: 0.9rem; cursor: pointer;
  background: var(--surface);
}
.seg input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.seg-people .person-dot { width: 12px; height: 12px; }

.hint { margin: 0; color: var(--muted); font-size: 0.82rem; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.8rem; z-index: 30;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 0.8rem;
  max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--bg);
  padding: 0.5rem 0.6rem 0.5rem 1.2rem; min-height: 52px; border-radius: 999px;
  font-weight: 600; font-size: 0.95rem;
  box-shadow: var(--shadow-lg);
  animation: rise 0.2s ease-out;
}
.toast-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding-right: 0.6rem; }
.toast-btn {
  flex: 0 0 auto;
  min-height: 44px; padding: 0 1.2rem;
  border: 0; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-weight: 800; font-size: 0.95rem; cursor: pointer;
}

/* ---------- Tablet: fit one screen, scroll inside panels ---------- */
@media (min-width: 900px) and (min-height: 540px) {
  body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  .topbar, .error-line { flex: 0 0 auto; }
  .board { flex: 1 1 auto; min-height: 0; align-items: stretch; grid-template-rows: minmax(0, 1fr); }
  .col { min-height: 0; }
  .panel.scroll { display: flex; flex-direction: column; min-height: 0; flex: 1 1 0; overflow: hidden; }
  .panel-weather { flex: 0 0 auto; }
  /* .panel.x beats the generic .panel.scroll rule above. */
  .panel.panel-upcoming { flex-grow: 1; }
  .panel.panel-adira { flex-grow: 1.3; }
  /* Fixed-height stage that scales with the screen; Addie stays centred and whole. */
  .adira-scene { flex: 0 0 auto; aspect-ratio: auto; height: clamp(110px, 24vh, 170px); max-height: none; }
  .panel-adira .scroll-area { min-height: 70px; }
  .panel.panel-meals { flex-grow: 0.8; }
  .scroll-area {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.5rem; padding: 0 0.5rem 1.2rem;
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
            mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }
}

/* Short tablets (about 600 px tall, e.g. older Galaxy Tabs in landscape): tighten everything
   so Today, Coming up and Adira's list each keep at least a couple of rows. */
@media (min-width: 900px) and (max-height: 720px) {
  .topbar { padding-top: 0.5rem; padding-bottom: 0.2rem; }
  .clock { font-size: 2.4rem; }
  .today-date { font-size: 0.9rem; margin-top: 0.15rem; }
  .wx-addie { width: 74px; height: 74px; border-radius: 18px; }
  .wx-temp { font-size: 2.1rem; }
  .add-btn { height: 46px; }
  .countdowns { padding-top: 0.3rem; }
  .countdown { min-height: 44px; padding-block: 0.25rem; }
  .countdown .days { min-width: 38px; height: 38px; font-size: 0.95rem; }
  .board { gap: 0.7rem; padding-top: 0.5rem; padding-bottom: 0.7rem; }
  .col { gap: 0.7rem; }
  .panel { padding: 0.65rem 0.85rem 0.35rem; }
  .panel-weather { padding-bottom: 0.6rem; }
  .wx-tile { padding: 0.3rem 0.45rem; }
  .wx-tile .d { display: none; }
  .adira-scene { height: 104px; }
  .error-line { padding: 0.5rem 0.8rem; font-size: 0.85rem; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .topbar { gap: 1rem; }
  .sync { display: none; }
  .clock { font-size: 2.8rem; }
  .wx-temp { font-size: 2.4rem; }
  .wx-now-main .wx-icon { width: 46px; height: 46px; }
}
@media (max-width: 899px) {
  .board { grid-template-columns: 1fr 1fr; }
  .col-left { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .panel-weather { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; gap: 0.8rem; padding: 0.9rem 1rem 0.4rem; }
  .wx-header { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .wx-addie { width: 76px; height: 76px; border-radius: 18px; }
  .clock { font-size: 2.5rem; }
  .add-btn span { display: none; }
  .add-btn { width: 52px; padding: 0; justify-content: center; }
  .countdowns, .board { padding-left: 1rem; padding-right: 1rem; }
  .error-line { margin-left: 1rem; margin-right: 1rem; }
  .board, .col-left { grid-template-columns: 1fr; display: grid; }
  .col-left { display: flex; }
  .field-row { grid-template-columns: 1fr; }
  .wx-tile .wx-icon { width: 26px; height: 26px; }
}

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