/* =========================================================================
   Evra: design tokens

   Palette (schemecolor.com "Blue Silence" and "Pale Blue and Green"):
     Alpine White #EDEEFB   St. Louis #CDD7F0   Pastel Denim #B3C6EA
     Kawaii Sky Blue #9AAFDD   Splashy Blue #9ED5FD
     Sea Wash Green #B3C6B3   Light Neutral Green #DAE7D1
     Arctic White #E1EDF1   St. Louis #CFDBE7   Gentle Blue #B8CBE4
   The pastels are used as they are for the brand, fills and tints. Text and
   icons on the light theme use deeper shades of the same hues so they stay
   readable. Red (alarms) and amber (warnings, heating) are kept on purpose.
   ========================================================================= */
:root {
  --p-alpine: #EDEEFB;
  --p-stlouis: #CDD7F0;
  --p-denim: #B3C6EA;
  --p-sky: #9AAFDD;
  --p-splash: #9ED5FD;
  --p-seawash: #B3C6B3;
  --p-mint: #DAE7D1;
  --p-arctic: #E1EDF1;
  --p-stlouis-2: #CFDBE7;
  --p-gentle: #B8CBE4;

  color-scheme: dark;
  --bg: #0E1322;
  --card: #151B2E;
  --card-2: #1C2440;
  --card-3: #283153;
  --line: rgb(205 215 240 / 0.08);
  --line-strong: rgb(205 215 240 / 0.16);
  --text: var(--p-alpine);
  --muted: #9AA5C6;
  --accent: var(--p-sky);          /* text and icons */
  --accent-fill: var(--p-sky);     /* buttons, switches */
  --accent-fill-ink: #10162A;
  --accent-ink: #10162A;
  --ok: var(--p-seawash);
  --warn: #E9BE7C;
  --warm: #E9BE7C;
  --danger: #F27D89;
  --danger-ink: #2A0E14;
  --cool: var(--p-splash);
  --violet: var(--p-denim);
  --tone-ink: #10162A;             /* icons drawn on a pastel fill */
  --tint: 10%;                     /* how strongly an "on" tile takes its colour */
  --tint-soft: 7%;                 /* same, for lights, whose colour can be strong */
  --bubble: 20%;                   /* icon bubble background strength */
  --ink-mix: 100%;                 /* coloured icon text: pure pastel on dark */
  --knob: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  --radius: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --nav-h: 70px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: var(--p-alpine);
  --card: #ffffff;
  --card-2: #E6EBF8;
  --card-3: var(--p-stlouis);
  --line: rgb(40 56 100 / 0.10);
  --line-strong: rgb(40 56 100 / 0.18);
  --text: #1A2240;
  --muted: #5C6787;
  --accent: #4A64AC;
  --accent-fill: var(--p-sky);
  --accent-fill-ink: #1A2240;
  --accent-ink: #ffffff;
  --ok: #3F6B49;
  --warn: #85580F;
  --warm: #A0661C;
  --danger: #C43D4B;
  --danger-ink: #ffffff;
  --cool: #2F6E9E;
  --violet: #4A64AC;
  --tone-ink: #1A2240;
  --tint: 22%;
  --tint-soft: 9%;
  --bubble: 55%;
  --ink-mix: 40%;
  --shadow: 0 1px 2px rgb(40 56 100 / 0.06), 0 4px 16px -8px rgb(40 56 100 / 0.16);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: var(--p-alpine);
    --card: #ffffff;
    --card-2: #E6EBF8;
    --card-3: var(--p-stlouis);
    --line: rgb(40 56 100 / 0.10);
    --line-strong: rgb(40 56 100 / 0.18);
    --text: #1A2240;
    --muted: #5C6787;
    --accent: #4A64AC;
    --accent-fill: var(--p-sky);
    --accent-fill-ink: #1A2240;
    --accent-ink: #ffffff;
    --ok: #3F6B49;
    --warn: #85580F;
    --warm: #A0661C;
    --danger: #C43D4B;
    --danger-ink: #ffffff;
    --cool: #2F6E9E;
    --violet: #4A64AC;
    --tone-ink: #1A2240;
    --tint: 22%;
    --tint-soft: 9%;
    --bubble: 55%;
    --ink-mix: 40%;
    --shadow: 0 1px 2px rgb(40 56 100 / 0.06), 0 4px 16px -8px rgb(40 56 100 / 0.16);
  }
}

/* =========================================================================
   Base
   ========================================================================= */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.4; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 0; }
.icon { flex: none; display: block; }
/* "hidden" always wins over a component's own display. */
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 28px 4px; }
.boot { padding: 40px; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sep { flex: 1; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: 0.45; display: inline-block; }

/* =========================================================================
   Shell: header, navigation, page
   ========================================================================= */
.app { min-height: 100dvh; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 16px) 20px 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.top-left { min-width: 0; }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.theme-btn {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; padding: 0;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.theme-btn:hover { color: var(--text); }
.custom-btn { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card)); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.custom-btn[aria-expanded="true"] { background: var(--accent-fill); color: var(--accent-fill-ink); }

/* Developer mode off: technical details are hidden. */
:root:not(.dev) .dev-only { display: none !important; }
.top-title { font-size: 24px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-sub { color: var(--muted); font-size: 13px; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 7px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; font-weight: 650; text-decoration: none; white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.status-pill.connected { color: var(--ok); }
.status-pill.connected .status-dot, .status-dot.connected { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.status-pill.demo { color: var(--violet); }
.status-pill.demo .status-dot { background: var(--violet); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 22%, transparent); }
.status-pill.connecting .status-dot, .status-pill.reconnecting .status-dot,
.status-dot.connecting, .status-dot.reconnecting { background: var(--warn); animation: blink 1.2s infinite; }
.status-pill.error, .status-pill.idle { color: var(--danger); }
.status-pill.error .status-dot, .status-dot.error { background: var(--danger); }
@keyframes blink { 50% { opacity: 0.3; } }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  /* One column per visible tab, however many there are. */
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 6px 6px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav-brand { display: none; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 650;
}
.nav-icon { display: grid; place-items: center; width: 54px; height: 30px; border-radius: 999px; transition: background 0.2s, color 0.2s; }
.nav-item.active { color: var(--text); }
.nav-item.active .nav-icon { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

.view {
  max-width: 1200px; margin: 0 auto;
  padding: 6px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px);
  display: flex; flex-direction: column; gap: var(--gap);
}
.view:focus { outline: none; }

@media (min-width: 900px) {
  .nav {
    top: 0; right: auto; width: 96px; height: auto;
    grid-auto-flow: row; grid-auto-columns: auto;
    grid-template-columns: 1fr; grid-auto-rows: 72px; align-content: start;
    padding: 18px 0 0; border-top: 0; border-right: 1px solid var(--line);
  }
  .nav-brand {
    display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 18px;
    border-radius: 14px; color: var(--accent);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
  }
  .top { padding: 22px 28px 14px 124px; }
  .view { padding: 6px 28px 36px 124px; max-width: none; }
  .view > * { width: 100%; max-width: 1180px; }
}

.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 6px 4px -4px;
}

/* =========================================================================
   Cards
   ========================================================================= */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--card-pad, 18px);
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 12px; }
.card-head h2 { font-size: 17px; flex: 1; min-width: 0; }
.card-icon {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--card)); color: var(--accent);
}
.card-extra { display: flex; align-items: center; gap: 8px; }
.card-status { color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.card-foot.muted { color: var(--muted); }

.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.grid.devices { grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid.devices { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1500px) { .grid.devices { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Device tiles light up in their own colour (--tone) when on. */
.device { --tone: var(--accent); transition: background 0.3s, border-color 0.3s, box-shadow 0.3s; }
.device-head { display: flex; align-items: center; gap: 12px; }
.device-icon {
  width: 46px; height: 46px; border-radius: 15px; flex: none;
  display: grid; place-items: center;
  background: var(--card-2); color: var(--muted);
  transition: background 0.3s, color 0.3s, box-shadow 0.3s;
}
.device-titles { flex: 1; min-width: 0; }
.device-titles h2 { font-size: 17px; }
.device-state { color: var(--muted); font-size: 13px; font-weight: 550; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device.is-on {
  background: color-mix(in srgb, var(--tone) var(--tint), var(--card));
  border-color: color-mix(in srgb, var(--tone) 40%, transparent);
  box-shadow: var(--shadow), 0 18px 40px -26px color-mix(in srgb, var(--tone) 70%, transparent);
}
.device.is-on .device-icon {
  background: var(--tone); color: var(--tone-ink);
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--tone) 80%, transparent);
}
.device.is-on .device-state { color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text)); }
/* A light's tone is its real colour, which can be dark and saturated. */
.light-card.is-on { background: color-mix(in srgb, var(--tone) var(--tint-soft), var(--card)); }
.light-card.is-on .device-state { color: color-mix(in srgb, var(--tone) 45%, var(--text)); }

/* =========================================================================
   Home: room card and quick actions
   ========================================================================= */
.home-top { display: grid; gap: var(--gap); }
@media (min-width: 1100px) {
  .home-top { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: stretch; }
  .home-top .quick { display: flex; flex-direction: column; }
  .home-top .quick-row { grid-template-columns: 1fr 1fr; flex: 1; }
}

.hero {
  --hero: var(--muted);
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px 22px 20px;
  background:
    radial-gradient(120% 130% at 100% 0%, color-mix(in srgb, var(--hero) 24%, transparent) 0%, transparent 58%),
    var(--card);
  display: flex; flex-direction: column; gap: 6px;
  transition: background 0.4s;
}
.hero.tone-ok { --hero: var(--ok); }
.hero.tone-warm { --hero: var(--warm); }
.hero.tone-cool { --hero: var(--cool); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hero-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.badge {
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
  color: color-mix(in srgb, var(--hero) 80%, var(--text));
  background: color-mix(in srgb, var(--hero) 16%, transparent);
}
.hero-temp { display: flex; align-items: flex-start; margin: 6px 0 0; line-height: 0.95; font-variant-numeric: tabular-nums; }
.hero-num { font-size: clamp(64px, 16vw, 96px); font-weight: 250; letter-spacing: -0.05em; }
.hero-deg { font-size: clamp(28px, 6vw, 40px); font-weight: 300; color: var(--muted); margin-top: 0.15em; margin-left: 2px; }
.hero-range { color: var(--muted); font-size: 13px; }
.hero-stats { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 10px; }
.stat { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.stat .icon { color: var(--hero); opacity: 0.9; }
.stat strong { color: var(--text); font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--card-2); color: var(--text);
  font-size: 13px; font-weight: 600;
}
.chip.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, var(--card)); }
.chip.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, var(--card)); }
.chip.accent { color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, var(--card)); }
.chip.muted { color: var(--muted); }
.chip.live .icon { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; } }

.quick { display: flex; flex-direction: column; gap: 12px; }
.quick .section-title { margin: 6px 4px 0; }
.quick-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) and (max-width: 1099px) { .quick-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } .quick-btn { flex-direction: column; align-items: flex-start; } .quick-text small { white-space: normal; } }
.quick-btn {
  --tone: var(--accent);
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: var(--radius-md);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  text-align: left; min-width: 0;
  transition: transform 0.12s ease, border-color 0.2s, background 0.2s;
}
.quick-btn:hover { border-color: color-mix(in srgb, var(--tone) 35%, transparent); }
.quick-btn:active { transform: scale(0.97); }
.quick-icon {
  width: 42px; height: 42px; border-radius: 13px; flex: none;
  display: grid; place-items: center;
  color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text));
  background: color-mix(in srgb, var(--tone) var(--bubble), transparent);
}
.quick-text { display: flex; flex-direction: column; min-width: 0; }
.quick-text strong { font-size: 15px; font-weight: 650; }
.quick-text small {
  color: var(--muted); font-size: 12px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.quick-btn.busy { pointer-events: none; }
.quick-btn.busy .quick-icon .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================================
   Controls
   ========================================================================= */
.switch {
  position: relative; width: 52px; height: 30px; flex: none;
  border-radius: 999px; border: 0; padding: 0;
  background: var(--card-3);
  transition: background 0.2s;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--knob); box-shadow: 0 1px 3px rgb(0 0 0 / 0.35);
  transition: transform 0.22s cubic-bezier(0.3, 0.7, 0.4, 1.2);
}
.switch[aria-checked="true"] { background: var(--accent-fill); }
.switch[aria-checked="true"] .knob { transform: translateX(22px); }

