:root {
  --bg: #0a0a0c;
  --panel: rgba(255,255,255,0.035);
  --panel-hi: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.08);
  --border-hi: rgba(255,255,255,0.16);
  --text: #f2efe9;
  --text-dim: rgba(242,239,233,0.55);
  --text-faint: rgba(242,239,233,0.32);
  --accent: #c9a468;
  --accent-hi: #e0c08a;
  --accent-glow: rgba(201,164,104,0.22);
  --good: #7fbf9e;
  --bad: #d98b7a;
  --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  /* Homie-style four-corner "bloom" wash — same layering as its applyThemeBg(), tinted to
   * our own gold accent instead of the live per-user theme colour it computes there. */
  background-image:
    radial-gradient(ellipse 60% 25% at 50% 0%, rgba(0,0,0,0.5) 0%, transparent 100%),
    radial-gradient(ellipse 80% 80% at 100% 0%, rgba(224,192,138,0.14) 0%, transparent 70%),
    radial-gradient(ellipse 80% 80% at 0% 100%, rgba(201,164,104,0.10) 0%, transparent 80%),
    radial-gradient(ellipse 80% 80% at 100% 100%, rgba(201,164,104,0.14) 0%, transparent 80%),
    radial-gradient(ellipse 100% 90% at 0% 0%, rgba(201,164,104,0.20) 0%, transparent 65%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Montserrat', sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── paged layout + bottom dock ── */
.pages {
  position: relative;
  flex: 1;
  min-height: 0;
}
.page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 0 1.6rem calc(6rem + env(safe-area-inset-bottom));
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.page.active { opacity: 1; transform: translateY(0); pointer-events: auto; }
.page-inner { max-width: 1180px; margin: 0 auto; }

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  gap: 4px;
  padding: 7px;
  border-radius: 22px;
  background: rgba(12,12,14,0.72);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  max-width: calc(100vw - 20px);
  overflow-x: auto;
  scrollbar-width: none;
}
.dock::-webkit-scrollbar { display: none; }
.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px 7px;
  border-radius: 15px;
  border: none;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  transition: all 0.2s;
}
.dock-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.dock-btn span { font-size: 8.5px; letter-spacing: 0.14em; text-transform: uppercase; }
.dock-btn:hover { color: var(--text-dim); }
.dock-btn.active { color: var(--accent-hi); background: rgba(201,164,104,0.14); }

/* ── header (slim utility bar — the clock lives on the Home page hero instead) ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
  padding: 1.2rem 1.6rem;
}
.header.header-end { justify-content: flex-end; }
.header .brand {
  font-size: 11px;
  letter-spacing: 0.35em;
  color: var(--accent);
  text-transform: uppercase;
}
.header-right { display: flex; align-items: center; gap: 14px; }
.header-status { display: flex; align-items: center; white-space: nowrap; }

/* ── home hero (big centered clock) ── */
.home-inner { display: flex; flex-direction: column; min-height: 100%; }
.home-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1.5rem 0 2.5rem; }
.home-hero .hero-brand {
  font-size: 13px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.home-hero .greeting {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.6rem;
}
.home-hero .clock {
  font-size: clamp(4.5rem, 16vw, 9rem);
  font-weight: 200;
  letter-spacing: 0.02em;
  line-height: 1;
}
.home-hero .date {
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 14px;
}
.conn-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--bad);
  margin-right: 6px;
  vertical-align: middle;
  transition: background 0.3s;
}
.conn-dot.ok { background: var(--good); box-shadow: 0 0 6px var(--good); }
.conn-label { font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-faint); }

/* ── section shell ── */
.section { margin-bottom: 2.4rem; }
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.9rem;
}
.section-title svg { width: 13px; height: 13px; stroke: var(--accent); }

/* ── room cards ── */
.rooms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.room-card {
  cursor: pointer;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.3rem 1.1rem;
  transition: border-color 0.25s, background 0.25s;
}
.room-card.active { border-color: var(--accent-glow); background: rgba(201,164,104,0.05); }
.room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.room-id { display: flex; align-items: center; gap: 10px; }
.room-id svg { width: 18px; height: 18px; stroke: var(--text-dim); transition: stroke 0.25s; }
.room-card.active .room-id svg { stroke: var(--accent-hi); }
.room-name { font-size: 1.02rem; font-weight: 400; letter-spacing: 0.01em; }
.room-head-right { display: flex; align-items: center; gap: 10px; }
.room-more {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.room-more svg { width: 12px; height: 12px; stroke: currentColor; }
.room-more:hover { border-color: var(--accent-glow); color: var(--accent-hi); }
.room-modal-body { padding: 1.2rem 1.3rem 1.4rem; }
.room-modal-body .qa-mini-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }

