/* House Assistant web panel. Devices are wall plates: an unlit plate is off, lamp light is on. */
:root {
  --night: #161b2e;
  --plate: #1f2640;
  --edge: #2f3858;
  --ink: #e8ebf4;
  --dim: #8c94ae;
  --lamp: #ffb547;
  --lamp-glow: rgba(255, 181, 71, .28);
  --heat: #ff7a59;
  --bad: #ff8a8a;
  --radius-plate: 18px;
  --radius-key: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --night: #e7eaf1;
    --plate: #f7f8fb;
    --edge: #cfd4e2;
    --ink: #1b2136;
    --dim: #5d6683;
    --lamp: #c97a00;
    --lamp-glow: rgba(255, 170, 40, .35);
    --heat: #c94a28;
    --bad: #b3261e;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font: 16px/1.45 var(--font);
}
#app { max-width: 1120px; margin: 0 auto; padding: 20px 16px 48px; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.top h1 { font-size: 28px; font-weight: 750; letter-spacing: -.01em; }
.sync { color: var(--dim); font-size: 14px; }

/* Buttons */
button {
  background: var(--plate);
  border: 1px solid var(--edge);
  border-radius: var(--radius-key);
  padding: 9px 14px;
  cursor: pointer;
  min-height: 42px;
}
button:hover { border-color: var(--dim); }
button:disabled { opacity: .5; cursor: progress; }
button.quiet { background: none; border-color: transparent; color: var(--dim); padding-left: 0; }
button.quiet:hover { color: var(--ink); }
button[aria-pressed="true"] { border-color: var(--lamp); color: var(--lamp); }

