/* QiHome Web — consumer smart-home UI. Tokens follow QiHome/CrossPlatform/DesignTokens/tokens.json. */
:root {
  /* motion: one set of curves for the whole app (emil-design-eng / improve-animations) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1); --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1); --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-press: 160ms; --dur-ui: 200ms; --dur-sheet: 320ms;
  /* "Warm light": a warm-paper / near-black ground, warm light for actions and for what is on, cool light for AI
     and selection, thin figures. Every page reads these variables — new pages use them, never their own colours. */
  --bg: #efede9;
  --surface: #ffffff;
  --surface-2: #f5f3ef;
  --ink: #141518;
  --muted: #5f6269;
  --line: rgba(20, 22, 26, .08);
  --switch-off: #dcd8d1; /* an off switch's track: visible on a card and on --surface-2 alike */
  --brand: #b25e17;
  --on-brand: #ffffff;
  --brand-2: #1673b8;
  --on: #ffb45a;
  --on-ink: #1a1206;
  --glow: #ffb45a;
  --cool: #1673b8;
  --good: #1e8f5a;
  --warn: #c2410c;
  --bad: #c8372d;
  --glass: rgba(255, 255, 255, .62);
  --glass-line: rgba(255, 255, 255, .9);
  --side: #f5f3ef;
  --hover: rgba(20, 22, 26, .045);
  --selected: color-mix(in srgb, var(--brand) 11%, transparent);
  --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 18px 48px rgba(40, 36, 30, .08);
  --radius-card: 24px;
  --radius-tile: 20px;
  --radius-control: 14px;
  /* Design tokens (docs/qihome-design-system.md): one scale each for radius, type and spacing. */
  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 24px; --r-pill: 999px;
  --fs-caption: 12px; --fs-secondary: 13px; --fs-body-sm: 14px; --fs-body: 15px; --fs-lead: 17px; --fs-section: 20px; --fs-title: 30px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --touch: 44px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --rounded: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --ai: #1673b8; /* AI is the cool light ✦; warm light is for actions and for things that are on */
  --ambient: radial-gradient(900px 520px at 50% -120px, rgba(255, 180, 90, .10), transparent 70%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #040405;
    --surface: #111216;
    --surface-2: #1a1c21;
    --ink: #f1ede6;
    --muted: #8e929b;
    --line: rgba(255, 255, 255, .09);
    --switch-off: #3d4048; /* --surface-2 vanished on dark cards */
    --brand: #ffb45a;
    --on-brand: #1a1206;
    --brand-2: #86cfff;
    --cool: #86cfff;
    --good: #6fd6a0;
    --warn: #ff8a5b;
    --bad: #ff7a6e;
    --glass: rgba(18, 20, 24, .62);
    --glass-line: rgba(255, 255, 255, .08);
    --side: #08090b;
    --hover: rgba(255, 255, 255, .05);
    --selected: color-mix(in srgb, var(--brand) 16%, transparent);
    --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 24px 60px rgba(0, 0, 0, .45);
    --ai: #86cfff;
    --ambient: radial-gradient(900px 520px at 50% -120px, rgba(255, 180, 90, .16), transparent 70%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* An app, not a document: no double-tap zoom, no sideways drift (the map and sliders keep their own gestures) */
html, body { touch-action: manipulation; overflow-x: clip; overscroll-behavior-x: none; }
@media (max-width: 999px) {
  /* iPhone zooms into any field under 16px when it is tapped */
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; }
}
body { margin: 0; background: var(--ambient) no-repeat, var(--bg); background-attachment: fixed; color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

.boot { display: grid; place-items: center; min-height: 100svh; }
.boot img { animation: pulse 1.4s ease-in-out infinite; border-radius: 15px; }
@keyframes pulse { 50% { opacity: .55; transform: scale(.96); } }

/* ---------- shell: sidebar on wide screens; top bar + bottom tabs on phones and tablets ---------- */
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 252px; display: flex; flex-direction: column; gap: 4px; padding: 18px 14px 14px; background: var(--side); border-right: 1px solid var(--line); overflow-y: auto; }
.sidebar .brand { padding: 4px 10px 14px; }
.brand { display: flex; align-items: center; gap: 10px; font: 400 19px/1 var(--rounded); letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: var(--r-sm); }
.search-trigger { display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--muted); font-size: var(--fs-body-sm); text-align: left; }
.search-trigger svg { width: 16px; height: 16px; }
.search-trigger span { flex: 1; }
kbd { font: 500 11px/1 var(--font); padding: 3px 6px; border-radius: var(--r-xs); background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-weight: 500; font-size: var(--fs-body-sm); transition: background-color .15s; }
.side-nav a svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.side-nav a span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .side-nav a:hover { background: var(--hover); } }
.side-nav a[aria-current="page"] { background: var(--selected); color: var(--brand); }
.side-nav a[aria-current="page"] svg { color: var(--brand); }
.side-h { margin: 18px 10px 6px; color: var(--muted); font-size: var(--fs-caption); font-weight: 600; letter-spacing: .02em; }
.side-foot { margin-top: auto; padding-top: 14px; display: grid; gap: 10px; }
.side-foot .conn { padding: 0 10px; }
.count-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--bad); color: #fff; font: 600 12px/1 var(--font); font-style: normal; }
.content { margin-left: 252px; min-width: 0; }
.topbar { display: none; position: sticky; top: 0; z-index: 20; background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.topbar .inner { padding: 0 16px; height: 52px; display: flex; align-items: center; gap: 10px; }
.topbar .grow { flex: 1; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--hover); } }
.conn { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: var(--fs-secondary); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

main { max-width: 1120px; margin: 0 auto; padding: 34px 36px 120px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; flex: 1 1 280px; }
.page-head h1 { margin: 0; font: 300 32px/1.1 var(--rounded); letter-spacing: -.03em; text-wrap: balance; } /* no single character left on its own line */
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.page-head p a { text-decoration: none; font-weight: 500; }
h2 { margin: 32px 0 12px; font: 400 19px/1.2 var(--rounded); letter-spacing: -.015em; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.bottom-tabs { display: none; }
@media (max-width: 999px) {
  .sidebar { display: none; }
  .content { margin-left: 0; }
  .topbar { display: block; }
  /* On a phone the page may run under the status bar and the Dynamic Island (viewport-fit=cover, home-screen app): keep the bar below them. */
  .topbar { padding-top: env(safe-area-inset-top); }
  main { padding: 22px 18px 120px; }
  .page-head h1 { font-size: 28px; }
  .bottom-tabs { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--line); }
  .bottom-tabs a { position: relative; display: grid; justify-items: center; gap: 2px; padding: 4px 0; color: var(--muted); text-decoration: none; font-size: 10.5px; min-height: 44px; }
  .bottom-tabs a svg { width: 24px; height: 24px; }
  .bottom-tabs a[aria-current="page"] { color: var(--brand); }
  .bottom-tabs .count-badge { position: absolute; top: 0; left: calc(50% + 6px); min-width: 17px; height: 17px; font-size: 10.5px; padding: 0 4px; }
}

/* "⋯" menu for extra header actions */
.more-menu { position: relative; }
.more-menu > summary { list-style: none; min-width: 40px; justify-content: center; }
.more-menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; z-index: 25; right: 0; top: calc(100% + 6px); min-width: 200px; padding: 6px; border-radius: var(--r-md); background: var(--surface); box-shadow: 0 10px 40px rgba(0, 0, 0, .18); border: 1px solid var(--line); display: grid; animation: pop .14s var(--ease-out); transform-origin: top right; }
.menu-item { display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); text-align: left; text-decoration: none; font-weight: 500; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .menu-item:hover { background: var(--hover); } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-pop.held { animation: none; } /* kept open across a live redraw (app.js render) */
.more-menu:not([open]) > .menu-pop { animation: none; } /* a closed <details> still runs its content's animation (Chrome): start it on open instead */

/* search everything */
.pal-backdrop { position: fixed; z-index: 60; inset: 0; background: rgba(0, 0, 0, .28); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.pal { width: min(620px, 100%); max-height: 70vh; display: flex; flex-direction: column; border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 24px 80px rgba(0, 0, 0, .3); overflow: hidden; }
.pal-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pal-input svg { width: 20px; height: 20px; color: var(--muted); }
.pal-input input { flex: 1; border: 0; outline: 0; background: none; font-size: var(--fs-lead); }
.pal-list { overflow-y: auto; padding: 6px; }
.pal-row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 11px; cursor: pointer; }
.pal-row.sel, .pal-row:hover { background: var(--selected); }
.pal-row .title { font-weight: 600; }
.pal-row .sub { color: var(--muted); font-size: var(--fs-secondary); }
.pal-empty { padding: 28px; text-align: center; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
@media (max-width: 999px) { .pal-backdrop { padding-top: 8px; } .pal { max-height: 80vh; } }

/* the settings hub */
.menu-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); flex: none; }
.menu-icon svg { width: 19px; height: 19px; }
.menu-row .menu-icon { color: var(--brand); background: var(--surface-2); border: 1px solid var(--line); border-radius: 50%; }
.menu-icon.c-life, .menu-icon.c-energy, .menu-icon.c-home { color: var(--brand); }
.menu-icon.c-devices, .menu-icon.c-assist, .menu-icon.c-advanced, .menu-icon.c-apps, .menu-icon.c-ha { color: var(--cool); }
.menu-icon.c-automation { color: var(--brand); } .menu-icon.c-maint { color: var(--muted); }
.menu-row { color: inherit; text-decoration: none; min-height: 60px; transition: background-color .15s; }
@media (hover: hover) and (pointer: fine) { .menu-row:hover { background: var(--hover); } }
.menu-row .title { font-weight: 550; }
.chev { color: var(--muted); font-size: var(--fs-section); line-height: 1; }
.menu-h { font-size: var(--fs-secondary); font-weight: 600; color: var(--muted); margin: 26px 4px 8px; font-family: var(--font); letter-spacing: .01em; }
.list.menu { grid-template-columns: 1fr; }
@media (min-width: 1000px) { .menu-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-items: start; } }
.sys-hero { margin-bottom: 14px; }
.sys-hero .grow { flex: 1; min-width: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sys-attention { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 14px 16px; color: inherit; text-decoration: none; font-weight: 550; }
.sys-meters .stat .value { font-size: var(--fs-section); }
.sys-page > h2:first-child, .sys-page > .section-head:first-child > h2 { display: none; }
.sys-page > .section-head:first-child:not(:has(> :not(h2))) { display: none; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 12px; }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.grid.rooms { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
@media (max-width: 420px) { .grid.tiles { grid-template-columns: 1fr 1fr; } }

.hero { position: relative; overflow: hidden; border-radius: 26px; padding: 26px; color: #fff; background: radial-gradient(420px 260px at 18% 0%, rgba(255, 180, 90, .28), transparent 70%), #0c0d10; box-shadow: var(--shadow); }
.hero h1 { margin: 0 0 4px; font: 300 32px/1.1 var(--rounded); letter-spacing: -.03em; }
.hero p { margin: 0; opacity: .85; }
.hero .climate { display: flex; gap: 28px; margin-top: 22px; flex-wrap: wrap; }
.hero .metric b { display: block; font: 200 46px/1 var(--rounded); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hero .metric span { font-size: var(--fs-secondary); opacity: .8; }

.stat .label { color: var(--muted); font-size: var(--fs-secondary); }
.stat .value { font: 300 26px/1.2 var(--rounded); letter-spacing: -.02em; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: var(--fs-secondary); margin-top: 2px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--brand); box-shadow: 0 0 12px -2px var(--glow); }

/* device tile */
.tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; min-height: 128px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-tile); background: var(--surface); box-shadow: var(--shadow); text-align: left; transition: background-color .2s, transform .15s; }
.tile:active { transform: scale(.98); }
.tile .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tile .icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.tile .icon svg { width: 22px; height: 22px; }
.tile .name { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.tile .state { color: var(--muted); font-size: var(--fs-secondary); margin-top: 2px; }
.tile.on { background: color-mix(in srgb, var(--on) 10%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--glow) 55%, transparent), 0 0 34px -16px var(--glow); }
.tile.on .icon { background: color-mix(in srgb, var(--glow) 16%, transparent); color: var(--brand); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--glow) 55%, transparent), 0 0 18px -4px var(--glow); }
.tile.offline { opacity: .55; }
.power { flex: none; width: 44px; height: 28px; border: 0; border-radius: var(--r-pill); background: var(--switch-off); position: relative; transition: background-color .2s; }
.power::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--dur-ui) var(--ease-out); }
.power[aria-pressed="true"] { background: var(--brand); box-shadow: 0 0 14px -3px var(--glow); }
.power[aria-pressed="true"]::after { transform: translateX(16px); }
.power:disabled { opacity: .5; cursor: default; }
.open-detail { position: absolute; inset: 0; border: 0; background: none; border-radius: inherit; }
.tile .top, .tile .bottom { position: relative; pointer-events: none; }
.tile .power { pointer-events: auto; }

/* room card */
.room { display: block; border: 0; text-align: left; width: 100%; padding: 18px; border-radius: var(--radius-card); color: #fff; min-height: 128px; box-shadow: var(--shadow); }
.room { background: var(--surface); border: 1px solid var(--line); color: var(--ink) !important; }
.room p, .room .climate { color: var(--muted); }
.room.lit p { color: var(--brand); }
.room h3 { margin: 0 0 4px; font: 400 20px/1.2 var(--rounded); }
.room p { margin: 0; opacity: .9; font-size: var(--fs-body-sm); }
.room .climate { margin-top: 22px; font: 300 26px/1 var(--rounded); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { border: 0; padding: 7px 14px; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow); color: var(--muted); font-weight: 500; min-height: 36px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.search { width: 100%; max-width: 320px; padding: 9px 14px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); }
/* Fixed field widths as classes: the strict CSP (style-src 'self') forbids inline style="" on these inputs. */
.search.w80 { max-width: 80px; }
.search.w90 { max-width: 90px; }
.search.w110 { max-width: 110px; }
.search.w170 { max-width: 170px; }

.list { display: grid; gap: 1px; background: var(--line); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); min-height: 56px; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: var(--fs-secondary); overflow-wrap: anywhere; } /* long entity ids widened rows past a phone screen */
.row .sub, .row .title { text-wrap: pretty; } /* no orphan character on a phone */
.nobr { white-space: nowrap; }
.row .value { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
/* A long value (a timestamp, an address) folds itself instead of squeezing the name into fragments. */
.row .value { max-width: 45%; overflow-wrap: anywhere; }
/* Phones: a row with several buttons puts them on their own line under the name, so the name is not squeezed. */
@media (max-width: 560px) {
  .row:has(> .btn.small ~ .btn.small) { flex-wrap: wrap; row-gap: 10px; }
  .row:has(> .btn.small ~ .btn.small) > .grow { flex-basis: calc(100% - 40px); }
}

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border: 0; border-radius: var(--r-pill); background: var(--surface-2); font-weight: 600; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: var(--fs-secondary); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); font-size: var(--fs-secondary); font-weight: 600; }
.badge.ok { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.notice { padding: 14px 16px; border-radius: var(--radius-control); background: color-mix(in srgb, var(--warn) 12%, var(--surface)); color: var(--ink); margin-bottom: 16px; }

/* sheet (device detail) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s var(--ease-out); }
.sheet { width: min(560px, 100%); max-height: 88svh; overflow: auto; background: var(--bg); border-radius: var(--r-xl) 22px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); animation: rise .28s var(--ease-drawer); }
@media (min-width: 761px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: var(--r-xl); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet-backdrop.live .sheet { animation: none; } /* a sheet redrawn in place (live state, next flow step) does not rise again */
.sheet-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.sheet-head .icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.sheet-head .icon.on { background: var(--on); color: var(--on-ink); box-shadow: 0 0 22px -4px var(--glow); }
.sheet-head .icon svg { width: 28px; height: 28px; }
.sheet-head h2 { margin: 0; }
.sheet-head .grow { flex: 1; min-width: 0; }
.close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--surface-2); font-size: var(--fs-lead); line-height: 1; }
.control { background: var(--surface); border-radius: var(--radius-card); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.control label { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 10px; }
.control label span { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.control input[type="range"] { width: 100%; accent-color: var(--brand); height: 28px; }
.control .buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 22px; }
.stepper b { font: 300 40px/1 var(--rounded); min-width: 110px; text-align: center; }
.stepper button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--surface-2); font-size: var(--fs-section); }
details.advanced { margin-top: 12px; color: var(--muted); font-size: var(--fs-secondary); }
details.advanced code { font-size: var(--fs-caption); }

/* login */
.login { display: grid; place-items: center; min-height: 100svh; padding: 20px; }
.login form { width: min(380px, 100%); display: grid; gap: 12px; text-align: center; }
.login img { width: 72px; height: 72px; border-radius: var(--r-lg); margin: 0 auto 6px; }
.login h1 { margin: 0; font: 300 28px/1.2 var(--rounded); }
.login p { margin: 0 0 10px; color: var(--muted); }
.login input { width: 100%; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); }
.login .btn { min-height: 48px; }
.login .error { color: var(--bad); min-height: 1.4em; margin: 0; }