/* toggle switch */
.switch {
  width: 40px; height: 22px;
  border-radius: 20px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.25s, border-color 0.25s;
}
.switch::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  top: 2px; left: 2px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.22s ease, background 0.22s;
}
.switch.on { background: rgba(201,164,104,0.28); border-color: var(--accent-glow); }
.switch.on::after { transform: translateX(18px); background: var(--accent-hi); }

.room-readouts {
  display: flex;
  gap: 1.4rem;
  margin-bottom: 1rem;
}
.readout .val { font-size: 1.6rem; font-weight: 300; line-height: 1; }
.readout .lbl { font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-faint); margin-top: 5px; }
.readout.empty { display: none; }

.room-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.chip svg { width: 13px; height: 13px; stroke: currentColor; }
.chip:hover { border-color: var(--border-hi); color: var(--text); }
.chip.active { border-color: var(--accent-glow); background: rgba(201,164,104,0.12); color: var(--accent-hi); }
.chip.static { cursor: default; }
.stepper { display: inline-flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; }
.stepper button {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.stepper button:hover { border-color: var(--accent-hi); color: var(--accent-hi); }

/* ── quick actions ── */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}
.qa-group {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1rem;
}
.qa-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.9rem;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.qa-group-head svg { width: 14px; height: 14px; stroke: var(--accent); }
.qa-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
}
.qa-btn {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 6px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.qa-btn:hover { border-color: var(--border-hi); }
.qa-btn.active { border-color: var(--accent-glow); background: rgba(201,164,104,0.1); }
.qa-btn svg { width: 16px; height: 16px; stroke: var(--text-dim); transition: stroke 0.2s; }
.qa-btn.active svg { stroke: var(--accent-hi); }
.qa-btn .qa-label { font-size: 10px; letter-spacing: 0.01em; color: var(--text-dim); text-align: center; line-height: 1.25; }
.qa-btn.active .qa-label { color: var(--text); }
.qa-dot {
  position: absolute; top: 7px; right: 8px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent-hi);
  box-shadow: 0 0 5px var(--accent-hi);
  opacity: 0;
  transition: opacity 0.2s;
}
.qa-btn.active .qa-dot { opacity: 1; }

/* ── media ── */
.media-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem 2rem 2rem;
  max-width: 980px;
  margin: 0 auto;
}
.media-tabs { display: flex; justify-content: center; gap: 8px; margin-bottom: 1.4rem; flex-wrap: wrap; }
.media-tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s;
}
.media-tab:hover { border-color: var(--border-hi); }
.media-tab.active { border-color: var(--accent-glow); background: rgba(201,164,104,0.14); color: var(--accent-hi); }

/* Side-by-side on wide screens (fills the display instead of one tall centered column) —
 * stacks back to a single centered column on phones/narrow tablets, see the breakpoint below. */
.media-layout { display: flex; align-items: center; gap: 2rem; }
.media-art {
  flex: 1 1 50%; min-width: 0; aspect-ratio: 16/9;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  box-shadow: 0 18px 45px rgba(0,0,0,0.45);
}
.media-art svg { width: 34px; height: 34px; stroke: currentColor; }
.media-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-info { flex: 1 1 50%; min-width: 0; text-align: left; }
.media-title-row { display: flex; align-items: center; gap: 10px; max-width: 100%; }
.media-title { font-size: 1.4rem; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.media-sub { font-size: 12px; color: var(--text-faint); margin-top: 6px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-imdb {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: all 0.2s;
}
.media-imdb:hover { border-color: #f5c518; color: #f5c518; }
.media-power {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.media-power svg { width: 14px; height: 14px; stroke: currentColor; }
.media-power.on { border-color: var(--accent-glow); color: var(--accent-hi); background: rgba(201,164,104,0.12); }

.media-transport { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 1.4rem; }
.media-transport button {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text-dim);
  border-radius: 50%;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.media-transport button svg { width: 15px; height: 15px; }
.media-transport button:hover { border-color: var(--border-hi); color: var(--text); }
.media-transport button.primary {
  width: 54px; height: 54px;
  border-color: var(--accent-glow);
  background: rgba(201,164,104,0.16);
  color: var(--accent-hi);
}
.media-transport button.primary svg { width: 19px; height: 19px; }

.media-volume { display: flex; align-items: center; gap: 10px; color: var(--text-faint); }
.media-volume svg { width: 15px; height: 15px; stroke: currentColor; flex-shrink: 0; }
.media-volume input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 3px;
  border-radius: 3px;
  background: rgba(255,255,255,0.12);
  outline: none;
}
.media-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent-hi);
  box-shadow: 0 0 6px var(--accent-glow);
  cursor: pointer;
}
.media-volume input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border: none; border-radius: 50%;
  background: var(--accent-hi); cursor: pointer;
}
.media-volume span { font-size: 11px; width: 32px; text-align: right; }
.media-volume button {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.media-volume button:hover { border-color: var(--border-hi); color: var(--text); }

.media-extra { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.media-extra button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text-dim);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s;
}
.media-extra button svg { width: 13px; height: 13px; stroke: currentColor; }
.media-extra button:hover { border-color: var(--border-hi); color: var(--text); }
.media-extra button.active { border-color: var(--accent-glow); background: rgba(201,164,104,0.12); color: var(--accent-hi); }