.slider { display: flex; flex-direction: column; gap: 8px; }
.slider-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.slider-value { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 650; }
.slider input[type="range"] {
  --fill: 50%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 38px; margin: 0;
  border-radius: 13px; cursor: pointer;
  background: linear-gradient(to right, color-mix(in srgb, var(--tone, var(--accent-fill)) 85%, transparent) var(--fill), var(--card-2) var(--fill));
}
.slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 5px; height: 22px; border-radius: 3px; background: var(--knob); box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15), 0 1px 4px rgb(0 0 0 / 0.3); }
.slider input[type="range"]::-moz-range-thumb { width: 5px; height: 22px; border: 0; border-radius: 3px; background: var(--knob); }
.slider input[type="range"]:disabled { opacity: 0.35; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 12px; }
.field.inline > span { flex: none; }
.field[hidden] { display: none; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.setting-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 200px; }
.setting-text strong { font-size: 15px; font-weight: 650; }
.setting-text small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.theme-tabs button { display: inline-flex; align-items: center; gap: 6px; }
.select, .input {
  width: 100%; padding: 11px 12px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
}
.select:disabled { opacity: 0.45; }

.link {
  background: none; border: 0; padding: 0; color: var(--accent);
  font-weight: 650; text-decoration: none; display: inline-flex; align-items: center; gap: 2px; font-size: 13px;
}
.link.subtle { color: var(--muted); font-weight: 550; }
.link.subtle:hover { color: var(--text); }
.link.small { font-size: 12px; }

/* IR buttons */
.ir-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 0;
  background: var(--card-2); color: var(--text);
  font-weight: 650; position: relative;
  transition: transform 0.1s ease, background 0.2s;
}
.ir-btn:hover:not(:disabled) { background: var(--card-3); }
.ir-btn:active, .ir-btn.sending { transform: scale(0.94); background: var(--card-3); }
.ir-btn.pulse::after {
  content: ""; position: absolute; inset: -3px; border-radius: inherit;
  border: 2px solid var(--tone, var(--accent)); animation: pulse 0.7s ease-out forwards; pointer-events: none;
}
@keyframes pulse { from { opacity: 1; transform: scale(0.96); } to { opacity: 0; transform: scale(1.08); } }
.ir-btn.round { width: 46px; height: 46px; padding: 0; border-radius: 50%; }
.ir-btn.flat { background: transparent; }
.ir-btn.netflix { color: #e50914; }
.ir-btn.mode { flex-direction: column; gap: 4px; min-height: 64px; font-size: 12px; }
.ir-btn.mode .icon { color: color-mix(in srgb, var(--tone, var(--accent)) var(--ink-mix), var(--text)); }
.ir-btn.mini { min-height: 34px; padding: 0 11px; font-size: 12px; border-radius: 10px; gap: 5px; }
.ir-btn.pill { flex: 1 1 auto; min-width: 78px; font-size: 13px; }

.stepper {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card-2); border-radius: 999px; padding: 5px;
}
.stepper .ir-btn.round { background: var(--card); box-shadow: var(--shadow); }
.stepper-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 13px; }
.mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.tv-mini { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vol { display: flex; align-items: center; background: var(--card-2); border-radius: 999px; padding: 0 2px; }
.vol-label { color: var(--muted); padding: 0 2px; }

/* LED strip */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%; border: 0; padding: 0; position: relative;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18);
  transition: transform 0.12s;
}
.swatch:hover { transform: scale(1.08); }
.swatch:active { transform: scale(0.92); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--text); }
.swatch.custom { display: grid; place-items: center; background: var(--card-2); color: var(--muted); cursor: pointer; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line-strong); }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Plug */
.plug-now { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.big-number { font-size: 44px; font-weight: 250; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1; }
.big-number small { font-size: 16px; color: var(--muted); font-weight: 550; letter-spacing: 0; }
.spark-wrap { height: 48px; margin: -4px -2px 0; }
.sparkline { width: 100%; height: 48px; display: block; }

/* =========================================================================
   Remotes
   ========================================================================= */
/* One remote at a time in a sideways-swiping track. */
.remote-slider { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 480px; margin: 0 auto; }
.remote-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.remote-nav .icon-btn:disabled { opacity: 0.35; }
.remote-tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 18px; }
.remote-track {
  display: flex; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none;
  margin: 0 -4px;
  transition: height 0.25s ease;
}
.remote-track::-webkit-scrollbar { display: none; }
.remote-slide { flex: 0 0 100%; min-width: 0; padding: 2px 4px 10px; scroll-snap-align: start; scroll-snap-stop: always; }
@media (prefers-reduced-motion: reduce) { .remote-track { transition: none; } }
.remote { gap: 12px; }
.tv-remote { --tone: var(--cool); }
.heater-remote { --tone: var(--warm); }
.remote .card-icon { color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text)); background: color-mix(in srgb, var(--tone) var(--bubble), var(--card)); }
.remote-head { display: flex; align-items: center; gap: 10px; }
.remote-state { font-weight: 650; color: var(--muted); font-size: 13px; }
.remote-row { display: grid; gap: 10px; }
.remote-row.two { grid-template-columns: repeat(2, 1fr); }
.remote-row.three { grid-template-columns: repeat(3, 1fr); }
.remote-row.five { grid-template-columns: repeat(5, 1fr); }
.key { height: 52px; padding: 0; }
.key.danger { color: var(--danger-ink); background: var(--danger); }
.key.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 85%, #000); }
.key.small-text { font-size: 13px; }
.key.labelled { flex-direction: column; gap: 3px; height: 64px; font-size: 12px; }
.key.labelled .icon { color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text)); }
.key.big { height: 76px; width: 76px; border-radius: 50%; }
.key.warm { color: var(--warm); }
.key.cool { color: var(--cool); }
.dpad {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 4px; width: min(100%, 240px); aspect-ratio: 1; margin: 6px auto;
  padding: 10px; border-radius: 50%;
  background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line);
}
.dp { background: transparent; min-height: 0; border-radius: 18px; }
.dp.up { grid-area: 1 / 2; }
.dp.left { grid-area: 2 / 1; }
.dp.ok { grid-area: 2 / 2; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 15px; }
.dp.right { grid-area: 2 / 3; }
.dp.down { grid-area: 3 / 2; }
.rockers { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.rocker { display: flex; flex-direction: column; align-items: stretch; background: var(--card-2); border-radius: 26px; overflow: hidden; }
.rk { background: transparent; height: 54px; border-radius: 0; }
.rocker-label { text-align: center; font-size: 11px; font-weight: 750; color: var(--muted); letter-spacing: 0.1em; }
.key.mute { width: 56px; height: 56px; border-radius: 50%; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.digit { font-size: 18px; font-variant-numeric: tabular-nums; }
.digit.zero { grid-column: 2; }
.temp-keys { display: flex; align-items: center; justify-content: space-around; padding: 8px 0; }
.temp-keys-label { color: var(--muted); font-weight: 650; font-size: 13px; }

/* =========================================================================
   Energy
   ========================================================================= */
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile {
  --tone: var(--accent);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: var(--radius-md); padding: 14px 16px;
}
.tile-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.tile-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text)); background: color-mix(in srgb, var(--tone) var(--bubble), transparent); }
.tile-value { font-size: 28px; font-weight: 300; letter-spacing: -0.03em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.tile-value small { font-size: 13px; color: var(--muted); letter-spacing: 0; font-weight: 550; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.energy-charts { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); }
.segmented { display: inline-flex; background: var(--card-2); border-radius: 13px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 650; font-size: 13px; color: var(--muted); transition: background 0.2s, color 0.2s; }
.segmented button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { color: var(--text); }

.chart { width: 100%; height: auto; display: block; }
.chart-line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
path.chart-area { stroke: none; }
.chart-dot { stroke: var(--card); stroke-width: 2.5; }
.fade-top { stop-opacity: 0.32; }
.fade-bottom { stop-opacity: 0; }
.c-power { stroke: var(--accent); }
.chart-dot.c-power { fill: var(--accent); }
.fade-top.c-power, .fade-bottom.c-power { stop-color: var(--accent); }
.c-temp { stroke: var(--warm); }
.chart-dot.c-temp { fill: var(--warm); }
.fade-top.c-temp, .fade-bottom.c-temp { stop-color: var(--warm); }
.c-hum { stroke: var(--cool); }
.chart-dot.c-hum { fill: var(--cool); }
.fade-top.c-hum, .fade-bottom.c-hum { stop-color: var(--cool); }
.c-plug { stroke: var(--ok); }
.fade-top.c-plug, .fade-bottom.c-plug { stop-color: var(--ok); }
.chart-band { fill: var(--ok); opacity: 0.1; }
.chart-grid { stroke: var(--line-strong); stroke-dasharray: 2 5; }
.chart-label, .chart-empty { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart-empty { font-size: 13px; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.band-swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--ok); opacity: 0.35; display: inline-block; }

.timeline { display: flex; flex-direction: column; gap: 10px; --tl-label: 96px; }
.tl-lane { display: grid; grid-template-columns: var(--tl-label) 1fr; align-items: center; gap: 10px; }
.tl-label { font-size: 12px; color: var(--muted); font-weight: 650; }
.tl-bar { position: relative; height: 22px; border-radius: 7px; background: var(--card-2); overflow: hidden; }
.tl-seg { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; }
.tl-presence { background: var(--accent); }
.tl-window { background: var(--ok); }
.tl-gap { top: 0; bottom: 0; background: repeating-linear-gradient(45deg, var(--card-3) 0 4px, transparent 4px 8px); }
.tl-axis { display: flex; justify-content: space-between; margin-left: calc(var(--tl-label) + 10px); font-size: 11px; color: var(--muted); }

/* =========================================================================
   Automations and settings
   ========================================================================= */
.intro { margin: 0 4px; max-width: 70ch; }
.auto-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.auto-item {
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  transition: opacity 0.2s;
}
.auto-item.off { opacity: 0.62; }
.auto-top { display: flex; align-items: flex-start; gap: 12px; }
.auto-icon {
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  display: grid; place-items: center;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.auto-item.off .auto-icon { color: var(--muted); background: var(--card-2); }
.auto-titles { flex: 1; min-width: 0; }
.auto-titles h3 { font-size: 15px; line-height: 1.3; }
.auto-meta { margin-top: 3px; font-size: 12px; color: var(--muted); }
.auto-desc { color: var(--muted); font-size: 14px; }
.auto-desc:empty { display: none; }
.auto-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.auto-mine, .ideas { display: flex; flex-direction: column; gap: var(--gap); }
.auto-mine[hidden], .ideas[hidden] { display: none; }
.tab-count { margin-left: 6px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }
.input.short { width: 80px; flex: 0 0 80px; }
.segmented button { white-space: nowrap; }
.narrow-text { display: none; }
@media (max-width: 480px) {
  .wide-text { display: none; }
  .narrow-text { display: inline; }
}
.idea-hint { margin: 0; }

/* ---- automation ideas: ready ones in full colour, the rest faded ---- */
.idea-group { display: flex; flex-direction: column; gap: 10px; }
.idea-group > .muted.small { margin: -4px 4px 0; }
.idea-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.idea {
  --tone: var(--accent);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.idea-top { display: flex; align-items: flex-start; gap: 12px; align-self: stretch; }
.idea-icon {
  width: 40px; height: 40px; border-radius: 13px; flex: none; display: grid; place-items: center;
  color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text));
  background: color-mix(in srgb, var(--tone) var(--bubble), var(--card));
}
.idea-titles { flex: 1; min-width: 0; }
.idea-titles h4 { font-size: 15px; line-height: 1.3; }
.idea-cat { font-size: 12px; color: var(--muted); }
.idea-text { color: var(--muted); font-size: 14px; }
.idea-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.idea-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--card-2); color: var(--text); text-decoration: none; white-space: nowrap;
}
.idea-chip .icon { color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text)); }
/* A product the idea still needs: dashed, colourless, links to the catalogue. */
.idea-chip.missing { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); }
.idea-chip.missing .icon { color: var(--muted); }
.idea-chip.missing:hover { color: var(--text); border-color: var(--muted); }
.idea-chip .chip-note { font-weight: 550; font-size: 11px; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.idea-lock { color: var(--muted); padding: 4px; }
.idea.unavailable { background: transparent; box-shadow: none; border-style: dashed; border-color: var(--line-strong); }
.idea.unavailable .idea-icon { color: var(--muted); background: var(--card-2); filter: grayscale(1); }
.idea.unavailable .idea-titles h4 { color: var(--muted); }
.idea.unavailable .idea-chip:not(.missing) { background: color-mix(in srgb, var(--card-2) 60%, transparent); color: var(--muted); }
.idea.unavailable .idea-chip:not(.missing) .icon { color: var(--muted); }

/* ---- scenes ---- */
.scene-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); align-items: start; }
.scene {
  --tone: var(--accent);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  transition: opacity 0.2s;
}
.scene.busy { opacity: 0.7; }
.scene-top { display: flex; align-items: center; gap: 12px; }
.scene-icon {
  width: 48px; height: 48px; border-radius: 15px; flex: none; display: grid; place-items: center;
  color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text));
  background: color-mix(in srgb, var(--tone) var(--bubble), var(--card));
}
.scene-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.scene-titles h3 { font-size: 17px; }
.scene-last { font-size: 12px; font-weight: 650; color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text)); }
.scene-start { flex: none; }
.scene-start:disabled { opacity: 0.45; cursor: default; }
.scene-text { color: var(--muted); font-size: 14px; margin-top: -4px; }
.scene-rooms { display: flex; flex-wrap: wrap; gap: 6px; }
.room-chip.small { padding: 6px 12px; font-size: 13px; }
.scene-steps summary { cursor: pointer; font-size: 13px; font-weight: 650; color: var(--text); list-style-position: outside; }
.scene-steps ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.scene-steps li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.scene-steps li .icon { color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text)); flex: none; }
.scene-steps li span { flex: 1; min-width: 0; }
.scene-steps li strong { color: var(--text); font-weight: 650; }
.scene-empty { margin: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--card-2); font-weight: 650; font-size: 14px; text-decoration: none;
  transition: background 0.2s;
}
.btn:hover { background: var(--card-3); }
.btn.primary { background: var(--accent-fill); color: var(--accent-fill-ink); border-color: transparent; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent-fill) 85%, var(--text)); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--card-2); }
.btn[hidden] { display: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.status-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 650; }
.battery-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.battery-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.battery-list li:first-child { border-top: 0; padding-top: 0; }
.battery-list li .icon { color: var(--muted); }
.battery-list li span { flex: 1; }
.battery-list strong { font-variant-numeric: tabular-nums; }
.battery-list strong.low { color: var(--danger); }
.about { text-align: center; margin: 4px 0; }
.card[hidden] { display: none; }