/* Command bar */
.command { display: flex; gap: 8px; }
.command input, .pair-form input {
  flex: 1;
  min-width: 0;
  background: var(--plate);
  border: 1px solid var(--edge);
  border-radius: var(--radius-key);
  padding: 12px 14px;
  font-size: 17px;
}
.command input::placeholder { color: var(--dim); }
.command button { background: var(--lamp); color: #1b1404; border-color: var(--lamp); font-weight: 650; }
/* The answer floats: it has to be seen from any screen, at any scroll. */
.reply {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 2;
  width: max-content; max-width: min(92vw, 560px);
  background: var(--plate); border: 1px solid var(--dim); border-radius: var(--radius-key);
  padding: 10px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.reply:empty { display: none; }
.reply.fail { color: var(--bad); border-color: var(--bad); }
.note { margin: 0 2px 12px; }
.note:empty { display: none; }

/* Tiles: the start screen */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-top: 18px; }
.tiles-devices { display: contents; }
.tile {
  display: grid; align-content: start; gap: 2px; min-height: 136px; padding: 16px;
  background: var(--plate); border: 1px solid var(--edge); border-radius: var(--radius-plate);
  color: inherit; text-decoration: none;
  transition: box-shadow .35s ease, border-color .35s ease;
}
button.tile { width: 100%; text-align: left; font: inherit; cursor: pointer; }
.tile-netflix svg { stroke: #e8222c; stroke-width: 2.4; }
.tile:hover { border-color: var(--dim); }
.tile:active { transform: translateY(1px); }
.tile strong { font-size: 18px; font-weight: 700; margin-top: 10px; }
.tile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-height: 34px; }
.tile-top svg { width: 30px; height: 30px; fill: none; stroke: var(--dim); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tile-big { font-size: 28px; font-weight: 300; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile.on, .plate.on { border-color: var(--lamp); box-shadow: 0 0 0 1px var(--lamp) inset, 0 10px 40px -12px var(--lamp-glow); }
.tile.on svg { stroke: var(--lamp); }
.tile.on .state { color: var(--lamp); }
.tile.heating, .plate.heating { border-color: var(--heat); box-shadow: 0 0 0 1px var(--heat) inset, 0 10px 40px -12px rgba(255, 122, 89, .35); }
.tile.heating svg { stroke: var(--heat); }
.tile.unknown { opacity: .75; }
.back { display: inline-block; color: var(--dim); padding: 8px 0; margin-bottom: 10px; text-decoration: none; }
.back::before { content: "‹ "; }
.back:hover { color: var(--ink); }
.detail { max-width: 560px; margin: 0 auto; }

/* Plates */
.plate {
  background: var(--plate);
  border: 1px solid var(--edge);
  border-radius: var(--radius-plate);
  padding: 18px;
  display: grid;
  gap: 14px;
  transition: box-shadow .35s ease, border-color .35s ease;
}
.plate.unknown { opacity: .75; }
.plate-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plate h3 { font-size: 20px; font-weight: 700; }
.state { color: var(--dim); font-size: 14px; }
.on > .plate-head .state, .row.on .state { color: var(--lamp); }

/* Rocker: the light switch. aria-checked carries the state. */
.rocker {
  width: 64px; height: 38px; min-height: 0; padding: 0; flex: none;
  border-radius: 12px;
  position: relative;
  background: var(--night);
}
.rocker::after {
  content: ""; position: absolute; top: 4px; left: 4px;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--dim);
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.rocker[aria-checked="true"] { border-color: var(--lamp); }
.rocker[aria-checked="true"]::after { transform: translateX(26px); background: var(--lamp); box-shadow: 0 0 16px var(--lamp-glow); }
.rocker.small { width: 52px; height: 32px; }
.rocker.small::after { width: 22px; height: 22px; }
.rocker.small[aria-checked="true"]::after { transform: translateX(20px); }

.rows { display: grid; gap: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--edge); }
.row:first-child { border-top: 0; }
.row-name { display: grid; }

/* Thermostat */
.temp { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.temp-now { font-size: 56px; font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.temp-now small { font-size: 24px; }
.temp-meta { color: var(--dim); padding-bottom: 6px; }
.boiler-on { color: var(--heat); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper output { min-width: 4.5ch; text-align: center; font-size: 20px; font-variant-numeric: tabular-nums; }
.stepper button { width: 46px; font-size: 20px; padding: 0; }

/* TV remote: a dark object in either theme, as the real one is. */
.remote {
  width: 232px; margin: 0 auto; padding: 14px 18px 0; display: grid; gap: 12px; overflow: hidden;
  background: linear-gradient(90deg, #1b1b1e, #2b2b2f 10%, #2b2b2f 90%, #1b1b1e);
  border: 1px solid #3c3c42; border-radius: 10px;
  box-shadow: 0 22px 44px -22px rgba(0, 0, 0, .65);
  color: #e4e4e8; touch-action: manipulation;
}
.remote button {
  width: 48px; height: 48px; min-height: 0; padding: 0; display: grid; place-items: center;
  background: #111113; border: 0; border-radius: 50%; color: inherit; font-size: 15px; font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .09), inset 0 1px 2px rgba(255, 255, 255, .06);
}
.remote button:hover { background: #1d1d20; }
.remote button:active { background: #3b3b42; }
.remote svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.remote-row { display: flex; align-items: center; justify-content: space-between; }
.remote-row.solo { justify-content: center; }
.remote .power { width: 46px; height: 26px; border-radius: 13px; background: #2a1517; color: #e5484d; }
.remote .power svg { width: 16px; height: 16px; }
.remote .dots { grid-auto-flow: column; grid-auto-columns: 7px; justify-content: center; align-content: center; gap: 1px; }
.remote .dots i { width: 6px; height: 6px; border-radius: 50%; }
.dot-red, .color-red { background: #e5484d; }
.dot-green, .color-green { background: #30a46c; }
.dot-yellow, .color-yellow { background: #f5d90a; }
.dot-blue, .color-blue { background: #3e8ed0; }
.remote .keygrid button { width: auto; height: 42px; border-radius: 12px; }
.remote .color-red { background: #e5484d; }
.remote .color-green { background: #30a46c; }
.remote .color-yellow { background: #f5d90a; }
.remote .color-blue { background: #3e8ed0; }
.dpad {
  position: relative; display: grid; grid-template: 1fr 1fr / 1fr 1fr; width: 176px; height: 176px; margin: 0 auto;
  border-radius: 50%; overflow: hidden; transform: rotate(45deg);
  background: #1f1f22; box-shadow: 0 0 0 1px #0c0c0e, inset 0 0 14px rgba(0, 0, 0, .7);
}
.remote .dpad button { width: 100%; height: 100%; background: none; border-radius: 0; box-shadow: none; }
.remote .dpad button:hover, .remote .dpad button:focus-visible { background: #2b2b30; }
.remote .dpad button:active { background: #3b3b42; }
.remote .dpad .ok { position: absolute; inset: 44px; width: auto; height: auto; border-radius: 50%; background: #0c0c0e; }
.remote-row.arc > :nth-child(2) { transform: translateY(12px); }
.levers { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin-top: 12px; }
.lever { display: grid; }
.remote .lever button { width: 100%; height: 38px; background: none; border-radius: 0; box-shadow: none; color: #b4b4ba; }
.remote .lever button:hover, .remote .lever button:active { color: #fff; }
.remote .lever .slit {
  height: 24px; background: #0c0c0e; background-clip: padding-box; border: 5px solid transparent;
  border-width: 5px 0;
}
.remote .lever .slit:active { background-color: #3b3b42; }
.lever:first-child .slit { border-radius: 8px 0 0 8px; }
.lever:last-child .slit { border-radius: 0 8px 8px 0; }
.remote .app { width: 52px; height: 52px; font-size: 9px; font-weight: 800; letter-spacing: .01em; color: #fff; }
.remote-foot {
  height: 170px; margin: 4px -18px 0; padding-bottom: 18px; display: grid; justify-items: center; align-items: end;
  border-top: 1px solid #111113; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.remote-foot span { font-size: 13px; font-weight: 700; letter-spacing: .12em; color: #bcbcc2; }
.keygrid { display: grid; gap: 8px; }
.keygrid.three { grid-template-columns: repeat(3, 1fr); }
.keygrid.four { grid-template-columns: repeat(4, 1fr); }
.keygrid.five { grid-template-columns: repeat(5, 1fr); }
.digits button { font-variant-numeric: tabular-nums; }
.digits button:last-child { grid-column: 2; }

/* Groups of keys */
.keys { display: flex; flex-wrap: wrap; gap: 8px; }
.field { display: grid; gap: 6px; }
.field-label { color: var(--dim); font-size: 14px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.segmented button { padding: 9px 4px; font-size: 15px; }
.segmented button.blocked:disabled { opacity: .35; cursor: not-allowed; }

/* Consumables */
.wear { display: grid; grid-template-columns: repeat(2, 1fr); align-items: start; gap: 8px 14px; font-size: 14px; }
.wear div { display: grid; gap: 4px; }
.wear span { color: var(--dim); }
.wear .reset { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.wear .reset button { min-height: 32px; padding: 4px 8px; font-size: 13px; }
.wear .reset button.quiet { padding-left: 0; }
.bar { height: 6px; border-radius: 3px; background: var(--night); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--dim); }
.bar.low i { background: var(--bad); }

/* Phones */
.phones h2 { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.phones h3 { font-size: 17px; font-weight: 700; margin: 22px 0 8px; }
.phones ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.phones li { background: var(--plate); border: 1px solid var(--edge); border-radius: var(--radius-key); padding: 10px 14px; display: grid; gap: 2px; min-width: 200px; }
.phones .home { color: var(--lamp); }
.phones .low { color: var(--bad, #e5484d); }
.phones .dim { color: var(--dim); font-size: 14px; }
.phones .phone-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.phones .chips { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--dim); }
.phones .chip { white-space: nowrap; }
.phones .ring { justify-self: start; margin-top: 6px; }
.reminder-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.reminder-form input, .reminder-form select {
  background: var(--night); border: 1px solid var(--edge); border-radius: var(--radius-key); padding: 10px 12px; min-width: 0;
}
.reminder-form #reminder-text, .reminder-form input:first-child { flex: 1 1 16em; }
.reminder-actions { display: flex; gap: 8px; }
.reminder-pending { border-left: 3px solid var(--lamp); padding-left: 9px; }

/* Paired clients */
.clients + .clients { margin-top: 28px; }
.clients-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.clients h2 { font-size: 20px; font-weight: 700; }
.clients ul { list-style: none; margin: 0; padding: 0; background: var(--plate); border: 1px solid var(--edge); border-radius: var(--radius-plate); }
.clients li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; padding: 10px 16px; border-top: 1px solid var(--edge); }
.clients li:first-child { border-top: 0; }
.clients .dim { color: var(--dim); font-size: 14px; }
.client-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.client-rename { display: flex; flex-wrap: wrap; gap: 8px; }
.client-rename input { background: var(--night); border: 1px solid var(--edge); border-radius: var(--radius-key); padding: 8px 12px; min-width: 0; width: 16em; max-width: 100%; }
.device-rename { display: grid; gap: 10px; width: 100%; }
.device-rename input, .add-form input, .add-form select {
  background: var(--night); border: 1px solid var(--edge); border-radius: var(--radius-key);
  padding: 10px 12px; width: 100%; min-width: 0;
}
.add-form { background: var(--plate); border: 1px solid var(--lamp); border-radius: var(--radius-plate);
  padding: 18px; margin-bottom: 14px; display: grid; gap: 14px; max-width: 560px; }
.add-fields { display: grid; gap: 14px; }
.hint { color: var(--dim); font-size: 13px; }
button.primary { background: var(--lamp); color: #1b1404; border-color: var(--lamp); font-weight: 650; }
button.danger { border-color: var(--bad); color: var(--bad); }

/* Pairing and footer */
.pair { max-width: 460px; display: grid; gap: 14px; }
.pair h2 { font-size: 22px; }
.pair p { color: var(--dim); }
.pair-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pair-form label { width: 100%; color: var(--dim); font-size: 14px; }
.pair-form input { letter-spacing: .2em; text-transform: uppercase; }
.pair-error { color: var(--bad); min-height: 1.4em; }
.foot { margin-top: 36px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
#new-code-out { font-variant-numeric: tabular-nums; }
#new-code-out strong { color: var(--lamp); letter-spacing: .15em; font-size: 20px; }

@media (max-width: 520px) {
  .temp-now { font-size: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Vacuum map */
.vmap-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vmap-frame { position: relative; width: 100%; max-width: 560px; margin: 0 auto; }
.vmap-canvas { display: block; width: 100%; height: 100%; cursor: pointer; image-rendering: pixelated; }
.vmap-labels { position: absolute; inset: 0; pointer-events: none; }
.vmap-label {
  position: absolute; transform: translate(-50%, -50%); pointer-events: auto;
  min-height: 30px; padding: 3px 8px; font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--plate); border-color: var(--edge); box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.vmap-label[aria-pressed="true"] { background: var(--lamp); color: #1b1404; border-color: var(--lamp); }
.vmap-room { display: flex; align-items: center; gap: 10px; background: none; border-color: transparent; padding-left: 0; text-align: left; }
.vmap-room[aria-pressed="true"] { color: var(--lamp); background: none; border-color: transparent; font-weight: 650; }
.swatch { width: 16px; height: 16px; border-radius: 4px; flex: none; }
.row-end { display: flex; align-items: center; gap: 10px; }
.vmap-rename { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
.vmap-rename input {
  flex: 1 1 140px; min-height: 42px; padding: 8px 10px; color: var(--ink);
  border: 1px solid var(--edge); border-radius: var(--radius-key); background: var(--night);
}

/* Sliders: volume, thermostat target */
.slider { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.slider input[type="range"] { flex: 1; min-width: 120px; height: 32px; accent-color: var(--lamp); cursor: pointer; }
.slider output { min-width: 4.5ch; text-align: right; font-size: 20px; font-variant-numeric: tabular-nums; }
.row .slider { max-width: 340px; }

/* Vacuum map legend and schedules */
.vmap-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.vmap-key { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: middle; }
.vmap-key.path { height: 2px; background: rgba(255, 255, 255, 0.85); }
.vmap-key.robot { border-radius: 50%; background: #fff; border: 2px solid #1b2136; }
.vmap-key.dock { background: #2ecc71; border: 2px solid #0b3d20; }
.keys.inline { display: flex; gap: 8px; align-items: center; }
.vsched-form { display: flex; flex-direction: column; gap: 10px; padding: 10px 0; }
.vsched-form input[type="time"] { font-size: 22px; max-width: 160px; }
.vsched-days { display: flex; gap: 6px; flex-wrap: wrap; }
.vsched-day { min-width: 44px; padding: 8px 0; }
.vsched-day[aria-pressed="true"] { background: var(--lamp); color: #1b1404; border-color: var(--lamp); }
