:root {
  --bg: #030713;
  --panel: rgba(12, 21, 37, .78);
  --panel2: rgba(17, 27, 45, .82);
  --line: rgba(154, 183, 221, .14);
  --ink: #f6f8ff;
  --muted: #8d9bb2;
  --cyan: #39cfff;
  --blue: #3988ff;
  --violet: #ae54ff;
  --green: #52f29a;
  --danger: #ff7285;
  --nav: calc(65px + env(safe-area-inset-bottom, 0px));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 22%, rgba(42, 92, 164, .18), transparent 28%),
    radial-gradient(circle at 92% 8%, rgba(95, 48, 163, .15), transparent 23%),
    linear-gradient(180deg, #07101e 0%, #030713 55%, #02050c 100%);
}
button, textarea, select { font: inherit; }
button { color: inherit; }
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .25;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 100% 4px;
}
.app {
  position: relative;
  width: min(100%, 500px);
  min-height: 100dvh;
  margin: auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(var(--nav) + 24px);
}

/* Brand */
.brandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}
.wordmark {
  font-size: 21px;
  font-weight: 300;
  letter-spacing: .46em;
  color: #d8e1ff;
  text-shadow: 0 0 14px rgba(130, 167, 255, .45);
}
.core-mark {
  margin-top: 5px;
  padding-left: 2px;
  font-size: 8px;
  letter-spacing: .72em;
  color: #7f8da5;
}
.header-actions { display: flex; gap: 9px; }
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(13, 22, 38, .65);
}
.icon-button svg, .tabbar svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.view { display: none; }
.view.active { display: block; }

