/* Family Hub — kiosk dashboard styles (approved Step 4 prototype design).
   Single pane, no scrolling in landscape; member colors are per-card accents. */
:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #26221d;
  --muted: #7a7264;
  --line: #e7e0d2;
  --gold: #b45309;
  --ok: #15803d;
  --warn: #b91c1c;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

/* ------------------------------------------------------------- buttons */
.btn {
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 18px;
  min-height: 44px;
  font-weight: 600;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-ghost { background: transparent; }
.btn-big { min-height: 56px; font-size: 20px; width: 100%; }
.btn-done { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-skip { background: transparent; border-color: var(--muted); color: var(--muted); }
.btn-danger { background: #fff; border-color: var(--warn); color: var(--warn); }

/* ------------------------------------------------------------- auth */
.auth-view {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  width: min(430px, 100%);
  box-shadow: 0 8px 30px rgba(90, 70, 20, 0.08);
}
.auth-card h1 { margin: 6px 0 0; font-size: 28px; text-align: center; }
.auth-card h2 { margin: 14px 0 6px; font-size: 21px; }
.auth-logo {
  width: 64px; height: 64px; margin: 0 auto;
  border-radius: 16px; background: var(--gold); color: #fff;
  font-size: 36px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.tagline { text-align: center; color: var(--gold); font-weight: 700; margin: 2px 0 10px; }
.auth-note { color: var(--muted); font-size: 15px; line-height: 1.45; }
.auth-card label, .tm-form label, .admin-form label {
  display: block; font-weight: 600; font-size: 15px; margin: 12px 0 0;
}
.auth-card input, .tm-form input, .tm-form select, .admin-form input, .admin-form select {
  width: 100%; margin-top: 5px; padding: 12px;
  border: 2px solid var(--line); border-radius: 10px; background: #fff;
  min-height: 48px;
}
.auth-card .btn { margin-top: 18px; }
.form-error { color: var(--warn); font-weight: 600; margin: 10px 0 0; }
.form-warn { color: #92400e; font-weight: 600; margin: 10px 0 0; }

/* ------------------------------------------------------------- dashboard frame */
#dash-view {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  gap: 10px;
  overflow: hidden;
}
.topbar {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 16px;
  flex: 0 0 auto;
}
.brand-name { font-size: 24px; font-weight: 800; white-space: nowrap; }
.brand-tag { color: var(--gold); font-weight: 700; font-size: 14px; white-space: nowrap; }
.clockbox { text-align: center; margin-left: auto; }
.clock { font-size: 44px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.dateline { color: var(--muted); font-weight: 600; font-size: 15px; }
.weather-chip {
  font-size: 17px; font-weight: 700; background: #fdf3e3;
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px;
  white-space: nowrap; display: flex; align-items: center; gap: 10px;
}
/* Weather symbol at 2.5× the chip text (Johanes, 2026-11-19). */
.wx-icon { font-size: 2.5em; line-height: 1; }
.scorebox { display: flex; align-items: center; gap: 8px; position: relative; }
.score-ring { width: 72px; height: 72px; transform: rotate(-90deg); }
.score-ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: #eee4d3; }
.ring-fg { stroke: var(--gold); stroke-linecap: round; stroke-dasharray: 188.5; stroke-dashoffset: 188.5; transition: stroke-dashoffset 0.6s ease; }
.score-pct { font-size: 24px; font-weight: 800; line-height: 1; }
.score-label { font-size: 11px; color: var(--muted); font-weight: 700; line-height: 1.1; }
.score-bar { position: absolute; left: 0; right: 0; bottom: -6px; height: 4px; background: #eee4d3; border-radius: 2px; overflow: hidden; }
#score-bar-fill { height: 100%; width: 0%; background: var(--gold); transition: width 0.6s ease; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-chip { font-weight: 700; color: var(--muted); }
.version-tag { font-size: 11px; color: #fff; background: #a8a094; border-radius: 6px; padding: 2px 6px; font-weight: 700; }
.vacation-banner {
  background: #fef3c7; border: 1px solid #f59e0b; color: #92400e;
  border-radius: 12px; padding: 8px 14px; font-weight: 700; text-align: center;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------- member cards */
.cards {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 1fr 1fr;
  gap: 10px;
}
.mcard {
  /* Johanes (2026-11-18): each pane carries its member's theme color as a
     light background tint — the theme color at 10% over white. */
  background: color-mix(in srgb, var(--mc, var(--gold)) 10%, #fff);
  border: 1px solid var(--line);
  border-top: 5px solid var(--mc, var(--gold));
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.mcard-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--mc); color: #fff;
  font-size: 24px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.mcard-name { font-size: 27px; font-weight: 800; line-height: 1.05; }
.mcard-role { color: var(--muted); font-size: 13px; font-weight: 700; }
.mcard-points { margin-left: auto; font-size: 17px; font-weight: 800; white-space: nowrap; }
.tasks-btn { min-height: 24px; padding: 6px 12px; font-size: 15px; }
.acts { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: hidden; }
.free-note { color: var(--muted); font-size: 17px; padding: 8px 2px; }

.act {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 7px 10px;
  display: flex; flex-direction: column; gap: 2px;
  background: #fff;
}
.act-top { display: flex; align-items: baseline; gap: 8px; }
.act-name { font-size: 19px; font-weight: 700; }
.act-time { font-size: 16px; font-weight: 700; color: var(--muted); white-space: nowrap; margin-left: auto; }
.act-time-compact { display: none; }
.act-sub { font-size: 13.5px; color: var(--muted); }
.act-btns { display: flex; gap: 6px; margin-top: 4px; }
.act-btns .btn { flex: 1; min-height: 26px; padding: 6px 8px; font-size: 16px; }
.chip-status {
  font-size: 12px; font-weight: 800; border-radius: 999px; padding: 2px 8px;
  background: #f1ead9; color: #6b6252; white-space: nowrap;
}
.chip-status.done { background: #dcfce7; color: var(--ok); }
.chip-status.overdue { background: #fee2e2; color: var(--warn); }
.chip-status.now { background: var(--mc, var(--gold)); color: #fff; }
.act.is-done { opacity: 0.72; }
.act.is-skipped { opacity: 0.55; background: #f7f4ee; }
.act.is-skipped .act-name { text-decoration: line-through; }

/* spotlight: the current (or next) activity stands out */
.act.spotlight {
  border: 3px solid var(--mc, var(--gold));
  /* stronger tint than the card's 10% so the spotlight still stands out
     against the tinted card background */
  background: color-mix(in srgb, var(--mc, var(--gold)) 24%, #fff);
  padding: 10px 12px;
}
.act.spotlight .act-name { font-size: 24px; }
.act.spotlight .act-time { font-size: 20px; color: var(--ink); }
.act.spotlight .act-btns .btn { min-height: 31px; font-size: 18px; }
/* compact siblings while a spotlight is active in the card */
.acts.has-spotlight .act:not(.spotlight) {
  flex-direction: row; align-items: center; padding: 4px 10px;
}
.acts.has-spotlight .act:not(.spotlight) .act-sub { display: none; }
.acts.has-spotlight .act:not(.spotlight) .act-name { font-size: 16.5px; }
.acts.has-spotlight .act:not(.spotlight) .act-btns { margin: 0 0 0 auto; }
.acts.has-spotlight .act:not(.spotlight) .act-btns .btn { min-height: 22px; flex: 0 0 auto; padding: 4px 12px; font-size: 14.5px; }

/* ------------------------------------------------------------- bottom strip */
.bottom-strip {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1.15fr 1fr 0.95fr 1.4fr;
  gap: 10px;
}
.strip-panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 14px; min-height: 0;
}
.strip-panel h3 { margin: 0 0 4px; font-size: 15px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.04em; }
.strip-list { list-style: none; margin: 0; padding: 0; font-size: 16px; font-weight: 600; }
.strip-list li { padding: 1.5px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip-list .when { color: var(--muted); font-weight: 700; margin-right: 6px; }
.strip-note { color: var(--muted); font-size: 14px; margin: 2px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: #fdf3e3; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13.5px; font-weight: 700; }
.briefing-text { font-size: 14.5px; line-height: 1.4; margin: 0 0 6px; max-height: 5.6em; overflow: hidden; }
/* The briefing's playback engine is a native <audio> element kept
   invisible; the visible control is the regular button, whose tap calls
   play()/pause() on it directly. (Native playback is what finally
   worked on the phone — see the briefing README.) */
.audio-engine { display: block; width: 100%; height: 40px; margin-top: 6px; }
.briefing-panel .btn { min-height: 44px; }

/* ------------------------------------------------------------- overlays */
.overlay {
  position: fixed; inset: 0; background: rgba(38, 32, 20, 0.45);
  display: flex; align-items: stretch; justify-content: center;
  padding: 18px; z-index: 40;
}
.sheet {
  background: var(--bg); border-radius: 20px; width: min(880px, 100%);
  padding: 18px 22px; overflow-y: auto;
}
/* Hermanto Center kiosk mode: a narrow sheet for the exit gate.
   (Tasks buttons DO show in Center — each asks for that member's PIN.) */
.center-exit-sheet { width: min(430px, 100%); align-self: center; }
/* Member photos (Admin-assigned): an <img> avatar fills the circle. */
.avatar-img { object-fit: cover; background: #fff; }
.avatar-btn { background: none; border: none; padding: 0; cursor: pointer; border-radius: 50%; flex: none; }
.avatar-btn .avatar { display: block; }
.photo-actions { flex-direction: column; align-items: stretch; margin: 10px 0 0; }
.u-name { font-size: 19px; }
#rem-list .rem-label, #rem-new-label { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
/* One-row admin lists: last control sits at the far right. */
.push-right { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
#rem-new-name { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; flex: 1; min-width: 140px; }
.center-exit-sheet .sheet-actions { margin: 14px 0 0; }

.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head h2 { margin: 0; font-size: 28px; }
.sheet-actions { margin-left: auto; display: flex; gap: 8px; }
.empty-note { color: var(--muted); font-size: 19px; padding: 22px 4px; }
.tm-list { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tm-row {
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 10px 14px; display: flex; align-items: center; gap: 12px;
}
.tm-main { flex: 1; min-width: 0; }
.tm-name { font-size: 20px; font-weight: 700; }
.tm-meta { color: var(--muted); font-size: 15px; font-weight: 600; }
.tm-row .btn { min-height: 48px; }
.tm-confirm { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--warn); }
.tm-form { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-top: 12px; }
.tm-form h3 { margin: 0 0 4px; font-size: 22px; }
.seg { display: flex; gap: 8px; margin-top: 14px; }
.seg-btn { flex: 1; min-height: 50px; border: 2px solid var(--line); background: #fff; border-radius: 12px; font-weight: 700; font-size: 17px; }
.seg-on { background: var(--gold); border-color: var(--gold); color: #fff; }
.time-row { display: flex; gap: 12px; }
.time-row label { flex: 1; }
.day-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.day-chip { min-width: 56px; min-height: 48px; border: 2px solid var(--line); background: #fff; border-radius: 12px; font-weight: 700; }
.day-chip.on { background: var(--gold); border-color: var(--gold); color: #fff; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.form-actions .btn { flex: 1; }

/* ------------------------------------------------------------- admin */
#admin-view { min-height: 100dvh; padding: 10px 14px; display: flex; flex-direction: column; gap: 12px; }
.pin-card { margin: 24px auto; }
.admin-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.admin-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.admin-panel h2 { margin: 0 0 8px; font-size: 23px; }
.admin-panel h3 { margin: 16px 0 2px; font-size: 18px; }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 17px; font-weight: 600; }
.admin-list .u-role { color: var(--muted); font-size: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.check-row { display: flex !important; align-items: center; gap: 10px; font-size: 17px; }
.check-row input { width: 26px; height: 26px; }
.admin-form .btn { margin-top: 14px; min-height: 50px; }
.chime-list, .member-list { list-style: none; margin: 0; padding: 0; }
.chime-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.chime-pick { display: flex !important; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; cursor: pointer; }
.chime-pick input { width: 26px; height: 26px; }
.chime-row .btn { min-height: 48px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.member-avatar { flex: none; }
.member-name-input {
  flex: 1; min-width: 0; padding: 12px;
  border: 2px solid var(--line); border-radius: 10px; background: #fff;
  min-height: 48px;
}
.member-row .btn { min-height: 48px; }

/* ------------------------------------------------------------- short screens */
@media (max-height: 950px) {
  .clock { font-size: 36px; }
  .brand-name { font-size: 21px; }
  .score-ring { width: 60px; height: 60px; }
  .mcard-name { font-size: 23px; }
  .avatar { width: 38px; height: 38px; font-size: 20px; }
  .act-name { font-size: 17px; }
  .act.spotlight .act-name { font-size: 21px; }
  .act-btns .btn { min-height: 24px; }
  .briefing-text { max-height: 4.2em; }
}

/* ------------------------------------------------------------- portrait / phones */
@media (max-aspect-ratio: 1/1) {
  #dash-view { height: auto; overflow: visible; }
  .topbar { flex-wrap: wrap; }
  .clockbox { margin-left: 0; }
  .cards { grid-template-columns: 1fr; grid-template-rows: none; }
  .mcard { overflow: visible; }
  .bottom-strip { grid-template-columns: 1fr; }
  .admin-body { grid-template-columns: 1fr; }
  .time-row { flex-direction: column; gap: 0; }
}

/* ------------------------------------------------------------- phone portrait (Johanes, 2026-11-18)
   The phone version of the dashboard: portrait, ONE screen, NO scrolling —
   the same single-pane idea as the Surface, condensed for a narrow screen.
   Applies only to phones (<=520px wide, portrait); the landscape rules above
   are untouched, and wider portrait screens keep the stacking layout above.
   Condensations vs landscape:
   - Top bar: brand block hidden; clock + Family Score ring + Admin/Sign out
     on one row, weather chip on its own full-width row under them.
   - Member cards: 2x3 grid; each card shows its current/next (spotlight)
     activity with Start/Done. A card with no spotlight (everything done or
     past) shows its first activity instead. Other activities are not listed
     on the phone dashboard (they remain on the Surface view / Task Manager),
     and the activity's points/note sub-line is not shown on phone.
   - Bottom strip: one-line panels — Up Next (first 2), Birthdays (first 2),
     Saturday Ideas as a single line (chips hidden), Briefing collapsed to
     its Play button (panel hidden entirely when no briefing audio exists). */
@media (max-width: 520px) and (orientation: portrait) {
  #dash-view {
    height: 100dvh;
    overflow: hidden;
    padding: 7px 8px;
    padding-bottom: max(7px, env(safe-area-inset-bottom));
    gap: 5px;
  }

  /* --- top bar --- */
  .topbar { flex-wrap: wrap; gap: 4px 8px; padding: 8px 10px; border-radius: 12px; }
  .brand { display: none; }
  .clockbox { margin-left: 0; text-align: left; }
  .clock { font-size: 22px; }
  .dateline { display: none; }
  .scorebox { gap: 6px; }
  .score-ring { width: 42px; height: 42px; }
  .score-pct { font-size: 17px; }
  .score-label { display: none; }
  .score-bar { display: none; }
  .top-actions { margin-left: auto; gap: 6px; }
  .user-chip { display: none; }
  /* the build tag stays visible on phone (tiny) so a screenshot always
     shows which version the phone is actually running */
  .version-tag { font-size: 9px; padding: 1px 4px; }
  .top-actions .btn { min-height: 34px; padding: 5px 7px; font-size: 12px; border-radius: 10px; }
  .weather-chip {
    order: 5; flex: 1 1 100%;
    font-size: 10.5px; letter-spacing: -0.3px;
    padding: 4px 10px; text-align: center;
    overflow: hidden; text-overflow: ellipsis;
  }
  .vacation-banner { padding: 6px 10px; font-size: 13.5px; border-radius: 10px; }

  /* --- member cards: 2 x 3, spotlight activity only --- */
  .cards {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
  }
  .mcard { padding: 5px 7px; border-radius: 12px; border-top-width: 4px; overflow: hidden; }
  /* Phone panes are name-only (Johanes, 2026-11-19): the day's tasks
     live in the press-and-hold popup, so nothing in a pane can clip.
     Long-press must not select text or open a callout menu. */
  .mcard .acts, .mcard .free-note, .mcard .fam-ideas { display: none; }
  .mcard { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
  .mcard-head {
    display: grid;
    grid-template-areas: "avatar name tasks" "avatar points tasks";
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 7px; row-gap: 0;
    margin-bottom: 4px;
  }
  .mcard-head .avatar { grid-area: avatar; width: 30px; height: 30px; font-size: 16px; }
  .mcard-head > div:nth-child(2) { grid-area: name; min-width: 0; }
  .mcard-name { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mcard-role { display: none; }
  .mcard-points { grid-area: points; margin-left: 0; font-size: 11.5px; }
  .tasks-btn { grid-area: tasks; min-height: 20px; padding: 4px 7px; font-size: 12px; border-radius: 10px; }

  .free-note { font-size: 13px; padding: 4px 2px; }
  .acts { gap: 0; }
  .acts .act { display: none; }
  .acts .act.spotlight,
  .acts:not(:has(.spotlight)) .act:first-child { display: flex; }
  /* The phone DOM only contains ongoing activities (renderCards filters by
     device class), so every rendered act is shown — including a started
     task whose window has passed, which carries no spotlight class. */
  body[data-device="phone"] .acts .act { display: flex; }
  /* Phone view: no future tasks anywhere on the dashboard (Johanes) — the
     Up Next panel is hidden; Birthdays takes the first strip cell. */
  .strip-panel:has(#up-next) { display: none; }
  .act { padding: 5px 6px; border-radius: 10px; gap: 2px; }
  .act-top { flex-wrap: wrap; gap: 2px 6px; }
  /* Name may wrap to two lines at most (clamped) — the card's vertical
     budget is planned for exactly two lines, so a long name like
     "Devotion with Herry" can never push the buttons out of the card. */
  .act-name {
    font-size: 16.5px; line-height: 1.08; flex: 1 1 100%;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .chip-status { font-size: 10.5px; padding: 1px 6px; flex: 0 0 auto; }
  /* Status chip and time share ONE row under the name (they used to wrap
     onto two rows and overflow the card); phones show the compact range
     ("7:00–7:15 AM") so the row fits, and the time still shrinks with an
     ellipsis on the narrowest screens rather than wrapping. */
  .act-time { font-size: 11.5px; letter-spacing: -0.2px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .act-time-full { display: none; }
  .act-time-compact { display: inline; }
  /* the points/note sub-line is landscape-only; the phone card keeps the
     name, status + time and the Start/Done buttons */
  .act-sub { display: none; }
  .act-btns { gap: 5px; margin-top: 2px; }
  /* slimmer buttons on phone (Johanes): the whole pane outline, buttons
     included, must stay visible inside the card */
  .act-btns .btn { min-height: 22px; padding: 4px 6px; font-size: 14px; border-radius: 10px; }
  .act.spotlight { border-width: 2.5px; padding: 5px 6px; }
  .act.spotlight .act-name { font-size: 16.5px; }
  .act.spotlight .act-time { font-size: 12.5px; color: var(--muted); }
  .act.spotlight .act-btns .btn { min-height: 22px; font-size: 14px; }

  /* --- bottom strip: Up Next + Birthdays side by side (this two-column
     grid used to apply only on short phones; making it the layout at every
     portrait height frees ~50px of vertical room for the member cards,
     which is what finally keeps a two-line activity name + buttons inside
     its card on tall phones too) --- */
  .bottom-strip { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px; }
  .strip-panel {
    padding: 4px 10px; border-radius: 10px; min-height: 24px; min-width: 0;
    display: flex; align-items: center; gap: 8px;
  }
  .strip-panel:nth-child(-n+2) { flex-direction: column; align-items: stretch; gap: 1px; padding: 3px 8px; }
  .strip-panel:nth-child(-n+2) .strip-list { flex-direction: column; gap: 1px; font-size: 12px; line-height: 1.25; width: 100%; }
  .strip-panel:nth-child(-n+2) h3 { text-align: center; }
  #saturday-panel, .briefing-panel { grid-column: 1 / -1; }
  .strip-panel h3 { margin: 0; font-size: 10.5px; flex: 0 0 auto; }
  .strip-list { display: flex; gap: 4px 12px; font-size: 12.5px; overflow: hidden; flex: 1; min-width: 0; }
  .strip-list li { padding: 0; min-width: 0; }
  .strip-list li:nth-child(n+3) { display: none; }
  .strip-note { margin: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .strip-panel .chips { display: none; }
  .briefing-panel .strip-note { display: none; }
  /* The briefing must not look blank on the phone (Johanes): its text
     shows under the title row, clamped to three lines; Play stays on the
     title row. */
  .briefing-panel { flex-wrap: wrap; }
  .briefing-panel .btn { order: 1; }
  .briefing-panel .briefing-text {
    order: 2; flex: 1 1 100%;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
    overflow: hidden; font-size: 12.5px; line-height: 1.35; margin: 2px 0 0;
    max-height: none;
  }
  .briefing-panel:has(#briefing-audio.hidden) { display: none; }
  .briefing-panel .btn { min-height: 36px; padding: 4px 14px; font-size: 14px; flex: 1; }

  /* --- overlays on small screens (sheet may scroll internally) --- */
  .overlay { padding: 8px; }
  .sheet { padding: 14px; border-radius: 14px; }
}

/* Taller phones (e.g. Galaxy S25 Ultra, 412x915) get slightly larger type —
   only where the extra height exists; the fit rules above still govern. */
@media (max-width: 520px) and (orientation: portrait) and (min-height: 880px) {
  .clock { font-size: 26px; }
  .score-ring { width: 48px; height: 48px; }
  .mcard-head .avatar { width: 32px; height: 32px; font-size: 17px; }
  .mcard-name { font-size: 16.5px; }
  .act-name, .act.spotlight .act-name { font-size: 18px; }
  .act-btns .btn, .act.spotlight .act-btns .btn { min-height: 24px; }
  .strip-list, .strip-note { font-size: 13px; }
}

/* Shorter phones (e.g. 360x800): the bottom strip folds into two columns —
   Up Next and Birthdays side by side with their heading stacked above the
   items, Saturday Ideas and the Briefing full-width below — and the card
   metrics tighten slightly, so a two-line activity name still fits. */
@media (max-width: 520px) and (orientation: portrait) and (max-height: 860px) {
  /* (the two-column strip grid + column-panel rules now live in the base
     portrait block above — they apply at every portrait height) */
  .strip-panel h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; max-width: 100%; }
  .strip-panel { min-height: 26px; }
  .briefing-panel { padding: 3px 10px; }
  #dash-view { gap: 5px; }
  .topbar { padding: 6px 10px; }
  .mcard { padding: 5px 8px; }
  .mcard-head { margin-bottom: 1px; }
  .act, .act.spotlight { padding: 4px 8px; }
  .act { gap: 1px; }
  .act-btns { margin-top: 0; }
  .act-name, .act.spotlight .act-name { line-height: 1.05; letter-spacing: -0.2px; }
  .act-btns .btn, .act.spotlight .act-btns .btn { min-height: 22px; }
}

/* Narrowest phones: shrink the weather chip a touch so even the longest
   condition label ("Thunderstorms ... Diamond Bar, CA") fits unclipped,
   and slim the card head so every member name fits without truncating. */
@media (max-width: 380px) and (orientation: portrait) {
  .weather-chip { font-size: 10px; }
  .mcard-head { column-gap: 5px; }
  .mcard-name { letter-spacing: -0.2px; }
  .tasks-btn { padding: 5px 6px; font-size: 12px; }
}

/* Phone split view (Johanes, 2026-11-19): when you're signed in on a
   phone, YOUR pane takes the top half of the members area — current
   task big, bold, readable from far, with your whole day listed below
   it — and the other five panes share the bottom half at equal size.
   The .others wrapper only exists in this layout; everywhere else it
   is display:contents and the layout never notices it. */
.others { display: contents; }
@media (max-width: 520px) and (orientation: portrait) {
  #cards { display: flex; flex-direction: column; }
  /* The other panes are compact name bars (Johanes, 2026-11-19: about
     a quarter of their former height), and the signed-in pane takes
     ALL the space they free up, showing the member's whole day with
     the current task bold and standing out. */
  .mcard.mine, body.userview .mcard.mine { flex: 1 1 auto; max-height: none; min-height: 0; display: flex; flex-direction: column; }
  .others, body.userview .others { flex: 0 0 auto; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: min-content; gap: 6px; }
  .mcard.mine .acts { display: flex; }
  .mcard.mine .free-note { display: block; }
  .others .mcard { min-height: 0; }
  .mcard.mine .acts { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
  .mcard.mine .act.spotlight .act-name { font-size: 26px; font-weight: 800; line-height: 1.15; }
  .mcard.mine .act.spotlight .act-time { font-size: 15px; }
  .mcard.mine .act.spotlight .chip-status { font-size: 13px; }
  /* The other panes get compact type (Johanes, 2026-11-19) so each
     small pane fits its header and current activity without clipping. */
  .others .mcard { padding: 4px 6px; }
  .others .mcard-head .avatar { width: 26px; height: 26px; font-size: 14px; }
  .others .mcard-name { font-size: 14px; }
  .others .mcard-points { font-size: 10.5px; }
  .others .act { padding: 4px 5px; }
  .others .act-name, .others .act.spotlight .act-name { font-size: 13.5px; line-height: 1.1; }
  .others .act-time, .others .act.spotlight .act-time { font-size: 10.5px; }
  .others .chip-status { font-size: 9.5px; padding: 1px 5px; }
}

/* User (non-admin) view (Johanes, 2026-11-19): the split layout applies
   on EVERY screen for a signed-in member — own pane top half, the other
   members sharing the bottom half — with full-day lists in every pane.
   (The portrait block above gives admins the same split on phones;
   these rules extend it to all screens for the read-only user view.) */
body.userview #cards { display: flex; flex-direction: column; }
body.userview .mcard.mine { flex: 0 1 auto; max-height: 62%; min-height: 0; display: flex; flex-direction: column; }
body.userview .mcard.mine .acts { flex: 1 1 auto; }
/* Members don't need the briefing text (Johanes, 2026-11-19) — just
   the player. Admins keep the text. (!important: the portrait strip
   styles the text with a -webkit-box clamp that must never win.) */
body.userview .briefing-panel .briefing-text { display: none !important; }
body.userview .others { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, 1fr); gap: 8px; }
body.userview .others .mcard { min-height: 0; }
body.userview .mcard .acts { overflow-y: auto; min-height: 0; }
body.userview .mcard.mine .act.spotlight .act-name { font-size: 26px; font-weight: 800; line-height: 1.15; }
/* The Birthdays pane as the sixth cell of the others grid, beside the
   Family pane (Johanes, 2026-11-19) — it renders as a card there
   instead of a strip panel. The others grid is two columns at every
   size, so the six cells (5 members + Birthdays) always fill evenly. */
.others #birthdays-panel {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 6px 8px; overflow: hidden; min-height: 0;
  display: flex; flex-direction: column; align-items: stretch; gap: 2px;
}
.others #birthdays-panel h3 { font-size: 10.5px; }
.others #birthdays-panel .strip-list { flex-direction: column; gap: 1px; font-size: 12px; line-height: 1.3; overflow: hidden; }
/* Phone overrides for the user view (must follow the base user-view
   rules above to win): the signed-in pane fills the freed space and
   the other panes shrink to name bars. */
@media (max-width: 520px) and (orientation: portrait) {
  body.userview .mcard.mine { flex: 1 1 auto; max-height: none; }
  body.userview .others { flex: 0 0 auto; grid-template-rows: none; grid-auto-rows: min-content; }
}

/* Press-and-hold pane popup (phone; Johanes, 2026-11-19) */
.pane-popup {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 430px); max-height: 78vh; overflow-y: auto;
  background: #fff; border-radius: 18px; border-top: 6px solid var(--mc, #2563eb);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35); padding: 14px 16px; z-index: 60;
}
.pane-popup.hidden { display: none; }
.pp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.pp-head .avatar { width: 36px; height: 36px; font-size: 19px; }
.pp-title { font-size: 20px; font-weight: 800; }
.pp-sec h4 { margin: 10px 0 4px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pp-row { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 5px; flex-wrap: wrap; }
.pp-name { font-weight: 700; font-size: 16px; }
.pp-time { margin-left: auto; font-size: 13.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.pp-past { opacity: .62; }
.pp-none { color: var(--muted); font-weight: 600; margin: 6px 0; }

/* Saturday ideas (2026-11-19): three weekly ideas with a slide toggle
   that adds them to the Family pane, arranged into 9 AM–9 PM. */
#saturday-panel { flex-wrap: wrap; }
.saturday-ideas { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; flex: 1 1 100%; }
.idea-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 7px 9px; text-align: left; }
.idea-row.picked { border-color: var(--accent); background: #fff7ea; }
.idea-main { flex: 1; min-width: 0; }
.idea-title { font-weight: 800; font-size: 14.5px; }
.idea-meta { font-size: 12px; color: var(--muted); font-weight: 600; }
.idea-detail { font-size: 12.5px; }
/* Slide switch (Johanes, 2026-11-19): knob slides RIGHT = on (idea is on
   the Family pane), slides LEFT = off (removed). */
.idea-toggle { display: inline-flex; align-items: center; gap: 8px; background: none; border: none; padding: 2px; font: inherit; font-weight: 800; font-size: 13px; color: var(--ink); cursor: pointer; flex: 0 0 auto; }
.idea-toggle .track { position: relative; width: 46px; height: 26px; border-radius: 999px; background: #ddd5c4; border: 1.5px solid var(--line); transition: background .18s ease, border-color .18s ease; flex: 0 0 auto; }
.idea-toggle .knob { position: absolute; top: 50%; left: 2px; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 1px solid var(--line); transition: left .18s ease; }
.idea-toggle.on .track { background: var(--accent); border-color: var(--accent); }
.idea-toggle.on .knob { left: calc(100% - 22px); }
.idea-toggle:disabled { opacity: .55; }

/* Picked ideas preview inside the Family pane (Johanes, 2026-11-19):
   shown right away under a day header, dashed so they read as plans,
   not as today's activities. */
.fam-ideas { margin-top: 8px; border-top: 1.5px dashed var(--line); padding-top: 6px; }
.fam-ideas-head { font-size: 13px; font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.act.idea-act { border-style: dashed; background: #fffdf6; }
.act.idea-act .act-name { font-size: 16.5px; }

/* Wide screens (Johanes, 2026-11-19): bottom strip in TWO columns — left
   column stacks Up Next / Birthdays / Briefing at natural height, right
   column is Saturday Ideas — kept as short as possible so the member
   panes get the rest of the screen. Panels scroll internally if the
   strip reaches its height cap. */
@media (min-width: 700px) {
  .bottom-strip {
    /* Left column hugs its content (Johanes, 2026-11-19: shrink as tight
       as possible); the right column takes everything else so the
       Saturday idea text wraps less and the strip gets shorter. */
    grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
    grid-template-rows: minmax(0, auto) minmax(0, auto) minmax(0, 1fr);
    grid-template-areas:
      "up sat"
      "bday sat"
      "brief sat";
    max-height: 46%;
  }
  .bottom-strip .strip-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
  .bottom-strip .strip-panel:has(#up-next) { grid-area: up; }
  .bottom-strip #birthdays-panel { grid-area: bday; }
  .bottom-strip #saturday-panel { grid-area: sat; }
  .bottom-strip .briefing-panel { grid-area: brief; }
  .bottom-strip .strip-list { overflow-y: auto; min-height: 0; }
  .bottom-strip .saturday-ideas { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
  .bottom-strip .briefing-text { overflow-y: auto; min-height: 0; max-height: none; }
  .bottom-strip .audio-engine { flex: 0 0 auto; }

  /* Member panes (Johanes, 2026-11-19): rows auto-size to their content
     so a busy pane gets the room it needs and a quiet pane doesn't waste
     it; leftover height is shared between the rows. */
  .cards { grid-template-rows: minmax(min-content, 1fr) minmax(min-content, 1fr); }

  /* Auto-fit levels — fitCards() in app.js sets data-fit when the panes
     would overflow the screen: fonts, paddings, and buttons step down
     until everything fits. Level 3 also lets a pane's list scroll
     internally as a last resort, so nothing is ever cut off. */
  #cards[data-fit="1"] .acts { gap: 4px; }
  #cards[data-fit="1"] .act { padding: 5px 8px; }
  #cards[data-fit="1"] .act-name { font-size: 17px; }
  #cards[data-fit="1"] .act-time { font-size: 14px; }
  #cards[data-fit="1"] .act-sub { font-size: 12.5px; }
  #cards[data-fit="1"] .act-btns .btn { min-height: 22px; padding: 4px 6px; font-size: 14.5px; }
  #cards[data-fit="1"] .act.spotlight { padding: 8px 10px; }
  #cards[data-fit="1"] .act.spotlight .act-name { font-size: 21px; }
  #cards[data-fit="1"] .act.spotlight .act-time { font-size: 17px; }
  #cards[data-fit="1"] .mcard { padding: 8px 10px; }
  #cards[data-fit="1"] .mcard-name { font-size: 24px; }
  #cards[data-fit="1"] .avatar { width: 40px; height: 40px; font-size: 21px; }

  #cards[data-fit="2"] .acts { gap: 3px; }
  #cards[data-fit="2"] .act { padding: 4px 7px; }
  #cards[data-fit="2"] .act-name { font-size: 15.5px; }
  #cards[data-fit="2"] .act-time { font-size: 13px; }
  #cards[data-fit="2"] .act-sub { font-size: 11.5px; }
  #cards[data-fit="2"] .act-btns .btn { min-height: 20px; padding: 3px 5px; font-size: 13.5px; }
  #cards[data-fit="2"] .act.spotlight { padding: 7px 9px; }
  #cards[data-fit="2"] .act.spotlight .act-name { font-size: 19px; }
  #cards[data-fit="2"] .act.spotlight .act-time { font-size: 15px; }
  #cards[data-fit="2"] .mcard { padding: 7px 9px; }
  #cards[data-fit="2"] .mcard-name { font-size: 22px; }
  #cards[data-fit="2"] .avatar { width: 36px; height: 36px; font-size: 19px; }
  #cards[data-fit="2"] .chip-status { font-size: 11px; padding: 1px 6px; }

  #cards[data-fit="3"] .acts { gap: 2px; overflow-y: auto; }
  #cards[data-fit="3"] .act { padding: 3px 6px; }
  #cards[data-fit="3"] .act-name { font-size: 14.5px; }
  #cards[data-fit="3"] .act-time { font-size: 12.5px; }
  #cards[data-fit="3"] .act-sub { font-size: 11px; }
  #cards[data-fit="3"] .act-btns .btn { min-height: 18px; padding: 2px 4px; font-size: 12.5px; }
  #cards[data-fit="3"] .act.spotlight { padding: 6px 8px; }
  #cards[data-fit="3"] .act.spotlight .act-name { font-size: 17px; }
  #cards[data-fit="3"] .act.spotlight .act-time { font-size: 14px; }
  #cards[data-fit="3"] .mcard { padding: 6px 8px; }
  #cards[data-fit="3"] .mcard-head { margin-bottom: 3px; }
  #cards[data-fit="3"] .mcard-name { font-size: 20px; }
  #cards[data-fit="3"] .avatar { width: 32px; height: 32px; font-size: 17px; }
  #cards[data-fit="3"] .chip-status { font-size: 10.5px; padding: 1px 5px; }
}

/* Yearly reminders (Admin, 2026-11-19) */
.rem-icon { font-size: 19px; }
#rem-list select, #rem-form select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

/* Admin "User" section + weekend idea categories (2026-11-19) */
.user-main { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.user-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-line .member-name-input { flex: 1; min-width: 140px; }
.user-pass-input { flex: 1; min-width: 180px; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 15px; }
.user-role-sel { padding: 9px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 15px; background: #fff; }
.btn-danger { background: #c0392b; border-color: #c0392b; color: #fff; }
.btn-danger-ghost { background: transparent; border-color: #c0392b; color: #c0392b; }
.u-confirm { font-size: 14px; color: #c0392b; display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cat-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 14px; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 8px 6px 14px; font-size: 14.5px; }
.cat-x { border: none; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; padding: 2px 6px; }

/* Johanes, 2026-11-19: the dashboard shows NO morning briefing text —
   just the audio control. */
.briefing-text { display: none !important; }
