/* ── Design tokens — light mode (default) ── */
:root {
  --bg:          #F5F5F3;
  --bg-card:     #FFFFFF;
  --bg-raised:   #EBEBEA;
  --bg-sunken:   #E4E4E2;
  --border:      #E5E5E3;
  --border-b:    rgba(0,0,0,.1);
  --text:        #111111;
  --text2:       rgba(17,17,17,.5);
  --text3:       rgba(17,17,17,.28);
  --gold:        #C9A84C;
  --gold-bg:     rgba(201,168,76,.1);
  --gold-border: rgba(201,168,76,.32);
  --green:       #10B981;
  --green-bg:    rgba(16,185,129,.1);
  --green-b:     rgba(16,185,129,.3);
  --red:         #EF4444;
  --red-bg:      rgba(239,68,68,.1);
  --red-b:       rgba(239,68,68,.3);
  --blue:        #3B82F6;
  --blue-bg:     rgba(59,130,246,.1);
  --blue-b:      rgba(59,130,246,.28);
  --amber:       #F59E0B;
  --amber-bg:    rgba(245,158,11,.1);
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
}

/* ── Dark mode overrides ── */
html.dark {
  --bg:          #0A0A0A;
  --bg-card:     #1A1A1A;
  --bg-raised:   #141414;
  --bg-sunken:   #111111;
  --border:      #242424;
  --border-b:    rgba(255,255,255,.07);
  --text:        #FFFFFF;
  --text2:       rgba(255,255,255,.45);
  --text3:       rgba(255,255,255,.22);
  --gold-bg:     rgba(201,168,76,.12);
  --gold-border: rgba(201,168,76,.28);
  --green-bg:    rgba(16,185,129,.1);
  --green-b:     rgba(16,185,129,.28);
  --red-bg:      rgba(239,68,68,.1);
  --red-b:       rgba(239,68,68,.28);
  --blue-bg:     rgba(59,130,246,.1);
  --blue-b:      rgba(59,130,246,.25);
  --amber-bg:    rgba(245,158,11,.1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; font-family: 'Space Grotesk', system-ui, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; font-size: 16px; }
button { font-family: inherit; }

/* ── Layout ── */
body { display: flex; flex-direction: column; transition: background .2s, color .2s; }

/* ── Header ── */
.hdr {
  flex-shrink: 0;
  padding: calc(var(--st) + 14px) calc(var(--sr) + 16px) 12px calc(var(--sl) + 16px);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.hdr-inner { display: flex; align-items: center; justify-content: space-between; }
.hdr-left { display: flex; align-items: center; gap: 10px; }
.greet  { font-size: 13px; font-weight: 500; color: var(--text2); letter-spacing: .01em; }
.hdr-actions { display: flex; align-items: center; gap: 8px; }
.hdr-logo { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }

/* ── Content ── */
.content {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px calc(var(--sr) + 14px) 20px calc(var(--sl) + 14px);
}

/* ── Tab bar ── */
.tab-bar {
  flex-shrink: 0; display: flex;
  background: var(--bg); border-top: 1px solid var(--border);
  padding-bottom: var(--sb);
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; padding: 12px 4px 10px; min-height: 56px;
  background: none; border: none; cursor: pointer;
  color: var(--text3); transition: color .15s;
}
.tab-btn.active { color: var(--gold); }
.tab-icon  { font-size: 20px; line-height: 1; }
.tab-label { font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(var(--sb) + 64px); left: 50%;
  transform: translateX(-50%) translateY(80px);
  opacity: 0;
  background: var(--bg-card); border: 1px solid var(--gold-border);
  border-radius: 100px; padding: 9px 18px; font-size: 13px; font-weight: 500;
  color: var(--text); white-space: nowrap; pointer-events: none; z-index: 999;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.toast.show  { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.ok    { color: var(--green); border-color: var(--green-b); }
.toast.err   { color: var(--red);   border-color: var(--red-b); }

/* "New version" toast — stays until tapped (or the app is backgrounded, which reloads it) */
.upd-toast {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 10px); left: 50%; z-index: 1000;
  transform: translate(-50%, -80px); opacity: 0; pointer-events: none;
  background: var(--bg-card); border: 1px solid var(--gold-border); border-radius: 100px;
  padding: 10px 18px; font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.25); cursor: pointer;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
}
.upd-toast b { color: var(--gold); font-weight: 600; }
.upd-toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }

/* ── Loader ── */
.loader { display: flex; align-items: center; justify-content: center; height: 120px; }
.spin { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: _spin .7s linear infinite; }
@keyframes _spin { to { transform: rotate(360deg); } }

/* ── Section label ── */
.slabel { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text3); margin: 10px 0 7px; }
.slabel:first-child { margin-top: 0; }
.sec { margin-bottom: 12px; }

/* ── Icon button ── */
.ibtn { width: 44px; height: 44px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 17px; color: var(--text2); transition: border-color .15s; }
.ibtn:hover { border-color: var(--gold-border); color: var(--gold); }