/* Persona home */
.persona {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 8px;
}
.face-button {
  position: relative;
  width: min(63vw, 270px);
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.face-button img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  animation: breathe 5s ease-in-out infinite;
}
.face-pulse {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  box-shadow: 0 0 42px rgba(61, 193, 255, .18), 0 0 70px rgba(174, 84, 255, .12);
  pointer-events: none;
}
.face-button.talking .face-pulse {
  box-shadow: 0 0 52px rgba(61, 193, 255, .32), 0 0 90px rgba(174, 84, 255, .22);
}
.face-button.talking img {
  animation: breathe 2.8s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(.985); filter: brightness(.96); }
  50% { transform: scale(1.015); filter: brightness(1.08); }
}
.persona h1 {
  margin: -6px 0 0;
  font-size: 22px;
  letter-spacing: -.02em;
}
.context {
  max-width: 330px;
  min-height: 42px;
  margin: 8px auto 14px;
  color: #aeb8cc;
  font-size: 14px;
  line-height: 1.55;
}
.talk-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(78%, 310px);
  margin: 0 auto;
  padding: 13px 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(#0b1527, #0b1527) padding-box,
    linear-gradient(100deg, var(--cyan), var(--blue), var(--violet)) border-box;
  box-shadow: 0 0 18px rgba(57, 207, 255, .24), 0 0 26px rgba(174, 84, 255, .2);
  font-size: 16px;
  font-weight: 550;
}
.talk-button svg {
  width: 23px;
  fill: none;
  stroke: #7bddff;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.talk-button.listening {
  animation: listening 1.2s ease-in-out infinite;
  background:
    linear-gradient(#11152b, #11152b) padding-box,
    linear-gradient(100deg, #53ddff, #cd63ff) border-box;
}
.talk-button.live {
  animation: listening 1.6s ease-in-out infinite;
  background:
    linear-gradient(#10182b, #10182b) padding-box,
    linear-gradient(100deg, #52f29a, #39cfff) border-box;
}
@keyframes listening { 50% { box-shadow: 0 0 28px rgba(91, 208, 255, .5), 0 0 44px rgba(176, 84, 255, .35); } }
.talk-hint {
  margin: 8px 0 2px;
  color: #7f8da2;
  font-size: 11px;
  text-align: center;
}
.talk-hint.live { color: #8fe7b5; }
.composer[hidden], .type-toggle[hidden] { display: none !important; }
.voice-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 10px 0 2px;
}
.speak-button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 28, 48, .9);
  color: #d7e7ff;
  font-size: 12px;
}
.speak-button.speaking {
  border-color: rgba(57, 207, 255, .55);
  box-shadow: 0 0 14px rgba(57, 207, 255, .25);
}
.auto-speak {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #8795aa;
  font-size: 11px;
}
.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 12px;
}
.color-row button {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  font-size: 11px;
}
.color-row button[data-light-color="on"] { color: #9fe7c2; }
.color-row button[data-light-color="blue"] { color: #7ec8ff; }
.color-row button[data-light-color="red"] { color: #ff8a96; }
.color-row button[data-light-color="green"] { color: #7dffb0; }
.color-row button[data-light-color="purple"] { color: #d09cff; }
.color-row button[data-light-color="warm"] { color: #ffd29a; }
.color-row button[data-light-color="daylight"] { color: #eef6ff; }
.color-row button[data-light-color="off"] { color: #9aa7ba; }
.type-toggle {
  display: block;
  margin: 12px auto 8px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: #8795aa;
  font-size: 11px;
}
.type-toggle span { margin-left: 8px; font-size: 15px; color: #c8d2e7; }
.conversation {
  margin: 6px 0 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(5, 10, 20, .72);
}
.transcript {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 2px 10px;
}
.bubble {
  max-width: 88%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(18, 29, 49, .78);
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
  white-space: pre-wrap;
}
.bubble.user { align-self: flex-end; border-bottom-right-radius: 5px; background: rgba(46, 68, 112, .5); }
.bubble.looma { align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble .meta { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.attachments img { width: 100%; margin-top: 8px; border-radius: 10px; }
.audio-att { margin-top: 8px; }
.audio-att audio { width: 100%; }
.att-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.composer {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  gap: 7px;
  align-items: end;
}
.composer textarea {
  resize: none;
  min-height: 38px;
  max-height: 100px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  color: var(--ink);
  background: rgba(255,255,255,.045);
}
.composer textarea:focus { border-color: rgba(88, 188, 255, .48); }
.composer-icon, .send-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.send-button { color: #03101a; background: #71d9ff; font-weight: 800; }
.pending-media { display: flex; gap: 6px; margin-top: 8px; }
.pending-chip { position: relative; width: 54px; height: 54px; }
.pending-chip img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.chip-x { position: absolute; right: -4px; top: -4px; border: 0; border-radius: 50%; background: #222b3b; color: white; }
.correct-bar { margin-top: 7px; }
.correct-bar button { border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); }
.correct-form { display: grid; gap: 6px; margin-top: 6px; }
.correct-form input, .correct-form select { padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #080e1a; }
.system-line {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 11px 0;
  color: #7e8ba1;
  font-size: 10px;
}
.system-line span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.system-line i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #536077;
}
.system-line i.ok { background: var(--green); box-shadow: 0 0 7px rgba(82,242,154,.6); }
.system-line i.warn { background: #ffbf52; }
.system-line i.bad { background: var(--danger); }
.home-controls { margin: 6px 0 12px; }
.home-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 8px;
  color: #dce5f7;
  font-size: 12px;
  font-weight: 600;
}
.home-section-title button {
  padding: 4px;
  border: 0;
  background: transparent;
  color: #8290a6;
  font-size: 10px;
}
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.quick-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 84px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(16,28,48,.88), rgba(8,15,27,.88));
  text-align: left;
}
.quick-button:active { transform: scale(.98); background: rgba(29,47,76,.85); }
.quick-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  margin-bottom: 8px;
  border-radius: 9px;
  color: #83dcff;
  background: rgba(47,151,255,.1);
  font-size: 18px;
}
.quick-button strong { font-size: 11px; font-weight: 600; }
.quick-button small { margin-top: 2px; color: #748299; font-size: 9px; }
.latest-card {
  display: grid;
  grid-template-columns: 96px 1fr 16px;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  text-align: left;
}
.latest-card img {
  width: 96px;
  height: 68px;
  object-fit: cover;
  border-radius: 12px;
  background: #070b12;
}
.latest-copy { display: flex; flex-direction: column; min-width: 0; }
.latest-copy strong { font-size: 13px; }
.latest-copy small { margin: 3px 0; color: #75849a; font-size: 10px; }
.latest-copy > span { overflow: hidden; color: #a7b2c5; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.chevron { color: #b9c5dc; font-size: 26px; }

/* Secondary pages */
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 18px 0 12px;
}
.kicker { color: #6c7b94; font-size: 9px; letter-spacing: .22em; }
.section-head h2 { margin: 3px 0 0; font-size: 25px; }
.small-button {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 11px;
}
.section-tabs, .device-filters {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 1px 1px 11px;
  scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar, .device-filters::-webkit-scrollbar { display: none; }
.section-tabs button, .device-filters button {
  flex: 0 0 auto;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #8d9bb2;
  background: rgba(13, 23, 40, .72);
  font-size: 11px;
}
.section-tabs button.active, .device-filters button.active {
  border-color: rgba(54, 190, 255, .75);
  color: #ecf9ff;
  background: rgba(31, 132, 224, .18);
  box-shadow: 0 0 14px rgba(47, 159, 255, .22);
}
.camera-card {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16/10;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #050911;
}
.camera-card > img { width: 100%; height: 100%; object-fit: cover; }
#liveBoxes, #coreCamBoxes { position: absolute; inset: 0; pointer-events: none; }
.bbox { position: absolute; border: 2px solid var(--cyan); border-radius: 4px; }
.bbox.named { border-color: #cd75ff; box-shadow: 0 0 10px rgba(205,117,255,.55); }
.bbox span {
  position: absolute;
  top: -18px;
  left: -2px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(1,5,12,.88);
  color: white;
  font-size: 9px;
  white-space: nowrap;
}
.camera-caption {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  padding: 35px 14px 12px;
  background: linear-gradient(transparent, rgba(1,4,10,.92));
}
.camera-caption strong { font-size: 14px; }
.camera-caption > span:last-child { grid-column: 2; color: #9aa7ba; font-size: 11px; }
.live-badge { grid-row: 1/3; align-self: center; color: white; font-size: 9px; letter-spacing: .12em; }
.live-badge i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #ff5166; }
.vision-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.vision-actions button, .ptz button {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel2);
}
.ptz { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; margin-top: 8px; }
.overview { color: #b5c0d3; font-size: 14px; line-height: 1.5; }
.stats { display: flex; flex-wrap: wrap; gap: 5px; }
.stats span { padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; }
.timeline { list-style: none; display: grid; gap: 8px; margin: 12px 0 0; padding: 0; }
.timeline li { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); font-size: 13px; }
.when { display: block; margin-bottom: 4px; color: #70809a; font-size: 10px; }
.home-summary {
  margin: 3px 0 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: #9cabc1;
  background: var(--panel);
  font-size: 12px;
}
.device-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(12, 21, 37, .78);
  color: #7a8aa2;
}
.device-search input {
  width: 100%;
  padding: 10px 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}
.ha-device-list { display: grid; gap: 7px; }
.device-card {
  min-height: 68px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.device-card strong { display: block; margin-bottom: 6px; font-size: 14px; }
.device-card span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.device-card .device-state { display: block; margin-top: 12px; color: var(--green); }
.device-control-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.device-kind-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #73d6ff;
  background: rgba(49,154,226,.1);
  font-size: 16px;
}
.device-kind-icon.light { color: #ffe489; background: rgba(255,201,67,.09); }
.device-kind-icon.switch { color: #7ff5aa; background: rgba(82,242,154,.09); }
.device-kind-icon.automation { color: #bf79ff; background: rgba(174,84,255,.1); }
.device-kind-icon.sensor, .device-kind-icon.climate { color: #ff9f86; background: rgba(255,114,133,.09); }
.device-control-copy { min-width: 0; }
.device-control-copy strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-control-copy small {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: #738199;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-switch {
  min-width: 50px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #8593a9;
  background: rgba(255,255,255,.05);
  font-size: 10px;
}
.device-switch.on {
  border-color: rgba(47, 143, 255, .65);
  color: #eaf8ff;
  background: linear-gradient(90deg, #2179ef, #45a6ff);
  box-shadow: 0 0 13px rgba(47,143,255,.25);
}
.device-value { color: #becbe0; font-size: 11px; }

/* Rich secondary views */
.page-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 94px;
  padding: 10px 0 8px;
}
.page-intro h2 {
  margin: 0;
  font-size: 31px;
  line-height: 1;
  letter-spacing: -.035em;
}
.page-intro p {
  margin: 8px 0 0;
  color: #9ba9be;
  font-size: 13px;
}
.page-persona {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #a9b6ca;
  font-size: 9px;
  line-height: 1.35;
}
.page-persona img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 50%;
  filter: drop-shadow(0 0 10px rgba(77, 169, 255, .35));
}
.content-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 1px 8px;
}
.content-heading h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.content-heading > span, .content-heading button {
  border: 0;
  color: #8795aa;
  background: none;
  font-size: 10px;
}

.camera-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.camera-card {
  width: 100%;
  padding: 0;
  color: var(--ink);
  text-align: left;
}
.camera-feature { grid-column: 1 / -1; aspect-ratio: 16 / 9; }
.camera-planned { aspect-ratio: 1.55; }
.camera-card .camera-caption {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 35px 11px 10px;
}
.camera-card .camera-caption strong { font-size: 12px; }
.camera-card .camera-caption > span:last-child {
  color: #a0aec2;
  font-size: 9px;
}
.tile-status {
  position: absolute;
  z-index: 3;
  top: 9px;
  left: 9px;
  padding: 5px 7px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: rgba(4, 9, 17, .72);
  backdrop-filter: blur(10px);
  font-size: 9px;
}
.tile-status i, .live-label i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 7px rgba(82, 242, 154, .7);
}
.tile-status.planned { color: #9ba8bc; }
.camera-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: rgba(221,232,255,.35);
  background:
    radial-gradient(circle at 70% 30%, rgba(126,71,200,.25), transparent 25%),
    linear-gradient(135deg, #17263a, #090e17 58%, #111b29);
  font-size: 9px;
  letter-spacing: .35em;
}
.door-camera {
  background:
    radial-gradient(circle at 50% 32%, rgba(245,180,93,.2), transparent 22%),
    linear-gradient(150deg, #1f242a, #091019 65%, #15121b);
}
.wide-link {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  margin: 10px 0 16px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #dce6f8;
  background: var(--panel);
  text-align: left;
  font-size: 11px;
}
.wide-icon {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 10px;
  color: #76d7ff;
  background: rgba(45, 151, 235, .12);
}
.insight-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(14, 27, 46, .95), rgba(8, 16, 29, .92));
  text-align: left;
}
.insight-orb {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #8de3ff;
  background: radial-gradient(circle, rgba(61,184,240,.28), rgba(22,74,111,.1));
  box-shadow: 0 0 18px rgba(44, 177, 244, .18);
  font-size: 20px;
}
.insight-card strong, .insight-card small { display: block; }
.insight-card strong { font-size: 12px; }
.insight-card small { margin-top: 3px; color: #8493aa; font-size: 9px; line-height: 1.35; }
.insight-card time { align-self: start; color: #748198; font-size: 8px; }
.signal-grid, .activity-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 9px;
}
.signal-grid > div {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 1px 6px;
  align-items: center;
  min-height: 52px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.signal-icon { grid-row: 1 / 3; font-size: 18px; }
.signal-icon.cyan { color: #51cfff; }
.signal-icon.violet { color: #b372ff; }
.signal-icon.red { color: #ff6b82; }
.signal-grid strong { font-size: 11px; font-weight: 550; }
.signal-grid small { color: #78869c; font-size: 8px; }
.action-grid, .device-quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
.action-grid button, .device-quick-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(16,29,49,.95), rgba(7,14,25,.9));
  text-align: center;
}
.action-grid span, .device-quick-grid span { margin-bottom: 8px; color: #b6dfff; font-size: 20px; }
.action-grid strong, .device-quick-grid strong { font-size: 9px; font-weight: 500; }
.device-quick-grid small { margin-top: 3px; color: #76849a; font-size: 8px; }
.camera-controls {
  margin-top: 10px;
  color: #7f8da2;
  font-size: 10px;
}
.camera-controls summary { padding: 7px 2px; }

.device-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
}
.device-summary-grid > div {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 0 5px;
  align-items: center;
  min-height: 58px;
  padding: 10px 8px;
}
.device-summary-grid > div + div::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 1px;
  background: var(--line);
}
.device-summary-grid span, .online-dot { grid-row: 1 / 3; color: #b6dfff; font-style: normal; }
.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(82,242,154,.55);
}
.device-summary-grid strong { font-size: 14px; font-weight: 550; }
.device-summary-grid small { color: #77859a; font-size: 7px; }
.room-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 36%;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: none;
}
.room-card {
  position: relative;
  overflow: hidden;
  min-height: 90px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(0deg, rgba(2,5,10,.9), transparent 70%),
    radial-gradient(circle at 68% 28%, rgba(219,170,80,.36), transparent 25%),
    linear-gradient(135deg, #314032, #121820);
  text-align: left;
}
.room-card.core-room { background: linear-gradient(0deg, rgba(2,5,10,.9), transparent), radial-gradient(circle at 45% 35%, rgba(77,144,255,.35), transparent 30%), #101827; }
.room-card.entry-room { background: linear-gradient(0deg, rgba(2,5,10,.9), transparent), radial-gradient(circle at 75% 28%, rgba(215,141,78,.28), transparent 30%), #111923; }
.room-card > span { position: absolute; inset: auto 8px 8px; }
.room-card strong, .room-card small { display: block; }
.room-card strong { font-size: 10px; }
.room-card small { margin-top: 3px; color: #99a8bd; font-size: 7px; }
.home-summary {
  margin: 0 0 8px;
  padding: 0 2px;
  border: 0;
  color: #77869c;
  background: transparent;
  font-size: 9px;
}

.activity-metrics > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 94px;
  padding: 12px 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(16,29,49,.94), rgba(7,14,25,.92));
}
.activity-metrics span { margin-bottom: 5px; font-size: 22px; }
.activity-metrics .blue span { color: #58a3ff; }
.activity-metrics .violet span { color: #8e7bff; }
.activity-metrics .purple span { color: #bd68ff; }
.activity-metrics .red span { color: #ff667c; }
.activity-metrics strong { font-size: 19px; font-weight: 500; }
.activity-metrics small { margin-top: 2px; color: #8795aa; font-size: 8px; text-align: center; }
.activity-overview {
  margin: 11px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10,19,33,.62);
}
.activity-overview .overview { margin: 0 0 7px; font-size: 11px; }

.notify-panel {
  margin: 0 0 14px;
  padding: 12px 4px 4px;
}
.notify-panel .content-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.notify-hint {
  margin: 0 0 10px;
  color: #9aabbc;
  font-size: 12px;
  line-height: 1.4;
}
.notify-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.notify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(140, 170, 200, 0.12);
}
.notify-row:last-child { border-bottom: 0; }
.notify-copy strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #e7f1fa;
}
.notify-copy span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: #8fa3b5;
}
.notify-toggle {
  position: relative;
  width: 46px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(80, 100, 120, 0.45);
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s ease;
}
.notify-toggle.on { background: rgba(57, 136, 255, 0.85); }
.notify-toggle i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f2f7fc;
  transition: transform 0.15s ease;
}
.notify-toggle.on i { transform: translateX(18px); }
.text-btn {
  border: 0;
  background: transparent;
  color: #8eb7ff;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
}
.timeline-heading { margin-top: 14px; }
.live-label { color: #aebbd0 !important; }
.timeline {
  position: relative;
  gap: 6px;
  margin-left: 0;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 34px;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: rgba(86,125,180,.22);
}
.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 52px 34px 1fr;
  gap: 7px;
  align-items: center;
  min-height: 58px;
  padding: 7px 10px 7px 0;
  border-radius: 13px;
  font-size: 11px;
}
.timeline .when {
  z-index: 1;
  margin: 0;
  padding-right: 8px;
  color: #94a4ba;
  font-size: 8px;
  text-align: right;
}
.event-icon {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(76,185,255,.18);
  border-radius: 50%;
  color: #68d4ff;
  background: #0b1b2c;
  box-shadow: 0 0 12px rgba(41,148,226,.12);
  font-size: 15px;
}
.event-copy strong, .event-copy small { display: block; }
.event-copy strong { color: #e8edf7; font-size: 11px; font-weight: 500; }
.event-copy small { margin-top: 3px; color: #7e8ca2; font-size: 8px; }

/* Settings */
.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  align-items: end;
  padding: 16px;
  background: rgba(0,3,9,.76);
  backdrop-filter: blur(12px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(100%, 470px);
  max-height: 82vh;
  overflow: auto;
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #0a1120;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; }
.modal-head button { border: 0; background: none; color: var(--muted); font-size: 28px; }
.modal-sub { color: var(--muted); }
.modal label { display: grid; gap: 6px; color: #a6b2c5; font-size: 12px; }
.modal select { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #050a14; }
.volume-label { margin-top: 12px; }
.volume-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.volume-row input[type="range"] {
  flex: 1;
  accent-color: #5bd0ff;
}
#volumeValue {
  min-width: 3.2em;
  color: var(--ink);
  font-size: 14px;
}
.save-settings { width: 100%; margin-top: 10px; padding: 11px; border: 0; border-radius: 12px; background: linear-gradient(90deg, #3acfff, #a95dff); font-weight: 650; }
.modal pre { overflow: auto; max-height: 150px; padding: 10px; border-radius: 10px; background: #050a14; color: #75849a; font-size: 9px; }
.ha-card { min-height: 42vh; }
.ha-list { display: grid; gap: 8px; }
.ha-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.035);
}
.ha-row-copy { min-width: 0; }
.ha-row strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ha-row small {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: #748299;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ha-toggle {
  min-width: 56px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: #9ba9bf;
  font-size: 10px;
}
.ha-toggle.on {
  border-color: rgba(82,242,154,.25);
  color: var(--green);
  background: rgba(82,242,154,.08);
}
.ha-empty { padding: 20px 4px; color: var(--muted); font-size: 12px; text-align: center; }
.ha-value { color: #d9e5f8; font-size: 12px; }

/* Bottom navigation */
.tabbar {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(calc(100% - 24px), 476px);
  min-height: var(--nav);
  padding: 7px 18px max(7px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 25px 25px 0 0;
  background: rgba(5, 10, 20, .92);
  backdrop-filter: blur(18px);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #79869b;
  font-size: 10px;
  text-decoration: none;
}
.tabbar a.active { color: #d8eeff; text-shadow: 0 0 12px rgba(57,155,255,.8); }
.tabbar a.active svg { filter: drop-shadow(0 0 7px #3988ff); }

/* House dashboard */
.house-summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}
.house-summary-line button {
  border: 0;
  background: transparent;
  color: var(--cyan);
  padding: 0;
}
.house-list { display: grid; gap: 8px; }
.house-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(14, 24, 40, .72);
  text-align: left;
}
.house-row.dim { opacity: .55; }
.house-trail {
  min-width: 52px;
  text-align: right;
  font-size: 13px;
  color: var(--muted);
}
.house-trail.power, .house-trail.action {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255,255,255,.03);
  color: #c9d6ea;
}
.house-trail.power.on { color: var(--green); border-color: rgba(82,242,154,.35); }
.house-trail.value { font-variant-numeric: tabular-nums; }

/* Climate — room + outdoor, readable on small LCDs */
.climate-panel {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(154, 183, 221, .18);
  border-radius: 22px;
  background:
    radial-gradient(circle at 12% 0%, rgba(57, 207, 255, .16), transparent 42%),
    radial-gradient(circle at 88% 8%, rgba(255, 159, 102, .14), transparent 40%),
    linear-gradient(160deg, rgba(18, 32, 52, .95), rgba(10, 18, 32, .92));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.climate-room { padding: 18px 18px 14px; }
.climate-kicker {
  margin-bottom: 8px;
  color: #8ea3c0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.climate-hero {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.climate-temp {
  line-height: .9;
  font-size: clamp(52px, 18vw, 72px);
  font-weight: 300;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  color: #f4f8ff;
  text-shadow: 0 0 28px rgba(57, 207, 255, .25);
}
.climate-hero-meta {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
}
.climate-hero-meta strong {
  font-size: 15px;
  font-weight: 600;
  color: #dce7f8;
}
.climate-hero-meta small {
  color: #8d9bb2;
  font-size: 12px;
}
.climate-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.climate-stat {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(154, 183, 221, .1);
}
.climate-stat span {
  color: #7f8da5;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.climate-stat strong {
  font-size: 18px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  color: #e8eef8;
}
.climate-outside {
  padding: 14px 18px 16px;
  border-top: 1px solid rgba(154, 183, 221, .12);
  background: rgba(0, 0, 0, .16);
}
.climate-outside-main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}
.climate-glyph {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 186, 120, .1);
  font-size: 22px;
}
.climate-outside-main strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
  color: #f0f4ff;
}
.climate-outside-main small {
  display: block;
  margin-top: 3px;
  color: #8796ad;
  font-size: 12px;
}
.climate-out-temp {
  font-size: 28px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  color: #ffd7a8;
}

@media (max-height: 700px) {
  .climate-room { padding: 14px 14px 10px; }
  .climate-temp { font-size: clamp(44px, 16vw, 58px); }
  .climate-stats { margin-top: 12px; gap: 8px; }
  .climate-stat { padding: 8px 10px; }
  .climate-stat strong { font-size: 16px; }
  .climate-outside { padding: 12px 14px 14px; }
  .climate-out-temp { font-size: 24px; }
  .climate-glyph { width: 38px; height: 38px; font-size: 18px; }
}

.device-sheet, .camera-sheet { max-height: min(88dvh, 720px); overflow: auto; }
.device-controls { display: grid; gap: 14px; margin-top: 8px; }
.device-power {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(57, 136, 255, .16);
  color: #dcebff;
}
.device-power.on { background: rgba(82, 242, 154, .14); color: #baf8d4; }
.device-slider {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.device-slider em { color: var(--ink); font-style: normal; }
.device-slider input[type="range"] { width: 100%; accent-color: var(--cyan); }
.device-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.color-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255,255,255,.04);
  text-transform: capitalize;
}
.color-chip[data-tone="blue"] { color: #7ec8ff; }
.color-chip[data-tone="red"] { color: #ff8a96; }
.color-chip[data-tone="green"] { color: #7dffb0; }
.color-chip[data-tone="purple"] { color: #d09cff; }
.color-chip[data-tone="warm"] { color: #ffd29a; }
.color-chip[data-tone="daylight"],
.color-chip[data-tone="cool"] { color: #eef6ff; }
.device-media-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.device-media-actions button,
.camera-actions button {
  flex: 1;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
}
.device-note, .device-reading {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.device-reading {
  font-size: 28px;
  color: var(--ink);
  font-weight: 500;
}

.camera-stage {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: #000;
  aspect-ratio: 16 / 10;
}
.camera-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.camera-live-badge {
  position: absolute;
  top: 12px;
  left: 12px;
}
.camera-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.camera-ptz {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.camera-ptz button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  color: var(--ink);
}
.camera-ptz .ptz-home { grid-column: 2; }

/* Fullscreen camera viewer */
.modal.camera-fs {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  background: #000;
  z-index: 80;
}
.camera-fs-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  background: #000;
}
.camera-fs-frame {
  position: relative;
  min-height: 0;
  background: #000;
  overflow: hidden;
}
.camera-fs-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}
#cameraModalBoxes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.camera-fs-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 5;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.camera-fs-chrome {
  display: grid;
  gap: 10px;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, rgba(3, 7, 18, 0.92) 28%);
  color: #e8eef8;
}
.camera-fs-chrome .kicker {
  letter-spacing: 0.12em;
  font-size: 11px;
  color: #8ea0b8;
}
.camera-fs-chrome h2 {
  margin: 2px 0 0;
  font-size: 1.35rem;
}
.camera-fs-chrome .modal-sub {
  margin: 4px 0 0;
  color: #a6b2c5;
}
.camera-fs .camera-actions button {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  color: #e8eef8;
  padding: 10px 14px;
  cursor: pointer;
}
.camera-fs .camera-ptz[hidden] { display: none; }

@media (max-height: 700px) {
  .face-button { width: min(44vw, 205px); }
  .context { margin-bottom: 8px; }
  .latest-card { display: none; }
  .quick-button { min-height: 70px; padding: 8px; }
  .quick-icon { width: 23px; height: 23px; margin-bottom: 5px; }
}

@media (max-width: 370px) {
  .app { padding-inline: 12px; }
  .page-persona span { display: none; }
  .section-tabs button, .device-filters button { padding-inline: 12px; }
  .action-grid strong, .device-quick-grid strong { font-size: 8px; }
}

@media (max-height: 520px) and (min-width: 700px) {
  .app { width: 100%; max-width: none; padding: 8px 18px 70px; }
  .brandbar { min-height: 38px; }
  #view-home.active { display: grid; grid-template-columns: 45% 55%; gap: 10px 24px; align-items: center; }
  .persona { grid-row: 1/6; }
  .face-button { width: 210px; }
  .persona h1 { font-size: 18px; }
  .context { margin-bottom: 6px; }
  .talk-button { width: 280px; }
  .type-toggle { margin: 4px auto; }
  .system-line { margin: 4px 0; }
  .latest-card { display: none; }
  .home-controls { margin: 0; }
  .quick-grid { grid-template-columns: repeat(6, 1fr); }
  .quick-button { min-height: 64px; }
}