/* ── agenda ── */
.agenda-list { display: flex; flex-direction: column; gap: 1.1rem; }
.agenda-day-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.agenda-group {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}
.agenda-row {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.agenda-row:last-child { border-bottom: none; }
.agenda-time {
  flex-shrink: 0;
  width: 66px;
  font-size: 11px;
  color: var(--text-faint);
  padding-top: 1px;
}
.agenda-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.agenda-title { font-size: 13px; color: var(--text); }
.agenda-location { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }

/* ── cameras ── */
.cam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.cam-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  cursor: pointer;
  position: relative;
}
.cam-card .cam-img-wrap { aspect-ratio: 16/9; background: #050505; overflow: hidden; }
.cam-card img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 0.3s; }
.cam-card img.loaded { opacity: 1; }
.cam-label {
  position: absolute; left: 12px; bottom: 10px;
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.cam-live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--bad); animation: blink 1.6s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.modal-backdrop.hidden { display: none; }
.modal-cam {
  width: min(720px, 100%);
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  background: #000;
}
.modal-cam .cam-img-wrap { aspect-ratio: 16/9; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(10,10,12,0.9);
}
.modal-head .name { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent-hi); }
.modal-close { background: none; border: none; color: var(--text-dim); cursor: pointer; }
.modal-close svg { width: 18px; height: 18px; stroke: currentColor; }

/* ── grocery ── */
.grocery-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
}
.grocery-top {
  display: flex;
  flex-wrap: wrap;
  gap: 2.2rem;
  align-items: flex-end;
  margin-bottom: 1.2rem;
}
.g-main .val { font-size: 2.3rem; font-weight: 300; line-height: 1; }
.g-main .lbl { font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-faint); margin-top: 6px; }
.g-delta { font-size: 12px; margin-top: 8px; }
.g-delta.down { color: var(--good); }
.g-delta.up { color: var(--bad); }
.g-stats { display: flex; gap: 1.8rem; margin-left: auto; }
.g-stat .val { font-size: 1.15rem; font-weight: 400; }
.g-stat .lbl { font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-faint); margin-top: 4px; }

.g-body { display: flex; gap: 2rem; flex-wrap: wrap; }
.g-chart { flex: 1 1 260px; min-width: 240px; }
.g-chart svg { width: 100%; height: 90px; overflow: visible; }
.g-chart-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 9px; color: var(--text-faint); letter-spacing: 0.08em; }

.g-recent { flex: 1 1 260px; min-width: 240px; }
.g-recent-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 12px;
}
.g-recent-row:last-child { border-bottom: none; }
.g-recent-row .merchant { color: var(--text); }
.g-recent-row .meta { color: var(--text-faint); font-size: 10px; margin-top: 2px; }
.g-recent-row .amount { color: var(--accent-hi); font-weight: 400; white-space: nowrap; margin-left: 12px; }

.empty-note { color: var(--text-faint); font-size: 11px; padding: 1rem 0; }
.section-hint { font-size: 9px; text-transform: none; letter-spacing: 0.05em; color: var(--text-faint); margin-left: 2px; }

.hidden { display: none !important; }

/* ── login screen ── */
.login-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 10%, rgba(201,164,104,0.08), transparent 55%),
                     radial-gradient(circle at 80% 90%, rgba(201,164,104,0.06), transparent 55%);
  padding: 1.5rem;
}
.login-card {
  width: min(340px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.8rem;
}
.login-brand { font-size: 11px; letter-spacing: 0.35em; text-transform: uppercase; color: var(--accent); text-align: center; }
.login-sub { font-size: 13px; color: var(--text-dim); text-align: center; margin-bottom: 8px; font-weight: 300; }
.login-card input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.login-card input:focus { border-color: var(--accent-glow); }
.login-card button {
  margin-top: 6px;
  background: rgba(201,164,104,0.16);
  border: 1px solid var(--accent-glow);
  color: var(--accent-hi);
  border-radius: 10px;
  padding: 11px;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
}
.login-card button:hover { background: rgba(201,164,104,0.24); }
.login-error { min-height: 14px; font-size: 11px; color: var(--bad); text-align: center; }

/* ── header extras: voice button + user/logout ── */
.header-right { display: flex; align-items: center; gap: 14px; }
.voice-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.voice-btn svg { width: 15px; height: 15px; stroke: currentColor; }
.voice-btn:hover { border-color: var(--border-hi); color: var(--text); }
.voice-btn .voice-dot {
  position: absolute; top: -2px; right: -2px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-hi);
  opacity: 0;
  box-shadow: 0 0 6px var(--accent-hi);
  transition: opacity 0.2s;
}
.voice-btn.listening { border-color: var(--accent-glow); color: var(--accent-hi); background: rgba(201,164,104,0.12); }
.voice-btn.listening .voice-dot { opacity: 1; animation: blink 1s infinite; }
.voice-btn.thinking { animation: pulse-soft 1.1s infinite; border-color: var(--accent-glow); color: var(--accent-hi); }
@keyframes pulse-soft { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.voice-caption {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  max-width: min(420px, calc(100vw - 2rem));
  background: rgba(12,12,14,0.85);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--text);
  text-align: center;
  backdrop-filter: blur(10px);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.voice-caption.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.user-name { font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-faint); margin-left: 10px; }