/* ── Base card ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; cursor: pointer; position: relative; overflow: hidden;
  user-select: none; transition: border-color .18s, background .18s;
}
.card:active { transform: scale(.97); }
.card.on   { background: var(--bg-card); border-color: var(--gold-border); }
.card.busy { opacity: .55; pointer-events: none; }
.card.ok   { border-color: var(--green-b); }
.card.fail { border-color: var(--red-b); }

.cglow { position: absolute; top: -20px; right: -20px; width: 70px; height: 70px; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .3s; }
.card.on .cglow { opacity: .12; }

.cico { width: 40px; height: 40px; background: var(--bg-raised); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 19px; margin-bottom: 10px; transition: background .18s; }
.card.on .cico { background: var(--gold-bg); }
.cname { font-size: 12px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.croom { font-size: 10px; color: var(--text3); margin-top: 1px; font-weight: 500; }
.cst   { font-size: 10px; color: var(--text3); margin-top: 3px; min-height: 14px; font-weight: 500; }
.card.on   .cst { color: var(--gold); }
.card.ok   .cst { color: var(--green); }
.card.fail .cst { color: var(--red); }

/* ── Shared grid ── */
.grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }

/* ── Shared buttons ── */
.btn { padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; text-align: center; transition: all .15s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn:active  { opacity: .8; }
.btn-gold    { background: var(--gold-bg); border-color: var(--gold-border); color: var(--gold); }
.btn-green   { background: var(--green-bg); border-color: var(--green-b); color: var(--green); }
.btn-wa      { background: #25D366; border-color: #25D366; color: #fff; }
.btn.ok      { border-color: var(--green-b); color: var(--green); background: var(--green-bg); }

/* ── Shared inputs ── */
.inp { width: 100%; padding: 11px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; font-size: 15px; color: var(--text); outline: none; -webkit-appearance: none; font-family: inherit; transition: border-color .15s; }
.inp:focus { border-color: var(--gold); }
.inp::placeholder { color: var(--text3); }

/* ── Action row ── */
.action-row { display: flex; gap: 8px; }
.action-row .btn { flex: 1; }
.action-row .btn-wa { flex: 1.5; }

/* ── Message box ── */
.msg-box { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 10px; padding: 14px; font-size: 14px; white-space: pre-wrap; line-height: 1.9; min-height: 80px; color: var(--text); margin-bottom: 10px; font-family: inherit; }

/* ── Misc ── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.empty   { text-align: center; padding: 32px 16px; color: var(--text2); font-size: 14px; line-height: 2; }
.trans-preview { font-size: 13px; color: var(--gold); min-height: 18px; padding: 0 2px; margin-bottom: 6px; font-weight: 500; }


/* ════════════════════════════════════════
   GROCERIES TAB
════════════════════════════════════════ */
.cat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 16px; }
.cat-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 4px 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); cursor: pointer; gap: 4px; min-height: 64px; transition: all .15s; }
.cat-tile.active         { background: var(--gold-bg); border-color: var(--gold-border); }
.cat-tile-emoji          { font-size: 22px; line-height: 1; }
.cat-tile-label          { font-size: 11px; font-weight: 600; color: var(--text2); text-align: center; line-height: 1.1; }
.cat-tile.active .cat-tile-label { color: var(--gold); }

.items-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.item-row { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); min-height: 60px; transition: border-color .15s, background .15s; }
.item-row.selected { border-color: var(--gold-border); background: var(--gold-bg); }

.item-card { border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); transition: border-color .15s, background .15s; }
.item-card.selected { border-color: var(--gold-border); background: var(--gold-bg); }
.item-row-inner { display: flex; align-items: center; gap: 10px; padding: 12px; min-height: 60px; }