/* intelligence */
.chat { display: grid; gap: 10px; margin-bottom: 14px; }
.bubble { max-width: 80%; padding: 11px 15px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); overflow-wrap: anywhere; }
.bubble.me { justify-self: end; background: var(--brand); color: var(--on-brand); }
.bubble .meta { margin-top: 6px; font-size: var(--fs-caption); color: var(--muted); }
.bubble.me .meta { color: rgba(255,255,255,.8); }
.bubble ul { margin: 6px 0 0; padding-left: 18px; font-size: var(--fs-secondary); }
.ask { display: flex; gap: 10px; }
.ask input { flex: 1; min-width: 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: var(--fs-body-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.os-card { display: flex; align-items: center; gap: 16px; }
.os-card img { width: 56px; height: 56px; border-radius: var(--r-md); }
.os-card h3 { margin: 0; font: 400 21px/1.2 var(--rounded); }
.os-card p { margin: 2px 0 0; color: var(--muted); }
.footer-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.dlg-backdrop { position: fixed; z-index: 95; inset: 0; background: rgba(0, 0, 0, .32); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .16s var(--ease-out); }
.dlg { width: min(420px, 100%); padding: 20px; border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(0, 0, 0, .3); animation: pop .16s var(--ease-out); }
.dlg-msg { margin: 0 0 16px; white-space: pre-line; line-height: 1.55; overflow-wrap: anywhere; }
.dlg-input { width: 100%; margin: 0 0 16px; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 10px 18px; border-radius: var(--r-pill); background: var(--ink); color: var(--bg); font-size: var(--fs-body-sm); box-shadow: var(--shadow); max-width: calc(100% - 32px); animation: toast-in .22s var(--ease-out); }
.mb { margin-bottom: 16px; }
.mt { margin-top: 12px; }
.muted { color: var(--muted); }
.muted.lead { margin: 0 0 12px; }
.search.lang { max-width: 140px; }

/* pairing */
.pair-sheet { text-align: center; }
.pair-sheet .qr { width: 220px; height: 220px; image-rendering: pixelated; border-radius: var(--r-md); background: #fff; padding: 6px; }
.pair-code { font: 300 40px/1.2 var(--rounded); letter-spacing: .12em; margin: 14px 0 6px; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
code.cmd { display: block; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--fs-secondary); text-align: left; overflow-wrap: anywhere; user-select: all; }
.check { font: 400 20px/1 var(--rounded); letter-spacing: .1em; font-variant-numeric: tabular-nums; }
.check.big { font-size: 38px; margin: 10px 0 14px; }
.pair-prompt { position: fixed; z-index: 70; right: 16px; top: 70px; width: min(340px, calc(100% - 32px)); padding: 18px; border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 12px 40px rgba(0,0,0,.25); text-align: center; animation: rise .28s var(--ease-drawer); }
.pair-prompt p { margin: 6px 0 0; color: var(--muted); font-size: var(--fs-body-sm); }
.pair-prompt .buttons { display: flex; gap: 10px; justify-content: center; }

/* integrations */
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.search.wide { max-width: none; width: 100%; }
.int-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.int-card { display: flex; flex-direction: column; gap: 6px; }
.int-card .title { font-weight: 600; }
.int-card .sub { color: var(--muted); font-size: var(--fs-secondary); flex: 1; }
.int-action { margin-top: 6px; }
.small-text { font-size: var(--fs-secondary); }
.row-notice { display: flex; align-items: center; gap: 12px; }
.flow-sheet.busy { opacity: .6; pointer-events: none; }
.flow-desc { color: var(--muted); margin: 0 0 14px; overflow-wrap: anywhere; }
.flow-form { display: grid; gap: 8px; }
.flow-form label, .flow-form .field-label { font-weight: 600; font-size: var(--fs-body-sm); margin-top: 6px; }
.flow-form .check-row { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.flow-form fieldset.section { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px 14px; display: grid; gap: 8px; }
.field-error { color: var(--bad); font-size: var(--fs-secondary); }
.menu-options { display: grid; gap: 8px; }
.wide-btn { width: 100%; justify-content: flex-start; }
.flow-done { font: 400 20px/1.3 var(--rounded); }
.progress-dots { display: flex; gap: 8px; justify-content: center; padding: 24px; }
.progress-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); animation: pulse 1s infinite ease-in-out; }
.progress-dots i:nth-child(2) { animation-delay: .15s; } .progress-dots i:nth-child(3) { animation-delay: .3s; }

/* ---------- first-run setup wizard (setup.js) ---------- */
.setup { min-height: 100svh; display: grid; place-items: start center; padding: 40px 16px; }
.setup-card { width: min(640px, 100%); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow); padding: 26px; }
.setup-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.setup-head img { width: 44px; height: 44px; border-radius: 11px; }
.setup-steps { display: flex; gap: 6px; }
.setup-steps span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-caption); font-weight: 700; background: var(--surface-2); color: var(--muted); }
.setup-steps span.on { background: var(--brand); color: var(--on-brand); }
.setup-steps span.ok { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.setup h1 { font: 300 24px/1.25 var(--rounded); margin: 4px 0 6px; }
.setup h2 { font: 400 18px/1.3 var(--rounded); margin: 20px 0 4px; }
.setup .small { font-size: var(--fs-secondary); }
.setup-form { display: grid; gap: 12px; margin-top: 14px; }
.setup-form label { display: grid; gap: 6px; font-weight: 600; font-size: var(--fs-body-sm); }
.setup-form input { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); font-weight: 400; }
.setup-form small { font-weight: 400; }
.setup .error { color: var(--bad); min-height: 1.2em; margin: 0; }
.setup-choices { display: grid; gap: 12px; margin-top: 16px; }
.setup-choice { display: grid; gap: 6px; text-align: left; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: transparent; }
@media (hover: hover) and (pointer: fine) { button.setup-choice:hover, .setup-choice-head:hover { border-color: var(--brand); } }
.setup-choice span { color: var(--muted); font-size: var(--fs-body-sm); }
.setup-choice-head { display: grid; gap: 6px; text-align: left; border: 0; background: transparent; padding: 0; }
.setup-more { display: none; gap: 12px; margin-top: 8px; }
.setup-choice.open .setup-more { display: grid; }
.warn-text { color: var(--warn); margin: 0; font-size: var(--fs-body-sm); }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-body-sm); }
.check-row input { margin-top: 4px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
/* An on/off setting: the text on the left, the same switch as a device tile's on the right. */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-body); }
.switch-row b { font-weight: 600; }
input.switch { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 44px; height: 28px; margin: 0; border-radius: var(--r-pill); background: var(--switch-off); cursor: pointer; transition: background-color .2s; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--dur-ui) var(--ease-out); }
input.switch:checked { background: var(--brand); box-shadow: 0 0 14px -3px var(--glow); }
input.switch:checked::after { transform: translateX(16px); }
input.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.setup-apply { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); margin: 10px 0; }
.setup-apply.bad { color: var(--bad); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.setup-dls { display: grid; gap: 10px; margin-top: 10px; }
.setup-dl { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); }
.setup-dl .btn { justify-self: start; }
.setup-links { font-size: var(--fs-secondary); }
.setup-pair { display: flex; gap: 16px; align-items: flex-start; margin-top: 16px; padding: 14px; border-radius: var(--r-md); background: var(--surface-2); }
.setup-pair .qr { width: 140px; height: 140px; image-rendering: pixelated; border-radius: var(--r-sm); background: #fff; padding: 4px; flex: none; }
.setup-pair > div { min-width: 0; display: grid; gap: 6px; }
.setup-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.setup-actions.end { justify-content: flex-end; margin-top: 20px; }
.setup-status { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.setup-status li { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.setup-status li.ok { color: var(--good); }
.setup-status .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.setup-status li:not(.ok) .dot { animation: pulse 1.4s ease-in-out infinite; }
@media (max-width: 520px) { .setup-pair { flex-direction: column; align-items: center; } .setup-card { padding: 20px; } }

/* Notices, activity, scenes, device history (phase 1 of replacing Home Assistant's own frontend). */
.notice-bar { display: flex; align-items: center; gap: 10px; margin: 14px 0 18px; padding: 12px 16px; color: var(--ink); background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); text-decoration: none; font-weight: 600; }
.notice-bar svg { width: 20px; height: 20px; color: var(--warn); }
.notice-bar span:first-of-type { flex: 1; }
.chev { color: var(--muted); font-size: var(--fs-lead); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head a { color: var(--brand); font-size: var(--fs-body-sm); text-decoration: none; }
/* Buttons beside a section title: on one line; when title and buttons do not fit side by side, the buttons go under it. */
.section-head:has(> span > .btn) { flex-wrap: wrap; row-gap: 0; }
.section-head > span:has(> .btn) { flex: none; white-space: nowrap; margin-bottom: 12px; }
.row.act { width: 100%; font: inherit; text-align: left; color: inherit; background: var(--surface); border: 0; cursor: default; }
button.row.act { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { button.row.act:hover { background: var(--surface-2); } }
.act-time { flex: none; min-width: 3.2em; color: var(--muted); font-size: var(--fs-secondary); font-variant-numeric: tabular-nums; }
.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.scene { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: var(--ink); background: var(--surface); border: 0; border-radius: var(--radius-tile); box-shadow: var(--shadow); font: inherit; text-align: left; cursor: pointer; }
.scene svg { flex: none; width: 26px; height: 26px; color: var(--brand-2); }
.scene .grow { flex: 1; min-width: 0; }
.scene b { display: block; font-size: var(--fs-body); }
.scene small { display: block; color: var(--muted); font-size: var(--fs-caption); }
.scene .run { padding: 5px 12px; color: var(--brand); background: var(--surface-2); border-radius: var(--r-pill); font-size: var(--fs-secondary); font-weight: 600; }
.scene.running .run { background: color-mix(in srgb, var(--glow) 18%, transparent); color: var(--brand); }
.scene:disabled { opacity: .5; cursor: default; }
.sheet-h { margin: 20px 0 8px; font-size: var(--fs-body); }
.chart { margin: 0 0 12px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-control); }
.chart figcaption { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: var(--fs-secondary); }
.chart figcaption span { color: var(--muted); }
.chart svg { display: block; width: 100%; height: 72px; overflow: visible; }
.chart.tl svg { height: 14px; border-radius: 4px; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .area { fill: var(--brand); opacity: .12; stroke: none; }
.chart rect.on { fill: var(--on); }
.chart rect.off { fill: var(--line); }
.chart rect.na { fill: transparent; }
.chart-range { display: flex; justify-content: space-between; margin-top: 2px; color: var(--muted); font-size: var(--fs-caption); font-variant-numeric: tabular-nums; }
.wide-btn { display: block; margin-top: 16px; text-align: center; }

/* Device panels */
.panel { margin: 4px 0 16px; padding: 22px; background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); }
.panel-row { display: flex; justify-content: center; gap: 12px; }
.panel-hint { margin: 10px 0 0; color: var(--muted); font-size: var(--fs-secondary); text-align: center; }
.panel-power { display: grid; place-items: center; width: 64px; height: 64px; color: var(--muted); background: var(--surface-2); border: 0; border-radius: 50%; font-size: var(--fs-section); cursor: pointer; transition: background .2s, color .2s, box-shadow .2s, scale var(--dur-press) var(--ease-out); }
.panel-power:active:not(:disabled) { scale: .97; }
.panel-power svg { width: 28px; height: 28px; }
.panel-power.big { width: 112px; height: 112px; }
.panel-power.big svg { width: 44px; height: 44px; }
.panel-power.on { color: var(--on-ink); background: var(--on); box-shadow: 0 0 0 8px color-mix(in srgb, var(--on) 22%, transparent), 0 12px 32px -8px var(--on); }
@media (prefers-reduced-motion: no-preference) { .panel-power.spin.on svg { animation: panel-spin 1.6s linear infinite; } }
@keyframes panel-spin { to { transform: rotate(360deg); } }
.big-buttons .btn { min-width: 84px; }

.light-panel { display: flex; align-items: center; justify-content: center; gap: 28px; }
.pill { --glow: #ffd27a; position: relative; width: 104px; height: 240px; overflow: hidden; background: var(--surface-2); border-radius: 30px; cursor: ns-resize; touch-action: none; user-select: none; }
.pill-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--glow); transition: height .15s ease-out; }
.pill.on { box-shadow: 0 16px 40px -18px var(--glow); }
.pill:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.pill-label { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-size: var(--fs-lead); }
.pill-label b { color: var(--on-ink); mix-blend-mode: normal; }
.panel-side { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 220px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; color: var(--muted); background: none; border: 0; font: inherit; font-size: var(--fs-caption); cursor: pointer; }
.swatch i { width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line); }
.swatch.sel i { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand); }
.swatch.k2700 i { background: #ffc46b; } .swatch.k4000 i { background: #ffe8c2; } .swatch.k6000 i { background: #e4efff; }
.swatch.h0 i { background: #ff453a; } .swatch.h30 i { background: #ff9f0a; } .swatch.h55 i { background: #ffd60a; }
.swatch.h130 i { background: #30d158; } .swatch.h200 i { background: #0a84ff; } .swatch.h280 i { background: #bf5af2; }

.climate-panel { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.dial { position: relative; width: 220px; height: 220px; }
.dial svg { width: 100%; height: 100%; }
.dial circle { fill: none; stroke-width: 14; stroke-linecap: round; }
.dial .track { stroke: var(--surface-2); }
.dial .fill { stroke: var(--cool); transition: stroke-dasharray .3s; }
.dial.heat .fill { stroke: var(--glow); }
.dial.off .fill { stroke: var(--muted); }
.dial-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dial-center b { font-family: var(--rounded); font-size: 46px; font-weight: 600; letter-spacing: -.02em; }
.dial-center span { color: var(--muted); font-size: var(--fs-secondary); }
.dial-btn { position: absolute; bottom: 6px; width: 44px; height: 44px; color: var(--ink); background: var(--surface-2); border: 0; border-radius: 50%; font-size: 24px; cursor: pointer; }
.dial-btn.minus { left: 22px; } .dial-btn.plus { right: 22px; }
.modes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.presets { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 8px; max-width: 420px; margin-left: auto; margin-right: auto; }
.presets .chip { padding-left: 4px; padding-right: 4px; white-space: nowrap; }
.presets { margin-top: 14px; }
.mode { padding: 8px 14px; color: var(--ink); background: var(--surface-2); border: 0; border-radius: var(--r-pill); font: inherit; font-size: var(--fs-body-sm); font-weight: 600; cursor: pointer; }
.mode.sel { color: var(--on-brand); background: var(--brand); }
.mode.sel.m-heat { background: #ff9f0a; } .mode.sel.m-off { background: var(--muted); } .mode.sel.m-dry { background: #64d2ff; color: #003; }
.chip.sel { color: var(--on-brand); background: var(--brand); }

.cover-panel { text-align: center; }
.window { position: relative; display: flex; justify-content: space-between; height: 150px; margin: 0 auto 12px; max-width: 280px; overflow: hidden; background: linear-gradient(180deg, #bfe0ff, #e8f4ff); border: 6px solid var(--surface-2); border-radius: var(--r-md); }
.drape { height: 100%; background: repeating-linear-gradient(90deg, #b8894f 0 10px, #c49a62 10px 20px); transition: width .4s; }
.cover-state b { font-size: var(--fs-section); }
.cover-panel .panel-row { margin-top: 12px; }

.meters { display: flex; justify-content: center; gap: 12px; margin-top: 14px; }
.sensor-panel .meters { margin-top: 0; }
.meter { flex: 1; max-width: 160px; padding: 12px; text-align: center; background: var(--surface-2); border-radius: var(--radius-control); }
.meter b { display: block; font-family: var(--rounded); font-size: var(--fs-title); font-weight: 600; }
.meter b small { font-size: var(--fs-body); color: var(--muted); }
.meter b.alert { color: var(--warn); font-size: var(--fs-section); }
.meter span { color: var(--muted); font-size: var(--fs-caption); }

.lock-panel { display: flex; justify-content: center; }
.lock-button { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 170px; padding: 22px 12px; color: var(--ink); background: var(--surface-2); border: 0; border-radius: 26px; font: inherit; cursor: pointer; }
.lock-button svg { width: 52px; height: 52px; color: var(--warn); }
.lock-button.locked svg { color: var(--good); }
.lock-button b { font-size: var(--fs-lead); } .lock-button small { color: var(--muted); }

.now { margin-bottom: 14px; text-align: center; }
.now small { display: block; color: var(--muted); font-size: var(--fs-caption); }
.now b { font-size: var(--fs-lead); }
@media (max-width: 480px) {
  .light-panel { gap: 18px; }
  .pill { width: 92px; height: 210px; }
}
@media (max-width: 600px) {
  .page-head { flex-wrap: wrap; }
  .page-head > div:first-child { flex: 1 1 100%; }
  .head-actions { width: 100%; }
  .head-actions .search { flex: 1; min-width: 0; }
}
.notice-bar.found svg { color: var(--brand); }
.notice-bar + .notice-bar { margin-top: -8px; }
.pair-sheet [data-copylink] { margin-top: 10px; }

/* Organizing: rooms and device names */
.edit-form { display: grid; gap: 8px; }
.edit-form label { font-weight: 600; font-size: var(--fs-body-sm); margin-top: 6px; }
.edit-form .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.text-input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); }
.pick-list { display: grid; max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.edit-form label.pick { display: flex; align-items: center; gap: 10px; margin: 0; padding: 12px 14px; font-weight: 500; cursor: pointer; }
.pick + .pick { border-top: 1px solid var(--line); }
.pick input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.room.editing { min-height: 0; }
.room-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.room-tools .btn { background: rgba(255,255,255,.22); color: #fff; }
.edit-device { margin: 12px 0 4px; }

/* Energy */
.energy-chart svg { width: 100%; height: 120px; display: block; }
.energy-chart rect { fill: var(--brand); }
.energy-chart .ticks, .big-chart .ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: var(--fs-caption); margin-top: 6px; }
.energy-row { width: 100%; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.energy-row .grow { display: grid; gap: 2px; min-width: 0; }
.use-bar { width: 100%; height: 4px; margin-top: 6px; }
.use-bar rect { fill: var(--brand); }
.use-bar rect.track { fill: var(--surface-2); }
.room { text-decoration: none; }
.pick .grow { flex: 1; min-width: 0; }
.grid.stats.energy-stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }  /* the totals share the row, however many there are */
.energy-chart { margin: 16px 0 8px; padding: 14px 16px; }
.grid.stats.energy-stats .value { white-space: nowrap; font-size: clamp(20px, 6vw, 26px); }

/* ---------- managing: editors, helpers, logs, device settings (manage.js) ---------- */
.scene-wrap { position: relative; display: grid; }
.scene-wrap .scene { padding-bottom: 34px; }
.scene-edit { position: absolute; right: 10px; bottom: 8px; font-size: var(--fs-caption); color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: var(--r-pill); background: var(--surface-2); }
.editor { display: grid; gap: 12px; max-width: 760px; }
.editor h2 { margin: 14px 0 0; }
.editor h2 small { font-weight: 400; font-size: var(--fs-body-sm); }
.ed-card { background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 10px; }
.ed-card.raw { border: 1px dashed var(--line); }
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ed-tools { display: flex; gap: 6px; }
.ed-tools .btn { min-height: 32px; padding: 4px 10px; }
.ed-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.ed-field { display: grid; gap: 4px; font-size: var(--fs-secondary); color: var(--muted); }
.ed-field .search, .ed-field textarea { color: var(--ink); font-size: var(--fs-body); }
.ed-name .ed-field span { font-weight: 600; }
.ed-add { max-width: 260px; }
.ed-raw { display: block; white-space: pre-wrap; word-break: break-all; font-size: var(--fs-caption); background: var(--surface-2); padding: 8px 10px; border-radius: var(--r-sm); grid-column: 1 / -1; }
.ed-fields > p { grid-column: 1 / -1; margin: 0; }
.wd { display: flex; flex-wrap: wrap; gap: 6px; }
.wd .chip { min-height: 32px; padding: 4px 10px; }
.ed-footer { position: sticky; bottom: 0; padding: 12px 0; background: var(--bg); justify-content: flex-end; }
.helper-row { flex-wrap: wrap; }
.helper-row .search { max-width: 200px; }
.helper-row .h-num { max-width: 110px; }
.h-range { width: min(220px, 40vw); }
.log-entry { display: block; padding: 0; }
.log-entry summary { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; list-style: none; }
.log-entry summary::-webkit-details-marker { display: none; }
.log-detail { margin: 0; padding: 0 16px 14px; white-space: pre-wrap; word-break: break-word; font-size: var(--fs-caption); color: var(--muted); max-height: 360px; overflow: auto; }
.log-line .title { font-size: var(--fs-body-sm); }
.log-line .sub { word-break: break-all; }
.ent-row { border: 1px solid var(--line); border-radius: var(--radius-control); padding: 10px 12px; display: grid; gap: 8px; margin: 0; }
.ent-row legend { font-weight: 600; padding: 0 4px; }
.ent-switches { display: flex; gap: 18px; flex-wrap: wrap; }
.dev-danger { margin-top: 8px; justify-content: flex-start; flex-wrap: wrap; }
.btn.danger { color: var(--bad); }
.btn.primary.danger { background: var(--bad); color: #fff; }
.notice.bad { color: var(--bad); }
.tools { justify-content: flex-start; flex-wrap: wrap; }
.ed-modes { margin: 0; }
.ed-yaml { width: 100%; min-height: 280px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--ink);
  font: 13px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace; tab-size: 2; white-space: pre; overflow: auto; resize: vertical; }
.ai-card { display: grid; gap: 12px; }
.ai-toggle { font-size: var(--fs-body); }
.ai-test { margin: 0; font-weight: 600; }

/* ---------- beyond Home Assistant (more.js) ---------- */
.why { font-size: var(--fs-caption); color: var(--brand); margin-top: 2px; }
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cam-grid.one { grid-template-columns: minmax(0, 520px); }
.cam-card { position: relative; display: block; padding: 0; border: 0; border-radius: var(--radius-tile); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow); cursor: pointer; aspect-ratio: 16 / 9; }
.cam-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-img.off { display: grid; place-items: center; color: var(--muted); }
.cam-name { position: absolute; left: 10px; bottom: 8px; padding: 3px 10px; border-radius: var(--r-pill); background: rgba(0, 0, 0, .55); color: #fff; font-size: var(--fs-secondary); font-weight: 600; }
.cam-sheet { max-width: 960px; }
.cam-live { width: 100%; border-radius: var(--radius-control); background: #000; display: block; }
.suggest-card { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.suggest-card svg { width: 18px; height: 18px; vertical-align: -3px; color: var(--brand); }
.describe { display: grid; gap: 8px; margin-bottom: 14px; }
.describe svg { width: 18px; height: 18px; vertical-align: -3px; color: var(--brand-2); }
.describe-row { display: flex; gap: 8px; }
.describe-row .search { max-width: none; }
.dev-out { white-space: pre-wrap; word-break: break-word; font: 12px/1.5 ui-monospace, Menlo, monospace; background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-sm); max-height: 420px; overflow: auto; }
.dash-row .title { font-size: var(--fs-body); }
.people-chips .chip { text-decoration: none; color: var(--ink); }
.health-bar svg { color: var(--warn); }
.field-error ul { margin: 6px 0; padding-left: 20px; }
.describe-row .btn { white-space: nowrap; flex-shrink: 0; }
.job-banner .spinner { display: inline-block; vertical-align: -3px; margin-right: 6px; }
.hacs-bar { display: flex; gap: 8px; margin: 10px 0 14px; }
.hacs-bar .search.wide { max-width: none; flex: 1 1 auto; min-width: 0; }
.hacs-bar select { flex: none; width: auto; }  /* the sort menu takes what it needs; the search box the rest */
.hacs-row { align-items: center; }
.hacs-row .sub a { color: var(--muted); }
.hacs-row .badge { font-size: var(--fs-caption); vertical-align: 1px; }

/* ---- pro.js: traces, history, energy report, labels, map, media, to-do ---- */
.trace-story { line-height: 1.6; margin-bottom: 14px; }
.trace-step.sub-step { padding-left: 32px; opacity: .85; }
.big-chart { margin: 0 0 14px; }
.big-chart svg { width: 100%; height: 150px; display: block; }
.big-chart .line { fill: none; stroke: var(--brand); stroke-width: 2; vector-effect: non-scaling-stroke; }
.big-chart .line.prev { stroke: var(--muted); stroke-dasharray: 4 4; opacity: .7; }
.big-chart .bar-grid { fill: var(--brand); }
.big-chart .bar-solar { fill: #ffb340; }
.er-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.er-nav b { font-size: var(--fs-lead); }
.label-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); vertical-align: middle; }
.label-dot.c-red { background: #ff3b30; } .label-dot.c-orange { background: #ff9500; } .label-dot.c-amber { background: #ffcc00; }
.label-dot.c-green { background: #34c759; } .label-dot.c-teal { background: #30b0c7; } .label-dot.c-blue { background: #007aff; }
.label-dot.c-indigo { background: #5856d6; } .label-dot.c-purple { background: #af52de; } .label-dot.c-pink { background: #ff2d55; }
.chip.sel { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.chip-x { border: 0; background: none; color: var(--muted); font-size: var(--fs-body); padding: 0 2px; min-height: 0; cursor: pointer; }
.adv-chips .chip { font-size: var(--fs-secondary); }
.media-now { display: flex; gap: 14px; align-items: center; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.media-item { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border-radius: var(--radius-tile); box-shadow: var(--shadow); padding: 10px; }
.media-item b { font-size: var(--fs-secondary); font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.media-item span { display: flex; gap: 6px; margin-top: auto; }
.media-art { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); background: var(--surface-2); }
.media-now .media-art { width: 64px; }
.media-art.empty { display: grid; place-items: center; color: var(--muted); font-size: 28px; }
.todo-row.done .check-row span { color: var(--muted); text-decoration: line-through; }
.todo-row .check-row { margin: 0; }

/* ---------- product pass: page template, home dashboard, settings columns ---------- */
.back-link { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 8px -2px; color: var(--brand); text-decoration: none; font-weight: 550; font-size: var(--fs-body-sm); white-space: nowrap; }
.back-link::before { content: ""; width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: 0 4px 0 4px; }
@media (hover: hover) and (pointer: fine) { .back-link:hover { text-decoration: underline; } }
.page-head > div:first-child { display: flex; flex-direction: column; align-items: flex-start; }
main.enter { animation: enter 150ms var(--ease-out); } /* navigation is frequent: a quick fade, no travel */
.room.is-new, .tile.is-new { animation: card-new .26s var(--ease-out) both; }
@keyframes card-new { from { opacity: 0; transform: translateY(8px) scale(.96); } }
@keyframes enter { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { main.enter, .menu-pop, .pal, .pal-backdrop, .dlg, .dlg-backdrop, .room.is-new, .tile.is-new { animation: none; } }
.section-head { margin-top: 32px; }
.section-head h2 { margin: 0 0 12px; }
.glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin: 14px 0 0; }
.glance .notice-bar { margin: 0; }
.glance .notice-bar + .notice-bar { margin-top: 0; }
/* The chips' soft shadows need room: a scrolling strip clips at its padding box, which drew a grey rectangle behind
   the chips. The padding holds the shadow, the negative margin keeps the chips where they were. */
.scene-strip { display: flex; gap: 10px; overflow-x: auto; padding: 12px 16px 22px; margin: -10px -16px -14px; scroll-padding-inline: 16px; scrollbar-width: none; scroll-snap-type: x proximity; }
.scene-strip::-webkit-scrollbar { display: none; }
.scene-chip { flex: none; display: inline-flex; align-items: center; gap: 9px; padding: 11px 16px 11px 12px; border: 0; border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow); font-weight: 600; scroll-snap-align: start; transition: transform .15s; }
.scene-chip svg { width: 22px; height: 22px; color: var(--brand-2); }
.scene-chip:active { transform: scale(.97); }
.scene-chip.running { background: color-mix(in srgb, var(--glow) 12%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--glow) 50%, transparent); }
.menu-group .menu-h { margin-top: 26px; }
@media (min-width: 1000px) {
  .menu-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; align-items: start; }
  .only-narrow { display: none; }
}
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -6px 0 6px; }
.toolbar .chips { margin: 0; }
.search-field { display: flex; align-items: center; gap: 8px; flex: 0 1 300px; min-width: 200px; padding: 0 12px; height: 38px; border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow); color: var(--muted); }
.search-field svg { width: 17px; height: 17px; flex: none; }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); }
h2 .count, h2 small.count { color: var(--muted); font-weight: 500; font-size: .8em; margin-left: 4px; }
@media (max-width: 760px) { .search-field { flex: 1 1 100%; } .toolbar .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } }
.grid.stats.sys-meters { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .grid.stats.sys-meters { grid-template-columns: 1fr 1fr; gap: 10px; } .sys-meters .stat { padding: 14px; } .sys-meters .stat .sub { display: none; } }
.sys-hero img { width: 60px; height: 60px; }
@media (max-width: 760px) { .sys-hero { align-items: flex-start; } .sys-hero img { width: 48px; height: 48px; } }
.auto-row { gap: 8px; padding-top: 0; padding-bottom: 0; }
.row-link { display: flex; flex: 1; min-width: 0; align-self: stretch; align-items: center; padding: 12px 0; color: inherit; text-decoration: none; }
.auto-row.off .title { color: var(--muted); }
.icon-btn.small { width: 36px; height: 36px; color: var(--muted); text-decoration: none; }
.icon-btn.small svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) { .icon-btn.small:hover { color: var(--brand); } }
@media (hover: hover) and (pointer: fine) { .list > .row:hover:has(.row-link) { background: color-mix(in srgb, var(--surface) 96%, var(--ink)); } }
.pal-row .grow { flex: 1; min-width: 0; }
.pal-row .chev { margin-right: 4px; }
.assistant { padding: 20px; }
.assistant-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.assistant-head svg { width: 38px; height: 38px; padding: 8px; border-radius: var(--r-md); color: #fff; background: var(--surface-2); color: var(--brand); }
.assistant-head b { display: block; font-size: var(--fs-lead); }
.assistant-head span { color: var(--muted); font-size: var(--fs-secondary); }
.assistant-hint { color: var(--muted); margin: 0 0 14px; }
.assistant .suggest { margin-bottom: 0; }
.assistant-more { margin-top: 14px; }
.assistant-more summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.assistant-more dl { margin: 12px 0 0; }
.btn svg { width: 18px; height: 18px; flex: none; }
.wide-btn.edit-device { display: flex; align-items: center; justify-content: center; gap: 8px; }

/* denser settings: rows like System Settings, groups flow in columns without gaps */
.menu-row { min-height: 50px; padding: 9px 14px; gap: 12px; }
.menu-row .title { font-size: var(--fs-body-sm); }
.menu-row .sub { font-size: var(--fs-secondary); line-height: 1.35; }
.menu-row .menu-icon { width: 28px; height: 28px; border-radius: var(--r-sm); }
.menu-row .menu-icon svg { width: 17px; height: 17px; }
.menu-row .chev { font-size: var(--fs-lead); }
.menu-h { margin: 18px 4px 7px; font-size: var(--fs-secondary); }
.menu-group .menu-h { margin-top: 18px; }
@media (min-width: 1000px) {
  .menu-cols { display: block; column-count: 2; column-gap: 20px; }
  .menu-group { break-inside: avoid; display: inline-block; width: 100%; }
}
.sys-hero { padding: 16px 18px; gap: 14px; }
.sys-hero img { width: 52px; height: 52px; }
.sys-hero h3 { font-size: 19px; }
.sys-hero .pills { margin-top: 6px; }
.grid.stats.sys-meters { gap: 10px; }
.sys-meters .stat { padding: 12px 14px; }
.sys-meters .stat .value { font-size: var(--fs-section); }
.sys-meters .stat .label, .sys-meters .stat .sub { font-size: var(--fs-caption); }
.sys-page .row, .sys-page .card { }
.restart-list { display: grid; gap: 10px; }
.restart-opt { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; border: 0; text-align: left; color: inherit; font: inherit; }
.restart-opt .menu-icon { color: var(--brand); background: var(--surface-2); width: 36px; height: 36px; border-radius: var(--r-sm); }
.restart-opt .grow { flex: 1; min-width: 0; }
.restart-opt b { display: block; font-size: 15.5px; }
.restart-opt span > span, .restart-opt .grow span { display: block; color: var(--muted); font-size: var(--fs-secondary); margin-top: 2px; }
@media (hover: hover) and (pointer: fine) { .restart-opt:hover:not(:disabled) { background: var(--hover); } }
.restart-opt:disabled { opacity: .6; }
.menu-icon.c-bad { background: var(--bad); }
.hero .metric b.unknown { font-size: var(--fs-title); font-weight: 300; line-height: 46px; opacity: .85; }
button.row.menu-row { width: 100%; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.menu-row.danger .title { color: var(--bad); }
.menu-row .lang { min-height: 34px; padding: 4px 10px; }
@media (min-width: 1000px) { .menu-group.only-narrow { display: none; } }

/* HACS repository page */
.repo-top { display: grid; gap: 10px; margin-bottom: 14px; }
.repo-top .footer-actions { margin: 0; }
.repo-ver { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: var(--fs-body-sm); }
.readme { padding: 22px 26px; line-height: 1.65; overflow-wrap: anywhere; }
.readme > :first-child { margin-top: 0; }
.readme .md-h { margin: 22px 0 8px; font-family: var(--rounded); letter-spacing: -.01em; }
.readme h3.md-h { font-size: var(--fs-section); } .readme h4.md-h { font-size: var(--fs-lead); } .readme h5.md-h { font-size: 15.5px; }
.readme p { margin: 8px 0; }
.readme ul, .readme ol { margin: 8px 0; padding-left: 22px; }
.readme li { margin: 3px 0; }
.readme code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 5px; border-radius: var(--r-xs); background: var(--surface-2); }
.readme pre { margin: 12px 0; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); overflow-x: auto; }
.readme pre code { padding: 0; background: none; }
.readme blockquote { margin: 12px 0; padding: 10px 14px; border-left: 3px solid var(--brand); border-radius: 0 10px 10px 0; background: color-mix(in srgb, var(--brand) 7%, transparent); color: var(--ink); }
.readme hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.readme .md-table { overflow-x: auto; margin: 12px 0; }
.readme table { border-collapse: collapse; font-size: var(--fs-body-sm); }
.readme th, .readme td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.readme th { background: var(--surface-2); }
.readme .md-img { display: inline-block; font-size: var(--fs-secondary); padding: 2px 8px; border-radius: var(--r-sm); background: var(--surface-2); text-decoration: none; }
.hacs-open { padding: 12px 0; }
.hacs-row { padding-top: 0; padding-bottom: 0; }
/* guided HACS installation */
.hs-start, .hs-done { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hs-start .grow, .hs-done .grow { flex: 1; min-width: 220px; }
.hs-start p, .hs-done p { margin: 4px 0 0; }
.hs-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--r-md); color: #fff; background: var(--surface-2); color: var(--brand); font-size: 24px; }
.hs-icon svg { width: 26px; height: 26px; }
.hs-icon.ok { background: var(--good); }
.hs-steps { list-style: none; margin: 0; padding: 8px 20px; }
.hs-step { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.hs-step:last-child { border-bottom: 0; }
.hs-step .grow { flex: 1; min-width: 0; }
.hs-step b { display: block; font-size: var(--fs-body); line-height: 28px; }
.hs-step.later { opacity: .5; }
.hs-num { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: var(--fs-body-sm); }
.hs-step.now .hs-num { background: var(--brand); color: var(--on-brand); }
.hs-step.done .hs-num { background: var(--good); color: #fff; }
.hs-list { margin: 6px 0 10px; padding-left: 20px; color: var(--ink); line-height: 1.7; }
.hs-code { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.hs-code span { font: 700 26px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; padding: 10px 16px; border-radius: var(--r-md); background: var(--surface-2); overflow-wrap: anywhere; }
.rm-addr .hs-code span { font-size: var(--fs-body); letter-spacing: 0; }
/* plugin center: where to look */
.where-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 8px; }
.where { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; transition: transform .15s; }
@media (hover: hover) and (pointer: fine) { .where:hover { transform: translateY(-2px); } }
.where .menu-icon { color: var(--brand); background: var(--surface-2); margin-bottom: 4px; }
.where b { font-size: var(--fs-body); }
.where span:not(.menu-icon) { color: var(--muted); font-size: var(--fs-secondary); }
.where em { margin-top: auto; padding-top: 6px; font-style: normal; font-size: var(--fs-secondary); font-weight: 600; color: var(--brand); }
/* remote access */
.rm-intro { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.rm-intro .menu-icon { color: #fff; }
.rm-intro p { margin: 0 0 6px; }
.rm-form { display: grid; gap: 6px; max-width: 460px; }
.rm-addr { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.rm-addr .grow { flex: 1; min-width: 240px; }
.rm-addr .qr { width: 140px; height: 140px; border-radius: var(--r-sm); background: #fff; padding: 6px; }
.hs-step, .hs-step .grow { text-align: left; }
/* rows that are buttons (health, map people, run history…) look like every other row */
button.row { width: 100%; border: 0; margin: 0; font: inherit; color: inherit; text-align: left; background: var(--surface); cursor: pointer; appearance: none; -webkit-appearance: none; }
@media (hover: hover) and (pointer: fine) { button.row:hover { background: var(--hover); } }
button.row .grow { text-align: left; }
.edge-upd { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0 4px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); }
.edge-upd .grow { flex: 1; min-width: 200px; }
.edge-upd b { display: block; }
.edge-upd span { color: var(--muted); font-size: var(--fs-secondary); }
.edge-upd p { margin: 4px 0 0; }
.eu-cmd { font: 12.5px ui-monospace, Menlo, monospace; padding: 6px 10px; border-radius: var(--r-sm); background: var(--surface); user-select: all; }

/* map: part of the page, not a pasted-in picture */
.map-wrap { position: relative; border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow); background: var(--surface-2); isolation: isolate; }
.map { position: relative; overflow: hidden; height: min(62vh, 540px); touch-action: none; cursor: grab; user-select: none; }
.map:active { cursor: grabbing; }
.map-tile { position: absolute; width: 256px; height: 256px; pointer-events: none; }
.map-zone { position: absolute; border-radius: 50%; background: color-mix(in srgb, var(--brand) 14%, transparent); border: 1.5px solid color-mix(in srgb, var(--brand) 55%, transparent); pointer-events: none; }
.map-pin { position: absolute; display: grid; place-items: center; pointer-events: none; }
.map-pin.person, .map-pin.tracker { width: 38px; height: 38px; border-radius: 50%; color: #fff; font: 500 15px/1 var(--rounded); background: var(--surface-2); color: var(--brand); border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .28); }
.map-pin.person.home { background: linear-gradient(135deg, #34c759, #30b0c7); }
.map-pin.zone { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.map-label { position: absolute; transform: translateX(-50%); padding: 3px 9px; border-radius: var(--r-pill); font: 600 12px/1.3 var(--font); white-space: nowrap; pointer-events: none; color: var(--ink); background: var(--glass); backdrop-filter: blur(12px) saturate(160%); -webkit-backdrop-filter: blur(12px) saturate(160%); box-shadow: 0 1px 6px rgba(0, 0, 0, .15); }
.map-label.zone { color: var(--brand); }
.map-ctrl { position: absolute; z-index: 2; top: 14px; right: 14px; display: grid; border-radius: var(--r-md); overflow: hidden; background: var(--glass); backdrop-filter: blur(16px) saturate(170%); -webkit-backdrop-filter: blur(16px) saturate(170%); box-shadow: 0 2px 12px rgba(0, 0, 0, .18); }
.map-ctrl button { width: 40px; height: 40px; border: 0; background: none; color: var(--ink); font-size: var(--fs-section); line-height: 1; }
.map-ctrl button + button { border-top: 1px solid var(--line); }
@media (hover: hover) and (pointer: fine) { .map-ctrl button:hover, .map-home:hover { background: var(--hover); } }
.map-home { position: absolute; z-index: 2; right: 14px; bottom: 14px; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; color: var(--brand); background: var(--glass); backdrop-filter: blur(16px) saturate(170%); -webkit-backdrop-filter: blur(16px) saturate(170%); box-shadow: 0 2px 12px rgba(0, 0, 0, .18); }
.map-home svg { width: 20px; height: 20px; }
.map-attr { position: absolute; z-index: 2; left: 10px; bottom: 8px; padding: 2px 8px; border-radius: var(--r-pill); font-size: var(--fs-caption); color: var(--muted); background: var(--glass); }
.map-fail { position: absolute; z-index: 2; left: 50%; top: 14px; transform: translateX(-50%); padding: 6px 12px; border-radius: var(--r-pill); font-size: var(--fs-secondary); background: var(--glass); box-shadow: var(--shadow); }
.map-avatar { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: #fff; font: 500 15px/1 var(--rounded); background: var(--surface-2); color: var(--brand); }
.map-avatar.home { background: linear-gradient(135deg, #34c759, #30b0c7); }
@media (prefers-color-scheme: dark) { .map-pin.person, .map-pin.zone { border-color: #1c1c1e; } }

/* "Write with AI" in the editors (manage.js) */
.aiw textarea { min-height: 44px; resize: vertical; font: inherit; line-height: 1.4; padding-top: 10px; }
.aiw .describe-row { align-items: flex-start; }
.aiw-done { margin: 0; color: var(--good); }
.aiw-done .btn { margin-left: 6px; }
.aiw-off p { margin: 0; }
.aiw .small-text { margin: 0; }

/* ---------- AI everywhere (ai.js) ---------- */
.ai-spark { font-size: var(--fs-body); line-height: 1; color: var(--ai); }
.ai-trigger { margin-top: -4px; color: var(--ink); background: color-mix(in srgb, var(--ai) 9%, var(--surface)); border-color: color-mix(in srgb, var(--ai) 30%, transparent); }
@media (hover: hover) and (pointer: fine) { .ai-trigger:hover { background: color-mix(in srgb, var(--ai) 15%, var(--surface)); } }
.ai-trigger .ai-spark { flex: none; width: 16px; text-align: center; }
.ai-card .ai-h, .ai-h { margin: 0 0 6px; font-size: var(--fs-body); }
.ai-card { margin: 16px 0 14px; }
.ai-off { margin: 4px 0; }
.ai-busy { animation: ai-pulse 1.4s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: .45; } }
.ai-text p { margin: 0 0 8px; } .ai-text ul { margin: 0 0 8px; padding-left: 20px; } .ai-text li { margin: 2px 0; }
.ai-text code, .ai-msg code { padding: 1px 5px; border-radius: var(--r-xs); background: var(--surface-2, rgba(127,127,127,.12)); font-size: .92em; }
.ai-code { margin: 6px 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2, rgba(127,127,127,.12)); white-space: pre-wrap; word-break: break-word; font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 360px; overflow: auto; }
.ai-sentence { color: var(--brand); }
.ai-digest { margin: 14px 0; padding: 14px 16px; border-radius: var(--radius-card); background: var(--surface); border: 1px solid color-mix(in srgb, var(--ai) 26%, transparent); }
.ai-digest.off { padding: 8px 14px; }
.ai-digest-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ai-digest .ai-text p:last-child { margin-bottom: 0; }
.ai-suggest { display: grid; gap: 10px; margin-bottom: 14px; }
.ai-sug { display: flex; gap: 12px; align-items: center; margin: 0; }
.ai-sug p { margin: 4px 0 0; }
.ai-sug-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .ai-sug { flex-direction: column; align-items: stretch; } .ai-sug-btns { justify-content: flex-start; } }
.ai-dev-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ai-model-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.ai-caps { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.ai-cap { padding: 3px 9px; border-radius: var(--r-pill); font-size: var(--fs-secondary); background: var(--surface-2, rgba(127,127,127,.12)); color: var(--muted); }
.ai-cap.ok { color: var(--good); }
.ai-feature small { display: block; }
.ai-audit summary, .ai-audit-row summary { cursor: pointer; padding: 6px 0; }
.ai-audit-row { border-top: 1px solid var(--line, rgba(127,127,127,.18)); font-size: var(--fs-secondary); }
.ai-hint { margin: 0 0 12px; }
/* the conversation drawer */
#ai-drawer { position: fixed; z-index: 60; right: 16px; bottom: 16px; top: 16px; width: min(420px, calc(100vw - 32px)); display: flex; }
.ai-chat { flex: 1; display: flex; flex-direction: column; background: var(--surface); color: var(--ink); border: 1px solid var(--line, rgba(127,127,127,.2)); border-radius: var(--r-lg); box-shadow: 0 24px 70px rgba(0,0,0,.28); overflow: hidden; }
.ai-chat-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line, rgba(127,127,127,.18)); }
.ai-chat-head .close { background: none; border: 0; font-size: var(--fs-section); color: var(--muted); cursor: pointer; padding: 0 4px; }
.ai-chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 92%; padding: 10px 12px; border-radius: var(--r-lg); line-height: 1.5; word-break: break-word; }
.ai-msg p { margin: 0 0 6px; } .ai-msg p:last-child { margin-bottom: 0; } .ai-msg ul { margin: 0 0 6px; padding-left: 18px; }
.ai-msg.me { align-self: flex-end; background: var(--brand); color: var(--on-brand); white-space: pre-wrap; }
.ai-msg.ai { align-self: flex-start; background: var(--surface-2, rgba(127,127,127,.12)); }
.ai-msg.err { color: var(--bad); }
.ai-msg.busy { color: var(--muted); animation: ai-pulse 1.4s ease-in-out infinite; }
.ai-act { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface); font-size: var(--fs-secondary); }
/* A narrow chat: the text takes its own line and the buttons stay whole (they wrapped letter by letter). */
.ai-act .grow { flex: 1 1 12em; min-width: 0; }
.ai-act .btn, .ai-act .muted { flex: none; white-space: nowrap; }
.ai-act.wait { border: 1px solid var(--warn); }
.ai-used { margin-top: 6px; font-size: var(--fs-caption); color: var(--muted); }
.ai-starters { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line, rgba(127,127,127,.18)); }
.ai-chat-input textarea { flex: 1; resize: none; min-height: 40px; max-height: 160px; padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--line, rgba(127,127,127,.25)); background: var(--bg); color: var(--ink); font: inherit; line-height: 1.4; transition: height .14s linear; }
.ai-chat-input .btn { flex: none; height: 40px; }
@media (prefers-reduced-motion: reduce) { .ai-chat-input textarea { transition: none; } }
/* A window of its own on a computer: moved by its title bar, resized from its edges and corners (ai.js). */
#ai-drawer.floating { right: auto; bottom: auto; }
#ai-drawer.moving, #ai-drawer.moving * { user-select: none; }
#ai-drawer .ai-chat-head { cursor: grab; }
#ai-drawer.moving .ai-chat-head { cursor: grabbing; }
.ai-resize { position: absolute; z-index: 1; }
.ai-resize-n, .ai-resize-s { left: 14px; right: 14px; height: 8px; cursor: ns-resize; }
.ai-resize-e, .ai-resize-w { top: 14px; bottom: 14px; width: 8px; cursor: ew-resize; }
.ai-resize-n { top: -4px; } .ai-resize-s { bottom: -4px; } .ai-resize-e { right: -4px; } .ai-resize-w { left: -4px; }
.ai-resize-ne, .ai-resize-nw, .ai-resize-se, .ai-resize-sw { width: 16px; height: 16px; }
.ai-resize-ne { top: -4px; right: -4px; cursor: nesw-resize; } .ai-resize-sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.ai-resize-nw { top: -4px; left: -4px; cursor: nwse-resize; } .ai-resize-se { bottom: -4px; right: -4px; cursor: nwse-resize; }
@media (max-width: 640px) { .ai-resize { display: none; } #ai-drawer .ai-chat-head { cursor: auto; } }
@media (max-width: 640px) { #ai-drawer { right: 0; left: 0; bottom: 0; top: auto; height: 86vh; width: auto; } .ai-chat { border-radius: var(--r-lg) 20px 0 0; } }
.ai-chat-head .grow { flex: 1; min-width: 0; }

/* The map drawn by MapLibre (OpenFreeMap): markers carry the same pins and labels as before. */
.ml-box, .ml-box.maplibregl-map { position: absolute; inset: 0; width: 100%; height: 100%; } /* MapLibre makes its container relative */
.ml-box .maplibregl-canvas { outline: none; }
.ml-marker { display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.ml-marker .map-pin, .ml-marker .map-label { position: static; transform: none; }
/* The image-tile fallback keeps a readable night look. */
@media (prefers-color-scheme: dark) { .map-tile.raster { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.55); } }
/* Map settings: the map in use, keys, the offline map (pro.js) */
.map-set { display: grid; gap: 10px; margin-bottom: 14px; }
.map-set .field { display: grid; gap: 6px; }
.map-set .field > span:first-child { font-size: var(--fs-secondary); color: var(--muted); }
.map-set p { margin: 0; }
.map-set .inline-field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.map-set .progress { height: 6px; margin-top: 8px; border-radius: var(--r-pill); background: var(--surface-2, rgba(127,127,127,.15)); overflow: hidden; }
.map-set .progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--brand); transition: width .4s; }

/* Step-by-step guides (guides.js) */
.g-card { max-width: 760px; }
.g-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.g-dots { display: flex; gap: 6px; }
.g-dots i { width: 22px; height: 5px; border-radius: var(--r-pill); background: var(--surface-2, rgba(127,127,127,.2)); }
.g-dots i.done { background: color-mix(in srgb, var(--brand) 45%, transparent); }
.g-dots i.cur { background: var(--brand); }
.g-h { margin: 8px 0 12px; font-size: var(--fs-section); }
.g-sub { margin: 18px 0 6px; font-size: 15.5px; }
.g-label { margin: 16px 0 8px; color: var(--muted); font-size: var(--fs-body-sm); }
.g-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.g-opt { display: grid; gap: 4px; text-align: left; padding: 14px 16px; border-radius: var(--r-lg); border: 1.5px solid var(--line, rgba(127,127,127,.25)); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.g-opt small { color: var(--muted); font-size: var(--fs-secondary); line-height: 1.45; white-space: pre-line; }
@media (hover: hover) and (pointer: fine) { .g-opt:hover { border-color: color-mix(in srgb, var(--brand) 50%, transparent); } }
.g-opt.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.g-list { margin: 8px 0 14px; padding-left: 22px; line-height: 1.6; }
.g-list li { margin: 3px 0; }
.g-cmd { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 8px 8px 8px 12px; border-radius: var(--r-md); background: var(--surface-2, rgba(127,127,127,.12)); }
.g-cmd code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.g-field { display: grid; gap: 6px; margin: 12px 0; }
.g-field > span { font-size: var(--fs-body-sm); color: var(--muted); }
.g-foot { display: flex; align-items: center; gap: 10px; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line, rgba(127,127,127,.18)); }
.g-foot .grow { flex: 1; }
.g-left { justify-content: flex-start; }
.g-ok { color: var(--good); font-weight: 600; }
.g-caps { margin: 8px 0; padding-left: 0; list-style: none; line-height: 1.8; }
.g-caps .ok { color: var(--good); } .g-caps .no { color: var(--muted); }
.g-found { margin: 8px 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2, rgba(127,127,127,.1)); }
.g-found .chips { margin-top: 8px; }
.g-manual { margin-top: 14px; } .g-manual summary { cursor: pointer; color: var(--muted); }
.g-progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-2, rgba(127,127,127,.15)); overflow: hidden; }
.g-progress i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .4s; }
.ai-start { margin-top: 10px; }

/* "Ask AI about this" (right-click / long-press) and the Intelligence page's memory and push cards */
.ai-about { position: fixed; z-index: 80; width: min(320px, calc(100vw - 16px)); padding: 10px; border-radius: var(--r-md); background: var(--surface); border: 1px solid rgba(123,140,255,.35); box-shadow: 0 12px 40px rgba(0,0,0,.28); display: grid; gap: 6px; }
.ai-about-h { margin: 2px 4px 4px; font-weight: 600; font-size: var(--fs-body-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-about-q { text-align: left; padding: 8px 10px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--ink); font-size: var(--fs-body-sm); }
@media (hover: hover) and (pointer: fine) { .ai-about-q:hover { background: var(--hover); } }
.ai-about-form { display: flex; gap: 6px; margin-top: 2px; }
.ai-about-form input { flex: 1; min-width: 0; padding: 7px 10px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: var(--fs-body-sm); }
.ai-about-foot { margin: 2px 4px 0; font-size: 11.5px; }
.ai-about .ai-off { margin: 2px 4px; }
.ai-mem .btn { flex: none; }
.ai-pu-brief { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ai-pu-brief label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-body-sm); }
.ai-pu-brief input[type=time] { width: auto; }
@media (hover: none) { main .tile, main .row, main .card { -webkit-touch-callout: none; } }
.ai-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.ai-form .search.wide { flex: 1; min-width: 200px; }
/* The AI bar under a page's title */
.ai-page { margin: -8px 0 20px; padding: 12px 14px; gap: 8px; border: 1px solid color-mix(in srgb, var(--ai) 30%, transparent); }
.ai-page.is-new { animation: pop .14s var(--ease-out); } /* only when just opened (app.js render) */
@media (prefers-reduced-motion: reduce) { .ai-page.is-new { animation: none; } } /* here, not in the list at the top: same specificity, so it must come after */
.ai-page-form { display: flex; align-items: center; gap: 8px; }
.ai-page-form input { flex: 1; min-width: 0; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: var(--fs-body-sm); }
.ai-page-chips { margin: 0; }
.ai-page .ai-off { margin: 0; }
/* Light AI on the home page */
.lg-card { margin: 14px 0; }
.lg-card .ai-h small { font-weight: 400; font-size: var(--fs-secondary); margin-left: 6px; }
.lg-row { align-items: center; gap: 10px; flex-wrap: wrap; }
.lg-ico { flex: none; width: 22px; text-align: center; }
.lg-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.lg-alert { background: color-mix(in srgb, #ff453a 12%, transparent); border-radius: var(--r-sm); }
.lg-warn { background: color-mix(in srgb, #ff9f0a 10%, transparent); border-radius: var(--r-sm); }

/* A back link for pages the sidebar lists: only where there is no sidebar */
@media (min-width: 1000px) { .back-link.phone-only { display: none; } }

/* Chips never squeeze their text; rows of them scroll sideways on phones */
.chips .chip { flex: none; white-space: nowrap; }
@media (max-width: 760px) { .toolbar .chips { width: 100%; min-width: 0; padding-bottom: 2px; } }
/* A segmented switch between two views of one place (rooms / all devices) */
.seg { display: inline-flex; gap: 2px; padding: 3px; margin: -8px 0 18px; border-radius: var(--r-md); background: var(--surface-2); }
.seg a { padding: 6px 16px; border-radius: var(--r-sm); color: var(--muted); text-decoration: none; font-weight: 600; font-size: var(--fs-body-sm); }
.seg a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Ask AI about this page: a small ✦ at the end of the title row */
.ai-head-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px; border: 1px solid color-mix(in srgb, var(--ai) 35%, transparent); border-radius: var(--r-pill); background: none; color: var(--ink); font-weight: 600; font-size: var(--fs-body-sm); }
.ai-head-btn:hover, .ai-head-btn.on { background: color-mix(in srgb, var(--ai) 12%, transparent); }
.ai-head-btn .ai-spark { font-size: var(--fs-body-sm); }
@media (max-width: 760px) { .ai-head-btn { padding: 8px 12px; } .ai-head-btn .ai-head-label { display: none; } }
/* Ask your home, always at hand on phones */
.ask-bar { display: none; }
@media (max-width: 999px) {
  .ask-bar { position: fixed; z-index: 19; left: 12px; right: 12px; bottom: calc(66px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px; border: 1px solid color-mix(in srgb, var(--ai) 35%, var(--line)); border-radius: var(--r-pill); background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); color: var(--muted); font-size: var(--fs-body-sm); text-align: left; box-shadow: 0 6px 24px rgba(0,0,0,.12); }
  main { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }
  /* Content passing under the ask bar and the tabs fades into the page instead of showing through them. */
  body::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 18; pointer-events: none;
    height: calc(140px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 62%); }
  .toast { bottom: calc(124px + env(safe-area-inset-bottom)); }
}

/* ---------- Home: one line of state, one "worth a look" card, then control ---------- */
.home-head { margin: 4px 0 18px; }
.home-head h1 { margin: 0; font: 300 32px/1.1 var(--rounded); letter-spacing: -.03em; }
.home-name { margin: 4px 0 12px; color: var(--muted); }
.home-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.hs { display: inline-flex; align-items: baseline; gap: 6px; padding: 7px 12px; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow); color: var(--muted); font-size: var(--fs-secondary); text-decoration: none; }
.hs b { color: var(--ink); font: 500 16px/1 var(--rounded); font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) { a.hs:hover { background: var(--hover); } }
.hs.warn b { color: var(--warn); }
@media (max-width: 760px) { .home-head h1 { font-size: 28px; } .home-stats { gap: 6px; } .hs { padding: 6px 10px; } }

.attn { margin: 0 0 18px; }
.attn-head { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; font-weight: 650; font-size: var(--fs-body); }
.attn-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); font-size: var(--fs-caption); }
.attn.urgent .attn-count { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.attn-row { gap: 12px; flex-wrap: wrap; color: inherit; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { a.attn-row:hover { background: var(--hover); } }
.attn-ico { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); font-size: var(--fs-body); }
.attn-ico svg { width: 17px; height: 17px; }
.attn-alert .attn-ico { background: color-mix(in srgb, var(--bad) 18%, transparent); }
.attn-warn .attn-ico { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.attn-tip .attn-ico { background: color-mix(in srgb, var(--ai) 16%, transparent); color: var(--ai); }
.attn-alert .grow { font-weight: 600; }
.attn-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.attn-more { display: block; width: 100%; margin-top: 6px; padding: 8px; border: 0; background: none; color: var(--brand); font-weight: 600; }
@media (max-width: 760px) { .attn-acts { width: 100%; justify-content: flex-end; } }

.ai-brief { margin: 0 0 18px; }
.ai-brief-text { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--ai) 26%, transparent); border-radius: var(--radius-card); background: var(--surface); color: var(--ink); text-align: left; font-size: var(--fs-body-sm); line-height: 1.5; }
.ai-brief:not(.open) .ai-brief-text .grow { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ai-brief-text .ai-spark { margin-top: 3px; }
.ai-brief-tools { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.scene-strip { margin-bottom: 4px; }

/* A small × to dismiss */
.x-btn { flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: var(--fs-lead); line-height: 1; }
@media (hover: hover) and (pointer: fine) { .x-btn:hover { background: var(--hover); color: var(--ink); } }
@media (max-width: 760px) {
  .wide-only { display: none; }
  .attn-row { flex-wrap: nowrap; align-items: center; }
  .attn-acts { width: auto; flex-wrap: nowrap; }
  .attn-row .grow small { display: none; }
  /* The title row stays one row: title, then its buttons */
  .page-head { flex-wrap: nowrap; align-items: center; gap: 10px; }
  .page-head > div:first-child { flex: 1 1 auto; min-width: 0; }
  /* A long title (a room called 儿童房 Kids' Room) wraps to two lines instead of losing its end. */
  .page-head h1 { max-width: 100%; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .page-head .head-actions { flex: none; width: auto; flex-wrap: nowrap; }
  /* The page's “＋ New …” button is just “＋” here (its full name stays its label), so the title keeps its room. */
  .page-head .head-actions > .btn.primary { width: 40px; padding-inline: 0; justify-content: center; font-size: 19px; }
  .page-head .head-actions > .btn.primary .btn-label { display: none; }
  /* Other buttons keep their words on one line; a main button without a “＋” form (✦ Ask AI) keeps its width. */
  .page-head .head-actions > .btn, .page-head .head-actions > .more-menu { flex: none; white-space: nowrap; }
  .page-head .head-actions > .btn.primary:not(:has(.btn-label)) { width: auto; padding-inline: 14px; font-size: var(--fs-body); }
  .page-head p { display: none; }
}

/* Settings: one status card (tap for the details) */
a.sys-hero { color: inherit; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { a.sys-hero:hover { background: color-mix(in srgb, var(--ink) 3%, var(--surface)); } }
.sys-hero h3 small { font: 500 13px/1 var(--font); margin-left: 6px; }
.sys-hero .pills { margin-top: 8px; }
.sys-load { margin: 8px 0 0; color: var(--muted); font-size: var(--fs-secondary); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .os-card img { width: 44px; height: 44px; } .os-card h3 { font-size: var(--fs-lead); } }

.room-stats { margin: -8px 0 18px; }
.link-btn { border: 0; background: none; color: var(--brand); font-weight: 600; font-size: var(--fs-body-sm); padding: 4px 0; }
.link-btn:disabled { color: var(--muted); }
.center-actions { justify-content: center; }

/* Scenes: run and edit on one line */
.scene-wrap { display: flex; align-items: stretch; gap: 0; border-radius: var(--radius-tile); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.scene-wrap .scene { flex: 1; min-width: 0; padding-bottom: 14px; box-shadow: none; border-radius: 0; background: none; }
.scene-wrap .scene-edit { position: static; display: grid; place-items: center; flex: none; padding: 0 14px; border-left: 1px solid var(--line); border-radius: 0; font-size: var(--fs-secondary); background: none; }
@media (max-width: 760px) {
  .scene-grid { grid-template-columns: 1fr; gap: 8px; }
  .scene { padding: 10px 12px; }
  .scene small { display: none; }
  /* brands to add: two a row */
  .int-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .int-card { padding: 12px; }
  /* energy totals: one row */
  .grid.stats.energy-stats { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
  .grid.stats.energy-stats .card { padding: 12px; }
  .grid.stats.energy-stats .value { font-size: var(--fs-lead); }
  .grid.stats.energy-stats .label, .grid.stats.energy-stats .sub { font-size: 11.5px; }
}

/* ---------- QiHome's engines (engines.js): the smart dehumidifier and desk lamp ---------- */
.en-top, .en-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.en-hero { display: flex; align-items: center; gap: 20px; }
.en-gauge { position: relative; width: 150px; height: 150px; flex: none; }
.en-ring { width: 100%; height: 100%; }
.en-ring circle { fill: none; stroke-width: 10; }
.en-ring .track { stroke: var(--surface-2); }
.en-ring .fill { stroke: #64d2ff; stroke-linecap: round; transition: stroke-dasharray .4s; }
.en-ring.run .fill { stroke: #30b0c7; }
.en-ring .tick { fill: var(--surface); stroke: var(--ink); stroke-width: 3; }
.en-gauge-c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.en-gauge-c b { font: 300 38px/1 var(--rounded); letter-spacing: -.02em; }
.en-gauge-c b small { font-size: var(--fs-lead); color: var(--muted); }
.en-gauge-c span { color: var(--muted); font-size: var(--fs-secondary); margin-top: 4px; }
.en-hero-text { display: grid; gap: 6px; min-width: 0; }
.en-state { font: 400 20px/1.2 var(--rounded); color: var(--muted); }
.en-state.on { color: var(--brand); }
.en-next { font-weight: 600; }
.en-controls { display: grid; gap: 14px; }
.en-switch { padding: 0; background: none; min-height: 0; }
.en-field { display: grid; gap: 8px; }
.en-field label { display: flex; justify-content: space-between; font-weight: 600; }
.en-field input[type=range] { width: 100%; accent-color: var(--brand); height: 28px; }
.en-label { font-weight: 600; }
.en-seg { margin: 0; display: flex; width: 100%; }
.en-seg button { flex: 1; padding: 7px 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); font-weight: 600; font-size: var(--fs-body-sm); }
.en-seg button[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.en-h { margin: 0 0 10px; font: 500 16px/1.3 var(--rounded); }
.en-why p { margin: 0 0 8px; line-height: 1.55; }
.en-risk { margin-bottom: 14px; border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.en-risk-row { margin-top: 8px; line-height: 1.5; }
.en-risk-row ul { margin: 6px 0 0; padding-left: 20px; }
.en-bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; margin: 4px 0 10px; }
.en-bar i { display: block; height: 100%; border-radius: 5px; background: var(--brand); box-shadow: 0 0 12px -2px var(--glow); }
.en-tank p, .en-learn p { margin: 0 0 8px; }
.en-curve, .en-learn, .en-more { margin-bottom: 14px; }
.en-more summary { cursor: pointer; }
.en-kv { font-weight: 500; font-size: var(--fs-body-sm); overflow-wrap: anywhere; }
.en-swatch { flex: none; display: grid; place-items: center; width: 110px; height: 110px; border-radius: 50%; background: var(--surface-2); font-size: 40px; filter: grayscale(1) opacity(.6); }
.en-swatch.on { filter: none; background: radial-gradient(circle, var(--lamp) 0%, color-mix(in srgb, var(--lamp) calc(var(--lvl) * 60%), transparent) 70%); box-shadow: 0 0 calc(var(--lvl) * 40px) color-mix(in srgb, var(--lamp) 60%, transparent); }
.en-reco .sub { color: var(--muted); font-size: var(--fs-secondary); }
.en-reco-v { display: flex; align-items: center; gap: 14px; margin: 10px 0; flex-wrap: wrap; }
.en-reco-v b { font: 300 30px/1 var(--rounded); }
.en-dot { width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line); }
@media (max-width: 760px) { .en-gauge { width: 120px; height: 120px; } .en-gauge-c b { font-size: var(--fs-title); } .en-swatch { width: 88px; height: 88px; } }

/* The local fallback guide */
.fb-level b small { font-weight: 600; margin-left: 6px; }
.fb-level b small.ok { color: var(--good); }
.fb-level.on { border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.fb-checks li.ok { color: var(--good); }

/* ---------- Intelligence: a status card, then settings in groups (like Settings) ---------- */
.ai-status { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.ai-status-ico { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--r-md); background: color-mix(in srgb, var(--ai) 16%, var(--surface-2)); color: var(--ai); font-size: 24px; }
.ai-status h3 { margin: 0; font: 400 20px/1.2 var(--rounded); overflow-wrap: anywhere; }
.ai-status h3 small { font: 500 13px/1 var(--font); margin-left: 6px; }
.ai-status .pills { margin-top: 8px; }
.ai-status-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ai-status-acts .btn { white-space: nowrap; }
.menu-lead { margin: -2px 4px 10px; color: var(--muted); font-size: var(--fs-secondary); line-height: 1.5; }
.set-row { gap: 12px; }
.set-row .sub { line-height: 1.4; }
.set-row .power { flex: none; }
.ai-settings .menu-group:first-child .menu-h { margin-top: 18px; }
.ai-mem-add { gap: 8px; flex-wrap: wrap; }
.ai-mem-add input:not([type=checkbox]) { flex: 1; min-width: 160px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); }
.ai-mem-shared { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-secondary); }
.pu-select { max-width: 150px; flex: none; }
.pu-times { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: var(--fs-secondary); }
.pu-times input { padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); }
.ai-audit { margin-top: 4px; }
.ai-audit summary { cursor: pointer; }
.ai-audit .ai-audit-row { display: block; }
.ai-manual { margin-top: 24px; }
.ai-manual summary { cursor: pointer; }
@media (max-width: 760px) {
  .ai-status { flex-wrap: wrap; }
  .ai-status-acts { width: 100%; justify-content: flex-start; }
  .pu-select { max-width: 120px; }
}

/* One address, at home or away (switch.js): the outage banner. */
.switch-banner { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; width: min(560px, calc(100% - 32px)); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 14px 16px; color: var(--ink); background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.switch-banner b { flex-basis: 100%; }
.switch-banner span { color: var(--muted); }
.switch-banner .switch-actions { display: flex; gap: 8px; margin-left: auto; }
@media (max-width: 767px) { .switch-banner { bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ---------- settings pages: status card, steps, form switches (app.js ui.*) ---------- */
.set-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.set-hero-ico { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--r-md); background: var(--surface-2); color: var(--muted); }
.set-hero-ico svg { width: 26px; height: 26px; }
.set-hero.good .set-hero-ico { background: color-mix(in srgb, var(--good) 16%, var(--surface-2)); color: var(--good); }
.set-hero.warn .set-hero-ico { background: color-mix(in srgb, var(--warn) 18%, var(--surface-2)); color: var(--warn); }
.set-hero.bad .set-hero-ico { background: color-mix(in srgb, var(--bad) 16%, var(--surface-2)); color: var(--bad); }
.set-hero.ai .set-hero-ico, .set-hero.accent .set-hero-ico { background: color-mix(in srgb, var(--brand) 16%, var(--surface-2)); color: var(--brand); }
.set-hero h3 { margin: 0; font: 400 20px/1.25 var(--rounded); overflow-wrap: anywhere; }
.set-hero p { margin: 4px 0 0; line-height: 1.5; }
.set-hero-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.set-steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.set-steps li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); font-size: var(--fs-secondary); }
.set-steps li.done { color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface-2)); }
.set-steps li.busy { color: var(--warn); }
.set-steps li.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface-2)); }
.set-steps .spinner { width: 12px; height: 12px; }
.set-row select.search, .set-row input.search { flex: none; width: min(260px, 45%); margin: 0; }
.set-row .value { flex: none; color: var(--muted); }
.set-row code { font-size: var(--fs-secondary); }
input.toggle { appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 28px; margin: 0; border-radius: var(--r-pill); background: var(--switch-off); position: relative; transition: background-color .2s; cursor: pointer; }
input.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--dur-ui) var(--ease-out); }
input.toggle:checked { background: var(--good); }
input.toggle:checked::after { transform: translateX(16px); }
input.toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.set-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; align-items: start; }
.set-cols .menu-group:first-child .menu-h, .set-cols > div > .menu-group:first-child .menu-h { margin-top: 18px; }
.set-save { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 18px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.set-save .field-error { margin: 0 auto 0 0; }
.set-hidden { display: none !important; }
.feature-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.feature-list li { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); }
.feature-list .f-ico { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--brand); }
.feature-list .f-ico svg { width: 20px; height: 20px; }
.feature-list b { display: block; margin-bottom: 2px; }
.feature-list span.sub { color: var(--muted); font-size: var(--fs-secondary); line-height: 1.5; }
@media (max-width: 767px) {
  .set-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 12px 14px; }
  .set-hero-ico { width: 44px; height: 44px; border-radius: var(--r-md); }
  .set-hero h3 { font-size: var(--fs-lead); }
  .set-hero-acts { grid-column: 1 / -1; justify-content: flex-start; }
  .set-row.stack > .grow { flex-basis: 100%; }
  .set-save { position: static; }
  .set-cols, .feature-list { grid-template-columns: 1fr; }
  .set-row select.search, .set-row input.search { width: 100%; }
  .set-row.stack { flex-wrap: wrap; }
}