.logout-btn {
  background: none; border: none; color: var(--text-faint); cursor: pointer;
  margin-left: 6px; padding: 2px; display: inline-flex; vertical-align: middle;
  transition: color 0.2s;
}
.logout-btn:hover { color: var(--bad); }
.logout-btn svg { width: 13px; height: 13px; stroke: currentColor; }

/* ── locations bar (fixed, centered above the dock) ── */
.locations-bar {
  /* Fixed + nested inside the Home page's own markup: the page's opacity/pointer-events
   * toggle (see .page / .page.active) cascades to this despite position:fixed, so it only
   * ever shows while Home is the active page — no extra JS needed to scope it. */
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 45;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(12,12,14,0.68);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 22px rgba(0,0,0,0.35);
  max-width: calc(100vw - 20px);
  overflow-x: auto;
  scrollbar-width: none;
}
.locations-bar::-webkit-scrollbar { display: none; }
.loc-bubble {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}
.loc-bubble:hover { background: rgba(255,255,255,0.05); }
.loc-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-glow);
  background: rgba(201,164,104,0.08);
  color: var(--accent-hi);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.loc-icon svg { width: 15px; height: 15px; stroke: currentColor; }
.loc-name { font-size: 13.5px; color: var(--text); line-height: 1.25; }
.loc-where { font-size: 11px; color: var(--text-faint); text-transform: capitalize; line-height: 1.25; }
.loc-card .loc-body { padding: 1.4rem 1.5rem; }
.loc-state { font-size: 1.4rem; font-weight: 300; text-transform: capitalize; }
.loc-travel { font-size: 12px; color: var(--accent-hi); margin-top: 4px; min-height: 16px; }
.loc-map {
  height: 320px;
  border-radius: 12px;
  overflow: hidden;
  margin: 12px 0;
  border: 1px solid var(--border);
  background: #0a0e1a;
}
.loc-map .leaflet-tile-pane { filter: grayscale(1) invert(1) brightness(0.85) contrast(1.15); }
.loc-map .leaflet-container { background: #0a0e1a; }
.loc-updated { font-size: 11px; color: var(--text-faint); margin-top: 6px; }
.loc-actions { display: flex; gap: 10px; margin-top: 1.2rem; }
.loc-action {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  transition: all 0.2s;
}
.loc-action:hover { border-color: var(--accent-glow); color: var(--accent-hi); }
.loc-action svg { width: 14px; height: 14px; stroke: currentColor; }

/* ── recently added to plex + cast picker ── */
.plex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
@media (min-width: 900px) {
  .plex-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px; }
}
.plex-card {
  display: flex;
  flex-direction: column;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font-family: inherit;
}
.plex-poster {
  aspect-ratio: 2/3;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  transition: border-color 0.2s;
}
.plex-card:hover .plex-poster { border-color: var(--accent-glow); }
.plex-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.plex-poster svg { width: 22px; height: 22px; stroke: currentColor; }
.plex-cap { margin-top: 7px; }
.plex-title { display: block; font-size: 12px; color: var(--text); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.plex-year { font-size: 10px; color: var(--text-faint); }

.cast-card .cast-body { padding: 1.4rem 1.5rem 1.6rem; }
.cast-hint { font-size: 11px; color: var(--text-faint); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.1em; }
.cast-targets { display: flex; flex-direction: column; gap: 8px; }
.cast-target-btn {
  padding: 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.cast-target-btn:hover { border-color: var(--accent-glow); background: rgba(201,164,104,0.1); }
.cast-target-btn:disabled { opacity: 0.6; cursor: default; }

/* ── recent activity (Frigate person-detection photos) ── */
.motion-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.motion-photo {
  display: block;
  text-decoration: none;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--panel);
  transition: border-color 0.2s;
}
.motion-photo:hover {
  border-color: var(--accent-glow);
}
.motion-photo-img { aspect-ratio: 4/3; background: #000; overflow: hidden; }
.motion-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.motion-photo .cap {
  padding: 8px 10px 9px;
  font-size: 11px; color: var(--text);
}
.motion-photo .cap .cam { font-weight: 500; }
.motion-photo .cap .time { display: block; font-size: 10px; color: var(--text-faint); margin-top: 2px; }

/* ── stocks ── */
.stocks-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 1.4rem;
  max-width: 560px;
}
.stock-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.stock-row:last-child { border-bottom: none; }
.stock-symbol { width: 90px; font-size: 13px; color: var(--text); }
.stock-price { flex: 1; font-size: 13px; color: var(--text-dim); }
.stock-change { font-size: 12px; font-weight: 400; }
.stock-change.up { color: var(--good); }
.stock-change.down { color: var(--bad); }
.stock-err { color: var(--text-faint); font-size: 11px; }

/* ── weather ── */
.weather-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  max-width: 420px;
  margin: 0 auto;
}
.weather-hero { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 1.8rem; }
.weather-icon { color: var(--accent-hi); margin-bottom: 6px; }
.weather-icon svg { width: 56px; height: 56px; stroke: currentColor; }
.weather-temp { font-size: 3.2rem; font-weight: 200; line-height: 1; }
.weather-desc { font-size: 13px; color: var(--text-dim); margin-top: 8px; }
.weather-feels { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.weather-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.weather-stat {
  text-align: center;
  padding: 12px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
}
.weather-stat .val { font-size: 1rem; font-weight: 400; }
.weather-stat .lbl { font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-faint); margin-top: 4px; }