.check-circle { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; color: var(--text3); background: var(--bg-raised); cursor: pointer; transition: all .15s; }
.item-row.selected .check-circle, .item-card.selected .check-circle { background: var(--gold); border-color: var(--gold); color: #fff; font-size: 13px; }

.item-emoji { font-size: 20px; flex-shrink: 0; width: 26px; text-align: center; cursor: pointer; }
.item-text  { flex: 1; min-width: 0; cursor: pointer; }
.item-en    { font-size: 15px; font-weight: 500; line-height: 1.2; letter-spacing: -.01em; }
.item-ta    { font-size: 12px; color: var(--text2); margin-top: 2px; }

.item-qty  { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.qty-in    { width: 48px; padding: 6px 4px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; text-align: center; background: var(--bg-raised); color: var(--text); outline: none; -webkit-appearance: none; font-family: inherit; }
.unit-sel  { padding: 6px 4px; border: 1px solid var(--border); border-radius: 7px; font-size: 12px; background: var(--bg-raised); color: var(--text2); outline: none; cursor: pointer; max-width: 52px; -webkit-appearance: none; appearance: none; text-align: center; font-family: inherit; }

.cut-row  { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px 46px; margin-top: -6px; }
.cut-btn  { padding: 5px 10px; border-radius: 100px; border: 1px solid var(--border); background: var(--bg-raised); color: var(--text2); font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit; transition: all .15s; }
.cut-btn.active { background: var(--gold-bg); border-color: var(--gold-border); color: var(--gold); }

.basket-head { display: flex; align-items: center; justify-content: space-between; }
.clear-lnk   { font-size: 12px; color: var(--red); cursor: pointer; background: none; border: none; font-weight: 600; letter-spacing: .01em; }

.pills-wrap { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.pill-item  { padding: 5px 11px 5px 10px; border-radius: 100px; background: var(--gold-bg); border: 1px solid var(--gold-border); font-size: 13px; color: var(--gold); display: flex; align-items: center; gap: 5px; font-weight: 500; }
.pill-x     { cursor: pointer; font-size: 17px; line-height: 1; opacity: .7; }

.lang-row  { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.lang-btn  { flex: 1; padding: 10px 4px; font-size: 12px; border: none; background: var(--bg-card); color: var(--text2); cursor: pointer; text-align: center; font-weight: 600; border-right: 1px solid var(--border); font-family: inherit; transition: all .15s; }
.lang-btn:last-child { border-right: none; }
.lang-btn.active { background: var(--gold-bg); color: var(--gold); }

.add-row   { display: flex; gap: 8px; margin-bottom: 6px; }
.sr-footer { text-align: center; margin-top: 20px; font-size: 11px; color: var(--text3); line-height: 1.9; }


/* ════════════════════════════════════════
   SMART HOME TAB
════════════════════════════════════════ */
.home-status-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.room-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.rcard { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 5px; transition: border-color .15s; }
.rcard:active { transform: scale(.97); }
.rcard-top { display: flex; align-items: center; gap: 6px; }
.ricon { font-size: 18px; }
.rname { font-size: 13px; font-weight: 700; letter-spacing: -.02em; }
.rsub  { font-size: 10px; color: var(--text2); font-weight: 500; }
.rdots { display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.rdot  { width: 5px; height: 5px; border-radius: 50%; background: var(--bg-sunken); flex-shrink: 0; }
.rdot.on { background: var(--gold); }
.rbtns { display: flex; gap: 5px; }
.rbtn  { flex: 1; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 7px; padding: 7px 4px; min-height: 34px; font-size: 11px; cursor: pointer; color: var(--text2); font-family: inherit; text-align: center; font-weight: 500; transition: all .15s; }
.rbtn:active { background: var(--gold-bg); color: var(--gold); border-color: var(--gold-border); }

/* room back header — sticky while scrolling inside a room */
.room-back-hdr { display: none; align-items: center; gap: 10px; }
.room-back-hdr.show { display: flex; position: sticky; top: 0; z-index: 10; background: var(--bg); padding-bottom: 12px; margin-bottom: 4px; }
.back-btn { width: 44px; height: 44px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 17px; color: var(--text2); flex-shrink: 0; transition: all .15s; }
.back-btn:hover { border-color: var(--gold-border); color: var(--gold); }
.room-back-title { font-size: 17px; font-weight: 700; letter-spacing: -.03em; }

.curtain-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; min-height: 160px; display: flex; flex-direction: column; justify-content: space-between; transition: border-color .15s; }
.curtain-card.busy { opacity: .55; pointer-events: none; }
.curtain-card.ok   { border-color: var(--green-b); }
.curtain-card.fail { border-color: var(--red-b); }
.cbtns { display: flex; gap: 5px; margin-top: 8px; }
.cbtn  { flex: 1; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 7px; padding: 11px 0; min-height: 44px; font-size: 12px; cursor: pointer; color: var(--text2); font-family: inherit; text-align: center; font-weight: 500; transition: background .15s; }
.cbtn:active { background: var(--gold-bg); border-color: var(--gold-border); color: var(--gold); }

.lbadge { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 100px; margin-top: 6px; letter-spacing: .02em; }
.lbadge.locked   { background: var(--green-bg); color: var(--green); }
.lbadge.unlocked { background: var(--red-bg);   color: var(--red); }

.acbtns { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.acbtn  { padding: 10px 14px; min-height: 40px; border-radius: 8px; background: var(--bg-raised); border: 1px solid var(--border); font-size: 11px; cursor: pointer; color: var(--text2); font-family: inherit; font-weight: 500; transition: all .15s; }
.acbtn:active { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-b); }
.acbtn.active { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-b); }
.actemp { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.atbtn  { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-raised); border: 1px solid var(--border); cursor: pointer; font-size: 18px; color: var(--text2); display: flex; align-items: center; justify-content: center; font-family: inherit; transition: all .15s; }
.atbtn:active { background: var(--gold-bg); color: var(--gold); }
.atval  { font-size: 13px; font-weight: 600; min-width: 30px; text-align: center; }
.atlabel { font-size: 10px; color: var(--text3); font-weight: 500; }
/* Fan card compact controls */
.fan-row { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.fan-lbl  { font-size: 10px; color: var(--text3); font-weight: 500; min-width: 34px; }
.fan-val  { font-size: 11px; font-weight: 600; min-width: 14px; text-align: right; color: var(--text2); }
.fan-slider { flex: 1; height: 3px; cursor: pointer; accent-color: var(--gold); }
.fan-light-row { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.fan-light-row .led-btn { padding: 0 10px; min-height: 26px; font-size: 13px; flex-shrink: 0; }
.fan-mode { display: flex; flex: 1; border-radius: 7px; overflow: hidden; border: 1px solid var(--border); }
.fan-mode-btn { flex: 1; padding: 5px 0; font-size: 10px; font-weight: 500; background: var(--bg-raised); border: none; border-left: 1px solid var(--border); cursor: pointer; color: var(--text2); font-family: inherit; transition: all .15s; }
.fan-mode-btn:first-child { border-left: none; }
.fan-mode-btn.active { background: var(--blue-bg); color: var(--blue); }

.srow  { display: flex; flex-direction: column; gap: 8px; }
.scard { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; cursor: pointer; display: flex; align-items: center; gap: 12px; transition: border-color .15s, background .15s; }
.scard:active { transform: scale(.98); }
.scard.ok   { border-color: var(--green-b); background: var(--green-bg); }
.scard.busy { opacity: .55; pointer-events: none; }
.siwrap { width: 40px; height: 40px; border-radius: 10px; background: var(--bg-raised); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.sname  { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.ssub   { font-size: 11px; color: var(--text2); margin-top: 2px; font-weight: 500; }


/* ════════════════════════════════════════
   SCHEDULE TAB
════════════════════════════════════════ */
.inner-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.itab { flex: 1; padding: 10px 4px 11px; border: none; font-size: 13px; font-weight: 600; cursor: pointer; text-align: center; background: transparent; color: var(--text3); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s; letter-spacing: .01em; font-family: inherit; }
.itab.active { color: var(--text); border-bottom-color: var(--gold); }
.itab-pane        { display: none; }
.itab-pane.active { display: block; }

.sync-badge { font-size: 10px; color: var(--green); display: flex; align-items: center; gap: 4px; font-weight: 500; }
.sync-dot   { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; }
.sync-dot.loading { background: var(--amber); animation: _blink 1s infinite; }
.sync-dot.error   { background: var(--red); }
@keyframes _blink { 0%,100% { opacity:1; } 50% { opacity:.3; } }

.alert-card  { background: var(--red-bg); border-left: 3px solid var(--red); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; font-size: 13px; line-height: 1.7; }
.alert-title { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--red); margin-bottom: 5px; }

.rooms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.room-tile { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 11px 10px 10px; cursor: pointer; min-height: 84px; display: flex; flex-direction: column; gap: 4px; transition: border-color .12s, background .12s; }
.room-tile.selected  { border-color: var(--blue-b); background: var(--blue-bg); }
.room-tile.overdue   { border-left: 3px solid var(--red); }
.room-tile.due-soon  { border-left: 3px solid var(--amber); }
.tile-top   { display: flex; align-items: center; gap: 6px; }
.tile-emoji { font-size: 18px; flex-shrink: 0; }
.tile-name  { font-size: 12px; font-weight: 600; line-height: 1.25; flex: 1; letter-spacing: -.01em; }
.tile-check { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--bg-raised); display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; transition: all .15s; }
.room-tile.selected .tile-check { background: var(--blue); border-color: var(--blue); color: #fff; }
.tile-last  { font-size: 10px; color: var(--text2); padding-left: 24px; }
.tile-badge { display: inline-block; font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 6px; margin-left: 24px; align-self: flex-start; letter-spacing: .03em; }
.badge-overdue { background: var(--red-bg);   color: var(--red); }
.badge-soon    { background: var(--amber-bg);  color: var(--amber); }
.badge-ok      { background: var(--green-bg);  color: var(--green); }
.badge-never   { background: var(--bg-sunken); color: var(--text3); }

.task-wrap { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; padding-left: 24px; }
.task-chip { font-size: 10px; padding: 3px 7px; border-radius: 6px; background: var(--bg-raised); color: var(--text2); cursor: pointer; border: 1px solid var(--border); font-weight: 500; transition: all .15s; }
.task-chip.on { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-b); }

.extra-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 4px; }
.extra-pill    { display: inline-flex; align-items: center; gap: 4px; background: var(--blue-bg); border: 1px solid var(--blue-b); border-radius: 7px; padding: 3px 8px; font-size: 11px; color: var(--blue); font-weight: 500; }
.extra-pill-x  { cursor: pointer; font-size: 13px; opacity: .7; }

.schedule-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.schedule-section-title { padding: 10px 14px; background: var(--bg-raised); border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; }
.sched-table    { width: 100%; border-collapse: collapse; }
.sched-table th { font-size: 10px; font-weight: 700; color: var(--text3); text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-raised); text-transform: uppercase; letter-spacing: .06em; }
.sched-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.sched-table tr:last-child td { border-bottom: none; }
.freq-pill      { display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--blue-bg); color: var(--blue); }
.freq-pill.deep { background: var(--amber-bg); color: var(--amber); }

.log-card       { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.log-card-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; letter-spacing: -.01em; }
.ev-sublabel    { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.photo-btns     { display: flex; gap: 8px; margin-bottom: 14px; }
.photo-btn { flex: 1; padding: 11px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-raised); font-size: 13px; cursor: pointer; font-weight: 600; text-align: center; color: var(--text); font-family: inherit; transition: all .15s; }
.photo-btn.yes { border-color: var(--green-b); background: var(--green-bg); color: var(--green); }
.photo-btn.no  { border-color: var(--red-b);   background: var(--red-bg);   color: var(--red); }

.morning-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; transition: all .15s; }
.morning-item.done    { border-color: var(--green-b); background: var(--green-bg); }
.morning-item.skipped { border-color: var(--red-b);   background: var(--red-bg); }
.mi-check { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; background: var(--bg-card); transition: all .15s; }
.morning-item.done    .mi-check { background: var(--green); border-color: var(--green); color: #fff; }
.morning-item.skipped .mi-check { background: var(--red);   border-color: var(--red);   color: #fff; }
.mi-text  { flex: 1; font-size: 13px; line-height: 1.4; }
.mi-tasks { font-size: 11px; color: var(--text2); margin-top: 1px; }
.mi-btns  { display: flex; gap: 5px; flex-shrink: 0; }
.mi-btn   { padding: 4px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg-card); font-size: 11px; cursor: pointer; font-weight: 600; color: var(--text2); font-family: inherit; transition: all .15s; }
.mi-btn.done-a { background: var(--green-bg); color: var(--green); border-color: var(--green-b); }
.mi-btn.skip-a { background: var(--red-bg);   color: var(--red);   border-color: var(--red-b); }

.ev-notes { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; background: var(--bg-raised); color: var(--text); outline: none; resize: none; font-family: inherit; margin-top: 10px; transition: border-color .15s; }
.ev-notes:focus { border-color: var(--gold); }

.past-log-item   { background: var(--bg-raised); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.past-log-date   { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 6px; letter-spacing: .02em; }
.past-log-rooms  { font-size: 13px; line-height: 1.7; }
.past-log-skip   { font-size: 12px; color: var(--red); margin-top: 3px; }
.past-log-photo  { font-size: 12px; margin-top: 4px; font-weight: 600; }
.past-log-photo.yes { color: var(--green); }
.past-log-photo.no  { color: var(--red); }
.past-log-note   { font-size: 12px; color: var(--text2); margin-top: 3px; font-style: italic; }

.suggest-card { background: var(--blue-bg); border: 1px solid var(--blue-b); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 13px; line-height: 1.6; display: flex; gap: 8px; }
.no-morning   { text-align: center; padding: 20px; color: var(--text2); font-size: 13px; line-height: 1.8; background: var(--bg-raised); border-radius: 10px; }

/* ── Power tab (energy meter) ─────────────────────────────────────────────
   Series colours are the validated categorical slots 1-3, stepped per mode.
   Aqua sits at 2.82:1 on the light surface, so phase identity is always
   carried by a direct label and the table view as well as by colour. */
:root {
  --pw-s1: #2a78d6;
  --pw-s2: #eb6834;
  --pw-s3: #1baf7a;
  --pw-s4: #eda100;
  --pw-warn: #b45309;
}
html.dark {
  --pw-s1: #3987e5;
  --pw-s2: #d95926;
  --pw-s3: #199e70;
  --pw-s4: #c98500;
  --pw-warn: #f0a94c;
}

.pw { padding: 0 14px 90px; }
.pw-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; margin-bottom: 12px;
}
.pw-sec-h {
  font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text); opacity: .62; margin: 2px 0 10px; display: flex; gap: 8px; align-items: baseline;
}
.pw-count { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .7; font-size: 11px; }
.pw-empty { padding: 22px 6px; text-align: center; opacity: .55; font-size: 13px; }
.pw-note { font-size: 11px; opacity: .55; line-height: 1.5; margin-top: 10px; }
.pw-warn {
  background: color-mix(in srgb, var(--pw-warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--pw-warn) 35%, transparent);
  color: var(--text); border-radius: 10px; padding: 10px 12px;
  font-size: 12px; line-height: 1.5; margin: 10px 0;
}

/* live header + hero */
.pw-live-hdr { display: flex; align-items: center; gap: 7px; font-size: 11px; opacity: .6; margin-bottom: 10px; }
.pw-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pw-s3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pw-s3) 22%, transparent); }
.pw-dot-stale { background: var(--pw-warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pw-warn) 22%, transparent); }
.pw-hero { margin: 4px 0 14px; }
.pw-hero-v { font-size: 44px; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.pw-hero-u { font-size: 17px; font-weight: 500; opacity: .5; margin-left: 6px; }
.pw-hero-l { font-size: 11px; opacity: .55; margin-top: 6px; }

/* stat tiles */
.pw-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.pw-tile { background: var(--bg-raised); border-radius: 10px; padding: 9px 10px; }
.pw-tile-l { font-size: 10px; opacity: .55; text-transform: uppercase; letter-spacing: .04em; }
.pw-tile-v { font-size: 19px; font-weight: 600; margin-top: 3px; letter-spacing: -.01em; }
.pw-tile-u { font-size: 11px; opacity: .5; margin-left: 3px; font-weight: 500; }
.pw-tile-s { font-size: 10px; opacity: .5; margin-top: 2px; }
.pw-tile.pw-warn { background: color-mix(in srgb, var(--pw-warn) 10%, var(--bg-raised)); border: 0; margin: 0; padding: 9px 10px; border-radius: 10px; }

/* per-phase strip */
.pw-phase-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.pw-ph { background: var(--bg-raised); border-radius: 10px; padding: 9px; }
.pw-ph-top { display: flex; align-items: center; gap: 5px; font-size: 10px; opacity: .65; }
.pw-ph-top i, .pw-lg i, .pw-bal-n i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }
.pw-ph-v { font-size: 16px; font-weight: 600; margin: 4px 0 5px; }
.pw-ph-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.pw-ph-bar span { display: block; height: 100%; border-radius: 2px; }
.pw-ph-s { font-size: 10px; opacity: .5; margin-top: 5px; }