/* ---------- remote access (hacs.js): sign-in on the left, what you get on the right ---------- */
.rm-cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 24px; align-items: start; }
.rm-start { display: grid; gap: 10px; padding: 24px; }
.rm-start .rm-ico { background: color-mix(in srgb, var(--brand) 16%, var(--surface-2)); color: var(--brand); }
.rm-start h2 { margin: 6px 0 0; font: 300 22px/1.25 var(--rounded); }
.rm-start > p { margin: 0; line-height: 1.55; }
.rm-seg { margin: 6px 0 4px; width: 100%; }
.rm-seg button { flex: 1; padding: 8px 12px; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); font-weight: 600; font-size: var(--fs-body-sm); cursor: pointer; }
.rm-seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.rm-start .rm-form { max-width: none; gap: 10px; }
.rm-start .rm-form .ed-field { margin: 0; }
.rm-start .btn.wide { width: 100%; justify-content: center; margin-top: 4px; }
.rm-start .link-btn { justify-self: center; }
.rm-also { margin: 12px 4px 0; line-height: 1.5; }
.rm-qr { display: grid; place-items: center; padding: 18px; }
.rm-qr .qr { width: 168px; height: 168px; border-radius: var(--r-md); background: #fff; padding: 8px; }
@media (max-width: 900px) { .rm-cols { grid-template-columns: 1fr; } }

/* ---------- energy settings (more.js) ---------- */
.ef-seg { margin: 0; flex: none; }
.ef-seg label { display: inline-flex; cursor: pointer; }
.ef-seg input { position: absolute; opacity: 0; pointer-events: none; }
.ef-seg span { padding: 6px 14px; border-radius: var(--r-sm); color: var(--muted); font-weight: 600; font-size: var(--fs-body-sm); }
.ef-seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.ef-seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }
.ef-price { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.ef-price input.search { width: 140px; }
#energy-form .menu-group .list.menu { max-height: none; }
.rm-cols .feature-list, .set-cols .feature-list { grid-template-columns: 1fr; gap: 0; padding: 4px 16px; background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); }
.rm-cols .feature-list li, .set-cols .feature-list li { padding: 14px 0; background: none; box-shadow: none; border-radius: 0; }
.rm-cols .feature-list li + li, .set-cols .feature-list li + li { border-top: 1px solid var(--line); }