/* ── responsive: phones, 8" tablets (portrait + landscape) ──────────────
 * Base layout above is already fluid (clamp()/min()/auto-fit grids), so these
 * breakpoints only correct the few fixed-size spots: the dock, the locations
 * bar, and paddings that get tight on a phone or a short landscape viewport. */

/* Phones and narrow tablet portrait (covers an 8" tablet in portrait too) */
@media (max-width: 700px) {
  .page { padding-left: 1rem; padding-right: 1rem; }
  .header { padding: 1rem 1rem; }
  .g-stats { margin-left: 0; gap: 1.2rem; flex-wrap: wrap; }
  .header-right { gap: 8px; }
  .rooms { grid-template-columns: 1fr; }
  .qa-group, .media-panel, .weather-panel, .stocks-panel, .grocery-panel { max-width: none; }
  .media-layout { flex-direction: column; }
  .media-art { margin-bottom: 1.1rem; }
  .media-info { text-align: center; }
  .media-title-row { justify-content: center; }
}

/* Tablet portrait and desktop/wide screens both read small at a distance — bump the
 * readable content text specifically (not the small uppercase structural labels). Phones
 * keep their own smaller sizing above, since this range starts past typical phone widths. */
@media (min-width: 500px) {
  .room-name { font-size: 1.45rem; }
  .readout .val { font-size: 2.3rem; }
  .readout .lbl { font-size: 12px; }
  .section-title { font-size: 15px; }
  .qa-label { font-size: 14px; }
  .chip { font-size: 15px; }
  .media-title { font-size: 1.9rem; }
  .media-sub { font-size: 16px; }
  .agenda-title { font-size: 18px; }
  .agenda-time { font-size: 16px; width: 88px; }
  .agenda-location { font-size: 14px; }
  .g-recent-row { font-size: 16px; }
  .g-main .val { font-size: 3.2rem; }
  .g-stat .val { font-size: 1.6rem; }
  .g-main .lbl, .g-stat .lbl { font-size: 11px; }
  .stock-symbol, .stock-price { font-size: 18px; }
  .stock-change { font-size: 16px; }
  .weather-temp { font-size: 4.4rem; }
  .weather-desc { font-size: 17px; }
  .weather-stat .val { font-size: 1.4rem; }
  .weather-stat .lbl { font-size: 11px; }
  .loc-name { font-size: 17px; }
  .loc-where { font-size: 14px; }
  .motion-cam { font-size: 16px; }
  .motion-time { font-size: 14px; }
  .greeting { font-size: 15px; }
  .home-hero .date { font-size: 13px; }
  .plex-title { font-size: 14px; }
  .plex-year { font-size: 12px; }
  .empty-note { font-size: 13px; }
}

/* 8" tablet portrait — the dock reads small relative to the screen at that size; a portrait
 * tablet has enough spare width for a bigger dock (unlike a phone, where it must stay compact). */
@media (min-width: 500px) and (max-width: 900px) and (orientation: portrait) {
  .dock { gap: 6px; padding: 10px; }
  .dock-btn { padding: 11px 20px 9px; gap: 6px; }
  .dock-btn svg { width: 24px; height: 24px; }
  .dock-btn span { font-size: 11px; }
}