/* =========================================================================
   Toast
   ========================================================================= */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); z-index: 50;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 460px); padding: 11px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-weight: 650; font-size: 14px;
  box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.5);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: var(--danger-ink); }
@media (min-width: 900px) { .toast { bottom: 24px; margin-left: 48px; } }

/* =========================================================================
   Small square screens (the 480x480 wall panel)
   ========================================================================= */
@media (max-width: 520px) and (max-height: 560px) {
  :root { --nav-h: 58px; --gap: 12px; }
  .top { padding: 10px 14px 8px; }
  .top-title { font-size: 19px; }
  .hero { padding: 14px 16px; gap: 2px; }
  .hero-num { font-size: 52px; }
  .hero-deg { font-size: 24px; }
  .hero-range { display: none; }
  .hero-stats { margin-top: 4px; }
  .hero-chips { margin-top: 8px; }
  .chip { padding: 5px 10px; font-size: 12px; }
  .nav-label { display: none; }
  .quick-row { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .quick-btn { flex-direction: column; gap: 6px; padding: 10px 6px; text-align: center; }
  .quick-text small { display: none; }
  .quick-text strong { font-size: 13px; }
  .quick-icon { width: 36px; height: 36px; }
}

/* =========================================================================
   Navigation extras
   ========================================================================= */
.nav-item.wide-only { display: none; }
.nav-item[hidden] { display: none !important; }
/* Six tabs on a phone: slightly smaller labels so "Automations" fits. */
@media (max-width: 899px) {
  .nav-item { font-size: 10px; letter-spacing: -0.01em; min-width: 0; }
  .nav-label { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav-icon { width: 48px; }
}
@media (min-width: 900px) { .nav-item.wide-only { display: flex; } }
.nav-devil.active .nav-icon { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }

/* =========================================================================
   Home: alerts, rooms
   ========================================================================= */
.alerts { display: flex; flex-direction: column; gap: 10px; }
.alerts:empty { display: none; }
.alert-banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--danger) 16%, var(--card)); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  animation: alarm-pulse 1.6s ease-in-out infinite;
}
.alert-banner .icon { color: var(--danger); margin-top: 1px; }
.alert-banner strong { color: var(--danger); }
.alert-banner p { font-size: 13px; color: var(--muted); margin-top: 2px; }
@keyframes alarm-pulse { 50% { border-color: color-mix(in srgb, var(--danger) 85%, transparent); } }

.section-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 4px -4px; }
.section-row .section-title { margin: 0; }
.room-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; }
.room-chips::-webkit-scrollbar { display: none; }
.room-chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  padding: 9px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  font-weight: 650; font-size: 14px; text-decoration: none; white-space: nowrap;
}
.room-chip .count { font-size: 12px; color: var(--muted); background: var(--card-2); border-radius: 999px; padding: 1px 7px; }
.room-chip.active { background: var(--text); color: var(--bg); border-color: transparent; }
.room-chip.active .count { background: color-mix(in srgb, var(--bg) 20%, transparent); color: var(--bg); }
.room-chip.add { color: var(--accent); border-style: dashed; }
.room-section { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.room-title { font-size: 17px; }
.devices-slot { display: flex; flex-direction: column; gap: var(--gap); }
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  padding: 36px 20px; border-radius: var(--radius); border: 1px dashed var(--line-strong); color: var(--muted);
}

/* =========================================================================
   Device cards: extra kinds
   ========================================================================= */
.batt { display: inline-flex; align-items: center; gap: 4px; }
.batt.low { color: var(--danger); }
.btn.mini-btn { padding: 6px 10px; font-size: 12px; border-radius: 10px; }
.cover-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cover-row .ir-btn { flex-direction: column; gap: 3px; min-height: 60px; font-size: 12px; }
.climate-now { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.target-value { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; margin-left: 4px; }
.btn.wide { width: 100%; justify-content: center; padding: 13px; font-size: 15px; }
.lock-card.warn-state { --tone: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.btn.danger { background: var(--danger); color: var(--danger-ink); border-color: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.danger-text { color: var(--danger); }
.device.alarm {
  --tone: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, var(--card));
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
  animation: alarm-pulse 1.6s ease-in-out infinite;
}
.device.alarm .device-state { color: var(--danger); font-weight: 750; }
.alarm-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--danger); font-weight: 600; }
.alarm-note.static { color: var(--muted); font-weight: 500; }
.alarm-note.static .icon { color: var(--warn); }
.alarm-note[hidden] { display: none; }
.camera-frame {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden;
  background-color: #0b0d10; background-size: cover; background-position: center;
}
.camera-frame.demo {
  background-image:
    radial-gradient(60% 80% at 30% 70%, rgb(158 213 253 / 0.20), transparent 60%),
    radial-gradient(50% 60% at 75% 30%, rgb(179 198 179 / 0.16), transparent 60%),
    linear-gradient(160deg, #1C2440, #0E1322);
}
.camera-frame.private { background-image: none !important; background-color: #050608; }
.camera-stamp {
  position: absolute; left: 10px; bottom: 8px; font-size: 11px; font-weight: 650; letter-spacing: 0.02em;
  color: #fff; background: rgb(0 0 0 / 0.45); padding: 3px 7px; border-radius: 6px; font-variant-numeric: tabular-nums;
}
.mini-toggle { display: inline-flex; align-items: center; gap: 6px; }
.mini-toggle .switch { transform: scale(0.8); transform-origin: left center; margin-right: -8px; }
.ir-section { display: flex; flex-direction: column; gap: 10px; padding-top: 2px; }
.ir-section + .ir-section { border-top: 1px solid var(--line); padding-top: 14px; }
.ir-line { display: flex; align-items: center; gap: 8px; }
.ir-line .icon { color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text)); }
.mode-row.four { grid-template-columns: repeat(4, 1fr); }
.ir-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.entity-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.entity-rows li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.entity-rows li:first-child { border-top: 0; }
.entity-rows strong { font-variant-numeric: tabular-nums; text-align: right; }
.entity-rows small { font-size: 11px; }