/* Automations: search and filters above the list; scripts folded away. */
.auto-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.auto-tools .search { flex: 1 1 220px; }
.scripts-fold > summary { list-style: none; cursor: pointer; }
.scripts-fold > summary::-webkit-details-marker { display: none; }
.scripts-fold > summary h2::after { content: ' ›'; color: var(--muted, #888); }
.scripts-fold[open] > summary h2::after { content: ' ⌄'; }
.energy-guide p { margin: 6px 0 10px; }
/* Empty rooms stay listed but step back. */
.room.room-empty { opacity: .55; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { .room.room-empty:hover { opacity: .85; } }
/* One-tap cards: the name on one line (with an ellipsis), never folded into three. */
.scene .grow { min-width: 0; }
.scene .grow b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene .run { flex: none; white-space: nowrap; }
/* Phones: the name folds onto two lines rather than pushing run / history / on-off to a row of their own. */
@media (max-width: 640px) {
  .auto-row { gap: 4px; padding-right: 10px; }
  .auto-row .row-link { min-width: 0; }
  .auto-row .row-link .title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}

/* Motion: tiles fade between off and on (patched in place, app.js), the chat window slides in and out, and
   new messages and action cards rise in once (data-new, ai.js). None of it where motion is reduced. */
.tile { transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-ui) ease, box-shadow var(--dur-ui) ease; }
.tile .icon { transition: background-color var(--dur-ui) ease, color var(--dur-ui) ease, box-shadow var(--dur-ui) ease; }
@media (prefers-reduced-motion: no-preference) {
  #ai-drawer.opening .ai-chat { animation: ai-drawer-in .3s var(--ease-drawer) both; }
  #ai-drawer.closing .ai-chat { animation: ai-drawer-out .18s var(--ease-out) both; }
  .ai-msg[data-new] { animation: ai-msg-in .24s var(--ease-out) both; }
  .ai-msg.me[data-new] { transform-origin: 100% 100%; }
  .ai-msg.ai[data-new] { transform-origin: 0 100%; }
  .ai-msg.busy[data-new] { animation: ai-msg-in .24s var(--ease-out) both, ai-pulse 1.4s ease-in-out .24s infinite; }
  .ai-act[data-new] { animation: ai-act-in .24s var(--ease-out) both; }
  .ai-msg[data-new] .ai-act[data-new] { animation-delay: .16s; }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 640px) {
  #ai-drawer.opening .ai-chat { animation-name: ai-sheet-in; }
  #ai-drawer.closing .ai-chat { animation-name: ai-sheet-out; }
}
@keyframes ai-drawer-in { from { opacity: 0; transform: translateX(28px) scale(.97); } }
@keyframes ai-drawer-out { to { opacity: 0; transform: translateX(28px) scale(.97); } }
@keyframes ai-sheet-in { from { transform: translateY(100%); } }
@keyframes ai-sheet-out { to { transform: translateY(100%); } }
@keyframes ai-msg-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes ai-act-in { from { opacity: 0; transform: translateY(6px); } }
.controls-off { opacity: .45; filter: grayscale(.6); pointer-events: none; }
.offline-note { margin: 4px 0 10px; padding: 10px 12px; border-radius: var(--r-md); background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--ink); font-size: var(--fs-secondary); }

/* Member access: the room and device picker */
.acc-pick { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 12px; margin-bottom: 12px; }
.acc-room + .acc-room { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.acc-room-h { font-weight: 600; }
.acc-devs { padding-left: 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 12px; }
.acc-devs .check-row { font-size: var(--fs-secondary); }

/* Developer page */
.dev-code { background: var(--surface-2, rgba(127,127,127,.1)); border-radius: var(--r-sm); padding: 10px 12px; font-size: var(--fs-secondary); overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.dev-secret { font-size: var(--fs-body-sm); user-select: all; }
.dev-prefix { font-size: var(--fs-caption); opacity: .7; }
.dev-url { word-break: break-all; }

/* Automation rehearsal */
.rehearsal h3 { margin: 0 0 6px; font-size: var(--fs-body); }
.rehearsal.warn { border: 1px solid rgba(255, 159, 10, .5); }
.rehearsal-times { columns: 2; font-size: var(--fs-secondary); padding-left: 18px; margin: 8px 0 0; }
.rehearsal-times .night { color: #ff9f0a; font-weight: 600; }

/* Forgot password, recovery codes */
.link-btn { background: none; border: 0; color: var(--accent, var(--brand)); box-shadow: none; margin-top: 4px; }
.rc-codes { font: 600 17px/1.8 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; background: rgba(127, 127, 127, .1); border-radius: var(--r-md); padding: 12px 16px; user-select: all; columns: 2; }
.recover-other { text-align: left; font-size: var(--fs-secondary); opacity: .85; margin-top: 14px; }
.recover-other ul { padding-left: 18px; margin: 6px 0; }
.recover-other code { font-size: var(--fs-caption); }
.login .recover-q { display: grid; gap: 10px; text-align: left; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.login:has(#recover) { align-content: center; gap: 4px; }
.login .recover-foot { width: min(380px, 100%); display: grid; gap: 6px; }
.recover-q h2 { font-size: var(--fs-body); margin: 0; text-align: center; }
.recover-q label { display: grid; gap: 4px; font-size: var(--fs-secondary); }
.seg button { padding: 6px 14px; border-radius: var(--r-sm); border: 0; background: none; color: var(--muted); font-weight: 600; font-size: var(--fs-body-sm); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink, inherit); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg { flex-wrap: wrap; }
.care-sensors { max-height: 260px; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 12px; padding: 8px 0; }
.care-form { display: grid; gap: 14px; max-width: 560px; }
.care-form > label:not(.check-row):not(.switch-row) { display: grid; gap: 6px; font-size: var(--fs-body-sm); }
.tou-head, .tou-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto; gap: 8px; align-items: center; margin-top: 8px; }
.tou-head { font-size: var(--fs-caption); color: var(--muted); margin-top: 14px; }
.tou-result h3 { margin: 0 0 6px; }
.tou-save { color: #30b158; white-space: nowrap; font-size: var(--fs-secondary); }
@media (max-width: 560px) { .tou-head { display: none; } .tou-row { grid-template-columns: 1fr 1fr; } }

/* Floor plan */
.fp-card { padding: 12px; background: var(--surface-2); box-shadow: none; overflow-x: auto; }
.fp-stage { position: relative; margin: 0 auto; }
.fp { width: 100%; height: auto; display: block; user-select: none; overflow: visible; }
.editing .fp { touch-action: none; }
.fp rect, .fp polygon, .fp line, .fp circle { vector-effect: non-scaling-stroke; }
.fp-room rect, .fp-room polygon { fill: var(--surface); stroke: var(--line); stroke-width: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.06)); }
.fp-room.sel rect, .fp-room.sel polygon { stroke: var(--brand); stroke-width: 2; }
.fp-handle { fill: var(--brand); stroke: var(--surface); stroke-width: 1.5; cursor: nwse-resize; }
.fp-obj rect { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; }
.fp-obj.cat-rug rect { fill: none; stroke-dasharray: 2 3; }
.fp-obj.guess rect { stroke-dasharray: 3 2; stroke: color-mix(in srgb, var(--muted) 45%, transparent); }
.fp-obj.sel rect { stroke: var(--brand); stroke-width: 2; fill: color-mix(in srgb, var(--brand) 10%, var(--surface-2)); }
.fp-wall { stroke: color-mix(in srgb, var(--ink) 80%, transparent); stroke-linecap: square; }
.fp-wall-end { fill: var(--surface); stroke: var(--brand); stroke-width: 3; cursor: grab; }
.fp-wall-end:active { cursor: grabbing; fill: color-mix(in srgb, var(--brand) 20%, var(--surface)); }
/* Styles moved off inline style="" (strict CSP style-src 'self'); dynamic sizes stay as SVG/data attributes. */
.fp-wall-hit { cursor: move; pointer-events: stroke; }
.fp-wall-cross { fill: none; stroke: #d97706; }
.fp-worth { color: #d97706; }
.fp-title.centre { transform: translate(-50%, -50%); text-align: center; }
.fp-window { stroke: color-mix(in srgb, var(--brand) 55%, transparent); stroke-width: 3; stroke-linecap: round; }
.fp-door { stroke: color-mix(in srgb, var(--muted) 55%, transparent); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 5 3; }
.editing .fp-obj, .editing .fp-room, .editing .fp-pin { cursor: move; }
.fp-over { position: absolute; inset: 0; pointer-events: none; }
.fp-title { position: absolute; z-index: 2; display: grid; gap: 1px; line-height: 1.2; white-space: nowrap; padding: 2px 6px; margin: -2px -6px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--surface) 88%, transparent); pointer-events: none; }
.fp-title b { font-weight: 600; font-size: var(--fs-body-sm); color: var(--ink); }
.fp-title span { font-size: var(--fs-caption); color: var(--muted); }
.fp-pin { position: absolute; transform: translate(-50%, calc(var(--pin, 40px) / -2)); display: grid; justify-items: center; gap: 3px; padding: 0; border: 0; background: none; pointer-events: auto; font: inherit; color: var(--ink); }
.fp-pin .icon { display: grid; place-items: center; width: var(--pin, 40px); height: var(--pin, 40px); border-radius: 50%; background: var(--surface-2); color: var(--muted); box-shadow: var(--shadow); transition: background-color .2s, transform .15s; }
.fp-pin .icon svg { width: 55%; height: 55%; }
.fp-pin.on .icon { background: var(--on); color: #fff; }
.fp-pin.offline { opacity: .55; }
.fp-pin.sel .icon { box-shadow: 0 0 0 3px var(--brand), var(--shadow); }
.fp-pin:active .icon { transform: scale(.94); }
.fp-pin .name { font-size: var(--fs-caption); font-weight: 500; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1px 6px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--surface) 85%, transparent); }
.fp-flabel { position: absolute; transform: translate(-50%, -50%); font-size: var(--fs-caption); color: var(--muted); white-space: nowrap; }
.fp-objname { position: absolute; transform: translate(-50%, -50%); font-size: var(--fs-caption); font-weight: 500; padding: 2px 8px; border-radius: var(--r-pill); background: var(--brand); color: var(--on-brand); white-space: nowrap; }
.mig-text { width: 100%; min-height: 130px; font: inherit; }
.rcp-slot { display: grid; gap: 4px; margin: 8px 0; font-size: var(--fs-body-sm); }
.acc-hours { display: grid; gap: 8px; padding: 4px 0 8px 26px; }
.acc-hours-row { display: flex; gap: 8px; align-items: center; }
.acc-hours-row .text-input { width: 120px; }
.acc-days { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.inc-table { max-height: 520px; overflow: auto; margin-top: 10px; }
.inc-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-secondary); }
.inc-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.inc-near td { background: rgba(255, 69, 58, .12); font-weight: 600; }
.split-tenant { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); } .split-tenant .text-input { max-width: 260px; }
.ho-list { margin: 6px 0 14px; padding-left: 20px; line-height: 1.8; }
.fp-read { margin-top: 12px; padding: 12px 14px; border-radius: var(--r-md); background: color-mix(in srgb, var(--on) 12%, var(--surface)); font-size: var(--fs-body-sm); }
.fp-read ul { margin: 6px 0 10px; padding-left: 18px; color: var(--ink); }
.fp-read.done { background: color-mix(in srgb, var(--good) 12%, var(--surface)); color: var(--ink); }
.fp-photo-rooms { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* Floor plan in 3D */
.fp3d-wrap { position: relative; padding: 0; overflow: hidden; }
.fp3d-host { width: 100%; height: min(70vh, 620px); touch-action: none; }
.fp3d-canvas { display: block; width: 100%; height: 100%; }
.fp3d-reset { position: absolute; right: 10px; top: 10px; }
.fp3d-panel h3 { margin: 0 0 8px; }
.fp3d-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.fp3d-fields label { display: grid; gap: 4px; font-size: var(--fs-caption); color: var(--muted); }
.fp3d-add { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; align-items: center; }
.fp3d-add .text-input { width: auto; }

/* Floor plan (spatial model, 2D): readable first — clear walls, soft colours by kind, few labels */
.care-form > .switch-row { padding: 4px 0 14px; }

/* Floor plan, "Home" (render) look: the 3D home at night with the devices as round buttons on top. */
.fp3d-host { position: relative; }
.fp-render { background: radial-gradient(120% 90% at 50% 20%, color-mix(in srgb, var(--brand) 10%, var(--surface-2)), var(--surface-2)); }
.fp-render .fp3d-host { height: min(72vh, 680px); }
.fp3d-pins { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fp3d-pin { position: absolute; left: 0; top: 0; width: 44px; height: 44px; margin: -22px 0 0 -22px; display: grid; place-items: center; padding: 0; border-radius: 50%;
  border: 0; background: var(--surface); color: var(--muted);
  box-shadow: 0 4px 14px rgba(0,0,0,.25); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: auto; cursor: pointer; transition: transform .12s, box-shadow .2s; will-change: transform; }
.fp3d-pin svg { width: 22px; height: 22px; }
.fp3d-pin.on { background: var(--on); color: #fff; box-shadow: 0 4px 16px color-mix(in srgb, var(--on) 55%, transparent); } /* as a device tile that is on */
.fp3d-pin.offline { opacity: .45; }
.fp3d-pin.sel { box-shadow: 0 0 0 3px var(--brand), 0 4px 14px rgba(0,0,0,.25); }
.fp3d-pin:active { scale: .94; }
.fp3d-room { position: absolute; left: 0; top: 0; font-size: var(--fs-caption); font-weight: 600; color: color-mix(in srgb, var(--ink) 70%, transparent); white-space: nowrap; pointer-events: none;
  padding: 2px 8px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--surface) 60%, transparent); }
@media (max-width: 640px) { .fp3d-pin { width: 38px; height: 38px; margin: -19px 0 0 -19px; } .fp3d-pin svg { width: 19px; height: 19px; } .fp-render .fp3d-host { height: min(56vh, 120vw); } }
.fp-color { padding: 4px; height: 40px; }

/* ✦ Set it up with AI */
.assist-card { background: color-mix(in srgb, var(--ai) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ai) 22%, transparent); }
.assist-top h3 { margin: 0 0 4px; font-size: var(--fs-body); color: var(--ai); }
.assist-row { display: flex; gap: 8px; margin-top: 10px; }
.assist-row .text-input { flex: 1; min-width: 0; }
.assist-card .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--r-pill); padding: 5px 12px; font: inherit; font-size: var(--fs-secondary); cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .chip:hover { border-color: color-mix(in srgb, var(--ai) 40%, transparent); } }
.assist-out { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: var(--fs-body-sm); }
.assist-out p { margin: 0 0 6px; }
.pick-group { margin: 6px 0 10px; }
.pick-h { font-size: var(--fs-caption); font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.stay-list { padding: 4px 16px; }
.stay-card { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stay-card:last-child { border-bottom: 0; }
.stay-guest { font-weight: 600; }
.stay-meta { font-size: var(--fs-secondary); color: var(--muted); margin-top: 2px; }
.stay-status { font-size: var(--fs-secondary); margin-top: 4px; }
.stay-card.now .stay-status { color: var(--good); }
.stay-card.soon .stay-status { color: var(--brand); }
.stay-card.done .stay-status { color: var(--muted); }
.ho-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .ho-cols { grid-template-columns: 1fr; } }
.ho-cols .card { margin: 0; }
.ho-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: var(--fs-body-sm); }
.ho-items li { display: flex; gap: 10px; align-items: flex-start; }
.ho-ico { width: 22px; flex: none; text-align: center; }
.ho-danger { border: 1px solid color-mix(in srgb, var(--bad, #ff3b30) 30%, transparent); }
.dev-filter { display: flex; gap: 8px; }
.dev-filter #dev-q { flex: 1; min-width: 0; }
.dev-filter #dev-st { width: auto; }
.assist-inline { background: color-mix(in srgb, var(--ai) 8%, var(--surface)); border-radius: var(--r-md); padding: 10px 12px; font-size: var(--fs-body-sm); }

/* Signing in through a return address the browser cannot open (Xiaomi Home): three steps and a paste field. */
.flow-relay { margin: 12px 0; }
.flow-relay .relay-steps { margin: 6px 0 12px; padding-left: 1.3em; line-height: 1.7; }
.flow-relay .relay-steps li { margin: 4px 0; }
.flow-relay .relay-steps .btn { margin-left: 6px; vertical-align: baseline; }
.flow-relay .describe-row { display: flex; gap: 8px; }
.flow-relay .describe-row input { flex: 1; min-width: 0; }

/* The floor plan's object library: common objects as picture cards (preset-thumbs.png), in folding groups. */
.fp-lib-group { margin: 6px 0; }
.fp-lib-group summary { cursor: pointer; padding: 6px 0; font-weight: 600; }
.fp-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.fp-lib-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; border: 1px solid transparent; border-radius: var(--r-md); background: var(--surface); color: var(--ink); cursor: grab; text-align: center; font: inherit; }
@media (hover: hover) and (pointer: fine) { .fp-lib-card:hover { border-color: var(--brand); } }
.fp-lib-card.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; }
.fp-lib-card small { font-size: var(--fs-caption); }
.fp-lib-name { font-size: var(--fs-secondary); font-weight: 500; line-height: 1.25; }
.fp-lib-thumb { width: 64px; height: 64px; background-image: url(preset-thumbs.png); background-repeat: no-repeat; flex: none; }

/* ---------- warm light: the home page's 3D home (floorplan.js "homeSpace" hook) ---------- */
.home-space { position: relative; margin: 14px 0 6px; }
.home-3d { position: relative; height: clamp(300px, 46vw, 460px); border-radius: var(--radius-card); overflow: hidden;
  -webkit-mask-image: radial-gradient(ellipse 72% 70% at 50% 50%, #000 60%, transparent 100%); mask-image: radial-gradient(ellipse 72% 70% at 50% 50%, #000 60%, transparent 100%); }
.home-3d canvas { display: block; width: 100% !important; height: 100% !important; }
.home-space-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: -8px; padding: 0 4px; }
.home-space-lit { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-secondary); letter-spacing: .04em; }
.home-space-lit i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.home-space-lit.on { color: var(--ink); }
.home-space-lit.on i { background: var(--glow); box-shadow: 0 0 10px var(--glow); }
.home-space-open { background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); font-size: var(--fs-secondary); letter-spacing: .04em; }