/* Phones only — the dock's 7 labeled buttons don't fit a phone's width */
@media (max-width: 480px) {
  .home-hero .clock { font-size: clamp(3.6rem, 18vw, 6rem); }
  .dock-btn { padding: 7px 10px; }
  .dock-btn span { display: none; }
  .loc-bubble .loc-name, .loc-bubble .loc-where { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .weather-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* Short viewports — phones/tablets in landscape, where header + dock + locations
 * bar can eat most of the available height. Shrink the chrome so content still
 * fits without the page needing to scroll past the fold for basic info. */
@media (max-height: 500px) {
  .header { padding: 0.6rem 1.2rem; }
  .home-hero { padding: 0.5rem 0 1rem; }
  .home-hero .hero-brand { margin-bottom: 0.3rem; }
  .home-hero .clock { font-size: clamp(2.4rem, 9vw, 4rem); }
  .home-hero .date { margin-top: 6px; }
  .page { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
  .dock { bottom: calc(10px + env(safe-area-inset-bottom)); padding: 5px; }
  .dock-btn { padding: 5px 10px; }
  .dock-btn span { display: none; }
  .locations-bar { padding: 4px 8px; }
  .voice-caption { top: 56px; }
  .modal-backdrop { padding: 0.75rem; }
  .loc-map { height: 160px; }
  .media-art { aspect-ratio: 21/9; }
}

/* On Deck resume progress bar along the bottom of the poster */
.plex-poster { position: relative; }
.plex-progress { height: 3px; border-radius: 2px; background: rgba(255,255,255,0.12); margin: 4px 2px 0; overflow: hidden; }
.plex-progress span { display: block; height: 100%; background: var(--accent-hi); }

/* ── Plex section: fluid sizing so posters + text stay readable from phones to TVs ── */
.media-tabs { gap: clamp(6px, 1.2vw, 12px); }
.media-tab {
  min-height: 40px;
  padding: 8px clamp(14px, 2.4vw, 22px);
  font-size: clamp(13px, 0.5vw + 11.5px, 17px);
}
.plex-grid {
  grid-template-columns: repeat(auto-fill, minmax(clamp(112px, 15vw, 190px), 1fr));
  gap: clamp(12px, 1.6vw, 22px);
}
.plex-title { font-size: clamp(13px, 0.45vw + 11.5px, 17px); line-height: 1.3; }
.plex-year { display: block; margin-top: 2px; font-size: clamp(12px, 0.35vw + 10.5px, 15px); color: var(--text-dim); }
.plex-progress { height: 4px; }
.cast-target-btn { min-height: 48px; font-size: clamp(15px, 0.4vw + 13.5px, 18px); }
.cast-hint { font-size: 12px; }
@media (max-width: 360px) {
  .plex-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── installed-app mode: edge-to-edge, no browser chrome, respect notches/status bar ── */
html, body { background: #0a0a0c; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body { padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
@media (display-mode: standalone), (display-mode: fullscreen) {
  body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  input, textarea { -webkit-user-select: text; user-select: text; }
}

/* type-to-ask box for browsers without speech recognition */
.voice-type {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(64px + env(safe-area-inset-top)); z-index: 60;
  width: min(420px, calc(100vw - 32px));
  display: flex; gap: 8px; padding: 8px;
  background: var(--panel); border: 1px solid var(--border-hi); border-radius: 14px;
  backdrop-filter: blur(12px);
}
.voice-type input { flex: 1; min-width: 0; padding: 11px 14px; font-size: 16px; color: var(--text); background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 10px; font-family: inherit; }
.voice-type button { padding: 0 16px; min-height: 44px; font-size: 14px; border-radius: 10px; border: 1px solid var(--accent-glow); background: rgba(201,164,104,0.14); color: var(--accent-hi); cursor: pointer; font-family: inherit; }
/* orb: at least a comfortable touch target */
.voice-btn { width: 42px; height: 42px; }

/* ── grocery: extra stats ── */
.g-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(clamp(130px, 18vw, 200px), 1fr)); gap: 10px; margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid rgba(255,255,255,0.06); }
.g-tile { background: rgba(255,255,255,0.025); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.g-tile .val { font-size: clamp(1.05rem, 0.6vw + 0.9rem, 1.4rem); font-weight: 400; }
.g-tile .lbl { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.g-note { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.g-note.down { color: var(--good); } .g-note.up { color: var(--bad); }
.g-split { margin-top: 1.1rem; }
.g-split-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: rgba(255,255,255,0.05); }
.g-split-bar span { display: block; height: 100%; }
.g-split .uber, .g-split-key .uber { background: var(--accent-hi); }
.g-split .groc, .g-split-key .groc { background: var(--good); }
.g-split-key { display: flex; gap: 1.2rem; margin-top: 8px; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; }
.g-split-key i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.g-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 14px; margin-top: 1.3rem; }
.g-card { background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.g-card-title { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 10px; }
.g-bar-row { margin-bottom: 11px; }
.g-bar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.g-bar-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.g-bar-val { color: var(--accent-hi); white-space: nowrap; }
.g-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.06); margin-top: 5px; overflow: hidden; }
.g-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.g-bar-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
/* keep the original grocery text readable too */
.g-main .lbl, .g-stat .lbl { font-size: 11px; }
.g-recent-row { font-size: 14px; } .g-recent-row .meta { font-size: 12px; }
.g-chart-labels { font-size: 11px; }

/* ══════════════════════════════════════════════════════════════════════════
 * 8" tablet polish (Fire HD 8 ≈ 533×853 portrait / 853×533 landscape CSS px)
 * Everything below only applies from 500px up, so phones keep their own layout.
 * ══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 500px) {
  /* Locations: an in-flow glass strip instead of a fixed pill floating over the room cards */
  .locations-bar {
    position: static; transform: none; max-width: none; width: 100%;
    justify-content: space-between; flex-wrap: wrap; gap: 6px;
    padding: 8px 10px; border-radius: 18px; overflow: visible;
  }
  .locations-bar .loc-bubble { flex: 1 1 auto; }
  .locations-bar .loc-name { font-size: 15px; }
  .locations-bar .loc-where { font-size: 12px; }

  /* Room cards: glass depth + real touch targets */
  .room-card {
    background: linear-gradient(160deg, rgba(255,255,255,0.055), rgba(255,255,255,0.02));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 12px 32px rgba(0,0,0,0.28);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  .room-card.active { box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 0 1px var(--accent-glow), 0 14px 36px rgba(201,164,104,0.12); }
  .room-card:active { transform: scale(0.985); }
  .chip { min-height: 44px; padding: 8px 16px; }
  .room-more { width: 44px; height: 44px; }
  .switch { transform: scale(1.15); transform-origin: right center; }
  .qa-btn, .quick-action { min-height: 64px; }
}

/* ── Portrait 8": compact hero so rooms show above the fold; all 7 dock buttons fit ── */
@media (min-width: 500px) and (max-width: 900px) and (orientation: portrait) {
  .header { padding: 0.55rem 1.1rem; }
  .home-hero { padding: 0.2rem 0 1rem; }
  .home-hero .clock { font-size: clamp(4rem, 15vw, 5.6rem); }
  .home-hero .date { margin-top: 8px; }
  .rooms { grid-template-columns: 1fr; gap: 12px; }
  .room-card { display: grid; grid-template-columns: auto 1fr; column-gap: 1.6rem; align-items: center; padding: 1rem 1.2rem; }
  .room-card .room-head { grid-column: 1 / -1; margin-bottom: 0.7rem; }
  .room-card .room-readouts { margin: 0; }
  .room-card .room-controls { justify-content: flex-end; margin: 0; }
  .readout .val { font-size: 2rem; }
  .dock {
    left: 10px; right: 10px; transform: none; max-width: none;
    justify-content: space-between; gap: 2px; padding: 8px 6px; border-radius: 24px;
  }
  .dock-btn { flex: 1 1 0; min-width: 0; padding: 10px 2px 8px; }
  .dock-btn span { font-size: 10px; letter-spacing: 0.07em; }
  .page { padding-bottom: calc(6.4rem + env(safe-area-inset-bottom)); }
}

/* ── Landscape 8": clock + locations side by side, all three rooms across, nothing hiding behind the dock ── */
@media (min-width: 700px) and (max-height: 640px) and (orientation: landscape) {
  .header { padding: 0.4rem 1.4rem; }
  .page { padding: 0 1.4rem calc(5.4rem + env(safe-area-inset-bottom)); }
  .home-inner {
    display: grid; grid-template-columns: 1fr 1.15fr; grid-template-rows: auto 1fr;
    column-gap: 1.6rem; align-items: center; min-height: 0;
  }
  .home-inner > .home-hero { grid-column: 1; grid-row: 1; align-items: flex-start; text-align: left; padding: 0 0 0.6rem; }
  .home-inner > .section:nth-child(3) { grid-column: 2; grid-row: 1; margin-bottom: 0.6rem; }
  .home-inner > .section:nth-child(3) .section-title { display: none; }
  .home-inner > .section:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .home-hero .clock { font-size: clamp(3.4rem, 8.5vw, 5rem); }
  .home-hero .date { margin-top: 4px; }
  .home-hero .greeting { margin-bottom: 0.3rem; }
  .rooms { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .room-card { padding: 0.9rem 1rem; }
  .room-head { margin-bottom: 0.6rem; }
  .room-name { font-size: 1.25rem; }
  .readout .val { font-size: 1.8rem; }
  .room-controls { gap: 6px; }
  .chip { padding: 8px 12px; font-size: 14px; }
  .dock { padding: 6px; }
  .dock-btn { padding: 8px 14px 6px; }
  .dock-btn svg { width: 22px; height: 22px; }
  .dock-btn span { display: block; font-size: 10px; letter-spacing: 0.1em; }
  .locations-bar .loc-bubble { padding: 4px 10px 4px 4px; }
}
@media (min-width: 700px) and (max-height: 640px) and (orientation: landscape) {
  .home-inner > .section:nth-child(2) { margin-top: 0.9rem; }
  .room-name { font-size: 1.1rem; white-space: nowrap; }
  .room-id { gap: 8px; min-width: 0; }
  .room-more { width: 40px; height: 40px; }
  .room-head-right { gap: 8px; }
}
@media (min-width: 700px) and (max-height: 640px) and (orientation: landscape) {
  .room-name { font-size: 1.02rem; }
  .room-more { width: 38px; height: 38px; }
  .switch { transform: scale(1); }
}
/* 8" landscape: location bubbles kept to a single compact row */
@media (min-width: 700px) and (max-height: 640px) and (orientation: landscape) {
  .locations-bar { flex-wrap: nowrap; gap: 2px; padding: 5px 6px; border-radius: 999px; justify-content: space-between; }
  .locations-bar .loc-bubble { flex: 1 1 0; min-width: 0; gap: 6px; padding: 3px 8px 3px 3px; }
  .locations-bar .loc-icon { width: 26px; height: 26px; flex-shrink: 0; }
  .locations-bar .loc-icon svg { width: 13px; height: 13px; }
  .locations-bar .loc-name { font-size: 13px; }
  .locations-bar .loc-where { font-size: 11px; }
  .locations-bar .loc-name, .locations-bar .loc-where { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* 8" landscape: tighter Home — small room cards (readouts + chips share a row), smaller clock/locations */
@media (min-width: 700px) and (max-height: 640px) and (orientation: landscape) {
  .header { padding: 0.3rem 1.2rem; }
  .voice-btn { width: 36px; height: 36px; }
  .home-hero .clock { font-size: clamp(2.8rem, 6.5vw, 3.8rem); }
  .home-hero .greeting { font-size: 12px; margin-bottom: 0.15rem; }
  .home-hero .date { font-size: 11px; margin-top: 2px; }
  .locations-bar .loc-icon { width: 22px; height: 22px; }
  .locations-bar .loc-name { font-size: 12px; }
  .locations-bar .loc-where { font-size: 10px; }
  .home-inner > .section:nth-child(2) { margin-top: 0.4rem; }
  .home-inner .section-title { font-size: 12px; margin-bottom: 0.5rem; }
  .rooms { gap: 8px; }
  .room-card { display: grid; grid-template-columns: auto 1fr; column-gap: 0.7rem; align-items: center; padding: 0.7rem 0.8rem; border-radius: 14px; }
  .room-card .room-head { grid-column: 1 / -1; margin-bottom: 0.4rem; }
  .room-card .room-readouts { margin: 0; gap: 0.7rem; }
  .room-card .room-controls { justify-content: flex-end; margin: 0; gap: 5px; }
  .room-name { font-size: 0.95rem; }
  .room-id svg { width: 18px; height: 18px; }
  .room-more { width: 34px; height: 34px; }
  .switch { transform: scale(0.9); transform-origin: right center; }
  .readout .val { font-size: 1.25rem; }
  .readout .lbl { font-size: 9px; letter-spacing: 0.12em; margin-top: 3px; }
  .chip { min-height: 38px; padding: 5px 10px; font-size: 12px; gap: 4px; }
  .chip svg { width: 14px; height: 14px; }
  .dock { padding: 4px; bottom: calc(8px + env(safe-area-inset-bottom)); }
  .dock-btn { padding: 6px 12px 4px; }
  .dock-btn svg { width: 20px; height: 20px; }
  .dock-btn span { font-size: 9px; }
  .page { padding-bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
}
/* 8" landscape: slightly smaller text, chips stay on one line */
@media (min-width: 700px) and (max-height: 640px) and (orientation: landscape) {
  .home-hero .clock { font-size: clamp(2.5rem, 5.6vw, 3.3rem); }
  .home-hero .greeting, .home-hero .date { font-size: 10px; }
  .room-name { font-size: 0.85rem; }
  .readout .val { font-size: 1.05rem; }
  .readout .lbl { font-size: 8px; }
  .room-card .room-controls { flex-wrap: nowrap; }
  .chip { min-height: 34px; padding: 4px 8px; font-size: 11px; white-space: nowrap; }
  .chip svg { width: 12px; height: 12px; }
  .room-more { width: 30px; height: 30px; }
  .locations-bar .loc-name { font-size: 11px; }
  .locations-bar .loc-where { font-size: 9px; }
  .section-title { font-size: 11px; }
  .dock-btn span { font-size: 8.5px; }
}