/* =========================================================================
   Devices screen
   ========================================================================= */
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; align-self: flex-start; }
.back-link:hover { color: var(--text); }
.search { max-width: 420px; }
.search[hidden] { display: none; }
.list-groups { display: flex; flex-direction: column; gap: 18px; }
.list-group { display: flex; flex-direction: column; gap: 8px; }
.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 0 4px; }
.list { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow); }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  text-decoration: none; color: var(--text); border-top: 1px solid var(--line);
}
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--card-2); }
.list-row > .icon { color: var(--muted); }
.row-icon { width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--card-2); color: var(--accent); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-text strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--card-2); color: var(--muted); white-space: nowrap; flex: none; }
.pill.bad { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill.pairing-zigbee { color: var(--ok); }
.pill.pairing-flow { color: var(--cool); }
.pill.pairing-matter { color: var(--violet); }
.pill.pairing-cloud { color: var(--warn); }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }
.rooms-panel { display: flex; flex-direction: column; gap: var(--gap); max-width: 720px; }
.icon-btn.danger:hover { color: var(--danger); }
.detail-head { display: flex; align-items: center; gap: 14px; }
.detail-head h2 { font-size: 22px; }
.detail-head p { font-size: 13px; margin-top: 2px; }
.detail-icon { width: 54px; height: 54px; border-radius: 17px; flex: none; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 15%, var(--card)); color: var(--accent); }
.detail-grid { display: grid; gap: var(--gap); align-items: start; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
@media (min-width: 1000px) { .detail-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.danger-zone .card-icon { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--card)); }
.catalog { display: flex; flex-direction: column; gap: 20px; }
.catalog-group { display: flex; flex-direction: column; gap: 8px; }
.product-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.product-tile {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow);
  text-decoration: none; color: var(--text); transition: border-color 0.2s;
}
.product-tile:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.pair-panel { display: flex; flex-direction: column; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.success-line { display: flex; align-items: center; gap: 8px; color: var(--ok); font-weight: 650; }
.error-line { color: var(--danger); font-size: 13px; font-weight: 600; }
.hint { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.hint .icon { color: var(--accent); margin-top: 2px; }
.waiting { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--card-3); border-top-color: var(--accent); animation: spin 0.9s linear infinite; flex: none; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.steps li::marker { color: var(--accent); font-weight: 700; }
.check-field { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check-field input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Home Assistant setup forms (Add device): its texts, found devices, folded sections. */
.flow-title { margin: 0; font-size: 16px; }
.flow-desc { color: var(--muted); font-size: 14px; }
.flow-desc p { margin: 0 0 6px; }
.flow-desc a { color: var(--accent); }
.flow-desc code { font-size: 13px; padding: 1px 5px; border-radius: 6px; background: var(--card-2); }
.field small.muted { font-size: 12px; }
.found-list { display: flex; flex-direction: column; gap: 8px; }
.found-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--card-2); border: 1px solid var(--line); }
.found-row .icon { color: var(--accent); flex: none; }
.found-name { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-section { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.flow-section > summary { cursor: pointer; font-weight: 650; font-size: 14px; }
.flow-section[open] { display: flex; flex-direction: column; gap: 12px; }
.flow-section[open] > summary { margin-bottom: 2px; }

/* =========================================================================
   Automation editor
   ========================================================================= */
.auto-item.running { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.auto-item.running .auto-icon .icon { animation: breathe 1.4s ease-in-out infinite; }
.toolbar .intro { flex: 1; }
.editor { display: flex; flex-direction: column; gap: var(--gap); max-width: 860px; }
.builder { display: flex; flex-direction: column; gap: var(--gap); }
.rule-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--radius-sm); background: var(--card-2); }
.rule-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.rule-fields .select, .rule-fields .input { background: var(--card); }
.rule-tools { display: flex; flex-direction: column; gap: 6px; }
.rule-tools .icon-btn { width: 34px; height: 34px; background: var(--card); }
.inline-fields { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-fields .input, .inline-fields .select { width: auto; flex: 1 1 110px; min-width: 0; }
.day-picks { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.day { border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 650; color: var(--muted); }
.day.on { background: var(--accent-fill); color: var(--accent-fill-ink); border-color: transparent; }
.add-rule { align-self: flex-start; }
textarea.json {
  width: 100%; min-height: 380px; resize: vertical; padding: 12px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  font: 13px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
}
.editor-bar {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px); z-index: 10;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; max-width: 860px;
  padding: 10px; border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--card) 94%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
@media (min-width: 900px) { .editor-bar { bottom: 16px; } }

/* =========================================================================
   Assistant chat and settings shortcuts
   ========================================================================= */
/* Read by screen readers, not shown. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.chat { display: flex; flex-direction: column; gap: 12px; max-width: 760px; width: 100%; margin: 0 auto; }
.chat-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.chat-avatar {
  width: 48px; height: 48px; border-radius: 16px; flex: none; display: grid; place-items: center;
  color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--card));
}
.chat-titles { flex: 1 1 180px; min-width: 0; }
/* On a phone the buttons move to their own row instead of squeezing the title. */
.chat-head-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-left: auto; }
.voice-btn[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.msg-tools { display: flex; margin-top: 6px; }
.msg-listen { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.msg-listen[aria-pressed="true"] { color: var(--accent); }
.chat-titles h2 { font-size: 18px; }
.chat-status { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.chat-log { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.chat-log:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 12px; }
.msg {
  max-width: min(88%, 620px); padding: 10px 14px; border-radius: 18px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  scroll-margin-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 130px);
}
.msg-body { display: flex; flex-direction: column; gap: 6px; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.msg-body ul, .msg-body ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 2px; }
.msg.user { align-self: flex-end; background: var(--accent-fill); color: var(--accent-fill-ink); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--card)); }
.msg.thinking { padding: 14px 16px; }
.dots { display: inline-flex; gap: 5px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: 0.7; } }
/* ---- Evra account and members ---- */
.account-panel { display: flex; flex-direction: column; gap: 12px; }
.account-who, .member-top { display: flex; align-items: center; gap: 12px; }
.account-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; color: var(--accent-fill-ink); background: var(--accent-fill);
}
.account-text, .member-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.member-text strong { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.account-pills .pill, .member-text .pill { display: inline-flex; align-items: center; gap: 5px; }
.pill.ok-pill { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.account-form { max-width: 420px; }
.account-form .error-line:empty, .member-add .error-line:empty { display: none; }
.member-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
.member {
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px;
}
.member.off { border-style: dashed; box-shadow: none; }
.member-top .select { width: auto; flex: none; }
.member-switches { display: flex; flex-direction: column; gap: 8px; }
.member-switch { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.member-reset[hidden] { display: none; }
.member-add-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.chat-locked .card { display: flex; flex-direction: column; gap: 10px; }

/* A change the assistant prepared: nothing happens until Approve. */
.proposals { display: flex; flex-direction: column; gap: 8px; align-self: stretch; }
.proposal {
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 14px;
  background: var(--card-2); border: 1px solid var(--line-strong);
}
.proposal.danger { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.proposal-head { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.proposal-icon {
  width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center;
  color: color-mix(in srgb, var(--accent) var(--ink-mix), var(--text)); background: color-mix(in srgb, var(--accent) var(--bubble), var(--card));
}
.proposal.danger .proposal-icon { color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, var(--card)); }
.proposal-details { margin: 0; padding-left: 20px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.proposal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.proposal-actions:empty { display: none; }
.proposal-result { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; color: var(--muted); margin: 0; }
.proposal-result:empty { display: none; }
.proposal-result:focus { outline: none; }
.proposal[data-status="done"] .proposal-result, .proposal[data-status="review"] .proposal-result { color: var(--ok); }
.proposal[data-status="failed"] .proposal-result { color: var(--danger); }
/* Finished cards step back with a plainer background, not opacity, so their text stays readable. */
.proposal[data-status="done"], .proposal[data-status="cancelled"], .proposal[data-status="review"], .proposal[data-status="failed"] { background: transparent; border-style: dashed; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-suggest[hidden] { display: none; }
.chat-suggest .room-chip { white-space: normal; text-align: left; }
/* The message box stays above the bottom navigation while the conversation scrolls. */
.chat-dock {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 5;
  display: flex; flex-direction: column; gap: 6px; padding: 10px 0 0;
  background: linear-gradient(to bottom, transparent, var(--bg) 14px);
}
@media (min-width: 900px) { .chat-dock { bottom: 12px; } }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 6px; border-radius: 18px; background: var(--card); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.chat-form:focus-within { border-color: var(--accent); }
.chat-input {
  flex: 1; min-width: 0; resize: none; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.4; padding: 9px 10px; max-height: 160px;
}
.chat-input:focus { outline: none; }
.chat-input::placeholder { color: var(--muted); }
.chat-send { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 14px; flex: none; }
.chat-send:disabled { opacity: 0.5; }
.chat-note { text-align: center; margin: 0 8px; }
.shortcut-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.shortcut {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow);
  text-decoration: none; color: var(--text); font-weight: 650;
}
.shortcut > .icon:first-child { color: var(--accent); }
.shortcut span { flex: 1; }
.shortcut > .icon:last-child { color: var(--muted); }

/* =========================================================================
   App feel: a contained layout, a header that settles as you scroll, and
   motion that answers every tap (turned off by prefers-reduced-motion below).
   ========================================================================= */
:root { --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1); --spring: cubic-bezier(0.3, 1.5, 0.5, 1); }
html { overscroll-behavior-y: none; }
body { overscroll-behavior-y: none; }
button, a, .nav-item, .room-chip { touch-action: manipulation; }
.nav, .btn, .theme-btn, .quick-btn, .room-chip, .segmented, .status-pill, .top-title { -webkit-user-select: none; user-select: none; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* The header settles into an app bar once the page moves. */
.top { transition: padding 0.25s var(--ease-out), box-shadow 0.25s, background 0.25s; }
.top-title { transition: font-size 0.25s var(--ease-out); }
.scrolled .top { padding-top: calc(env(safe-area-inset-top) + 10px); padding-bottom: 10px; box-shadow: 0 1px 0 var(--line), 0 10px 28px -20px rgb(0 0 0 / 0.55); }
.scrolled .top-title { font-size: 19px; }

/* Wide screens: content in one centred column, with the header lined up on it. */
@media (min-width: 900px) {
  .view > * { margin-inline: auto; }
  .top {
    padding-left: calc(124px + max(0px, (100% - 152px - 1180px) / 2));
    padding-right: calc(28px + max(0px, (100% - 152px - 1180px) / 2));
  }
  .scrolled .top { padding-top: 12px; padding-bottom: 10px; }
}

/* Changing tab: the new screen slides in from the side of the tab you went to,
   its parts arriving one after another. */
.view.view-enter > * { animation: view-in 0.42s var(--ease-out) backwards; }
.view.view-enter > :nth-child(2) { animation-delay: 0.04s; }
.view.view-enter > :nth-child(3) { animation-delay: 0.08s; }
.view.view-enter > :nth-child(4) { animation-delay: 0.12s; }
.view.view-enter > :nth-child(5) { animation-delay: 0.16s; }
.view.view-enter > :nth-child(n+6) { animation-delay: 0.2s; }
@keyframes view-in { from { opacity: 0; transform: translate3d(var(--enter-x, 0px), 12px, 0); } }

/* Buttons press in and spring back; on a mouse they lift a little. */
:is(.btn, .theme-btn, .room-chip, .quick-btn, .status-pill, .segmented button, .chat-send) {
  transition: transform 0.22s var(--spring), background-color 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
}
:is(.btn, .theme-btn, .room-chip, .status-pill, .chat-send):active { transform: scale(0.95); transition-duration: 0.08s; }
.segmented button:active { transform: scale(0.94); }
@media (hover: hover) {
  .btn:hover, .quick-btn:hover, .room-chip:hover { transform: translateY(-1px); }
  .btn.primary:hover { box-shadow: 0 8px 20px -10px var(--accent-fill); }
  .theme-btn:hover { transform: rotate(-8deg) scale(1.06); }
}
.card { transition: border-color 0.2s, box-shadow 0.25s, transform 0.25s var(--ease-out); }

/* Tabs: the active one pops; a press squeezes the icon. */
.nav-item { transition: color 0.2s; }
.nav-icon { transition: background 0.25s, color 0.25s, transform 0.25s var(--spring); }
.nav-item:active .nav-icon { transform: scale(0.88); }
.nav-item.active .nav-icon { animation: nav-pop 0.42s var(--spring); }
@keyframes nav-pop { 0% { transform: scale(0.82); } 100% { transform: scale(1); } }
@media (hover: hover) { .nav-item:not(.active):hover .nav-icon { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); } }

/* Switches and messages come in softly. */
.msg { animation: msg-in 0.32s var(--ease-out) backwards; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.proposal { animation: msg-in 0.36s var(--ease-out) 0.06s backwards; }

/* ---- the welcome screen (views/auth-gate.js) ---- */
.app.gated, #app.gated { min-height: 100dvh; display: grid; place-items: center; padding: calc(env(safe-area-inset-top) + 24px) 16px 24px; }
.gate { width: 100%; max-width: 430px; animation: gate-in 0.55s var(--ease-out) backwards; }
@keyframes gate-in { from { opacity: 0; transform: translateY(18px) scale(0.98); } }
.gate-card {
  background: color-mix(in srgb, var(--card) 92%, transparent); border: 1px solid var(--line); border-radius: 26px;
  padding: 30px 24px 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.gate-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.gate-logo {
  width: 68px; height: 68px; border-radius: 22px; display: grid; place-items: center; margin-bottom: 6px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent);
  animation: logo-pop 0.7s var(--spring) 0.12s backwards;
}
@keyframes logo-pop { from { opacity: 0; transform: scale(0.6) rotate(-12deg); } }
.gate-brand h1 { font-size: 25px; }
.gate-tabs { display: flex; align-self: stretch; }
.gate-tabs button { flex: 1; }
.gate-body.gate-swap { animation: view-in 0.32s var(--ease-out) backwards; }
.gate-body .account-form .btn.primary, .gate-body .btn-row .btn.primary { flex: 1; justify-content: center; }
.gate-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; }
.gate-steps li strong { display: block; }
.gate-steps li span { color: var(--muted); font-size: 13px; }
.gate-note { text-align: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 650; text-decoration: underline; }

.booting *, .booting *::after { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::after { animation: none !important; transition: none !important; }
}

/* =========================================================================
   Customization (js/custom.js, js/views/customize.js)
   ========================================================================= */
/* Tiles that are on keep a plain background when "Colour tiles" is off. */
.no-glow .device.is-on, .no-glow .light-card.is-on { background: var(--card); border-color: var(--line); box-shadow: var(--shadow); }

/* Tiles per row and wide tiles, from tablets up; phones show one column. */
@media (min-width: 700px) {
  :root[data-cols] .grid.devices { grid-template-columns: repeat(var(--tile-cols), minmax(0, 1fr)); }
  .grid.devices > .tile-wide { grid-column: span 2; }
  :root[data-cols="1"] .grid.devices > .tile-wide { grid-column: auto; }
}
@media (min-width: 1100px) {
  .home-top.quick-first { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
}

/* Quick action buttons with just an icon and a name. */
.quick-compact .quick-row { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
.quick-compact .quick-btn { flex-direction: column; align-items: center; gap: 8px; padding: 12px 6px; text-align: center; }
.quick-compact .quick-text small { display: none; }
.quick-compact .quick-text strong { font-size: 13px; }

/* ---- the panel ---------------------------------------------------------- */
.cz-backdrop { position: fixed; inset: 0; z-index: 60; background: rgb(0 0 0 / 0.38); opacity: 0; transition: opacity 0.25s; }
.cz-backdrop.show { opacity: 1; }
.cz-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(440px, 100%);
  display: flex; flex-direction: column; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 16px) 16px 0;
  background: var(--bg); color: var(--text);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 60px -30px rgb(0 0 0 / 0.55);
  transform: translateX(102%); transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.cz-panel.show { transform: none; }
.cz-head { display: flex; align-items: center; gap: 12px; }
.cz-head h2 { flex: 1; font-size: 20px; }
.cz-tabs { display: flex; }
.cz-tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.cz-body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 12px;
  margin: 0 -16px; padding: 2px 16px calc(env(safe-area-inset-bottom) + 24px);
}
.cz-group {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-radius: var(--radius-md);
  background: var(--card); border: 1px solid var(--line);
}
.cz-title { font-size: 15px; }
.cz-seg { display: flex; }
.cz-seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 6px; }
.cz-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cz-sub { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.cz-sub small { font-size: 12px; }
.cz-foot { justify-content: flex-end; }

.cz-palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
.cz-palette {
  display: flex; flex-direction: column; gap: 6px; padding: 5px;
  border-radius: var(--radius-sm); border: 2px solid transparent; background: var(--card-2); text-align: left;
}
.cz-palette:hover { border-color: var(--line-strong); }
.cz-palette.active { border-color: var(--accent); }
.cz-preview { display: block; height: 54px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }
.cz-preview-card { display: flex; align-items: center; gap: 5px; height: 100%; padding: 0 8px; border-radius: 7px; }
.cz-preview-card i { display: block; width: 13px; height: 13px; border-radius: 50%; }
.cz-palette-name { display: inline-flex; align-items: center; gap: 4px; padding: 0 3px 2px; font-size: 13px; font-weight: 650; }
.cz-palette.active .cz-palette-name { color: var(--accent); }

.cz-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.cz-swatch {
  position: relative; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--sw); color: #10162A; font-size: 13px; font-weight: 750;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.14);
}
.cz-swatch.active { outline: 2px solid var(--text); outline-offset: 3px; }
.cz-swatch.any { background: conic-gradient(#F27D89, #E9BE7C, #9CCB9A, #7FCBD6, #9AAFDD, #B9A6E8, #F27D89); }
.cz-swatch.any[style] { background: var(--sw); }
.cz-swatch.any input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.cz-swatch.any:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }

.cz-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cz-item { display: flex; align-items: center; gap: 6px; padding: 5px 5px 5px 2px; border-radius: 12px; background: var(--card-2); }
.cz-item.off .cz-item-icon, .cz-item.off .cz-item-label { opacity: 0.5; }
.cz-item.dragging { position: relative; z-index: 2; background: var(--card-3); box-shadow: 0 10px 24px -10px rgb(0 0 0 / 0.5); }
.cz-item-icon { display: grid; color: var(--accent); }
.cz-item-label { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; font-weight: 600; }
.cz-item-label small { color: var(--muted); font-size: 11px; font-weight: 500; }
.cz-mini {
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 9px; flex: none;
  display: grid; place-items: center; background: transparent; color: var(--muted);
}
.cz-mini:hover:not(:disabled) { background: var(--card-3); color: var(--text); }
.cz-mini[aria-pressed="true"] { color: var(--accent); }
.cz-mini.locked { opacity: 0.45; }
.cz-grip, .tile-grip { display: grid; place-items: center; width: 30px; height: 34px; flex: none; color: var(--muted); cursor: grab; touch-action: none; }
.sorting, .sorting * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }

/* ---- device tiles while editing ------------------------------------------------ */
.grid.arranging .device { position: relative; outline: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: -2px; }
.grid.arranging .device.dragging { z-index: 5; outline-style: solid; box-shadow: 0 22px 44px -20px rgb(0 0 0 / 0.6); }
.device.tile-hidden > :not(.tile-tools) { opacity: 0.35; filter: grayscale(1); }
.tile-tools {
  display: flex; align-items: center; gap: 2px; padding: 3px;
  margin: -6px -6px 0; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--line);
}
.tile-tools .tile-grip { width: auto; gap: 4px; padding: 0 8px 0 4px; display: inline-flex; align-items: center; font-size: 12px; font-weight: 650; }
.tile-tool { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 9px; display: grid; place-items: center; background: transparent; color: var(--muted); }
.tile-tool:hover { background: var(--card-2); color: var(--text); }
.tile-tool[aria-pressed="true"] { color: var(--accent); }

/* ---- editing the layout on the screen (js/edit.js) --------------------------- */
.edit-btn { width: auto; min-width: 34px; padding: 0 9px; gap: 6px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 13px; font-weight: 700; }
.edit-btn[aria-pressed="true"] { background: var(--accent-fill); color: var(--accent-fill-ink); border-color: transparent; }
.edit-bar {
  position: fixed; z-index: 35; left: 12px; right: 12px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px);
  display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--card) 96%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 16px 40px -18px rgb(0 0 0 / 0.55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
@media (min-width: 900px) { .edit-bar { left: 124px; right: 28px; bottom: 16px; max-width: 1180px; } }
.edit-bar-text { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; }
.edit-bar-text small { color: var(--muted); font-size: 12px; }
.editing .view { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 200px); }

/* Anything that can move gets a dashed outline; small things wobble a little
   and are dragged by themselves, big things by their handle. */
.edit-item { position: relative; }
.editing .edit-item { outline: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.edit-whole { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; animation: edit-wobble 1.6s ease-in-out infinite; }
.edit-whole:nth-child(even) { animation-delay: -0.8s; }
.edit-item.dragging { animation: none; z-index: 6; outline-style: solid; box-shadow: 0 16px 36px -14px rgb(0 0 0 / 0.55); }
@keyframes edit-wobble { 0%, 100% { rotate: -0.6deg; } 50% { rotate: 0.6deg; } }
.edit-hidden { opacity: 0.42; }
.edit-hidden:hover, .edit-hidden:focus-within { opacity: 0.75; }

.edit-tools {
  position: absolute; top: 6px; right: 6px; z-index: 4;
  display: inline-flex; align-items: center; gap: 2px; padding: 2px;
  border-radius: 999px; background: var(--card); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  font-size: 12px; line-height: 1; rotate: 0deg;
}
.edit-tools.mini { top: -11px; right: -9px; padding: 0; }
.edit-grip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px 5px 6px; color: var(--muted); font-weight: 650; cursor: grab; touch-action: none; }
.edit-eye { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; color: var(--accent); cursor: pointer; }
.edit-tools.mini .edit-eye { width: 22px; height: 22px; }
.edit-hidden .edit-eye { color: var(--muted); }

/* Room for the handles. */
.editing .home-block { padding: 40px 8px 10px; border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.editing .home-block > .edit-tools { top: 8px; right: 8px; }
.editing .room-chips { padding-top: 13px; padding-right: 12px; }
.editing .hero-chips, .editing .hero-stats { padding-top: 4px; }
.editing .scene.edit-item { padding-top: 46px; }
.editing .nav-item.edit-item { outline-offset: -2px; border-radius: 14px; }
.editing .top-left, .editing .top-right { padding-top: 8px; }
.hero-badge-box { display: inline-flex; }

/* ---- layout options ------------------------------------------------------------ */
/* Compact and small tiles: just the name, state and switch. */
.tiles-compact .grid.devices .device > :not(.device-head):not(.tile-tools),
.grid.devices .device.tile-small > :not(.device-head):not(.tile-tools) { display: none; }
.tiles-compact .grid.devices { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.nav-icons-only .nav-label { display: none; }
.phone-all-tabs .nav-item.wide-only { display: flex; }
@media (min-width: 900px) { .page-full .view > * { max-width: none; } }
.no-section-titles .section-title, .no-section-titles .room-section > .section-row { display: none; }
.cz-chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* A moving theme's preview turns slowly. */
.cz-preview { position: relative; overflow: hidden; }
.cz-preview-card { position: relative; z-index: 1; }
.cz-preview-glow { position: absolute; inset: -60%; background: conic-gradient(from 0deg, var(--m1), var(--m2), var(--m3), var(--m1)); filter: blur(14px); opacity: 0.55; animation: spin 9s linear infinite; }

/* =========================================================================
   Moving backgrounds (js/sky.js). <html data-sky> picks the kind; "night" is
   the Evra website's night background. --m1..--m3 are the theme's colours,
   --sky-op the strength, --sky-slow stretches every animation.
   ========================================================================= */
.sky { display: none; position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
:root[data-sky] { background: var(--bg); }
:root[data-sky] body { background: transparent; }
:root[data-sky] .sky { display: block; }
:root[data-sky-motion="calm"] { --sky-slow: 1.8; }
:root[data-sky-motion="still"] .sky * { animation-play-state: paused !important; }
.sky > * { display: none; position: absolute; }
/* data-sky lists the effects in use; each shows its own layer. */
:root[data-sky~="glow"] .sky-glow,
:root[data-sky~="aurora"] .sky-aurora,
:root[data-sky~="stars"] .sky-stars,
:root[data-sky~="lines"] .sky-lines,
:root[data-sky~="orbs"] .sky-orbs,
:root[data-sky~="waves"] .sky-waves,
:root[data-sky~="draw"] .sky-draw,
:root[data-sky~="beams"] .sky-beams,
:root[data-sky~="snow"] .sky-snow,
:root[data-sky~="embers"] .sky-embers,
:root[data-sky~="fireflies"] .sky-fireflies,
:root[data-sky~="flow"] .sky-flow,
:root[data-sky~="mountains"] .sky-mountains { display: block; }

.sky-glow { inset: 0; background: radial-gradient(120% 70% at 50% -10%, color-mix(in srgb, var(--m2) 22%, transparent) 0%, transparent 60%); opacity: var(--sky-op); }

/* Northern lights */
.sky-aurora { inset: -10% -20% auto; height: 75vh; opacity: var(--sky-op); }
.sky-aurora span {
  position: absolute; top: 0; height: 100%; border-radius: 50%; filter: blur(48px); mix-blend-mode: screen; opacity: 0.5; transform-origin: 50% 0;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 25%, #000 55%, transparent); mask-image: linear-gradient(180deg, transparent, #000 25%, #000 55%, transparent);
}
.sky-aurora span:nth-child(1) { left: 0%; width: 55%; background: linear-gradient(100deg, transparent 10%, var(--m1) 35%, var(--m3) 60%, transparent 90%); animation: sky-aurora-a calc(22s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
.sky-aurora span:nth-child(2) { left: 30%; width: 50%; background: linear-gradient(80deg, transparent 10%, var(--m2) 40%, color-mix(in srgb, var(--m2) 50%, #2d6bff) 65%, transparent 90%); opacity: 0.42; animation: sky-aurora-b calc(27s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
.sky-aurora span:nth-child(3) { left: 58%; width: 48%; background: linear-gradient(95deg, transparent 10%, var(--m3) 40%, var(--m1) 60%, transparent 90%); opacity: 0.37; animation: sky-aurora-c calc(31s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
:root[data-sky-tone="light"] .sky-aurora span { mix-blend-mode: normal; opacity: 0.22; }
@keyframes sky-aurora-a { 0% { transform: translateX(-6%) skewX(-12deg) scaleY(0.9); } 50% { transform: translateX(4%) skewX(8deg) scaleY(1.1); } 100% { transform: translateX(10%) skewX(-4deg) scaleY(0.95); } }
@keyframes sky-aurora-b { 0% { transform: translateX(6%) skewX(10deg) scaleY(1); } 50% { transform: translateX(-8%) skewX(-10deg) scaleY(1.2); } 100% { transform: translateX(2%) skewX(6deg) scaleY(0.9); } }
@keyframes sky-aurora-c { 0% { transform: translateX(-4%) skewX(-8deg) scaleY(1.05); } 100% { transform: translateX(-14%) skewX(12deg) scaleY(0.85); } }

/* Stars */
.sky-stars {
  inset: 0; opacity: calc(0.55 * var(--sky-op));
  background-image: radial-gradient(1.2px 1.2px at 12% 18%, var(--star), transparent), radial-gradient(1px 1px at 28% 62%, var(--star), transparent), radial-gradient(1.4px 1.4px at 47% 32%, var(--star), transparent), radial-gradient(1px 1px at 63% 78%, var(--star), transparent), radial-gradient(1.2px 1.2px at 78% 22%, var(--star), transparent), radial-gradient(1px 1px at 88% 58%, var(--star), transparent), radial-gradient(1px 1px at 36% 88%, var(--star), transparent), radial-gradient(1.3px 1.3px at 6% 74%, var(--star), transparent);
  background-size: 900px 700px;
  animation: sky-twinkle calc(6s * var(--sky-slow, 1)) ease-in-out infinite alternate;
}
@keyframes sky-twinkle { to { opacity: calc(0.25 * var(--sky-op)); } }

/* Lines of light that run across and fade out */
.sky-lines { inset: 0; width: 100%; height: 100%; opacity: var(--sky-op); }
.sky-lines path {
  fill: none; stroke: #f5b544; color: #f5b544; stroke-width: 1.8; stroke-linecap: round;
  stroke-dasharray: 180 2600; stroke-dashoffset: 2780; opacity: 0; filter: drop-shadow(0 0 6px currentColor);
  animation: sky-comet calc(9s * var(--sky-slow, 1)) cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.sky-lines path:nth-child(even) { stroke: #6f98ff; color: #6f98ff; }
.sky-lines path:nth-child(3n) { stroke: #2fe0c0; color: #2fe0c0; }
.sky-lines path:nth-child(2) { animation-duration: calc(11s * var(--sky-slow, 1)); animation-delay: -2s; }
.sky-lines path:nth-child(3) { animation-duration: calc(10s * var(--sky-slow, 1)); animation-delay: -5s; }
.sky-lines path:nth-child(4) { animation-duration: calc(12s * var(--sky-slow, 1)); animation-delay: -7s; }
.sky-lines path:nth-child(5) { animation-duration: calc(9.5s * var(--sky-slow, 1)); animation-delay: -3.5s; }
.sky-lines path:nth-child(6) { animation-duration: calc(13s * var(--sky-slow, 1)); animation-delay: -9s; }
.sky-lines path:nth-child(7) { animation-duration: calc(10.5s * var(--sky-slow, 1)); animation-delay: -1s; }
.sky-lines path:nth-child(8) { animation-duration: calc(12.5s * var(--sky-slow, 1)); animation-delay: -6s; }
@keyframes sky-comet { 0% { stroke-dashoffset: 2780; opacity: 0; } 10% { opacity: 0.85; } 65% { opacity: 0.5; } 100% { stroke-dashoffset: 0; opacity: 0; } }

/* Glow: soft lights drifting */
.sky-orbs { inset: 0; opacity: var(--sky-op); }
:root[data-sky-tone="light"] .sky-orbs { opacity: calc(0.6 * var(--sky-op)); }
.sky-orbs span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.55; animation: sky-float calc(18s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
.sky-orbs span:nth-child(1) { width: 46vmax; height: 46vmax; right: -12vmax; top: -14vmax; background: var(--m1); }
.sky-orbs span:nth-child(2) { width: 38vmax; height: 38vmax; left: -14vmax; bottom: -16vmax; background: var(--m2); opacity: 0.4; animation-duration: calc(23s * var(--sky-slow, 1)); animation-delay: -7s; }
.sky-orbs span:nth-child(3) { width: 28vmax; height: 28vmax; left: 35vw; top: 30vh; background: var(--m3); opacity: 0.28; animation-duration: calc(27s * var(--sky-slow, 1)); animation-delay: -12s; }
@keyframes sky-float { 33% { transform: translate(-6vw, 5vh) scale(1.08); } 66% { transform: translate(4vw, -3vh) scale(0.94); } 100% { transform: translate(-3vw, 7vh) scale(1.12); } }

/* Waves rolling along the bottom */
.sky-waves { left: 0; right: 0; bottom: 0; height: 42vh; opacity: var(--sky-op); }
.sky-waves .wave { position: absolute; left: 0; bottom: 0; width: 200%; height: 100%; animation: sky-wave calc(40s * var(--sky-slow, 1)) linear infinite; }
.sky-waves .w1 path { fill: color-mix(in srgb, var(--m1) 26%, transparent); }
.sky-waves .w2 { height: 85%; animation-duration: calc(28s * var(--sky-slow, 1)); animation-direction: reverse; }
.sky-waves .w2 path { fill: color-mix(in srgb, var(--m3) 22%, transparent); }
.sky-waves .w3 { height: 68%; animation-duration: calc(20s * var(--sky-slow, 1)); }
.sky-waves .w3 path { fill: color-mix(in srgb, var(--m2) 20%, transparent); }
@keyframes sky-wave { to { transform: translateX(-50%); } }
/* Small readings keep their text clear of the eye. */
.editing .hero .edit-whole, .editing .top-left .edit-whole { padding-right: 16px; }
/* On phones the edit bar is one slim row. */
@media (max-width: 600px) {
  .edit-bar { padding: 8px 10px; gap: 8px; }
  .edit-bar > .card-icon, .edit-bar-text small { display: none; }
  .edit-bar-text { flex: 1 1 auto; font-size: 14px; }
  .edit-bar .btn-row { flex-wrap: nowrap; gap: 6px; }
  .edit-bar .btn { padding: 8px 10px; font-size: 13px; }
  .edit-bar .btn.ghost .icon { display: none; }
}

/* =========================================================================
   One customize button (a colourful palette), half-width sections,
   dragging big things, and the Buttons options
   ========================================================================= */
.custom-btn, .custom-btn:hover {
  background: linear-gradient(135deg, #ffcf6e, #f472b6 55%, #8b5cf6); color: #1b1030; border-color: transparent;
  box-shadow: 0 4px 14px -4px rgb(244 114 182 / 0.65);
}
.custom-btn:hover { filter: brightness(1.08); }
.custom-btn-icon { display: grid; place-items: center; }
.custom-btn[aria-pressed="true"] { width: auto; padding: 0 12px 0 9px; gap: 6px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 13px; font-weight: 750; }
.card-icon.custom-btn-icon { background: linear-gradient(135deg, #ffcf6e, #f472b6 55%, #8b5cf6); color: #1b1030; }

/* Home's sections: one column, or two half-width ones side by side on big screens. */
.home-blocks { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); align-items: stretch; }
.home-block { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.home-block > .hero-slot { flex: 1; display: flex; flex-direction: column; }
.home-block > .hero-slot > .hero { flex: 1; }
.home-block > .quick { flex: 1; }
@media (min-width: 1100px) {
  .home-blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-blocks > .home-block { grid-column: 1 / -1; }
  .home-blocks > .home-block.half { grid-column: auto; }
  .home-block.half .quick-row { grid-template-columns: 1fr 1fr; flex: 1; }
  .home-block.half > .quick { display: flex; flex-direction: column; }
}

/* Big things are dragged anywhere on them while customizing. */
.edit-big, .grid.arranging .device { cursor: grab; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.edit-big.dragging, .grid.arranging .device.dragging { cursor: grabbing; }
.edit-flag { color: var(--muted); }
.edit-flag[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.editing .edit-zone { -webkit-touch-callout: none; }

/* ---- Buttons: shape ---- */
.btn-pill :is(.btn, .quick-btn, .icon-btn, .segmented, .segmented button, .ir-btn, .chip, .room-chip, .theme-btn, .tile-tool, .cz-icon) { border-radius: 999px; }
.btn-square :is(.btn, .quick-btn, .icon-btn, .segmented, .segmented button, .ir-btn, .ir-btn.round, .chip, .room-chip, .theme-btn, .status-pill, .quick-icon, .switch, .cz-swatch, .tile-tool, .cz-icon, .badge) { border-radius: 5px; }
.btn-square .switch .knob { border-radius: 3px; }
/* ---- Buttons: main button style ---- */
.btn-soft .btn.primary { background: color-mix(in srgb, var(--accent-fill) 24%, var(--card)); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.btn-outline .btn.primary { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-outline .btn:not(.primary):not(.danger) { background: transparent; }
/* ---- Buttons: size ---- */
.btn-small .btn { padding: 7px 11px; font-size: 13px; }
.btn-small .quick-btn { padding: 10px; gap: 9px; }
.btn-small .quick-icon { width: 34px; height: 34px; }
.btn-small .room-chip { padding: 7px 11px; font-size: 13px; }
.btn-large .btn { padding: 13px 18px; font-size: 16px; }
.btn-large .quick-btn { padding: 18px; gap: 14px; }
.btn-large .quick-icon { width: 52px; height: 52px; }
.btn-large .quick-text strong { font-size: 17px; }
.btn-large .room-chip { padding: 12px 18px; font-size: 15px; }
.btn-large .ir-btn { min-height: 54px; }
.btn-large .ir-btn.round { width: 54px; height: 54px; }
/* ---- Buttons: quick action look ---- */
.qb-tinted .quick-btn { background: color-mix(in srgb, var(--tone) 18%, var(--card)); border-color: color-mix(in srgb, var(--tone) 32%, transparent); }
.qb-outline .quick-btn { background: transparent; border: 1.5px solid color-mix(in srgb, var(--tone) 65%, transparent); box-shadow: none; }
.qb-solid .quick-btn { background: var(--tone); border-color: transparent; color: var(--tone-ink); }
.qb-solid .quick-text small { color: color-mix(in srgb, var(--tone-ink) 72%, transparent); }
.qb-solid .quick-icon { background: rgb(255 255 255 / 0.35); color: var(--tone-ink); }
/* ---- Buttons: icons ---- */
.qi-circle .quick-icon { border-radius: 50%; }
.qi-plain .quick-icon { background: transparent; width: auto; min-width: 26px; }
/* ---- Buttons: depth ---- */
:root.depth-flat { --shadow: none; }
:root.depth-raised { --shadow: 0 2px 4px rgb(0 0 0 / 0.16), 0 14px 30px -12px rgb(0 0 0 / 0.38); }
.depth-glow :is(.quick-btn, .btn.primary) { box-shadow: 0 0 0 1px color-mix(in srgb, var(--tone, var(--accent)) 30%, transparent), 0 10px 30px -8px color-mix(in srgb, var(--tone, var(--accent)) 70%, transparent); }
.depth-glow .card { box-shadow: 0 12px 34px -18px color-mix(in srgb, var(--accent) 60%, transparent); }
/* ---- Buttons: when pressed ---- */
.press-none :is(.btn, .quick-btn, .ir-btn, .room-chip):active { transform: none; }
.press-bouncy :is(.btn, .quick-btn, .room-chip, .ir-btn, .theme-btn) { transition: transform 0.28s cubic-bezier(0.3, 1.8, 0.5, 1), background 0.2s, border-color 0.2s; }
.press-bouncy :is(.btn, .quick-btn):hover { transform: translateY(-2px); }
.press-bouncy :is(.btn, .quick-btn, .room-chip, .ir-btn, .theme-btn):active { transform: scale(0.9); }

/* ---- the panel's Buttons tab ---- */
.cz-tabs button { padding: 8px 6px; }
.cz-chip-sep { flex-basis: 100%; height: 0; }
.room-chip.effect { gap: 5px; }
.cz-btn-preview { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; pointer-events: none; }
.cz-btn-preview .quick-btn { min-width: 150px; }
.cz-quick { padding: 8px 10px; border-radius: 12px; background: var(--card-2); }
.cz-quick > * + * { margin-top: 10px; }
.cz-quick summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
.cz-quick summary::-webkit-details-marker { display: none; }
.cz-quick summary small { margin-left: auto; font-size: 12px; text-align: right; }
.cz-quick summary .quick-icon { width: 34px; height: 34px; border-radius: 10px; }
.cz-quick .quick-icon { display: grid; place-items: center; color: color-mix(in srgb, var(--tone) var(--ink-mix), var(--text)); background: color-mix(in srgb, var(--tone) var(--bubble), transparent); }
.cz-swatches.small .cz-swatch { width: 30px; height: 30px; }
.cz-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.cz-icon { height: 38px; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); display: grid; place-items: center; }
.cz-icon.active { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card)); }

/* =========================================================================
   More background effects
   ========================================================================= */

/* Gold and blue lines that draw themselves (the website's showcase). */
.sky-draw { inset: 0; width: 100%; height: 100%; opacity: var(--sky-op); }
.sky-draw path { fill: none; stroke: #f5b544; stroke-width: 1.6; opacity: 0.45; filter: drop-shadow(0 0 6px #f5b544); stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: sky-draw calc(9s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
.sky-draw path:nth-child(2) { stroke: #5b8cff; filter: drop-shadow(0 0 6px #5b8cff); animation-delay: -3s; }
.sky-draw path:nth-child(3) { stroke: var(--m1); filter: drop-shadow(0 0 6px var(--m1)); opacity: 0.3; animation-delay: -6s; }
@keyframes sky-draw { from { stroke-dashoffset: 1400; } to { stroke-dashoffset: 0; } }

/* Connections: dashes flowing along lines between glowing points. */
.sky-beams { inset: 0; width: 100%; height: 100%; opacity: var(--sky-op); }
.sky-beams path { fill: none; stroke: var(--m1); stroke-width: 1.6; stroke-dasharray: 8 10; opacity: 0.45; animation: sky-flow-dash calc(1.4s * var(--sky-slow, 1)) linear infinite; }
.sky-beams path:nth-child(even) { stroke: var(--m2); animation-direction: reverse; }
.sky-beams circle { fill: var(--m3); transform-box: fill-box; transform-origin: center; filter: drop-shadow(0 0 6px var(--m3)); animation: sky-breathe calc(3.2s * var(--sky-slow, 1)) ease-in-out infinite; }
.sky-beams circle:nth-of-type(odd) { animation-delay: -1.6s; }
@keyframes sky-flow-dash { to { stroke-dashoffset: -18; } }
@keyframes sky-breathe { 50% { opacity: 0.25; transform: scale(0.6); } }

/* Snow falling. */
.sky-snow { inset: 0; opacity: var(--sky-op); }
.sky-snow span { position: absolute; top: -3vh; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%; background: var(--star); opacity: var(--o); animation: sky-fall calc(var(--d) * var(--sky-slow, 1)) linear infinite; animation-delay: var(--delay); }
@keyframes sky-fall { to { transform: translate(var(--sway), 106vh); } }

/* Embers rising and fading. */
.sky-embers { inset: 0; opacity: var(--sky-op); }
.sky-embers span { position: absolute; bottom: -3vh; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%; background: var(--c); box-shadow: 0 0 8px 2px var(--c); opacity: 0; animation: sky-rise calc(var(--d) * var(--sky-slow, 1)) ease-in infinite; animation-delay: var(--delay); }
@keyframes sky-rise { 0% { transform: translate(0, 0) scale(1); opacity: 0; } 10% { opacity: 0.95; } 70% { opacity: 0.6; } 100% { transform: translate(var(--sway), -78vh) scale(0.3); opacity: 0; } }

/* Fireflies drifting and blinking. */
@keyframes sky-firefly { to { transform: translate(var(--dx), var(--dy)); } }
@keyframes sky-blink { 0%, 100% { opacity: 0.1; } 50% { opacity: 0.95; } }

/* Colour flow: a huge soft wheel of the theme's colours turning slowly. */
.sky-flow { inset: -30%; background: conic-gradient(from 0deg at 50% 50%, var(--m1), var(--m2), var(--m3), var(--m1)); filter: blur(90px); opacity: calc(0.35 * var(--sky-op)); animation: spin calc(60s * var(--sky-slow, 1)) linear infinite; }
:root[data-sky-tone="light"] .sky-flow { opacity: calc(0.22 * var(--sky-op)); }

/* ---- more effects: fireplace, galaxy, retro, Istanbul, moon, seagulls, sunset glow ---- */
:root[data-sky~="fire"] .sky-fire,
:root[data-sky~="galaxy"] .sky-galaxy,
:root[data-sky~="retro"] .sky-retro,
:root[data-sky~="istanbul"] .sky-istanbul,
:root[data-sky~="moon"] .sky-moon,
:root[data-sky~="gulls"] .sky-gulls,
:root[data-sky~="dusk"] .sky-dusk { display: block; }

/* Sunset glow rising from the bottom */
.sky-dusk { left: 0; right: 0; bottom: 0; height: 75vh; opacity: var(--sky-op); background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--m2) 26%, transparent) 50%, color-mix(in srgb, var(--m1) 42%, transparent)); }

/* Moon */
.sky-moon {
  right: 12vw; top: 9vh; width: 9vmin; height: 9vmin; min-width: 46px; min-height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 36% 34%, #fffdf2, #f1e7c9 62%, #d8cca8);
  box-shadow: 0 0 40px 10px rgb(255 240 200 / 0.32), 0 0 140px 50px rgb(255 240 200 / 0.1);
  animation: sky-moon calc(7s * var(--sky-slow, 1)) ease-in-out infinite alternate;
}
@keyframes sky-moon { to { box-shadow: 0 0 52px 16px rgb(255 240 200 / 0.42), 0 0 160px 60px rgb(255 240 200 / 0.14); } }

/* Galaxy: a tilted spiral disc turning very slowly */
.sky-galaxy { left: 62%; top: 34%; width: 110vmax; height: 110vmax; margin: -55vmax 0 0 -55vmax; transform: rotate(-22deg) scaleY(0.42); opacity: var(--sky-op); }
.sky-galaxy span { position: absolute; inset: 0; border-radius: 50%; -webkit-mask-image: radial-gradient(circle, #000 0, #000 12%, transparent 58%); mask-image: radial-gradient(circle, #000 0, #000 12%, transparent 58%); }
.sky-galaxy span:nth-child(1) {
  background:
    radial-gradient(circle, rgb(255 255 255 / 0.95) 0, color-mix(in srgb, var(--m3) 70%, #fff) 2.5%, color-mix(in srgb, var(--m1) 70%, transparent) 8%, transparent 22%),
    conic-gradient(from 0deg, transparent 0deg, color-mix(in srgb, var(--m1) 75%, transparent) 40deg, transparent 100deg, color-mix(in srgb, var(--m2) 65%, transparent) 170deg, transparent 230deg, color-mix(in srgb, var(--m3) 65%, transparent) 290deg, transparent 350deg);
  filter: blur(16px); animation: spin calc(150s * var(--sky-slow, 1)) linear infinite;
}
.sky-galaxy span:nth-child(2) {
  background: repeating-conic-gradient(from 10deg, transparent 0deg 14deg, rgb(255 255 255 / 0.35) 20deg, transparent 28deg);
  filter: blur(6px); opacity: 0.5; animation: spin calc(220s * var(--sky-slow, 1)) linear infinite reverse;
}
:root[data-sky-tone="light"] .sky-galaxy { opacity: calc(0.6 * var(--sky-op)); }

/* Retro: striped sun on the horizon and a neon grid rolling towards you */
.sky-retro { left: 0; right: 0; bottom: 0; height: 58vh; overflow: hidden; background: radial-gradient(60% 45% at 50% 62%, color-mix(in srgb, var(--m1) 30%, transparent), transparent 70%); opacity: calc(0.4 + 0.6 * var(--sky-op)); }
.retro-sun {
  position: absolute; left: 50%; bottom: 40%; width: 28vmin; height: 28vmin; margin-left: -14vmin; border-radius: 50%;
  background: linear-gradient(180deg, var(--m3) 5%, color-mix(in srgb, var(--m3) 40%, var(--m1)) 45%, var(--m1) 80%);
  -webkit-mask: linear-gradient(#000 0 0) top / 100% 52% no-repeat, repeating-linear-gradient(180deg, #000 0 9px, transparent 9px 14px);
  mask: linear-gradient(#000 0 0) top / 100% 52% no-repeat, repeating-linear-gradient(180deg, #000 0 9px, transparent 9px 14px);
  animation: retro-sun calc(6s * var(--sky-slow, 1)) ease-in-out infinite alternate;
}
@keyframes retro-sun { to { transform: translateY(8px); filter: brightness(1.15); } }
.retro-horizon { position: absolute; left: 0; right: 0; bottom: 40%; height: 2px; background: color-mix(in srgb, var(--m1) 80%, #fff); box-shadow: 0 0 18px 4px color-mix(in srgb, var(--m1) 70%, transparent); }
.retro-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 40%; overflow: hidden; perspective: 260px; perspective-origin: 50% 0; background: linear-gradient(180deg, color-mix(in srgb, var(--m1) 16%, transparent), color-mix(in srgb, var(--bg) 50%, transparent)); }
.retro-plane {
  position: absolute; left: -150%; right: -150%; top: 0; height: 400%; transform-origin: 50% 0; transform: rotateX(80deg);
  background-image: linear-gradient(color-mix(in srgb, var(--m2) 85%, transparent) 2px, transparent 2px), linear-gradient(90deg, color-mix(in srgb, var(--m2) 85%, transparent) 2px, transparent 2px);
  background-size: 36px 36px; animation: retro-roll calc(1.2s * var(--sky-slow, 1)) linear infinite;
}
@keyframes retro-roll { to { background-position: 0 36px; } }

@keyframes sky-flicker {
  0% { transform: scale(1, 1) skewX(0deg); opacity: 0.85; }
  25% { transform: scale(0.92, 1.12) skewX(3deg); opacity: 1; }
  50% { transform: scale(1.06, 0.9) skewX(-2deg); opacity: 0.8; }
  75% { transform: scale(0.95, 1.08) skewX(2deg); opacity: 0.95; }
  100% { transform: scale(1.02, 0.95) skewX(-3deg); opacity: 0.85; }
}

/* Seagulls */
.sky-gulls { inset: 0; opacity: var(--sky-op); --gull: rgb(255 255 255 / 0.8); }
:root[data-sky-tone="light"] .sky-gulls { --gull: rgb(30 30 50 / 0.6); }
.sky-gulls span { position: absolute; left: -6vw; top: var(--y); width: 24px; height: 10px; animation: sky-glide calc(var(--d) * var(--sky-slow, 1)) linear infinite; animation-delay: var(--delay); }
.sky-gulls span::before, .sky-gulls span::after {
  content: ""; position: absolute; top: 0; width: 13px; height: 8px; border-top: 2px solid var(--gull); border-radius: 60% 60% 0 0;
  animation: sky-flap var(--f) ease-in-out infinite alternate;
}
.sky-gulls span::before { left: 0; transform-origin: 100% 100%; }
.sky-gulls span::after { right: 0; transform-origin: 0 100%; }
@keyframes sky-glide { 0% { transform: translate(0, 0) scale(var(--s)); } 50% { transform: translate(56vw, -3vh) scale(var(--s)); } 100% { transform: translate(114vw, 1vh) scale(var(--s)); } }
@keyframes sky-flap { to { transform: scaleY(0.45) rotate(4deg); } }

.sky-istanbul { left: 0; right: 0; bottom: 0; width: 100%; height: 50vh; }

/* =========================================================================
   Customize flow: the button opens the panel; "Move things" starts moving.
   ========================================================================= */
.editing .view { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px); }
@media (min-width: 900px) { .editing .view { padding-bottom: 36px; } }
.cz-back-btn { width: auto; padding: 0 12px 0 9px; gap: 6px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--text); }
.cz-back-btn[hidden] { display: none; }
@media (max-width: 600px) { .cz-back-btn span:not(.custom-btn-icon) { display: none; } .cz-back-btn { padding: 0; width: 34px; justify-content: center; } }

/* "Move things on the screen", at the top of the panel */
.cz-move {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left;
  border-radius: var(--radius-md); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, var(--card)); color: var(--text); cursor: pointer;
}
.cz-move:hover { background: color-mix(in srgb, var(--accent) 18%, var(--card)); }
.cz-move > .card-icon { flex: none; }
.cz-move strong { display: block; font-size: 15px; }
.cz-move small { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; margin-top: 2px; }
.cz-move > .icon:last-child { margin-left: auto; color: var(--muted); flex: none; }
.cz-hidden-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }

/* Bigger handles on touch screens, touchpads near small screens, and phones */
@media (pointer: coarse), (max-width: 600px) {
  .edit-eye { width: 32px; height: 32px; }
  .edit-tools.mini { top: -15px; right: -12px; }
  .edit-tools.mini .edit-eye { width: 28px; height: 28px; }
  .edit-grip { padding: 8px 10px 8px 8px; }
  .tile-tool { width: 38px; height: 38px; }
  .editing .room-chips { padding-top: 17px; }
}
.edit-item:focus-visible { outline: 3px solid var(--accent) !important; outline-offset: 3px; }

/* The panel on small screens: full width, tabs and choices that fit */
@media (max-width: 600px) {
  .cz-panel { width: 100%; border-left: 0; padding-left: 12px; padding-right: 12px; }
  .cz-body { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .cz-tabs button .icon { display: none; }
  .cz-seg { flex-wrap: wrap; }
  .cz-seg button { flex: 1 1 30%; }
  .cz-palettes { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

/* Settings: Look and layout */
.look-themes { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.look-themes .cz-palette { flex: 0 0 104px; }
.look-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.look-actions .btn { justify-content: center; }

/* =========================================================================
   Illustrated scenes (js/sky-scenes.js): Istanbul, fireplace, mountains,
   retro horizon. Colours are variables here so light and dark both work.
   ========================================================================= */
/* ---- Mountains: shaded ridges, snow caps, drifting mist, a pine treeline ---- */
.sky-mountains {
  left: 0; right: 0; bottom: 0; width: 100%; height: 40vh;
  --mt1a: color-mix(in srgb, var(--m2) 30%, color-mix(in srgb, var(--bg) 66%, #fff));
  --mt1b: color-mix(in srgb, var(--m2) 14%, color-mix(in srgb, var(--bg) 80%, #fff));
  --mt2a: color-mix(in srgb, var(--m2) 16%, color-mix(in srgb, var(--bg) 82%, #fff));
  --mt2b: color-mix(in srgb, var(--bg) 90%, #fff);
  --mt3a: color-mix(in srgb, var(--m1) 6%, color-mix(in srgb, var(--bg) 88%, #000));
  --mt3b: color-mix(in srgb, var(--bg) 78%, #000);
  --mt-tree: color-mix(in srgb, var(--bg) 58%, #000);
  --mt-mist: color-mix(in srgb, var(--m1) 30%, #fff);
  --mt-snow: rgb(240 248 255 / 0.85);
}
:root[data-sky-tone="light"] .sky-mountains {
  --mt1a: color-mix(in srgb, var(--m2) 22%, var(--bg)); --mt1b: color-mix(in srgb, var(--m2) 10%, var(--bg));
  --mt2a: color-mix(in srgb, var(--accent) 24%, var(--bg)); --mt2b: color-mix(in srgb, var(--accent) 14%, var(--bg));
  --mt3a: color-mix(in srgb, var(--accent) 40%, var(--bg)); --mt3b: color-mix(in srgb, var(--accent) 30%, var(--bg));
  --mt-tree: color-mix(in srgb, var(--accent) 55%, var(--bg)); --mt-mist: #fff; --mt-snow: #fff;
}
.mt-rim { fill: none; stroke: color-mix(in srgb, var(--m1) 60%, #fff); stroke-width: 1.4; opacity: 0.5; filter: drop-shadow(0 0 4px var(--m1)); }
.mt-caps { fill: var(--mt-snow); }
.mt-caps.two { opacity: 0.7; }
.mt-mist { opacity: 0.25; animation: mt-drift calc(40s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
.mt-mist.two { opacity: 0.25; animation-duration: calc(55s * var(--sky-slow, 1)); animation-direction: alternate-reverse; }
@keyframes mt-drift { to { transform: translateX(160px); } }
.mt-trees { fill: var(--mt-tree); }

/* ---- Fireplace: layered flames over glowing coals and logs ---- */
.sky-fire {
  left: 0; right: 0; bottom: 0; width: 100%; height: 50vh; opacity: calc(0.5 + 0.5 * var(--sky-op));
  --f-bark: color-mix(in srgb, var(--bg) 60%, #000);
  --f-bark-top: color-mix(in srgb, var(--m2) 22%, color-mix(in srgb, var(--bg) 72%, #000));
}
.fire-halo { transform-box: fill-box; transform-origin: center; animation: fire-glow calc(2.6s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
@keyframes fire-glow { to { opacity: 0.75; transform: scale(1.05); } }
.fire-coals { animation: fire-coals calc(1.8s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
@keyframes fire-coals { to { opacity: 0.65; } }
.fl-layer { mix-blend-mode: screen; }
:root[data-sky-tone="light"] .fl-layer { mix-blend-mode: normal; }
.fl-layer.outer { filter: blur(4px); opacity: 0.9; }
.fl-layer.mid { filter: blur(2px); }
.fl-layer.inner { filter: blur(0.6px); }
.fl { transform-box: fill-box; transform-origin: 50% 100%; animation: sky-flicker calc(var(--d) * var(--sky-slow, 1)) ease-in-out infinite alternate; }
.log-end { fill: color-mix(in srgb, var(--m1) 35%, var(--f-bark-top)); }
.log-ring { fill: none; stroke: color-mix(in srgb, var(--bg) 50%, #000); stroke-width: 1.2; }
.log-crack { fill: none; stroke: var(--m3); stroke-width: 2.2; stroke-linecap: round; filter: drop-shadow(0 0 4px var(--m1)); animation: fire-coals calc(1.4s * var(--sky-slow, 1)) ease-in-out infinite alternate; }

/* ---- Retro: sun glow and neon mountains on the horizon ---- */
.retro-glow { position: absolute; left: 50%; bottom: 34%; width: 64vmin; height: 44vmin; margin-left: -32vmin; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--m1) 50%, transparent), transparent); filter: blur(10px); }
.retro-mountains { position: absolute; left: 0; right: 0; bottom: 40%; width: 100%; height: 11vh; }
.retro-m-edge { fill: none; stroke: var(--m1); stroke-width: 2; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 5px var(--m1)); }

/* ---- Waves: crests ---- */
.sky-waves .wave path { stroke: color-mix(in srgb, #fff 30%, transparent); stroke-width: 1.2; vector-effect: non-scaling-stroke; }

/* ---- Istanbul: the shore, the Bosphorus bridge and Kız Kulesi ---- */
.sky-istanbul {
  left: 0; right: 0; bottom: 0; width: 100%; height: clamp(320px, 27.8vw, 52vh);
  --i-haze: color-mix(in srgb, var(--m2) 30%, color-mix(in srgb, var(--bg) 66%, #fff));
  --i-haze2: color-mix(in srgb, var(--m2) 18%, color-mix(in srgb, var(--bg) 78%, #fff));
  --i-far: color-mix(in srgb, var(--m2) 16%, color-mix(in srgb, var(--bg) 82%, #fff));
  --i-far2: color-mix(in srgb, var(--bg) 88%, #fff);
  --i-near: color-mix(in srgb, var(--bg) 70%, #000);
  --i-near2: color-mix(in srgb, var(--bg) 52%, #000);
  --i-bridge: color-mix(in srgb, var(--bg) 58%, #000);
  --i-tower: color-mix(in srgb, var(--bg) 50%, #000);
  --i-tower-lit: color-mix(in srgb, var(--m1) 22%, color-mix(in srgb, var(--bg) 50%, #000));
  --i-stone: color-mix(in srgb, var(--m1) 10%, color-mix(in srgb, var(--bg) 62%, #000));
  --i-rock: color-mix(in srgb, var(--bg) 40%, #000);
  --i-water-top: color-mix(in srgb, var(--m1) 34%, color-mix(in srgb, var(--bg) 80%, #fff));
  --i-water-mid: color-mix(in srgb, var(--m2) 22%, var(--bg));
  --i-water-bot: color-mix(in srgb, var(--bg) 62%, #000);
  --i-win: #ffd27a;
}
:root[data-sky-tone="light"] .sky-istanbul {
  --i-haze: color-mix(in srgb, var(--m2) 20%, var(--bg)); --i-haze2: color-mix(in srgb, var(--m2) 10%, var(--bg));
  --i-far: color-mix(in srgb, var(--accent) 22%, var(--bg)); --i-far2: color-mix(in srgb, var(--accent) 14%, var(--bg));
  --i-near: color-mix(in srgb, var(--accent) 46%, var(--bg)); --i-near2: color-mix(in srgb, var(--accent) 36%, var(--bg));
  --i-bridge: color-mix(in srgb, var(--accent) 52%, var(--bg)); --i-tower: color-mix(in srgb, var(--accent) 58%, var(--bg));
  --i-tower-lit: color-mix(in srgb, var(--accent) 40%, var(--bg)); --i-stone: color-mix(in srgb, var(--accent) 34%, var(--bg));
  --i-rock: color-mix(in srgb, var(--accent) 64%, var(--bg));
  --i-water-top: color-mix(in srgb, var(--m2) 30%, var(--bg)); --i-water-mid: color-mix(in srgb, var(--m2) 22%, var(--bg)); --i-water-bot: color-mix(in srgb, var(--accent) 30%, var(--bg));
  --i-win: var(--i-tower-lit);
}
.ist-bridge { fill: var(--i-bridge); }
.ist-hangers { fill: none; stroke: var(--i-bridge); stroke-width: 0.8; opacity: 0.8; }
.ist-cable { fill: none; stroke: var(--i-bridge); stroke-width: 3; }
.ist-deck-glow { fill: none; stroke: var(--m1); stroke-width: 2; opacity: 0.85; filter: drop-shadow(0 0 4px var(--m1)); animation: ist-hue calc(9s * var(--sky-slow, 1)) linear infinite; }
@keyframes ist-hue { 0%, 100% { stroke: var(--m1); } 33% { stroke: var(--m3); } 66% { stroke: var(--m2); } }
.ist-lamp { fill: #ffe2a0; filter: drop-shadow(0 0 3px #ffd27a); animation: ist-twinkle calc(3s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
.ist-win { fill: var(--i-win); opacity: 0.75; }
.ist-twinkle { fill: #fff1c2; animation: ist-twinkle calc(3.5s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
@keyframes ist-twinkle { from { opacity: 0.1; } to { opacity: 1; } }
.ist-waves path { stroke: color-mix(in srgb, var(--m1) 40%, #fff); stroke-width: 1.2; stroke-linecap: round; animation: ist-drift calc(12s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
@keyframes ist-drift { to { transform: translateX(40px); } }
.ist-sun, .ist-sunpath, .ist-moonpath { display: none; }
:root[data-sky~="dusk"] .ist-sun, :root[data-sky~="dusk"] .ist-sunpath { display: inline; }
:root[data-sky~="moon"]:not([data-sky~="dusk"]) .ist-moonpath { display: inline; }
.ist-sunpath path, .ist-moonpath path { stroke-width: 2.2; stroke-linecap: round; animation: ist-glitter calc(2.2s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
.ist-sunpath path { stroke: color-mix(in srgb, var(--m3) 70%, #fff); }
.ist-moonpath path { stroke: #fff6d8; stroke-width: 1.8; }
@keyframes ist-glitter { from { opacity: 0.15; transform: translateX(-4px); } to { opacity: 0.9; transform: translateX(4px); } }
.ist-streak { stroke: #ffd27a; stroke-width: 1.6; stroke-linecap: round; opacity: 0.5; animation: ist-glitter calc(2.6s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
/* Kız Kulesi */
.kk-rock { fill: var(--i-rock); }
.kk-stone { fill: var(--i-stone); }
.kk-body, .kk-rail { fill: var(--i-tower); }
.kk-facet { fill: var(--i-tower-lit); }
.kk-win { fill: var(--i-win); opacity: 0.85; }
.kk-lantern { fill: #ffe9a8; animation: kk-lantern calc(2.4s * var(--sky-slow, 1)) ease-in-out infinite; }
@keyframes kk-lantern { 50% { fill: #ffc861; } }
.kk-flag { fill: var(--m2); transform-box: fill-box; transform-origin: 0 50%; animation: kk-flag 1.2s ease-in-out infinite alternate; }
@keyframes kk-flag { to { transform: scaleX(0.7) skewY(8deg); } }
.kk-glow { transform-box: fill-box; transform-origin: center; animation: kk-glow calc(2.4s * var(--sky-slow, 1)) ease-in-out infinite; }
@keyframes kk-glow { 50% { opacity: 0.5; transform: scale(0.8); } }
/* The lantern's beam sweeps round, seen from the side. */
.kk-beam { transform-box: view-box; transform-origin: 1265px 181px; mix-blend-mode: screen; animation: kk-sweep calc(8s * var(--sky-slow, 1)) linear infinite; }
@keyframes kk-sweep {
  0%, 100% { transform: scaleX(1); opacity: 0.7; }
  25% { transform: scaleX(0.05); opacity: 0.15; }
  50% { transform: scaleX(-1); opacity: 0.7; }
  75% { transform: scaleX(0.05); opacity: 0.15; }
}
.kk-flip { transform: matrix(1, 0, 0, -0.72, 0, 516); }
.kk-ripple { transform-box: fill-box; transform-origin: 50% 0; animation: kk-ripple calc(4s * var(--sky-slow, 1)) ease-in-out infinite alternate; }
@keyframes kk-ripple { to { transform: skewX(4deg) scaleX(1.03); } }
:root[data-sky-tone="light"] :is(.kk-beam, .kk-glow, .ist-twinkle, .ist-lamp, .ist-streak) { display: none; }
/* Scenes are scaled to fill the screen; anything reaching above their box
   (like the fire's glow) carries on fading out instead of being cut off. */
.sky-fire, .sky-mountains, .sky-istanbul, .retro-mountains { overflow: visible; }