/* range + metric bars */
.pw-rangebar, .pw-metricbar { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.pw-metricbar { margin: -2px 0 10px; }
.pw-rb, .pw-mb, .pw-btn {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 7px 13px; font-size: 12px; font-weight: 500;
  font-family: inherit; cursor: pointer;
}
.pw-mb { padding: 5px 11px; font-size: 11px; }
.pw-rb-a, .pw-mb-a { background: var(--gold); border-color: var(--gold); color: #111; }
.pw-custom { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.pw-input {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 8px 11px; font-size: 12px; font-family: inherit; flex: 1; min-width: 120px;
}
.pw-input-s { max-width: 100px; flex: 0 0 auto; }
.pw-filters { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }

/* chart */
.pw-chart-wrap { position: relative; width: 100%; }
/* width/height are set as attributes at draw time so type is never rescaled */
.pw-svg { display: block; overflow: visible; }
.pw-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.pw-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.pw-axis { fill: var(--text); opacity: .42; font-size: 11px; font-family: inherit; }
.pw-dlabel { font-size: 11px; font-weight: 600; font-family: inherit; }
.pw-cross { stroke: var(--text); opacity: .3; stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.pw-legend { display: flex; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.pw-lg { display: flex; align-items: center; gap: 5px; font-size: 11px; opacity: .7; }
.pw-tip {
  position: absolute; top: 4px; pointer-events: none; z-index: 5;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 9px; font-size: 11px; box-shadow: 0 4px 18px rgba(0,0,0,.16); min-width: 108px;
}
.pw-tip-t { opacity: .55; margin-bottom: 4px; font-size: 10px; }
.pw-tip-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.pw-tip-row i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.pw-tip-row span { opacity: .7; }
.pw-tip-row b { margin-left: auto; font-weight: 600; }

/* balance bars */
.pw-balance { display: flex; flex-direction: column; gap: 7px; }
.pw-bal-row { display: flex; align-items: center; gap: 9px; font-size: 11px; }
.pw-bal-n { display: flex; align-items: center; gap: 5px; width: 74px; flex: none; opacity: .7; }
.pw-bal-bar { flex: 1; height: 7px; background: var(--bg-raised); border-radius: 4px; overflow: hidden; }
.pw-bal-bar span { display: block; height: 100%; border-radius: 4px; }
.pw-bal-v { width: 46px; text-align: right; font-weight: 600; }

/* table */
.pw-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pw-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.pw-table th {
  text-align: right; padding: 7px 8px; font-weight: 600; font-size: 10px;
  text-transform: uppercase; letter-spacing: .04em; opacity: .55;
  border-bottom: 1px solid var(--border); cursor: pointer; white-space: nowrap;
}
.pw-table th:first-child, .pw-table td:first-child { text-align: left; }
.pw-table th.pw-th-a { opacity: .9; }
.pw-arrow { font-size: 8px; }
.pw-table td { padding: 6px 8px; text-align: right; border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); white-space: nowrap; }
.pw-table tbody tr:hover { background: var(--bg-raised); }

/* Units-consumed panel — per-day stacked bands from the meter's counter */
.pw-hero-sm .pw-hero-v { font-size: 34px; }
.pw-edays { display: flex; flex-direction: column; gap: 12px; }
.pw-eday-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.pw-eday-d { font-size: 12px; font-weight: 600; }
.pw-eday-t { font-size: 14px; font-weight: 600; }
.pw-eday-u { font-size: 10px; opacity: .5; font-weight: 500; }
/* 2px surface gap between stacked segments, per the mark spec */
.pw-ebar {
  display: flex; height: 12px; border-radius: 6px; overflow: hidden;
  background: var(--bg-raised); gap: 2px;
}
.pw-eseg { display: block; height: 100%; }
.pw-eseg:first-child { border-radius: 6px 0 0 6px; }
.pw-eseg:last-child { border-radius: 0 6px 6px 0; }
.pw-ebands { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; }
.pw-eb { display: flex; align-items: center; gap: 5px; font-size: 10.5px; opacity: .7; }
.pw-eb i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.pw-eb b { font-weight: 600; opacity: 1; }
.pw-eb-n { font-style: normal; font-size: 9px; opacity: .5; margin-left: 3px;
           border: 1px solid var(--border); border-radius: 4px; padding: 0 3px; }


/* ════════════════════════════════════════
   TV TAB
════════════════════════════════════════ */
/* Top bar: back-to-room, compact TV chip (tap to switch), power */
.tv-top { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.tv-backroom { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border-radius: 100px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text2); font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.tv-backroom .tv-ic { width: 18px; height: 18px; }
.tv-chip { flex-shrink: 0; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 100px; border: 1px solid var(--border); background: none; color: var(--text2); font-family: inherit; cursor: pointer; margin-left: auto; min-width: 0; }
.tv-chip.off { cursor: default; }
.tv-chip-name { font-size: 12px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.tv-chip .tv-ic.sm { width: 14px; height: 14px; color: var(--text3); }
.tv-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text3); flex-shrink: 0; }
.tv-dot.on   { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.tv-dot.stby { background: var(--amber); }
.tv-power { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); color: var(--text2); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: color .15s, border-color .15s, background .15s; }
.tv-power .tv-ic { width: 18px; height: 18px; }
.tv-power.on { color: var(--gold); border-color: var(--gold-border); background: var(--gold-bg); }
.tv-power.off { opacity: .35; pointer-events: none; }

.tv-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--red-bg); border: 1px solid var(--red-b); border-radius: 12px; padding: 11px 13px; font-size: 13px; line-height: 1.45; margin-bottom: 12px; }
.tv-banner.ok { background: var(--green-bg); border-color: var(--green-b); }
.tv-banner-acts { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.tv-banner-acts .btn { padding: 8px 12px; font-size: 13px; }

.tv-remote { display: flex; flex-direction: column; gap: 20px; padding-bottom: 8px; transition: opacity .2s; }
.tv-remote.muted { opacity: .4; }

.tv-ic { width: 24px; height: 24px; display: block; }

/* Apps */
.tv-apps { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tv-apps::-webkit-scrollbar { display: none; }
.tv-app { position: relative; flex-shrink: 0; width: 36px; height: 36px; padding: 9px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-family: inherit; font-size: 9px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; overflow: hidden; -webkit-tap-highlight-color: transparent; transition: transform .08s, color .1s; }
.tv-app.wide { padding: 8px 6px; }
.tv-app svg { width: 100%; height: 100%; display: block; }
.tv-app:active { transform: scale(.92); color: var(--gold); border-color: var(--gold-border); }

/* Shared key */
.tv-k { display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-family: inherit; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: background .08s, color .08s, transform .08s; }
.tv-k.down { background: var(--gold-bg); border-color: var(--gold-border); color: var(--gold); transform: scale(.94); }
.tv-k.round { width: 64px; height: 64px; border-radius: 50%; }
.tv-k.round.big { width: 76px; height: 76px; }
.tv-k.round.big .tv-ic { width: 28px; height: 28px; }

/* D-pad: one big disc, four edge zones, centre select */
.tv-pad { position: relative; width: min(296px, 76vw); aspect-ratio: 1; margin: 0 auto; border-radius: 50%; background: var(--bg-card); border: 1px solid var(--border); box-shadow: inset 0 1px 0 var(--border-b), 0 10px 30px -18px rgba(0,0,0,.45); }
.tv-pad .tv-k { position: absolute; border: none; background: none; color: var(--text2); border-radius: 50%; }
.tv-pad .tv-k .tv-ic { width: 26px; height: 26px; }
.tv-pad .tv-k.down { background: var(--gold-bg); color: var(--gold); transform: none; }
.tv-pad .pad-up { top: 0; left: 28%; width: 44%; height: 30%; border-radius: 50% 50% 18% 18% / 70% 70% 30% 30%; }
.tv-pad .pad-dn { bottom: 0; left: 28%; width: 44%; height: 30%; border-radius: 18% 18% 50% 50% / 30% 30% 70% 70%; }
.tv-pad .pad-l  { left: 0; top: 28%; width: 30%; height: 44%; border-radius: 70% 30% 30% 70% / 50% 18% 18% 50%; }
.tv-pad .pad-r  { right: 0; top: 28%; width: 30%; height: 44%; border-radius: 30% 70% 70% 30% / 18% 50% 50% 18%; }
.tv-pad .pad-ok { left: 31%; top: 31%; width: 38%; height: 38%; background: var(--bg-raised); border: 1px solid var(--border); box-shadow: 0 1px 0 var(--border-b) inset; }
.tv-pad .pad-ok.down { background: var(--gold-bg); border-color: var(--gold-border); transform: scale(.96); }

/* Back / Home / Input / Options */
.tv-nav { display: flex; justify-content: space-evenly; }
.tv-rb { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tv-rb > span { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text3); }

/* Transport + mute, volume rocker */
.tv-bottom { display: grid; grid-template-columns: 1fr 70px; gap: 14px; align-items: stretch; }
.tv-media { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.tv-trans { display: flex; align-items: center; justify-content: space-evenly; }
.tv-mute { gap: 8px; height: 50px; border-radius: 100px; font-size: 13px; font-weight: 600; color: var(--text2); }
.tv-mute .tv-ic { width: 20px; height: 20px; }
.tv-vol { display: flex; flex-direction: column; align-items: stretch; background: var(--bg-card); border: 1px solid var(--border); border-radius: 36px; overflow: hidden; }
.tv-vol .tv-k { flex: 1; border: none; background: none; min-height: 62px; border-radius: 0; }
.tv-vol .tv-k.down { background: var(--gold-bg); transform: none; }
.tv-vol-lbl { text-align: center; font-size: 9px; font-weight: 700; letter-spacing: .14em; color: var(--text3); }

.tv-type { display: flex; gap: 8px; align-items: center; height: 46px; }
.tv-type[hidden], .tv-apps[hidden] { display: none; }
.tv-type .inp { flex: 1; height: 44px; font-size: 16px; }
.tv-type .btn { width: 44px; height: 44px; padding: 0; display: flex; align-items: center; justify-content: center; }
.tv-type .btn .tv-ic { width: 20px; height: 20px; }
.tv-type-x { width: 36px; height: 36px; border: none; background: none; color: var(--text3); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.tv-type-x .tv-ic { width: 18px; height: 18px; }

/* Every control is a <label> around a hidden switch, so a real tap gives the iOS haptic tick */
.tv-hap { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
label.tv-k, label.tv-app, label.tv-power, label.tv-chip, label.tv-backroom, label.tv-side { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.tv-type.ask .inp { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-bg); }

/* Manual keyboard button — only when the relay can't report the TV's keyboard */
.tv-padwrap { position: relative; }
.tv-side { position: absolute; top: 0; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); color: var(--text2); display: flex; align-items: center; justify-content: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tv-side .tv-ic { width: 19px; height: 19px; }
.tv-side.sl { left: 0; }
.tv-side:active { color: var(--gold); border-color: var(--gold-border); background: var(--gold-bg); }

/* Room card icon */
.tv-cico .tv-ic { width: 21px; height: 21px; color: var(--text2); }
.card.on .tv-cico .tv-ic { color: var(--gold); }

/* ── Cameras (go2rtc on pi-auto) ── */
.cam-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.cam-tile { display: block; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); overflow: hidden; cursor: pointer; font-family: inherit; text-align: left; color: var(--text); }
.cam-img { position: relative; aspect-ratio: 16/9; background: var(--bg-sunken); }
.cam-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-img img:not([src]) { display: none; }
.cam-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text3); }
.cam-tile.off .cam-wait { color: var(--red); }
.cam-name { font-size: 12px; font-weight: 600; padding: 7px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-msg { font-size: 13px; line-height: 1.5; color: var(--text2); background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.cam-msg b { color: var(--text); }
.cam-retry, .cam-hik { margin-top: 10px; height: 36px; padding: 0 16px; border-radius: 100px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text2); font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.cam-foot { display: flex; justify-content: center; margin: 6px 0 16px; }
.cam-ov { position: fixed; inset: 0; z-index: 200; background: #000; display: flex; flex-direction: column; padding: var(--st) var(--sr) var(--sb) var(--sl); }
.cam-ov-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; color: #fff; }
.cam-ov-name { flex: 1; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-ov-q, .cam-ov-x { height: 34px; min-width: 34px; padding: 0 12px; border-radius: 100px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.cam-ov-frame { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.cam-ov-frame iframe { width: 100%; aspect-ratio: 16/9; max-height: 100%; border: 0; background: #000; }
.cam-ov-hint { text-align: center; font-size: 11px; color: rgba(255,255,255,.45); padding: 10px; }
.pw-eb-hi { color: var(--pw-warn); font-weight: 600; }
.pw-eb-sub { font-size: 10px; opacity: .5; }
.curtain-card.cgroup { grid-column: 1 / -1; min-height: 0; gap: 8px; }
.cscope { flex: none; }
.cscope .fan-mode-btn { padding: 9px 0; font-size: 12px; }
.cscope .fan-mode-btn.active { background: var(--gold-bg); color: var(--gold); }
.fan-net { position: absolute; top: 12px; right: 12px; font-size: 9px; font-weight: 600; letter-spacing: .03em; padding: 2px 7px; border-radius: 99px; }
.fan-net.up   { color: var(--green, #4ecb8d); background: color-mix(in srgb, #4ecb8d 14%, transparent); }
.fan-net.down { color: var(--text3); background: var(--bg-raised); }
.card.fan-off .cico, .card.fan-off .cname { opacity: .55; }
.card.lcard { cursor: default; }
.card.lcard:active { transform: none; }
.card.lcard.ok   { border-color: var(--green-b); }
.card.lcard.fail { border-color: var(--red-b); }