/* ---------- warm light: the home page layout ---------- */
.home-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
/* A grid column is as wide as its widest content by default: a long row of scenes (it scrolls sideways) made the
   whole page wider than a phone. */
.home-top > *, .home-side, .home-side > * { min-width: 0; }
.home-date { margin: 0 0 6px; color: var(--muted); font-size: var(--fs-caption); letter-spacing: .18em; }
.home-head h1 { font: 200 44px/1.1 var(--rounded) !important; letter-spacing: .06em !important; }
.home-name { letter-spacing: .04em; }
.home-side .home-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 0; padding: 6px; border-radius: var(--radius-card);
  background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(24px) saturate(150%); -webkit-backdrop-filter: blur(24px) saturate(150%); box-shadow: var(--shadow); }
.home-side .hs { flex-direction: column-reverse; align-items: flex-start; gap: 6px; padding: 14px 16px; border-radius: var(--r-lg); background: none; box-shadow: none; font-size: var(--fs-caption); letter-spacing: .14em; }
.home-side .hs b { font: 200 30px/1 var(--rounded); letter-spacing: -.02em; }
@media (hover: hover) and (pointer: fine) { .home-side .hs:hover { background: var(--hover); } }
.home-side .hs.warn b { color: var(--warn); }
.home-side .scene-strip { margin-top: 14px; }
@media (min-width: 1200px) {
  .home-top { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .home-side { position: sticky; top: 24px; }
  .home-side .home-stats { grid-template-columns: 1fr 1fr; }
  .home-side .scene-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; overflow: visible; padding: 0; margin: 14px 0 0; }
}

/* ---------- QiHome's signature: what is on lights its own card ---------- */
.tile.on, .room.lit, .scene-chip.running {
  background: radial-gradient(240px 190px at 16% 18%, color-mix(in srgb, var(--glow) 34%, transparent), color-mix(in srgb, var(--glow) 8%, transparent) 55%, transparent 80%), var(--surface) !important;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--glow) 40%, transparent), 0 0 38px -18px var(--glow) !important;
  border-color: transparent !important;
}
.tile.on::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; padding: 1px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--glow) 90%, transparent), color-mix(in srgb, var(--glow) 10%, transparent) 60%, transparent);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }

/* ---------- phones: the floor plan's explanations fold away; the 3D home comes first ---------- */
@media (max-width: 640px) {
  .fp-note { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: var(--fs-secondary); }
  .fp-note.open { display: block; }
  .home-head h1 { font-size: 38px !important; }
  .home-side .hs { padding: 12px 14px; }
  .home-side .hs b { font-size: 26px; }
}
.fp-lib-search { width: 100%; margin: 10px 0 8px; }
/* Live world diagnostics: a readable table (headings align with their cells). */
.lw-table th { text-align: left; font-weight: 600; color: var(--muted, #888); font-size: var(--fs-caption); }
.lw-table td, .lw-table th { padding: 7px 10px 7px 0; vertical-align: top; }
.lw-list { margin: 0; padding-left: 18px; }
/* Home activity: timeline times in a column, filter chips, suggestion buttons that wrap on phones. */
.hi-time { min-width: 92px; color: var(--muted, #888); font-size: var(--fs-caption); font-variant-numeric: tabular-nums; }
.hi-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.hi-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.hi-sg { align-items: flex-start; flex-wrap: wrap; }
.hi-why { margin-left: 6px; font-size: var(--fs-caption); }
.hi-why-ans { margin-top: 2px; }
@media (max-width: 560px) { .hi-sg .hi-actions { width: 100%; justify-content: flex-start; } }

/* Guardian page */
.gd-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.gd-head h3 { margin: 0; }
.gd-card .row .grow { min-width: 0; }
.gd-card .row .sub { overflow-wrap: anywhere; }
.gd-pol { margin-top: 12px; display: grid; gap: 6px; }
.gd-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 6px 0 10px; }
.gd-stat { background: var(--surface-2); border-radius: var(--r-md); padding: 12px; display: grid; gap: 2px; }
.gd-stat b { font-size: 24px; }
.gd-stat span { color: var(--muted); font-size: var(--fs-secondary); }
.ok-text { color: var(--good); }

/* Member daily time limits */
.acc-lims { display: grid; gap: 8px; margin-bottom: 8px; }
.acc-lim { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; border-radius: var(--r-md); background: var(--surface-2); }
.acc-lim select { flex: 1 1 220px; min-width: 0; }
.acc-lim-min { display: inline-flex; gap: 6px; align-items: center; }
.acc-lim-min .text-input { width: 90px; }

/* Plugin Store and plugin views */
.st-card .st-link, a.st-link { color: inherit; text-decoration: none; min-width: 0; }
.st-card .sub, a.st-link .sub { overflow-wrap: anywhere; }
.st-metric { display: inline-grid; gap: 2px; min-width: 120px; margin: 4px 12px 8px 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.st-metric b { font-size: var(--fs-section); }
.st-metric span { color: var(--muted); font-size: var(--fs-secondary); }
.st-section { margin-top: 10px; }
.st-section h3 { font-size: var(--fs-body); margin: 8px 0; }
.st-field { display: grid; gap: 4px; margin-bottom: 10px; }
.st-tpl select { max-width: 160px; }
.st-pre { max-height: 320px; overflow: auto; font-size: var(--fs-caption); white-space: pre-wrap; overflow-wrap: anywhere; }
.st-view input[type=range] { width: 100%; }
.seg-btn { padding: 6px 14px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-weight: 600; font-size: var(--fs-body-sm); cursor: pointer; }
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.st-tpl { flex-wrap: wrap; }
.st-tpl .grow { flex: 1 1 100%; }
.st-tpl select { flex: 1 1 140px; max-width: none; }

/* Home network (network.js) */
.nw-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.nw-cell .title { font-size: 1.15rem; }
.nw-ok { color: var(--good); }
.nw-warn { color: var(--warn); }
.nw-bad { color: var(--bad); }
.nw-incident.nw-bad { border-left: 3px solid var(--bad); }
.nw-incident.nw-warn { border-left: 3px solid var(--warn); }
.nw-incident h3 { margin: 0 0 6px; }
.nw-facts ul { margin: 4px 0 8px; padding-left: 18px; }
.nw-client { flex-wrap: wrap; gap: 8px; }
.nw-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.nw-actions select, .nw-room { max-width: 180px; }
@media (max-width: 560px) { .nw-actions { width: 100%; } .nw-actions select { max-width: 100%; flex: 1; } }
.nw-roomlabel { display: flex; align-items: center; gap: 8px; }
.nw-level { margin: 0 0 12px; }
.nw-bar { margin: 0 0 16px; flex-wrap: wrap; }
.nw-choice { width: 100%; text-align: left; background: none; border: 0; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .nw-choice:hover { background: color-mix(in srgb, var(--good) 6%, transparent); } }

/* Local components (modules.js) */
.lm-card .lm-head { display: flex; gap: 12px; align-items: flex-start; }
.lm-card .lm-head .grow { flex: 1; min-width: 0; }
.lm-lines { margin: 8px 0; padding-left: 18px; font-size: 0.92em; }
.lm-lines li { margin: 2px 0; }
.lm-plan { border: 1px solid var(--brand); }
.lm-plan ul { margin: 4px 0 10px; padding-left: 18px; }
.lm-notices li { margin: 3px 0; }
.lm-deps { width: 100%; border-collapse: collapse; font-size: 0.92em; }
.lm-deps td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.lm-deps td:first-child { white-space: nowrap; font-weight: 600; }
.lm-chip { display: inline-block; padding: 3px 10px; border-radius: var(--r-pill); background: var(--hover); color: var(--ink); font-size: var(--fs-caption); font-weight: 600; white-space: nowrap; }
.lm-chip.subtle { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.lm-block { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.lm-nas { margin: 10px 0; background: var(--hover); box-shadow: none; }
.inf-ok { background: color-mix(in srgb, var(--good) 18%, var(--surface)); }
.inf-warn { background: color-mix(in srgb, var(--warn) 22%, var(--surface)); }
.inf-bad { background: color-mix(in srgb, var(--bad) 20%, var(--surface)); }
/* Floor plan overlays from plugins (world.overlay.publish) */
.fp-room.ov-ok rect, .fp-room.ov-ok polygon { fill: color-mix(in srgb, var(--good) 30%, var(--surface)); }
.fp-room.ov-warn rect, .fp-room.ov-warn polygon { fill: color-mix(in srgb, var(--warn) 34%, var(--surface)); }
.fp-room.ov-bad rect, .fp-room.ov-bad polygon { fill: color-mix(in srgb, var(--bad) 32%, var(--surface)); }
.fp-room.ov-info rect, .fp-room.ov-info polygon { fill: color-mix(in srgb, var(--cool) 26%, var(--surface)); }
.fp-room.ov-none rect, .fp-room.ov-none polygon { opacity: 0.55; }
.fp-ov-label { font-weight: 600; fill: var(--ink); opacity: 0.85; pointer-events: none; }

/* QiHome automations (qrules.js): When / If / Then, one line each; the selects fold under the word on phones. */
.qr-form .qr-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.qr-form .qr-line > b { width: 44px; flex: none; color: var(--muted); font-weight: 600; }
.qr-form .qr-line select { flex: 1 1 140px; min-width: 0; }
.qr-form .field { display: flex; align-items: center; gap: 8px; }
.qr-form .field > span { width: 44px; flex: none; color: var(--muted); font-weight: 600; }
.qr-form .field > input { flex: 1; min-width: 0; }

/* Plugin UI extensions (uix.js): sections on device and room pages, context actions, Home widgets, badges. */
.ux-section { margin: 14px 0 0; }
.ux-section .sheet-h small { font-weight: 400; margin-left: 6px; }
.ux-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.ux-room { margin-top: 18px; }
.ux-widgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 18px; }
.ux-widget.ux-large { grid-column: 1 / -1; }
.ux-widget h3 { margin: 0 0 8px; font-size: var(--fs-body); }
.ux-widget h3 a { color: inherit; text-decoration: none; }
.ux-from { margin-top: 10px; }
.ux-badge.bad { background: color-mix(in srgb, var(--bad) 22%, transparent); color: var(--bad); }
.ux-badge.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.seg a { text-decoration: none; color: inherit; padding: 6px 12px; border-radius: var(--r-pill); }
.seg a.on { background: var(--surface); font-weight: 600; }
.list a.row, .list a.row:hover { color: inherit; text-decoration: none; }
/* Declarative UI V1: progress, table, timeline, grid (store.js renderer). */
.st-progress { display: block; margin: 10px 0; }
.st-progress .row-flex { display: flex; gap: 8px; margin-bottom: 4px; }
.st-progress progress { width: 100%; height: 8px; accent-color: var(--brand); }
.st-table { overflow-x: auto; margin: 8px 0; }
.st-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-body-sm); }
.st-table th, .st-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--hairline, rgba(127,127,127,.2)); white-space: nowrap; }
.st-table th { color: var(--muted); font-weight: 600; }
.st-timeline { list-style: none; margin: 8px 0; padding: 0 0 0 14px; border-left: 2px solid var(--hairline, rgba(127,127,127,.25)); }
.st-timeline li { position: relative; display: flex; gap: 10px; align-items: center; padding: 8px 0 8px 10px; }
.st-timeline li::before { content: ''; position: absolute; left: -20px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--muted); }
.st-timeline li.ok::before { background: var(--good); } .st-timeline li.warn::before { background: var(--warn); } .st-timeline li.bad::before { background: var(--bad); }
.st-timeline .sub { color: var(--muted); font-size: var(--fs-secondary); }
.st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 8px 0; }
.st-tile { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: var(--r-md); background: var(--surface); }
.st-tile span:not(.badge) { color: var(--muted); font-size: var(--fs-secondary); }
/* Settings: developer tools folded away (open for those who look). */
.menu-fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.menu-fold > summary::-webkit-details-marker { display: none; }
.menu-fold > summary::after { content: '›'; transform: rotate(90deg); transition: transform var(--dur-ui) var(--ease-out); color: var(--muted); }
.menu-fold:not([open]) > summary::after { transform: none; }
.menu-fold[open] > summary { margin-bottom: var(--sp-2); }
.home-status { display: inline-flex; align-items: center; gap: var(--sp-2); margin: var(--sp-2) 0 0; font-size: var(--fs-body-sm); color: var(--muted); }
.home-status.warn { color: var(--warn); }
.home-status .hs-part { white-space: nowrap; } /* "5 devices on" stays together; a long line breaks at the dots */
/* A raw error for whoever needs it, folded under its plain-words sentence. */
.tech-details { margin-top: 6px; font-size: var(--fs-caption); color: var(--muted); }
.tech-details summary { cursor: pointer; }
.tech-details code { display: block; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* The assistant shows what it was opened about (ai.js contextChip). */
.ai-context { margin: 0; padding: var(--sp-1) var(--sp-4) 0; }
.ai-context span { display: inline-block; font-size: var(--fs-caption); color: var(--ai); background: color-mix(in srgb, var(--ai) 12%, transparent); border-radius: var(--r-pill); padding: 3px 10px; }

/* Add a node (Settings → QiHome nodes) */
.node-sheet .node-status { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; color: var(--muted); font-size: var(--fs-secondary); }
.node-sheet .node-status .link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.node-sheet .node-row { align-items: flex-start; }
.node-sheet .node-row .menu-icon { margin-top: 2px; border-radius: 50%; }
.node-sheet .node-row .btn { align-self: center; }
.node-sheet .node-tag { margin-top: 6px; }
.node-sheet .node-empty { display: grid; justify-items: center; gap: 8px; padding: 22px 16px; text-align: center; background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow); }
.node-sheet .node-empty p { margin: 0; max-width: 34ch; }
.node-sheet .node-more { display: block; margin: 16px auto 0; background: none; border: 0; color: var(--brand); font: inherit; font-size: var(--fs-body-sm); cursor: pointer; }
.node-sheet .node-manual { display: flex; gap: 8px; margin-top: 12px; }
.node-sheet .node-manual[hidden] { display: none; }
.node-sheet .node-manual input { flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); }
.node-sheet .node-manual input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 1px; border-color: transparent; }

/* Habit prediction shortcuts (home) and the nodes' advanced view */
.predict-chip span { display: grid; gap: 2px; text-align: left; }
.predict-chip small { font-weight: 500; font-size: 12px; color: var(--muted); }
.predict-chip svg { color: var(--glow); }
.node-adv { margin-top: 18px; }
.node-adv > summary { cursor: pointer; font-weight: 600; padding: 10px 0; color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .node-adv > summary:hover { color: var(--ink); } }
.adv-card h3 { margin: 0 0 6px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.adv-card p { margin: 6px 0; }
.adv-card .small { font-size: 13px; }
.adv-card .row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.adv-card .list { margin-top: 10px; }
.warn-card { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 45%, transparent), var(--shadow); }
.warn-card b { color: var(--warn); }
.warn-card .btn { margin-top: 6px; }

/* Node topology (Nodes page) */
.topo-card h3 { margin: 0 0 8px; font-size: 16px; }
.topo-wrap { overflow-x: auto; }
.topo-wrap svg { width: 100%; min-width: 520px; height: auto; display: block; }
.topo-link { stroke: color-mix(in srgb, var(--good) 70%, transparent); stroke-width: 2.5; }
.topo-link.off { stroke: var(--muted); stroke-dasharray: 6 6; opacity: .6; }
.topo-rtt { fill: var(--muted); font-size: 12px; text-anchor: middle; stroke: var(--surface); stroke-width: 6px; paint-order: stroke; stroke-linejoin: round; }
.topo-link.thin { stroke-width: 1; opacity: .5; }
.topo-mini { fill: var(--good); stroke: var(--surface); stroke-width: 1.5; }
.topo-mini.off { fill: var(--muted); }
.topo-node rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.topo-node.self rect { stroke: color-mix(in srgb, var(--brand) 55%, var(--line)); stroke-width: 2; }
.topo-link.far { opacity: .45; }
.topo-link.faint { opacity: .14; }
.topo-ring { fill: none; stroke: var(--line); stroke-width: 1.5; }
.topo-mini.self { stroke: var(--brand); stroke-width: 2; }
.topo-node.off rect { stroke-dasharray: 5 4; }
.topo-node.off text { opacity: .6; }
.topo-dot { fill: var(--good); }
.topo-node.off .topo-dot { fill: var(--muted); }
.topo-name { fill: var(--ink); font-size: 15px; font-weight: 600; }
.topo-sub { fill: var(--muted); font-size: 12.5px; }
.topo-tag { fill: var(--brand); font-size: 12px; font-weight: 600; }

/* Apps (Home Assistant add-ons) */
.ap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ap-card { display: flex; gap: 12px; align-items: flex-start; text-decoration: none; color: inherit; }
.ap-card.dim { opacity: .6; }
.ap-card .sub { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ap-icon { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; flex: none; background: var(--surface-2, rgba(127,127,127,.12)); }
.ap-icon.empty { display: inline-block; }
.ap-head { display: flex; gap: 16px; align-items: flex-start; }
.ap-head .ap-icon { width: 64px; height: 64px; }
.ap-toolbar { display: flex; gap: 8px; margin: 8px 0 12px; flex-wrap: wrap; }
.ap-toolbar input { flex: 1; min-width: 200px; }
.ap-logs, .ap-docs { white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; font-size: 12px; }
#ap-opts { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.ap-web { display: flex; flex-direction: column; height: calc(100dvh - 120px); }
.ap-web iframe { flex: 1; width: 100%; border: 0; border-radius: 12px; background: #fff; }
.ap-webbar { padding: 4px 0 8px; }

/* QiHome apps (qapps.js): configuration editor, MQTT explorer, network tools, dynamic DNS */
.bad-text { color: var(--bad); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.qa-ed, .qa-mq { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.qa-main { min-width: 0; display: grid; gap: 12px; }
.qa-side { display: grid; gap: 10px; min-width: 0; }
.qa-crumbs { font-size: var(--fs-secondary); color: var(--muted); overflow-wrap: anywhere; }
.qa-crumbs a { color: var(--brand); text-decoration: none; }
.qa-files { display: grid; max-height: 60vh; overflow: auto; }
.qa-file { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-size: var(--fs-body-sm); }
.qa-file svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.qa-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-file:hover, .qa-file.on, .qa-topic:hover, .qa-topic.on, .qa-hist a.on { background: var(--hover); }
.qa-new { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.qa-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qa-bar b { overflow-wrap: anywhere; }
.qa-editor { width: 100%; min-height: 60vh; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: 13px; line-height: 1.55; tab-size: 2; resize: vertical; box-sizing: border-box; }
.qa-pre { margin: 8px 0 0; padding: 10px 12px; max-height: 50vh; overflow: auto; background: var(--hover); border-radius: var(--r-sm); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.qa-hist { display: grid; margin-top: 6px; }
.qa-hist a { padding: 5px 8px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-size: var(--fs-secondary); font-variant-numeric: tabular-nums; }
.qa-tree { max-height: 62vh; overflow: auto; }
.qa-grp summary { cursor: pointer; padding: 6px 4px; font-weight: 600; }
.qa-topic { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 5px 8px 5px 16px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-size: 12.5px; }
.qa-topic span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-form { display: grid; gap: 10px; margin-top: 10px; }
.qa-form label { display: grid; gap: 4px; }
.qa-form textarea { width: 100%; box-sizing: border-box; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); }
.qa-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.qa-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.qa-row .search { flex: 1 1 180px; }
.qa-check { display: flex !important; align-items: center; gap: 8px; }
.qa-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.qa-res { margin-top: 10px; font-size: var(--fs-body-sm); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.qa-res:empty { display: none; }
@media (max-width: 760px) { .qa-ed, .qa-mq { grid-template-columns: minmax(0, 1fr); } .qa-files, .qa-tree { max-height: 40vh; } .qa-tools { grid-template-columns: minmax(0, 1fr); } }
.qa-grid label { grid-template-rows: 1fr auto; }
.page-head + .card + .qa-mq { margin-top: 16px; }

/* 家庭 (family.js) */
.fam-tabs { flex-wrap: wrap; max-width: 100%; margin-top: 0; }
.fam-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.fam-row .search { flex: 1 1 140px; }
.fam-sel { flex: 0 1 auto !important; max-width: 220px; }
.fam-check { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.fam-compose textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: var(--radius-control); padding: 10px 12px; background: var(--surface); color: var(--ink); font: inherit; resize: vertical; }
.fam-color input { display: none; }
.fam-color span { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.fam-color input:checked + span { border-color: var(--ink); }
.fam-c-yellow span, .fam-note.fam-c-yellow { background: #fff4c2; }
.fam-c-green span, .fam-note.fam-c-green { background: #dff5dc; }
.fam-c-blue span, .fam-note.fam-c-blue { background: #dcecff; }
.fam-c-pink span, .fam-note.fam-c-pink { background: #ffe0ea; }
.fam-notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.fam-note { padding: 14px 16px; border-radius: 14px; color: #2b241d; box-shadow: 0 2px 10px rgba(0, 0, 0, .06); display: grid; gap: 10px; align-content: space-between; min-height: 110px; }
.fam-note.pinned { outline: 2px solid rgba(0, 0, 0, .12); }
.fam-note p { margin: 0; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.fam-meta { font-size: 12px; color: rgba(43, 36, 29, .65); }
.fam-meta .link, .fam-chore .link, .fam-date .link { background: none; border: 0; padding: 0 0 0 8px; color: var(--brand); cursor: pointer; font: inherit; font-size: 12.5px; }
.fam-meta .link { color: #8a4b12; }
.fam-chore { margin-bottom: 12px; }
.fam-turn { font-size: 22px; font-weight: 600; margin-top: 8px; }
.fam-date { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.fam-date.today { box-shadow: inset 0 0 0 2px var(--brand), var(--shadow); }
.fam-big { min-width: 74px; text-align: center; font-variant-numeric: tabular-nums; }
.fam-big b { display: block; font-size: 30px; line-height: 1.1; }
.fam-big small { color: var(--muted); font-size: 12px; }
.fam-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.fam-timers { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 16px; }
.fam-timer { text-align: center; }
.fam-timer .fam-row { justify-content: center; }
.fam-clock { font-size: 44px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 6px 0; letter-spacing: .02em; }
.fam-timer.rang { box-shadow: inset 0 0 0 3px var(--bad), var(--shadow); animation: fam-pulse 1s ease-in-out infinite alternate; }
.fam-timer.rang .fam-clock { color: var(--bad); font-size: 30px; }
@keyframes fam-pulse { from { transform: scale(1); } to { transform: scale(1.02); } }
.fam-wifi { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.fam-qr { width: 220px; height: 220px; max-width: 100%; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 12px; }
.fam-wifi-v { font-size: 22px; font-weight: 600; margin: 2px 0 10px; overflow-wrap: anywhere; }
.fam-home { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.fam-chip { padding: 8px 14px; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; font-size: var(--fs-body-sm); }
.fam-chip.mine { background: color-mix(in srgb, var(--brand) 14%, var(--surface)); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .fam-timer.rang { animation: none; } }
#fam-tname { flex-basis: 100% !important; }
#fam-tmin, #fam-tsec { flex: 0 1 90px !important; }
.fam-chore .title, .fam-date .title { font-weight: 600; }
label .fam-row { margin-top: 0; flex-wrap: nowrap; gap: 6px; }
#fam-ly { flex: 0 0 76px !important; min-width: 0; }
#fam-lm, #fam-ld { flex: 1 1 0 !important; max-width: none; min-width: 0; }
.qa-grid label:has(#fam-ly) { grid-column: span 2; }
@media (max-width: 520px) { .qa-grid label:has(#fam-ly) { grid-column: auto; } }
.fam-mt { margin-top: 10px; }
.fam-ico { font-size: 22px; width: 32px; text-align: center; }
.fam-kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin: 12px 0 16px; }
.fam-kid { text-align: center; }
.fam-stars { font-size: 30px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
button.link[data-fam] { background: none; border: 0; padding: 0 0 0 10px; color: var(--brand); cursor: pointer; font: inherit; font-size: 12.5px; }
.side-nav a.ux-starting { opacity: .55; }

/* Remote access (remote.js): the ways as cards, the guide's numbered steps. */
.ra-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 24px; }
.ra-card { display: flex; flex-direction: column; gap: 8px; color: inherit; text-decoration: none; min-width: 0; }
@media (hover: hover) and (pointer: fine) { .ra-card:hover { box-shadow: var(--shadow-lg, var(--shadow)); } }
.ra-card.ra-rec { outline: 2px solid var(--brand); }
.ra-card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ra-card p { margin: 0; }
.ra-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ra-q { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.ra-q .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ra-pc { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.ra-pc p { margin: 6px 0 0; }
.ra-steps { list-style: none; margin: 0; padding: 8px 16px; display: flex; flex-direction: column; }
.ra-step { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line, var(--surface-2)); }
.ra-step:last-child { border-bottom: 0; }
.ra-n { flex: 0 0 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); font-weight: 600; font-size: var(--fs-secondary); }
.ra-step.done .ra-n { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.ra-body { min-width: 0; flex: 1; line-height: 1.55; }
.ra-body .care-form { margin-top: 8px; }
.ra-body code.cmd { word-break: break-all; }

/* Smart center (center.js) at the top of 智能 */
.cc-pause { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cc-pause .grow { flex: 1 1 260px; min-width: 0; }
.cc-pause p { margin: 4px 0 0; }
.cc-pause.paused { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
.cc-row { align-items: flex-start; }
.cc-time { flex: 0 0 auto; min-width: 64px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.cc-row .title .badge { margin-right: 4px; }

/* Notifications (notify.js) */
.nt-times { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0; }
.nt-times input { width: auto; }
.nt-check { display: flex; gap: 8px; align-items: flex-start; }
.nt-table-wrap { overflow-x: auto; }
.nt-table { border-collapse: collapse; width: 100%; font-size: var(--fs-secondary); }
.nt-table th, .nt-table td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--line); vertical-align: middle; }
.nt-table td:first-child, .nt-table th:first-child { text-align: left; }
.nt-table td:first-child .badge { margin-top: 4px; }
.nt-table th { white-space: nowrap; }

/* Install type (install.js) */
.sys-type { margin: 2px 0 6px; }
.it-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.it-list li { display: flex; gap: 10px; align-items: flex-start; }
.it-mark { flex: 0 0 18px; color: var(--good); font-weight: 700; }

/* Who runs what (roles.js) */
.rl-comps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* Smart screen (screen.js): large type, big targets, dim at night */
.scr { position: fixed; inset: 0; z-index: 50; overflow-y: auto; padding: calc(24px + env(safe-area-inset-top, 0px)) 28px calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--bg); color: var(--ink); display: flex; flex-direction: column; gap: 14px; transition: filter .6s; }
.scr.scr-night { filter: brightness(.45); }
.scr-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.scr-time { font: 200 clamp(64px, 12vw, 132px)/1 var(--rounded); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.scr-date { font-size: clamp(16px, 2.2vw, 22px); color: var(--muted); margin-top: 6px; }
.scr-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.scr-lights { font-size: 18px; color: var(--muted); }
.scr-btn { border: 0; border-radius: var(--r-pill); padding: 10px 18px; background: var(--surface); color: var(--ink); font-size: 16px; text-decoration: none; box-shadow: var(--shadow); }
.scr-h { font-size: 20px; margin: 10px 0 4px; color: var(--muted); font-weight: 500; }
.scr-scenes { display: flex; gap: 12px; flex-wrap: wrap; }
.scr-scene { border: 0; border-radius: 18px; padding: 18px 26px; font-size: 20px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); min-height: 64px; }
.scr-rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.scr-room { border: 0; border-radius: 22px; padding: 22px; min-height: 120px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; font-size: 22px; text-align: left; }
.scr-room.on { background: color-mix(in srgb, var(--brand) 22%, var(--surface)); }
.scr-room-s { font-size: 16px; color: var(--muted); }
.scr-bottom { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.scr-note, .scr-timer { background: var(--surface); border-radius: 16px; padding: 14px 18px; font-size: 19px; margin-bottom: 10px; box-shadow: var(--shadow); }
.scr-note small { color: var(--muted); }
.scr-wake { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--surface); padding: 10px 18px; border-radius: var(--r-pill); box-shadow: var(--shadow); color: var(--muted); }

/* People at home (household.js) */
.hh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 20px; }
.hh-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hh-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.hh-sec { display: flex; flex-direction: column; gap: 4px; }
.hh-h { font-size: var(--fs-secondary); color: var(--muted); font-weight: 600; }


/* ---- motion & touch polish (emil-design-eng, mobile-native) ---- */
html { -webkit-tap-highlight-color: transparent; }
a, button, [role=button], .tile, .row, label { touch-action: manipulation; }
.btn, .bottom-tabs a, .ask-bar, .power, .chip, button.row, .row.act, a.attn-row, a.hs, .icon-btn, .x-btn { transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-ui) ease, border-color var(--dur-ui) ease, color var(--dur-ui) ease; }
.btn:active:not(:disabled), .bottom-tabs a:active, .ask-bar:active, .power:active:not(:disabled), .chip:active:not(:disabled), .icon-btn:active:not(:disabled), .x-btn:active:not(:disabled) { transform: scale(0.97); }
.tile:has(.power:active) { transform: none; } /* one press, not two scales multiplied */
button.row:active, .row.act:active, a.attn-row:active, a.hs:active, .list a.row:active { background: var(--hover); }
.pill.dragging .pill-fill { transition: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.leaving { opacity: 0; transform: translate(-50%, 8px); transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out); }
.sheet-backdrop.leaving { opacity: 0; transition: opacity 180ms var(--ease-out); }
.sheet-backdrop.leaving .sheet { transform: translateY(24px); opacity: 0; transition: transform 200ms var(--ease-drawer), opacity 180ms var(--ease-out); }
@media (max-width: 760px) { .sheet-backdrop.leaving .sheet { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sheet-backdrop:not(.live) .sheet, .toast, .pair-prompt { animation-name: fade !important; }
  .boot img, .progress-dots i { animation: none !important; }
  .btn:active, .bottom-tabs a:active, .ask-bar:active, .power:active, .chip:active, .icon-btn:active, .x-btn:active, .tile:active { transform: none; }
  .panel-power:active:not(:disabled) { scale: none; } /* same specificity as the press rule, so it wins */
  .sheet-backdrop.leaving .sheet { transform: none; }
  .toast.leaving { transform: translate(-50%, 0); }
}
.row.folding { overflow: hidden; height: 0 !important; opacity: 0; padding-top: 0; padding-bottom: 0; transition: height 200ms var(--ease-out), opacity 150ms var(--ease-out), padding 200ms var(--ease-out); }

/* ---------- The desktop (desktop.js, docs/apps-and-files.md §2a) ---------- */
html.qd-on, html.qd-on body { overflow: hidden; height: 100%; }
.qd { position: fixed; inset: 0; overflow: hidden; color: #f6eee4; font-family: var(--font); -webkit-user-select: none; user-select: none; }
.qd-wall { position: absolute; inset: 0; background:
  radial-gradient(900px 600px at 64% 40%, rgba(255, 170, 80, .28), transparent 60%),
  radial-gradient(700px 500px at 16% 88%, rgba(255, 120, 60, .15), transparent 60%),
  radial-gradient(1200px 800px at 50% -10%, rgba(90, 110, 160, .22), transparent 60%),
  linear-gradient(180deg, #1b1714, #120f0d 60%, #0d0b0a); }
.qd-plan { position: absolute; left: 26%; top: 18%; width: min(900px, 58vw); opacity: .5; }
.qd-plan-walls { stroke: #ffb45a; stroke-opacity: .55; stroke-width: 2; }
.qd-plan-furn { stroke: #ffb45a; stroke-opacity: .2; stroke-width: 1; }
.qd-plan-lamps { fill: #ffb45a; stroke: none; }
.qd-top { position: absolute; z-index: 40; top: 0; left: 0; right: 0; height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: rgba(20, 16, 13, .5); backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%); border-bottom: 1px solid rgba(255, 255, 255, .06); font-size: 13px; }
.qd-top button { border: 0; color: inherit; background: none; font: inherit; }
.qd-top .grow { flex: 1; }
.qd-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 4px 6px; border-radius: 8px; }
.qd-brand img { width: 22px; height: 22px; border-radius: 7px; }
.qd-menu { padding: 5px 11px; border-radius: 8px; background: rgba(255, 255, 255, .08); }
.qd-menu:hover, .qd-tb:hover, .qd-brand:hover { background: rgba(255, 255, 255, .14); }
.qd-ask { display: flex; align-items: center; gap: 6px; padding: 5px 13px; border-radius: 99px; background: rgba(120, 170, 255, .18) !important; color: #d6e5ff !important; }
.qd-tb { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; }
.qd-tb svg { width: 18px; height: 18px; }
.qd-count { position: absolute; top: -3px; right: -4px; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad); color: #fff; font: 600 10px/16px var(--font); }
.qd-clock { opacity: .9; font-variant-numeric: tabular-nums; }
.qd-me { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(150deg, #8fb3ff, #4a6fd1) !important; font-weight: 600 !important; font-size: 12px !important; }
.qd-icons { position: absolute; z-index: 2; left: 18px; top: 58px; bottom: 100px; display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, 104px); grid-auto-columns: 96px; gap: 4px 8px; }
.qd-di { display: grid; justify-items: center; align-content: start; gap: 7px; padding: 8px 2px 6px; border: 0; border-radius: 14px; background: none; color: #fbf5ee; font: 12.5px/1.25 var(--font); text-align: center; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); cursor: default; }
.qd-di:hover, .qd-di:focus-visible { background: rgba(255, 255, 255, .12); outline: 1px solid rgba(255, 255, 255, .16); }
.qd-di .qd-ico { transition: scale var(--dur-press) var(--ease-out); }
.qd-di:active .qd-ico { scale: .95; }
.qd-label { max-width: 88px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qd-ico { position: relative; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, 0 10px 24px -10px rgba(0, 0, 0, .7); flex: none; }
.qd-ico svg { width: 27px; height: 27px; }
.qd-ico img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.qd-ico.small { width: 22px; height: 22px; border-radius: 7px; box-shadow: none; }
.qd-ico.small svg { width: 13px; height: 13px; }
.qd-state { position: absolute; right: -3px; top: -3px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #1b1714; }
.qd-state.ok { background: #2fbf7a; } .qd-state.off { background: #9c968e; }
.g-home { background: linear-gradient(155deg, #ffd29a, #e2832f); color: #3a1d05; }
.g-files { background: linear-gradient(155deg, #ffe3a8, #f0a93a); color: #4a2a02; }
.g-ai { background: linear-gradient(155deg, #cfe0ff, #6c8fe0); color: #0f2250; }
.g-auto { background: linear-gradient(155deg, #ffe0b8, #f08a3c); color: #3f1a02; }
.g-rooms { background: linear-gradient(155deg, #f3e3d0, #c9a37a); color: #3d2610; }
.g-plan { background: linear-gradient(155deg, #f6e6cf, #cfae84); color: #4a3115; }
.g-media { background: linear-gradient(155deg, #ffb3a0, #e0574a); color: #3d0e08; }
.g-cam { background: linear-gradient(155deg, #b9d4ff, #5d86d6); color: #0d2148; }
.g-energy { background: linear-gradient(155deg, #fff2b0, #e6b422); color: #3a2c00; }
.g-family { background: linear-gradient(155deg, #ffd6c2, #e48a6a); color: #3d1408; }
.g-cal { background: linear-gradient(155deg, #fff, #e9e4dc); color: #c2410c; }
.g-net { background: linear-gradient(155deg, #c7f0dd, #3fae7f); color: #0b3a24; }
.g-trash { background: linear-gradient(155deg, #e9eef3, #9fb0c0); color: #1f2a36; }
.g-store { background: linear-gradient(155deg, #ffd6e8, #d96aa0); color: #4a0f2b; }
.g-addon { background: linear-gradient(155deg, #dfe4ea, #8d97a5); color: #1b2230; }
.g-set { background: linear-gradient(155deg, #e7e5e1, #a8a39b); color: #2a2724; }
.g-plugin { background: linear-gradient(155deg, #fff0d6, #e7b25a); color: #4a2e05; }
.g-comm { background: linear-gradient(155deg, #eef2f7, #b8c6d8); color: #2c4363; }
.qd-widgets { position: absolute; z-index: 2; right: 18px; top: 58px; bottom: 100px; width: 330px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; scrollbar-width: none; -webkit-user-select: text; user-select: text; }
.qd-w { border-radius: 20px; padding: 14px 16px; color: #f7efe6; background: rgba(30, 24, 20, .44); backdrop-filter: blur(28px) saturate(150%); -webkit-backdrop-filter: blur(28px) saturate(150%); border: 1px solid rgba(255, 255, 255, .08); box-shadow: 0 18px 50px -20px rgba(0, 0, 0, .6); }
.qd-w-h { display: flex; justify-content: space-between; margin: 0 0 8px; font-size: 12px; color: rgba(247, 239, 230, .7); }
.qd-w .home-status { margin: 0 0 10px; color: #f7efe6; font-size: 17px; font-weight: 600; }
.qd-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: rgba(247, 239, 230, .78); }
.qd-stats b { display: block; font: 300 26px/1.1 var(--rounded); color: #fff; }
.qd-scenes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.qd-scenes .scene-chip { padding: 7px 11px 7px 8px; font-size: 12.5px; background: rgba(255, 255, 255, .12); color: #fff; box-shadow: none; }
.qd-scenes .scene-chip svg { width: 16px; height: 16px; color: #ffcf94; }
.qd-scenes .scene-chip.running { background: rgba(255, 180, 90, .35); }
.qd-w-link { margin-top: 12px; padding: 0; border: 0; background: none; color: #ffcf94; font: 600 13px var(--font); }
.qd-tiles { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
.qd-w .tile { color: var(--ink); -webkit-user-select: none; user-select: none; }
.qd-tiles .tile { min-height: 96px; padding: 11px; gap: 10px; }
.qd-row { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12.5px; }
.qd-row span:last-child { color: rgba(247, 239, 230, .72); font-variant-numeric: tabular-nums; }
.qd-bar { display: block; height: 5px; margin-top: 5px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.qd-bar i { display: block; height: 100%; background: var(--on); }
.qd-play { display: flex; align-items: center; gap: 9px; }
.qd-play b { display: block; font-size: 14px; } .qd-play small { font-size: 11.5px; opacity: .7; }
.qd-art { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: linear-gradient(135deg, #ffb45a, #c2410c 60%, #3a1d05); flex: none; }
.qd-art svg { width: 20px; height: 20px; color: #fff; }
.qd-round { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .1); color: #fff; flex: none; }
.qd-round.main { background: #fff; color: #1b1714; }
.qd-round svg { width: 15px; height: 15px; }
.qd-dock { position: absolute; z-index: 60; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 22px; background: rgba(30, 24, 20, .5); backdrop-filter: blur(28px) saturate(160%); -webkit-backdrop-filter: blur(28px) saturate(160%); border: 1px solid rgba(255, 255, 255, .1); }
.qd-dk { position: relative; padding: 0; border: 0; background: none; color: #fff; transition: transform var(--dur-press) var(--ease-out), scale var(--dur-press) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .qd-dk:hover { transform: translateY(-3px); } }
.qd-dk:active { scale: .95; }
.qd-dk .qd-ico { width: 48px; height: 48px; border-radius: 14px; }
.qd-dk .qd-ico svg { width: 24px; height: 24px; }
.qd-dk.run::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--on); }
.qd-dk.front::after { width: 12px; margin-left: -6px; border-radius: 3px; }
.qd-startbtn { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: rgba(255, 255, 255, .1); }
.qd-startbtn svg { width: 22px; height: 22px; }
.qd-sep { width: 1px; height: 38px; background: rgba(255, 255, 255, .15); }
.qd-wins { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.qd-win { position: absolute; display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; background: var(--bg); box-shadow: 0 30px 90px -20px rgba(0, 0, 0, .7), 0 0 0 1px rgba(0, 0, 0, .3); pointer-events: auto; color: var(--ink); }
.qd-win.max { border-radius: 12px; }
.qd-wt { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 8px 0 12px; background: var(--side); border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600; cursor: default; flex: none; }
.qd-win:not(.focused) .qd-wt { color: var(--muted); }
.qd-wtitle { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qd-wpage { font-weight: 500; color: var(--muted); }
.qd-win.focused .qd-wpage { color: var(--ink); }
.qd-wt .grow { flex: 1; min-width: 12px; align-self: stretch; }
.qd-wnav { display: flex; gap: 0; margin-left: 2px; }
.qd-wnav[hidden] { display: none; }
.qd-wnav .qd-wc { width: 26px; }
.qd-wc:disabled { opacity: .3; pointer-events: none; }
.qd-wtools { display: flex; align-items: center; gap: 6px; flex: none; }
.qd-wtools:empty { display: none; }
.qd-wsep { width: 1px; height: 18px; margin: 0 4px; background: var(--line); flex: none; }
.qd-wtools:empty + .qd-wsep { display: none; }
.qd-wbtn { height: 28px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: 600 12.5px var(--font); white-space: nowrap; transition: background-color var(--dur-press) ease, scale var(--dur-press) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .qd-wbtn:hover { background: var(--hover); } }
.qd-wbtn:active { scale: .97; }
.qd-wbtn.primary { border-color: transparent; background: var(--brand); color: var(--on-brand); }
@media (hover: hover) and (pointer: fine) { .qd-wbtn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); } }
.qd-wbtn:disabled { opacity: .45; }
.qd-wseg { margin: 0; padding: 2px; }
.qd-wseg button { padding: 3px 10px; font-size: 12.5px; }
@media (prefers-reduced-motion: reduce) { .qd-wbtn { transition: none; } .qd-wbtn:active { scale: none; } }
.qd-wc { display: grid; place-items: center; width: 30px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.qd-wc svg { width: 15px; height: 15px; }
.qd-wc:hover { background: var(--hover); color: var(--ink); }
.qd-wc.x:hover { background: var(--bad); color: #fff; }
.qd-frame { flex: 1; width: 100%; border: 0; background: var(--bg); }
.qd-grip { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; }
.qd-dragging .qd-frame { pointer-events: none; }
.qd-dragging { cursor: grabbing; }
.qd-start { position: absolute; z-index: 55; inset: 42px 0 0 0; padding: 40px 16px 110px; background: rgba(14, 11, 9, .55); backdrop-filter: blur(30px) saturate(140%); -webkit-backdrop-filter: blur(30px) saturate(140%); overflow-y: auto; animation: fade .16s var(--ease-out); }
.qd-start-in { max-width: 920px; margin: 0 auto; }
.qd-start-q { display: flex; align-items: center; gap: 10px; max-width: 540px; margin: 0 auto 10px; padding: 12px 16px; border-radius: 14px; background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .8); }
.qd-start-q svg { width: 18px; height: 18px; }
.qd-start-q input { flex: 1; border: 0; outline: 0; background: none; color: #fff; font: 15px var(--font); }
.qd-start h4 { margin: 24px 6px 8px; font: 500 12px var(--font); color: rgba(255, 255, 255, .6); }
.qd-start-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px 6px; }
.qd-none { text-align: center; color: rgba(255, 255, 255, .6); margin-top: 40px; }
.qd-pop { z-index: 120; min-width: 200px; gap: 2px; }
.qd-pop, .fs-menu { animation-name: menu-in; } /* placed at the pointer / button: grow from it (origin set in JS) */
@keyframes menu-in { from { opacity: 0; transform: scale(.96); } }
.qd-pop .menu-row { display: block; width: 100%; min-height: 0; padding: 9px 12px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); font: 500 14px var(--font); text-align: left; cursor: pointer; }
.qd-pop .menu-row.danger { color: var(--bad); }
.qd-pop .menu-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.qd-start-q input::placeholder { color: rgba(255, 255, 255, .55); }
@media (prefers-reduced-motion: reduce) { .qd-start { animation: none; } .qd-dk, .qd-di .qd-ico { transition: none; } .qd-dk:active, .qd-di:active .qd-ico { scale: none; } .qd-pop, .fs-menu { animation: none; } }
/* Desktop shell, second pass: snapping outline, dock names, search across apps and pages, hidden widgets. */
.qd-widgets[hidden] { display: none; }
.qd-snap { position: absolute; border-radius: 14px; background: rgba(255, 180, 90, .14); box-shadow: inset 0 0 0 2px rgba(255, 200, 140, .65), 0 20px 60px -20px rgba(0, 0, 0, .5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; pointer-events: none;
  transition: left 180ms var(--ease-out), top 180ms var(--ease-out), width 180ms var(--ease-out), height 180ms var(--ease-out), opacity 140ms var(--ease-out); }
.qd-snap.on { opacity: 1; }
.qd-tip { position: absolute; z-index: 70; transform: translate(-50%, -100%); padding: 4px 10px; border-radius: 8px; background: rgba(28, 22, 18, .86); color: #fbf5ee; font: 500 12.5px var(--font); white-space: nowrap; pointer-events: none; box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .5); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: tip-in 140ms var(--ease-out); }
.qd-tip.instant { animation: none; }
@keyframes tip-in { from { opacity: 0; transform: translate(-50%, calc(-100% + 4px)); } }
.qd-start-q kbd { padding: 2px 6px; border-radius: 6px; background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .6); font: 500 11.5px var(--font); }
.qd-res-list { max-width: 640px; margin: 0 auto; display: grid; gap: 2px; }
.qd-res-list h4 { margin: 16px 10px 4px; }
.qd-res { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: none; color: #fbf5ee; text-align: left; font: 14px var(--font); }
.qd-res .grow { flex: 1; min-width: 0; }
.qd-res b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qd-res small { display: block; color: rgba(255, 255, 255, .6); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qd-res .qd-ico.small { width: 30px; height: 30px; border-radius: 9px; }
.qd-res .qd-ico.small svg { width: 16px; height: 16px; }
.qd-res-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, .1); color: #ffcf94; flex: none; }
.qd-res-ico.ai { color: #b9d2ff; }
.qd-res-ico svg { width: 16px; height: 16px; }
.qd-res-k { padding: 2px 8px; border-radius: 99px; background: rgba(255, 255, 255, .12); font-size: 11.5px; color: rgba(255, 255, 255, .75); }
@media (hover: hover) and (pointer: fine) { .qd-res:hover { background: rgba(255, 255, 255, .06); } }
.qd-res.sel { background: rgba(255, 255, 255, .14); }
.qd-res:focus-visible { outline: 2px solid #ffcf94; outline-offset: -2px; }
/* A device's controls opened from search on the desktop sit above the dock. */
html.qd-on .sheet-backdrop { z-index: 90; }
html.qd-on .toast { z-index: 96; }
@media (prefers-reduced-motion: reduce) { .qd-snap { transition: opacity 120ms linear; } .qd-tip { animation: none; } }
/* Inside a desktop window: the page alone (the window has its own title bar). */
html.embedded .sidebar, html.embedded .topbar, html.embedded .bottom-tabs, html.embedded .ask-bar { display: none !important; }
html.embedded .content { margin-left: 0; }
html.in-window .fs-player { display: none; }
/* A window is an app (desktop.js): denser type than the phone-first pages, a window's spacing; the page's title row
   gives its title and "‹ back" to the title bar and its buttons to the toolbar there. */
html.embedded { --fs-caption: 11.5px; --fs-secondary: 12.5px; --fs-body-sm: 13px; --fs-body: 14px; --fs-lead: 15px; --fs-section: 17px; --fs-title: 24px; }
html.embedded body { font-size: var(--fs-body); }
html.embedded main { max-width: 1240px; padding: 18px 24px 40px; }
html.embedded h2, html.embedded .section-head h2 { font-size: 16px; }
html.embedded h2 { margin: 22px 0 10px; }
html.embedded .section-head { margin-top: 22px; }
html.embedded .section-head h2 { margin-bottom: 10px; }
html.embedded .card { padding: 14px 16px; }
html.embedded .row { min-height: 46px; padding: 10px 14px; gap: 12px; }
html.embedded .grid { gap: 10px; }
html.embedded .grid.tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
html.embedded .grid.rooms { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
html.embedded .tile { min-height: 104px; padding: 12px; gap: 12px; }
html.embedded .room { min-height: 104px; padding: 14px; }
html.embedded .win-head { align-items: center; min-height: 0; margin-bottom: 14px; }
html.embedded .win-head > div:first-child, html.embedded .ai-head-btn, html.embedded .win-proxied { display: none !important; }
html.embedded .win-head.win-head-empty { display: none; }
html.embedded .seg { margin-top: 0; }
html.win-home .rooms-seg { display: none; }
/* 家's overview: the home itself, not a greeting hero. */
html.win-home .home-date { display: none; }
html.win-home .home-head h1 { font-size: 24px; }
/* The list beside the page (家's rooms, 自动化's sections, Settings' pages, 栖家智能's sections); a narrow window
   shows the page alone, with back in the title bar. Its edge drags to resize it. */
.win-list, .win-grip { display: none; }
@media (min-width: 640px) {
  .win-list { position: fixed; z-index: 20; inset: 0 auto 0 0; width: var(--win-side, 236px); display: flex; flex-direction: column; padding: 10px 8px 20px; background: var(--side); border-right: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
  .win-grip { position: fixed; z-index: 21; top: 0; bottom: 0; left: calc(var(--win-side, 236px) - 3px); display: block; width: 6px; cursor: col-resize; }
  html.embedded .win-list + .content { margin-left: var(--win-side, 236px); }
  html.win-settings #main > .menu-cols { display: block; column-count: auto; }
  html.win-settings #main > .menu-cols > .menu-group:not(.account-group) { display: none; }
}
html.win-sizing, html.win-sizing * { cursor: col-resize !important; -webkit-user-select: none; user-select: none; }
.win-q { display: flex; align-items: center; gap: 7px; margin: 0 2px 8px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); }
.win-q svg { width: 14px; height: 14px; flex: none; }
.win-q input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font: 13px var(--font); }
.win-q:focus-within { border-color: var(--brand); }
.win-nav { display: grid; gap: 1px; }
.win-grp { display: grid; gap: 1px; }
.win-grp[hidden], .win-li[hidden], .win-none[hidden] { display: none; }
.win-h { margin: 12px 8px 3px; font: 600 11.5px var(--font); color: var(--muted); letter-spacing: .02em; }
.win-li { display: flex; align-items: center; gap: 9px; width: 100%; padding: 5px 8px; border: 0; border-radius: 8px; background: none; color: var(--ink); text-decoration: none; text-align: left; font: 500 13px var(--font); cursor: default; transition: background-color var(--dur-press) ease; }
.win-li .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-li .menu-icon { width: 22px; height: 22px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.win-li .menu-icon svg { width: 13px; height: 13px; }
.win-li .count-badge { min-width: 18px; height: 18px; font-size: 11px; }
.win-n { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) { .win-li:hover { background: var(--hover); } }
.win-li.on { background: var(--selected); color: var(--brand); }
.win-li.on .win-n { color: inherit; }
.win-li:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.win-ext { color: var(--muted); font-size: 12px; }
.win-none { margin: 18px 10px; color: var(--muted); font-size: 13px; }
h2.win-sec { scroll-margin-top: 14px; }
html.embedded .win-head-empty + *, html.embedded .win-head-empty + * > h2:first-child { margin-top: 0; }
/* A plugin's pages in its window's list (sub-pages indented); its own tabs give way to the list. */
.win-li.win-sub { padding-left: 22px; }
@media (min-width: 640px) { html.embedded .win-list + .content .ux-tabs { display: none; } }
/* 自动化 in a wide window (desktop.js): the section's list beside the selected item's details, each scrolling on
   its own; the window does not scroll as a page. */
html.embedded body:has(#main > .ws-split) { overflow: hidden; }
html.embedded .content:has(#main > .ws-split) { height: 100vh; display: flex; flex-direction: column; }
html.embedded #main:has(> .ws-split) { flex: 1; min-height: 0; max-width: none; width: 100%; padding: 0; display: flex; flex-direction: column; }
.ws-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(250px, 34%) minmax(0, 1fr); }
.ws-list { min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--line); background: var(--bg); }
.ws-tools { position: sticky; top: 0; z-index: 1; display: grid; gap: 8px; padding: 10px 10px 9px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.ws-tools .auto-tools { display: grid; gap: 8px; margin: 0; }
.ws-tools .search { width: 100%; max-width: none; height: 32px; padding: 0 10px; font-size: 13px; }
.ws-tools .chips { gap: 5px; margin: 0; flex-wrap: wrap; }
.ws-tools .chip { padding: 3px 9px; font-size: 12px; }
.ws-tools .link-btn { justify-self: start; font-size: 12.5px; }
.ws-rows { display: grid; gap: 1px; padding: 6px; align-content: start; }
.ws-row { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 7px 8px 7px 10px; border-radius: 10px; cursor: default; outline: 0; transition: background-color var(--dur-press) ease; }
@media (hover: hover) and (pointer: fine) { .ws-row:hover { background: var(--hover); } }
.ws-row.sel { background: var(--selected); }
.ws-row:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }
.ws-row .grow { flex: 1; min-width: 0; }
.ws-row b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-row small { display: block; margin-top: 1px; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-row.off b { color: var(--muted); }
.ws-row.sel b { color: var(--brand); }
.ws-ico { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); color: var(--brand); flex: none; }
.ws-ico svg { width: 15px; height: 15px; }
.ws-row.off .ws-ico { color: var(--muted); }
.ws-row .power { scale: .8; margin-right: -4px; }
.ws-row .ws-run { width: 30px; height: 30px; }
.ws-none { margin: 24px 14px; color: var(--muted); font-size: 13px; text-align: center; }
.ws-keys { margin: auto 0 0; padding: 10px 14px 12px; color: var(--muted); font-size: 11.5px; }
.ws-detail { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 28px 40px; }
.ws-detail > * { max-width: 760px; }
.ws-dh { display: flex; align-items: center; gap: 14px; }
.ws-dh h2 { margin: 0; font-size: 20px; line-height: 1.25; }
.ws-dh p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ws-dh .badge { padding: 1px 8px; font-size: 11.5px; }
.ws-dico { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: color-mix(in srgb, var(--brand) 12%, var(--surface)); color: var(--brand); flex: none; }
.ws-dico svg { width: 24px; height: 24px; }
.ws-acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.ws-acts .btn { height: 32px; min-height: 0; padding: 0 13px; font-size: 13px; gap: 6px; }
.ws-acts .btn svg { width: 14px; height: 14px; }
.ws-acts .ws-del { color: var(--bad); margin-left: auto; }
.ws-desc { margin: 14px 0 0; color: var(--ink); }
.ws-note { margin: 18px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.ws-loading { margin-top: 18px; }
.ws-sec { margin-top: 22px; }
.ws-sec h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.ws-sec-h { display: flex; align-items: baseline; justify-content: space-between; }
.ws-sec-h a { font-size: 12.5px; }
.ws-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; counter-reset: ws; }
.ws-steps li { position: relative; padding: 9px 12px 9px 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 13.5px; counter-increment: ws; }
.ws-steps li::before { content: counter(ws); position: absolute; left: 11px; top: 9px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font: 600 11px/18px var(--font); text-align: center; }
.ws-pick { display: grid; justify-items: center; gap: 10px; padding: 48px 20px 28px; color: var(--muted); text-align: center; max-width: none; }
.ws-pick p { margin: 0; font-size: 13.5px; }
.ws-pick-ico { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: var(--surface-2); }
.ws-pick-ico svg { width: 26px; height: 26px; }
.ws-extra > :first-child { margin-top: 0; }
/* 家: the device inspector on the right of a wide window (the device sheet, docked); tiles show what it shows and
   what is selected. */
@media (min-width: 900px) {
  html.insp-on .content { margin-right: var(--insp-w, 360px); }
  .sheet-backdrop.insp { inset: 0 0 0 auto; width: var(--insp-w, 360px); z-index: 30; background: none; animation: none; align-items: stretch; }
  .sheet-backdrop.insp .sheet { width: 100%; height: 100%; max-height: none; border-radius: 0; padding: 16px 18px 28px; border-left: 1px solid var(--line); background: var(--side); box-shadow: -18px 0 40px -34px rgba(0, 0, 0, .5); animation: insp-in 220ms var(--ease-out); }
  .sheet-backdrop.insp.live .sheet { animation: none; }
  .sheet-backdrop.insp .sheet-head { margin-bottom: 14px; }
  .sheet-backdrop.insp .sheet-head .icon { width: 42px; height: 42px; }
  .sheet-backdrop.insp .sheet-head .icon svg { width: 22px; height: 22px; }
  .sheet-backdrop.insp .sheet-head h2 { font-size: 17px; }
  .sheet-backdrop.insp.leaving { opacity: 1; transition: none; }
  .sheet-backdrop.insp.leaving .sheet { transform: translateX(14px); opacity: 0; transition: transform 160ms var(--ease-out), opacity 140ms var(--ease-out); }
}
@keyframes insp-in { from { transform: translateX(14px); opacity: 0; } }
.tile.insp-sel { box-shadow: 0 0 0 2px var(--brand), var(--shadow); }
.tile.msel { box-shadow: 0 0 0 2px var(--brand), 0 0 0 5px color-mix(in srgb, var(--brand) 20%, transparent); }
.tile.msel::after { content: "✓"; position: absolute; left: -6px; top: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: var(--on-brand); font: 700 12px/20px var(--font); text-align: center; }
html.win-home .tile, html.win-rooms .tile { -webkit-user-select: none; user-select: none; }
@media (prefers-reduced-motion: reduce) { .ws-row { transition: none; } .sheet-backdrop.insp .sheet { animation-name: fade; } .sheet-backdrop.insp.leaving .sheet { transform: none; } }
/* Files: its places are the window's list like every other app's (files.js draws them). */
@media (min-width: 640px) {
  html.win-files .fs-layout { display: block; }
  html.win-files .fs-places { display: block; position: fixed; z-index: 20; inset: 0 auto 0 0; width: var(--win-side, 236px); margin: 0; padding: 10px 8px 20px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: var(--side); box-shadow: none; overflow-y: auto; }
  html.win-files .content { margin-left: var(--win-side, 236px); }
  html.win-files .fs-place { padding: 6px 8px; font-size: 13px; border-radius: 8px; }
  html.win-files .fs-places h4 { margin: 12px 8px 3px; font-size: 11.5px; font-weight: 600; }
}
/* Settings → 界面布局 (both layouts) */
.layout-row .seg { margin: 0; flex: none; }
.layout-row .seg button { white-space: nowrap; }
.layout-group { margin-bottom: 8px; }
/* The classic sidebar's way to the desktop, beside the logo. */
.side-brand { display: flex; align-items: center; gap: 6px; padding-bottom: 14px; }
.side-brand .brand { flex: 1; min-width: 0; padding-bottom: 0 !important; }
.side-desk { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px 0 8px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); color: var(--ink); font: 600 12.5px var(--font); cursor: pointer; transition: background-color var(--dur-press) ease, scale var(--dur-press) var(--ease-out); }
.side-desk svg { width: 15px; height: 15px; color: var(--brand); }
@media (hover: hover) and (pointer: fine) { .side-desk:hover { background: var(--hover); } }
.side-desk:active { scale: .96; }
@media (prefers-reduced-motion: reduce) { .side-desk { transition: none; } .side-desk:active { scale: none; } }

/* ---------- Files (files.js) ---------- */
.fs-layout { position: relative; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
.fs-places { padding: 10px; position: sticky; top: 12px; }
.fs-place { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-size: 14px; }
.fs-place svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.fs-place span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-place:hover { background: var(--hover); }
.fs-place.on { background: var(--selected); color: var(--brand); }
.fs-place.on svg { color: var(--brand); }
.fs-places h4 { margin: 14px 10px 6px; font: 500 12px var(--font); color: var(--muted); }
.fs-meter { margin: 14px 10px 4px; }
.fs-meter small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.fs-meter-bar { display: block; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.fs-meter-bar i { display: block; height: 100%; background: var(--brand); }
.fs-main { min-width: 0; }
.fs-tool { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.fs-tool .btn svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.fs-tool .icon-btn { width: 36px; height: 36px; border-radius: 11px; }
.fs-tool .icon-btn svg { width: 18px; height: 18px; }
.fs-tool .icon-btn.on { background: var(--selected); color: var(--brand); }
.fs-crumbs { min-width: 160px; font-size: 15px; color: var(--muted); }
.fs-crumbs a { color: var(--muted); text-decoration: none; }
.fs-crumbs a.cur { color: var(--ink); font-weight: 600; }
.fs-sep { margin: 0 6px; }
.fs-search { width: 190px; margin: 0; }
.fs-sort { width: auto; margin: 0; }
.fs-selbar { padding: 8px 10px; border-radius: var(--r-md); background: var(--selected); }
.fs-ro { margin: -6px 2px 12px; }
.fs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.fs-tile { position: relative; display: flex; flex-direction: column; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; cursor: default; }
.fs-tile:hover { box-shadow: var(--shadow); }
.fs-tile.sel { outline: 2px solid var(--brand); outline-offset: -2px; }
.fs-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.fs-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fs-tile.dir .fs-thumb { background: color-mix(in srgb, var(--on) 12%, var(--surface)); }
.fs-badge { position: absolute; right: 7px; bottom: 7px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; }
.fs-badge svg { width: 13px; height: 13px; }
.fs-tile .fs-name { padding: 8px 10px 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-tile .fs-meta { padding: 2px 10px 9px; color: var(--muted); font-size: 11.5px; }
.fs-glyph { display: grid; place-items: center; color: var(--muted); }
.fs-glyph svg { width: 40px; height: 40px; }
.fs-k-folder { color: #e09a35; } .fs-k-image { color: #3f8fd2; } .fs-k-video { color: #d0574a; } .fs-k-audio { color: #9a5bd0; } .fs-k-pdf { color: #c8372d; } .fs-k-archive { color: #8a6a4a; }
.fs-check { position: absolute; z-index: 2; left: 8px; top: 8px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, .25); opacity: 0; transition: opacity .15s; }
.fs-tile:hover .fs-check, .fs-row:hover .fs-check, .fs-tile.sel .fs-check, .fs-row.sel .fs-check { opacity: 1; }
.fs-check[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); }
.fs-more { position: absolute; z-index: 2; right: 6px; top: 6px; width: 30px !important; height: 30px !important; background: rgba(255, 255, 255, .85); opacity: 0; transition: opacity .15s; }
.fs-more svg { width: 18px !important; height: 18px !important; }
.fs-tile:hover .fs-more, .fs-row:hover .fs-more, .fs-more:focus-visible, .fs-check:focus-visible { opacity: 1; }
/* No hover on touch screens: the menu and the select circle stay shown (they were there but invisible). */
@media (hover: none) { .fs-tile .fs-more, .fs-tile .fs-check, .fs-row .fs-check { opacity: 1; } }
.fs-rows { display: flex; flex-direction: column; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.fs-row { position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 40px; border-bottom: 1px solid var(--line); font-size: 14px; }
.fs-row:last-child { border-bottom: 0; }
.fs-row.sel { background: var(--selected); }
.fs-row .fs-check { left: 10px; top: 50%; margin-top: -11px; border-color: var(--muted); }
.fs-row .fs-more { position: static; opacity: .6; background: none; }
.fs-rthumb { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; overflow: hidden; background: var(--surface-2); flex: none; }
.fs-rthumb img { width: 100%; height: 100%; object-fit: cover; }
.fs-rthumb .fs-glyph svg { width: 22px; height: 22px; }
.fs-row .fs-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-row .fs-meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; min-width: 84px; text-align: right; }
.fs-uploads { padding: 10px 14px; margin: 0 0 14px; display: grid; gap: 8px; }
.fs-up { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.fs-up .fs-meter-bar { width: 140px; flex: none; }
.fs-up.done { color: var(--good); } .fs-up.bad { color: var(--bad); }
.fs-dropzone { display: none; }
.fs-layout.dragging .fs-dropzone { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; border: 2px dashed var(--brand); border-radius: var(--radius-card); background: color-mix(in srgb, var(--bg) 85%, transparent); color: var(--brand); font-weight: 600; }
.fs-menu { z-index: 120; min-width: 170px; }
.fs-viewer { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: rgba(8, 8, 10, .95); color: #fff; animation: fade .16s var(--ease-out); }
.fs-v-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.fs-v-top b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-v-top small { margin-left: 10px; font-weight: 400; color: rgba(255, 255, 255, .6); }
.fs-v-top .icon-btn { color: #fff; background: rgba(255, 255, 255, .1); border-radius: 12px; }
.fs-v-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 70px 24px; }
.fs-v-img, .fs-v-video { max-width: 100%; max-height: 100%; border-radius: 6px; }
.fs-v-doc { width: 100%; height: 100%; border: 0; border-radius: 8px; background: #fff; }
.fs-v-text { width: min(900px, 100%); height: 100%; overflow: auto; margin: 0; padding: 18px 20px; border-radius: 10px; background: #18191d; color: #e8e6e1; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; -webkit-user-select: text; user-select: text; }
.fs-v-cant { display: grid; justify-items: center; gap: 14px; text-align: center; color: rgba(255, 255, 255, .8); }
.fs-v-cant .btn svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }
.fs-v-note { position: absolute; bottom: 4px; color: rgba(255, 255, 255, .7); font-size: 13px; }
.fs-v-nav { position: absolute; top: 50%; margin-top: -24px; display: grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; }
.fs-v-nav svg { width: 22px; height: 22px; }
.fs-v-nav.prev { left: 12px; } .fs-v-nav.next { right: 12px; }
.fs-player { position: fixed; z-index: 35; left: 276px; right: 24px; bottom: 18px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 18px; background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); animation: rise .24s var(--ease-drawer); }
.fs-player-art { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, #ffb45a, #c2410c 60%, #3a1d05); color: #fff; flex: none; }
.fs-player-art svg { width: 20px; height: 20px; }
.fs-player b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-player small { color: var(--muted); font-size: 11.5px; }
.fs-player-bar { display: block; height: 3px; margin-top: 5px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.fs-player-bar i { display: block; height: 100%; background: var(--brand); }
.fs-player .icon-btn { width: 34px; height: 34px; }
.fs-player .icon-btn svg { width: 18px; height: 18px; }
.fs-player-main { background: var(--ink) !important; color: var(--bg) !important; }
@media (max-width: 760px) {
  .fs-layout { grid-template-columns: 1fr; }
  .fs-places { position: static; display: flex; gap: 4px; overflow-x: auto; padding: 6px; scrollbar-width: none; }
  .fs-places h4, .fs-meter { display: none; }
  .fs-place { flex: none; }
  .fs-search { width: 100%; order: 9; }
  .fs-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; }
  .fs-row .fs-meta:last-of-type { display: none; }
  .fs-player { left: 10px; right: 10px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .fs-v-stage { padding: 0 8px 16px; }
  .fs-v-nav { display: none; }
}
@media (prefers-reduced-motion: reduce) { .fs-viewer, .fs-player { animation: none; } .fs-check, .fs-more { transition: none; } }

/* ---------- the desktop's control centre and notification centre (controlcenter.js, notifcenter.js) ---------- */
.qd-top .qd-tb.on, .qd-top .qd-clock.on { background: rgba(255, 255, 255, .2); }
.qd-top .qd-clock { padding: 5px 8px; border-radius: 8px; cursor: default; }
.qd-top .qd-clock:hover { background: rgba(255, 255, 255, .12); }
.qd-top button:focus-visible { outline: 2px solid #ffcf94; outline-offset: 1px; }
.qd-panel { position: absolute; z-index: 65; color: #f7efe6; background: rgba(30, 24, 20, .64); backdrop-filter: blur(40px) saturate(170%); -webkit-backdrop-filter: blur(40px) saturate(170%);
  border: 1px solid rgba(255, 255, 255, .1); box-shadow: 0 30px 80px -24px rgba(0, 0, 0, .8), 0 0 0 .5px rgba(0, 0, 0, .45); outline: none; font-size: 13px; -webkit-user-select: none; user-select: none; }
.qd-panel button { font: inherit; color: inherit; }
.qd-panel button:focus-visible, .qd-panel input:focus-visible { outline: 2px solid #ffcf94; outline-offset: 2px; }
.qd-panel small { display: block; font-size: 11.5px; color: rgba(247, 239, 230, .62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qd-panel b { font-weight: 600; }
.qd-panel .grow { flex: 1; min-width: 0; }
.qd-cc { top: 48px; right: 10px; width: 384px; max-height: calc(100vh - 48px - 104px); display: flex; flex-direction: column; border-radius: 22px; }
.qcc-body { overflow-y: auto; padding: 12px; scrollbar-width: none; overscroll-behavior: contain; }
.qcc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qcc-card { min-width: 0; padding: 12px; border-radius: 16px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .06); }
.qcc-wide { grid-column: 1 / -1; }
.qcc-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; margin: 0 0 9px; font-size: 12px; font-weight: 600; color: rgba(247, 239, 230, .68); }
.qcc-h > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qcc-none { margin: 0; color: rgba(247, 239, 230, .6); font-size: 12.5px; }
.qcc-st { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.qcc-st b { display: block; font-size: 15px; }
.qcc-st > svg { width: 16px; height: 16px; opacity: .55; }
.qcc-st .dot { width: 10px; height: 10px; }
.qcc-status { padding: 12px 14px; }
.qcc-tgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(98px, 1fr)); gap: 6px; }
.qcc-tog { display: grid; justify-items: center; gap: 6px; padding: 6px 2px 4px; border: 0; border-radius: 12px; background: none; text-align: center; transition: background-color var(--dur-press) ease; }
.qcc-tog .qcc-tl { min-width: 0; max-width: 100%; }
.qcc-tog small { font-size: 11px; }
.qcc-ti { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: rgba(255, 255, 255, .14); flex: none; transition: background-color var(--dur-ui) ease, color var(--dur-ui) ease; }
.qcc-ti svg { width: 19px; height: 19px; }
.qcc-tog.on .qcc-ti, .qnc-quiet.on .qcc-ti { background: #ffb45a; color: #2a1604; box-shadow: 0 0 18px -4px rgba(255, 180, 90, .8); }
.qcc-tog:active .qcc-ti { scale: .94; }
.qcc-wait { min-height: 84px; }
.qcc-skel { display: block; height: 60px; border-radius: 12px; background: rgba(255, 255, 255, .06); }
.qcc-scenes { display: flex; flex-wrap: wrap; gap: 6px; }
.qcc-scene { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 7px 12px 7px 9px; border: 0; border-radius: 99px; background: rgba(255, 255, 255, .12); font-size: 12.5px; transition: background-color var(--dur-ui) ease, scale var(--dur-press) var(--ease-out); }
.qcc-scene span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qcc-scene svg { width: 15px; height: 15px; color: #ffcf94; flex: none; }
.qcc-scene:active { scale: .96; }
.qcc-scene.busy { background: rgba(255, 180, 90, .28); animation: qcc-pulse 1s ease-in-out infinite; }
.qcc-scene.ran, .qcc-scene.running { background: rgba(255, 180, 90, .42); }
.qcc-scene.ran svg { color: #fff; }
@keyframes qcc-pulse { 50% { opacity: .6; } }
.qcc-devs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qcc-dev { position: relative; display: flex; align-items: stretch; min-width: 0; border-radius: 14px; background: rgba(255, 255, 255, .09); transition: background-color var(--dur-ui) ease, color var(--dur-ui) ease; }
.qcc-dev.on { background: rgba(255, 233, 204, .94); color: #2a1604; }
.qcc-dev.on small { color: rgba(42, 22, 4, .62); }
.qcc-dev.offline, .qcc-dev.denied { opacity: .55; }
.qcc-dev.open { box-shadow: 0 0 0 2px rgba(255, 207, 148, .7); }
.qcc-dmain { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; padding: 10px 4px 10px 10px; border: 0; border-radius: 14px; background: none; text-align: left; }
.qcc-dmain:disabled { cursor: default; }
.qcc-dl { min-width: 0; }
.qcc-dl b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qcc-di { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: rgba(255, 255, 255, .12); flex: none; }
.qcc-dev.on .qcc-di { background: #ffb45a; color: #2a1604; }
.qcc-di svg { width: 17px; height: 17px; }
.qcc-dmore { display: grid; place-items: center; width: 26px; padding: 0; border: 0; border-radius: 0 14px 14px 0; background: none; opacity: .6; }
.qcc-dmore svg { width: 14px; height: 14px; transition: transform var(--dur-ui) var(--ease-out); }
.qcc-dmore[aria-expanded="true"] svg { transform: rotate(90deg); }
.qcc-dmore:hover { opacity: 1; }
.qcc-exp { margin-top: 10px; padding: 10px 10px 4px; border-radius: 12px; background: rgba(0, 0, 0, .18); animation: qcc-in .18s var(--ease-out); }
@keyframes qcc-in { from { opacity: 0; transform: translateY(-4px); } }
.qcc-range { display: block; margin: 0 0 10px; }
.qcc-rl { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 11.5px; color: rgba(247, 239, 230, .68); }
.qcc-rl b { font-weight: 500; font-variant-numeric: tabular-nums; color: rgba(247, 239, 230, .9); }
.qcc-range input { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 22px; margin: 0; border-radius: 11px; cursor: pointer;
  background: linear-gradient(90deg, #ffe2bd 0, #ffe2bd var(--v, 0%), rgba(255, 255, 255, .14) var(--v, 0%)); }
.qcc-range input::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.qcc-range input::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.qcc-btns { display: flex; gap: 6px; margin: 0 0 10px; }
.qcc-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 0; border-radius: 99px; background: rgba(255, 255, 255, .13); font-size: 12px; font-weight: 600; white-space: nowrap; transition: background-color var(--dur-ui) ease, scale var(--dur-press) var(--ease-out); }
.qcc-pill svg { width: 14px; height: 14px; }
.qcc-pill.warm { background: #ffb45a; color: #2a1604; }
.qcc-pill:active { scale: .96; }
.qcc-pill:disabled { opacity: .45; }
.qcc-link { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px; border: 0; border-radius: 8px; background: none; color: #ffcf94 !important; font-size: 12.5px; font-weight: 600; }
.qcc-link svg { width: 15px; height: 15px; }
.qcc-undo { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -2px 0 10px; padding: 7px 10px; border-radius: 10px; background: rgba(255, 180, 90, .16); font-size: 12.5px; animation: qcc-in .18s var(--ease-out); }
.qcc-room { padding: 8px 0 0; border-top: 1px solid rgba(255, 255, 255, .07); }
.qcc-room:first-of-type { border-top: 0; padding-top: 0; }
.qcc-rh { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.qcc-rh b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qd-panel .power { width: 40px; height: 24px; }
.qd-panel .power::after { width: 18px; height: 18px; }
.qd-panel .power[aria-pressed="true"] { background: #ffb45a; box-shadow: 0 0 12px -3px rgba(255, 180, 90, .8); }
.qd-panel .power[aria-pressed="true"]::after { transform: translateX(16px); }
.qd-panel .power[aria-pressed="false"] { background: rgba(255, 255, 255, .2); }
.qcc-cl { display: flex; gap: 12px; align-items: stretch; }
.qcc-air { display: grid; align-content: start; gap: 2px; min-width: 86px; padding-right: 12px; border-right: 1px solid rgba(255, 255, 255, .08); }
.qcc-air b { font: 300 30px/1.05 var(--rounded); color: #fff; }
.qcc-air span { font-size: 12px; color: rgba(247, 239, 230, .7); }
.qcc-ac { flex: 1; min-width: 0; }
.qcc-temp { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.qcc-temp b { display: block; font: 400 22px/1.1 var(--rounded); font-variant-numeric: tabular-nums; }
.qcc-round { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .13); flex: none; transition: scale var(--dur-press) var(--ease-out), background-color var(--dur-ui) ease; }
.qcc-round svg { width: 15px; height: 15px; }
.qcc-round.main { background: #fff; color: #1b1714 !important; }
.qcc-round:active { scale: .93; }
.qcc-round:disabled { opacity: .45; }
.qcc-modesrow { display: flex; flex-wrap: wrap; gap: 4px; }
.qcc-chip { padding: 3px 9px; border: 0; border-radius: 99px; background: rgba(255, 255, 255, .1); font-size: 11.5px !important; }
.qcc-chip.on { background: #ffb45a; color: #2a1604 !important; font-weight: 600; }
.qcc-play { display: flex; align-items: center; gap: 9px; }
.qcc-play b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qcc-art { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, #ffb45a, #c2410c 60%, #3a1d05); flex: none; }
.qcc-art.ha { background: linear-gradient(135deg, #9db8ff, #4a6fd1 60%, #1b2a55); }
.qcc-art svg { width: 19px; height: 19px; color: #fff; }
.qcc-bar { display: block; height: 4px; margin-top: 5px; border-radius: 2px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.qcc-bar i { display: block; height: 100%; width: 0; background: #ffcf94; }
.qcc-mp { margin-top: 10px; }
.qcc-media .qcc-mp:first-of-type, .qcc-media .qcc-h + .qcc-mp { margin-top: 0; }
.qcc-mp .qcc-range { margin: 8px 0 0; }
.qcc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 2px 0; }
.qcc-foot:only-child, .qcc-grid + .qcc-foot { justify-content: center; }
.qcc-edit { display: grid; gap: 6px; }
.qcc-elist { display: grid; gap: 2px; margin-bottom: 8px; padding: 4px; border-radius: 14px; background: rgba(255, 255, 255, .06); }
.qcc-erow { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; cursor: pointer; }
.qcc-erow:hover { background: rgba(255, 255, 255, .06); }
.qcc-erow.dim { opacity: .5; cursor: default; }
.qcc-erow b { display: block; font-size: 13px; font-weight: 500; }
.qcc-erow input { width: 18px; height: 18px; margin: 0; accent-color: #ffb45a; flex: none; }
/* The notification centre: a column at the right edge. */
.qd-nc { top: 48px; right: 8px; bottom: 8px; width: 384px; display: flex; flex-direction: column; border-radius: 22px; }
.qnc-body { flex: 1; overflow-y: auto; padding: 12px 12px 16px; scrollbar-width: none; overscroll-behavior: contain; }
.qnc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.qnc-headacts { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.qnc-quiet { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 8px 10px 8px 8px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, .08); text-align: left; }
.qnc-quiet .qcc-ti { width: 32px; height: 32px; }
.qnc-quiet .qcc-ti svg { width: 16px; height: 16px; }
.qnc-link { display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px; border: 0; border-radius: 8px; background: none; color: #ffcf94 !important; font-size: 12px; font-weight: 600; white-space: nowrap; }
.qnc-link svg { width: 14px; height: 14px; }
.qnc-sec { margin: 14px 4px 8px; font-size: 12px; font-weight: 600; color: rgba(247, 239, 230, .6); }
.qnc-group { margin-bottom: 10px; }
.qnc-gh { display: flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 2px 4px 4px; }
.qnc-gt { flex: 1; font-size: 12.5px; font-weight: 600; }
.qnc-gt i { font-style: normal; font-weight: 500; color: rgba(247, 239, 230, .55); }
.qnc-gx { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); opacity: .75; }
.qnc-gx:hover { opacity: 1; background: rgba(255, 255, 255, .2); }
.qnc-gx svg { width: 11px; height: 11px; }
.qnc-item { position: relative; z-index: 1; margin-bottom: 6px; border-radius: 15px; background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .06); animation: qcc-in .2s var(--ease-out); }
.qnc-item.warn { box-shadow: inset 3px 0 0 #ffb45a; }
.qnc-main { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 15px; background: none; text-align: left; }
@media (hover: hover) and (pointer: fine) { .qnc-main:hover, .qnc-w:hover, .qnc-quiet:hover { background: rgba(255, 255, 255, .05); } }
.qnc-top { display: flex; align-items: baseline; gap: 8px; }
.qnc-top b { flex: 1; min-width: 0; font-size: 13px; line-height: 1.35; }
.qnc-top time { flex: none; font-size: 11px; color: rgba(247, 239, 230, .55); white-space: nowrap; }
.qnc-text { display: -webkit-box; margin-top: 2px; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; font-size: 12.5px; line-height: 1.4; color: rgba(247, 239, 230, .75); }
.qnc-gi { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, .12); color: #ffcf94; flex: none; }
.qnc-gi svg { width: 16px; height: 16px; }
.qnc-gi.g-offline, .qnc-gi.g-guardian { background: rgba(255, 120, 96, .2); color: #ffb3a4; }
.qnc-gi.g-ai, .qnc-gi.g-roomauto { background: rgba(140, 170, 255, .2); color: #c4d4ff; }
.qnc-gi.g-timers { background: rgba(120, 220, 170, .18); color: #b7f0d2; }
.qnc-gi.g-updates, .qnc-gi.g-ha { background: rgba(255, 207, 148, .2); }
.qnc-acts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px 52px; }
.qnc-act { padding: 4px 11px; border: 0; border-radius: 99px; background: rgba(255, 255, 255, .13); font-size: 12px; font-weight: 600; transition: background-color var(--dur-ui) ease, scale var(--dur-press) var(--ease-out); }
.qnc-act.view { background: rgba(255, 180, 90, .3); }
.qnc-act:active { scale: .96; }
.qnc-act:disabled { opacity: .5; }
.qnc-stack { height: 10px; margin: -12px 10px 0; border-radius: 0 0 14px 14px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .05); border-top: 0; }
.qnc-empty { display: grid; justify-items: center; gap: 4px; padding: 40px 12px 30px; text-align: center; color: rgba(247, 239, 230, .6); }
.qnc-empty svg { width: 30px; height: 30px; margin-bottom: 6px; opacity: .5; }
.qnc-empty b { color: #f7efe6; font-size: 14px; }
.qnc-widgets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qnc-w { display: grid; align-content: start; gap: 2px; min-width: 0; padding: 12px; border: 0; border-radius: 15px; background: rgba(255, 255, 255, .09); text-align: left; }
.qnc-w b { font: 400 20px/1.15 var(--rounded); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.qnc-w span { font-size: 12px; color: rgba(247, 239, 230, .7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qd-banner { position: absolute; z-index: 70; top: 50px; right: 12px; width: 360px; display: flex; align-items: flex-start; border-radius: 18px; color: #f7efe6; background: rgba(34, 27, 22, .78);
  backdrop-filter: blur(36px) saturate(170%); -webkit-backdrop-filter: blur(36px) saturate(170%); border: 1px solid rgba(255, 255, 255, .1); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .8); font-size: 13px; }
.qd-banner button { font: inherit; color: inherit; }
.qnc-bmain { display: flex; align-items: flex-start; gap: 10px; flex: 1; min-width: 0; padding: 12px 6px 12px 12px; border: 0; border-radius: 18px; background: none; text-align: left; }
.qnc-bmain small { display: block; font-size: 11px; color: rgba(247, 239, 230, .6); }
.qnc-bmain b { display: block; font-size: 13.5px; line-height: 1.35; }
.qnc-bmain span span, .qnc-bmain .grow > span { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12.5px; color: rgba(247, 239, 230, .75); }
.qnc-bx { display: grid; place-items: center; width: 24px; height: 24px; margin: 10px 10px 0 0; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); opacity: .7; }
.qnc-bx svg { width: 11px; height: 11px; }
.qnc-bx:hover { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .qcc-tog, .qcc-ti, .qcc-scene, .qcc-dev, .qcc-pill, .qcc-round, .qnc-act, .qcc-dmore svg { transition: none; }
  .qcc-tog:active .qcc-ti, .qcc-scene:active, .qcc-pill:active, .qcc-round:active, .qnc-act:active { scale: none; }
  .qcc-scene.busy { animation: none; opacity: .7; }
  .qcc-exp, .qcc-undo, .qnc-item { animation: none; }
}

/* ---------- Wallpapers (desktop.js): the chosen picture over the desktop's own drawing (Warm Night, unchanged) ---------- */
.qd-wl { position: absolute; inset: 0; background-color: #121010; background-size: cover; background-position: center; background-repeat: no-repeat; }
/* Light wallpapers: dark icon names with a soft light halo, a light top bar and dock, widgets a little more opaque. */
.qd .qd-top, .qd .qd-dock, .qd .qd-w { transition: background-color 420ms var(--ease-out), color 420ms var(--ease-out), border-color 420ms var(--ease-out); }
.qd .qd-di { transition: color 420ms var(--ease-out), text-shadow 420ms var(--ease-out); }
.qd.tone-light .qd-di { color: #1f1a15; text-shadow: 0 0 2px rgba(255, 255, 255, .7), 0 1px 6px rgba(255, 255, 255, .55); }
.qd.tone-light .qd-di:hover, .qd.tone-light .qd-di:focus-visible { background: rgba(255, 255, 255, .34); outline-color: rgba(0, 0, 0, .1); }
.qd.tone-light .qd-top { color: #1f1a15; background: rgba(252, 249, 245, .66); border-bottom-color: rgba(0, 0, 0, .08); }
.qd.tone-light .qd-menu { background: rgba(0, 0, 0, .06); }
.qd.tone-light .qd-menu:hover, .qd.tone-light .qd-tb:hover, .qd.tone-light .qd-brand:hover, .qd.tone-light .qd-top .qd-clock:hover { background: rgba(0, 0, 0, .08); }
.qd.tone-light .qd-top .qd-tb.on, .qd.tone-light .qd-top .qd-clock.on { background: rgba(0, 0, 0, .12); }
.qd.tone-light .qd-ask { background: rgba(40, 100, 210, .12) !important; color: #1d4f9e !important; }
.qd.tone-light .qd-top button:focus-visible { outline-color: #b4610f; }
.qd.tone-light .qd-dock { background: rgba(252, 249, 245, .58); border-color: rgba(0, 0, 0, .08); box-shadow: 0 10px 30px -14px rgba(0, 0, 0, .35); }
.qd.tone-light .qd-dock .qd-sep { background: rgba(0, 0, 0, .14); }
.qd.tone-light .qd-dk.qd-startbtn { color: #1f1a15; }
.qd.tone-light .qd-w { background: rgba(30, 24, 20, .6); }
.qd .qd-top [data-dnd="on"] svg { color: #c9b8ff; }
.qd.tone-light .qd-top [data-dnd="on"] svg { color: #5b49b8; }
@media (prefers-reduced-motion: reduce) { .qd .qd-top, .qd .qd-dock, .qd .qd-di, .qd .qd-w { transition: none; } }

/* The picker (desktop.js): QiHome's wallpapers, the person's own picture, an upload tile. */
.qwp { width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; padding: 0; outline: none; }
.qwp-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 6px; }
.qwp-head h2 { margin: 0; font-size: var(--fs-section, 17px); }
.qwp-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.qwp-head .grow { flex: 1; min-width: 0; }
.qwp-x { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); flex: none; cursor: pointer; }
.qwp-x svg { width: 15px; height: 15px; }
.qwp-body { overflow-y: auto; padding: 10px 20px 4px; overscroll-behavior: contain; }
.qwp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 12px; align-items: start; }
.qwp-grid.qwp-wait { min-height: 240px; }
.qwp-tile { position: relative; display: grid; align-content: start; gap: 7px; min-width: 0; padding: 0; border: 0; background: none; color: var(--ink); font: 500 13px var(--font); text-align: left; cursor: pointer; }
.qwp-tile .qwp-img, .qwp-plus { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 12px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line), 0 6px 16px -10px rgba(0, 0, 0, .5); transition: box-shadow var(--dur-ui, 160ms) ease, scale var(--dur-press, 120ms) var(--ease-out); }
.qwp-tile:hover .qwp-img { box-shadow: 0 0 0 1px var(--line), 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent); }
.qwp-tile:active .qwp-img, .qwp-tile:active .qwp-plus { scale: .97; }
.qwp-tile.on .qwp-img { box-shadow: 0 0 0 2.5px var(--brand), 0 8px 22px -12px rgba(0, 0, 0, .55); }
.qwp-tile:focus-visible { outline: none; }
.qwp-tile:focus-visible .qwp-img, .qwp-tile:focus-visible .qwp-plus { box-shadow: 0 0 0 2.5px var(--brand), 0 0 0 6px color-mix(in srgb, var(--brand) 25%, transparent); }
.qwp-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qwp-name small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.qwp-tile.on .qwp-name small { color: var(--brand); font-weight: 600; }
.qwp-check { position: absolute; top: 7px; right: 7px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: var(--on-brand); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.qwp-check svg { width: 13px; height: 13px; }
.qwp-own { position: relative; display: grid; gap: 4px; min-width: 0; }
.qwp-remove { justify-self: start; padding: 3px 10px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); color: var(--bad); font: 600 12px var(--font); cursor: pointer; }
.qwp-plus { display: grid; place-items: center; background: transparent; box-shadow: none; border: 1.5px dashed color-mix(in srgb, var(--muted) 55%, transparent); color: var(--muted); }
.qwp-plus svg { width: 24px; height: 24px; }
.qwp-up .qwp-name, .qwp-up .qwp-name small { white-space: normal; }
.qwp-up.busy { cursor: progress; }
.qwp-up.busy .qwp-plus svg { animation: spin 1s linear infinite; }
.qwp-prog { display: block; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.qwp-prog i { display: block; height: 100%; width: 0; background: var(--brand); transition: width 160ms linear; }
.qwp-err { margin: 14px 0 0; padding: 10px 12px; border-radius: var(--r-md); background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--ink); font-size: 13px; line-height: 1.5; }
.qwp .dlg-actions { padding: 14px 20px 18px; }
.qwp-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
@media (max-width: 640px) { .qwp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { .qwp-tile .qwp-img, .qwp-plus { transition: none; } .qwp-tile:active .qwp-img, .qwp-tile:active .qwp-plus { scale: none; } .qwp-up.busy .qwp-plus svg { animation: none; } .qwp-prog i { transition: none; } }
/* Settings → 通用: the current wallpaper's thumbnail as the row's icon. */
.qwp-row .qwp-mini { width: 44px !important; height: 28px !important; padding: 0; border-radius: 7px !important; overflow: hidden; background: var(--surface-2); }
.qwp-row .qwp-mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.qwp-row .btn { min-height: 32px; padding: 5px 14px; flex: none; }

/* 免打扰 now: the choices under the control centre's (and the notification centre's) switch. */
.qcc-dnd { margin-top: 8px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .08); display: grid; gap: 8px; }
.qcc-dndrow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.qcc-dnd .qcc-chip { display: grid; gap: 1px; padding: 7px 10px; border-radius: 12px; text-align: left; font-size: 12.5px !important; }
.qcc-dnd .qcc-chip small { font-size: 11px; }
.qcc-dnd .qcc-chip.on small { color: rgba(42, 22, 4, .75); }
.qcc-dnd .qcc-chip.off { grid-column: 1 / -1; text-align: center; background: rgba(255, 255, 255, .06); }
.qcc-night { justify-self: start; padding-left: 2px; font-weight: 500 !important; color: rgba(247, 239, 230, .78) !important; }
.qcc-night svg { opacity: .7; }
.qnc-dnd { margin: 0 0 12px; padding: 10px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, .05); }

/* A device the person may not control (or not now): greyed, the switch off limits; its details still open. */
.tile.denied .top, .tile.denied .bottom { opacity: .55; filter: grayscale(.7); }
.tile.denied .icon { color: var(--muted); }
.ctl-note { background: color-mix(in srgb, var(--muted) 14%, transparent); }
.qcc-range input:disabled { opacity: .45; cursor: default; }
