/* Home Control - the site's look: LCARS, following the M47 design rules (~/.claude/skills/m47, MIT;
   LCARS design language by Michael Okuda; unofficial fan-made style). Loaded on every page, on top of
   the base layout in style.css (html.lcars).
   Colour roles (Voyager scheme): black ground, gold-orange structure (frames), periwinkle secondary bars, lavender controls, blue data,
   red only for alerts. 3px black gutters inside frames, elbow cutout = rail width, 44px controls,
   Antonio uppercase display labels, no gradients or shadows. */
@font-face { font-family: Antonio; src: url('fonts/Antonio.ttf') format('truetype'); font-weight: 100 700; font-display: swap; }   /* SIL OFL, fonts/OFL.txt */

.lcars {
  /* M47 tokens (core/tokens.json), Voyager-era scheme: gold-orange frames, periwinkle secondary bars,
     lavender controls kept. Classic (tng-default) was structure #FF9966, secondary #FFCC66. */
  --m47-ground: #000000;
  --m47-structure: #FF9900;
  --m47-secondary: #9999FF;
  --m47-interactive: #CC99CC;
  --m47-data: #99CCFF;
  --m47-text: #EDE7DB;
  --m47-bright: #FFFF99;
  --m47-muted: #B9AE9C;
  --m47-onShape: #000000;
  --m47-alert: #FF6666;          /* red-alert scheme structure colour: errors only */
  --m47-line: #423627;           /* M47 table rules and meter track */
  --frame-gap: 3px;
  /* page frame */
  --rail: 140px;                 /* vertical rail = elbow cutout inset (same token) */
  --bar: 22px;                   /* horizontal bar height */
  --arm: 48px;                   /* how far an elbow's horizontal arm reaches past the rail */
  --outer: 48px;                 /* generous outer curve */
  --inner: 12px;                 /* tight inner fillet */
  /* card frames */
  --c-rail: 16px;
  --c-bar: 30px;
  --c-inner: 12px;
  --display: 'Antonio', 'Arial Narrow', sans-serif;
  --on: var(--m47-bright);       /* power card: "sending to the grid" figure */
  --chart-1: #99CCFF; --chart-2: #9999FF; --chart-3: #FF9900;
  --chart-4: #FFFF99; --chart-5: #CC99CC; --chart-6: #B9AE9C;
  color-scheme: dark;
  background: var(--m47-ground);
}
.lcars body {
  background: var(--m47-ground); color: var(--m47-text); overflow-x: hidden;
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.lcars ::selection { background: var(--m47-interactive); color: #000; }
.lcars * { scrollbar-color: var(--m47-structure) #000; }
.lcars :focus-visible { outline: 2px solid var(--m47-bright); outline-offset: 4px; }

/* display type */
.lcars .brand, .lcars .icon-btn, .lcars .tab, .lcars h1, .lcars h2, .lcars h3, .lcars .btn,
.lcars .row, .lcars .big-temp, .lcars .status-pill, .lcars .chart-legend, .lcars .chart-tools,
.lcars .chart-stats, .lcars .field label, .lcars .check, .lcars .toast, .lcars .message,
.lcars .card .muted, .lcars .admin th {
  font-family: var(--display); text-transform: uppercase; letter-spacing: .03em;
}

/* ---------- frame pieces ---------- */
.lcars .lc-frame { display: flex; gap: var(--frame-gap); pointer-events: none; }
.lcars .lc-elbow { display: block; position: relative; flex: none; width: calc(var(--rail) + var(--arm)); background: var(--m47-structure); }
.lcars .lc-elbow::after { content: ''; position: absolute; background: var(--m47-ground); }
.lcars .lc-bar { display: block; height: var(--bar); background: var(--m47-secondary); }
.lcars .lc-bar:nth-of-type(2) { flex: 5 1 0; }
.lcars .lc-bar:nth-of-type(3) { flex: 2 1 0; background: var(--m47-structure); }
.lcars .lc-bar:nth-of-type(4) { flex: 0 0 64px; }
.lcars .lc-bar:last-child { border-radius: 0 calc(var(--bar) / 2) calc(var(--bar) / 2) 0; }

/* top frame: rail on the left, elbow at the bottom, bar along the bottom (opens upward) */
.lcars .lc-frame-up { position: absolute; inset: 0; align-items: flex-end; z-index: 0; }
.lcars .lc-frame-up .lc-elbow { align-self: stretch; border-radius: 0 0 0 var(--outer); }
.lcars .lc-frame-up .lc-elbow::after { left: var(--rail); top: 0; right: 0; bottom: var(--bar); border-bottom-left-radius: var(--inner); }

/* second frame (dashboard, wide screens): elbow at the top, rail continues down as the tab bank */
.lcars .lc-frame-down { align-items: flex-start; }
.lcars .lc-frame-down .lc-elbow { height: 64px; border-radius: var(--outer) 0 0 0; }
.lcars .lc-frame-down .lc-elbow::after { left: var(--rail); top: var(--bar); right: 0; bottom: 0; border-top-left-radius: var(--inner); }

/* ---------- header ---------- */
.lcars .header {
  position: relative; background: var(--m47-ground); box-shadow: none; height: auto; min-height: 120px;
  padding: 12px 12px calc(var(--bar) + 12px) calc(var(--rail) + var(--inner) + 16px);
  display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 8px 28px; margin: 0;
}
.lcars .header > :not(.lc-frame) { position: relative; z-index: 1; }
.lcars .brand { color: var(--m47-bright); font-size: 48px; font-weight: 600; line-height: 1; gap: 0; }
.lcars .brand svg { display: none; }
.lcars .header-right { gap: var(--frame-gap); flex-wrap: wrap; color: #000; font-size: 15px; }
/* user name sits in the rail, like a panel number (positioned against the header, not the nav) */
.lcars .header > .header-right { position: static; }
.lcars .header-right > * { position: relative; z-index: 1; }
.lcars .header-right > .who {
  position: absolute; z-index: 1; display: block; left: 0; top: calc(100% - var(--bar) - 36px); width: var(--rail);
  margin: 0; padding: 0 10px; text-align: right; color: var(--m47-onShape); font-weight: 600;
  font-family: var(--display); text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* header actions: one control bank (square inner cells, capped ends) + sign out as its own bank */
.lcars .icon-btn {
  background: var(--m47-interactive); color: #000; border-radius: 0; min-height: 44px; min-width: 44px;
  padding: 0 16px; justify-content: flex-end; align-items: flex-end; padding-bottom: 6px; font-size: 16px; font-weight: 600;
}
.lcars .icon-btn:first-of-type { border-radius: 22px 0 0 22px; }
.lcars .icon-btn:nth-last-of-type(2) { border-radius: 0 22px 22px 0; }
.lcars .icon-btn:first-of-type:nth-last-of-type(2) { border-radius: 22px; }
.lcars .icon-btn:last-of-type { border-radius: 22px; margin-left: 28px; }
.lcars .icon-btn:hover, .lcars .icon-btn:active { background: var(--m47-bright); }
.lcars .icon-btn:focus-visible { outline: 2px solid #000; outline-offset: -5px; }
.lcars .icon-btn svg { display: none; }

/* ---------- tabs ---------- */
.lcars .tabs { padding: 16px 16px 4px; gap: 8px; max-width: none; flex-wrap: wrap; }
.lcars .tab {
  background: var(--m47-interactive); color: #000; border-radius: 22px; min-height: 44px; padding: 0 18px;
  font-size: 17px; font-weight: 600;
}
.lcars .tab:nth-child(even) { background: var(--m47-secondary); }
.lcars .tab.active { background: var(--m47-bright); }
.lcars .tab:focus-visible { outline: 2px solid #000; outline-offset: -5px; }

.lcars .container { max-width: none; }
.lcars .message { background: transparent; color: var(--m47-muted); }

@media (min-width: 800px) {
  .lcars body.dash {
    display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: auto auto 1fr;
    row-gap: var(--frame-gap); min-height: 100vh;
  }
  .lcars body.dash .header { grid-column: 1 / -1; grid-row: 1; }
  .lcars body.dash .lc-frame-down { display: flex; grid-column: 1 / -1; grid-row: 2; }
  .lcars body.dash .tabs,
  .lcars body.dash .tabs[hidden] {
    grid-column: 1; grid-row: 3; display: flex; flex-direction: column; flex-wrap: nowrap;
    gap: var(--frame-gap); padding: 0; margin: 0; overflow: visible;
  }
  .lcars body.dash .tab {
    border-radius: 0; min-height: 64px; padding: 6px 10px; text-align: right; display: flex;
    align-items: flex-end; justify-content: flex-end; white-space: normal; line-height: 1.05;
  }
  /* rail filler below the tab bank, with a rounded exposed end */
  .lcars body.dash .tabs::after {
    content: ''; flex: 1 0 120px; background: var(--m47-structure); border-radius: 0 0 32px 32px;
  }
  .lcars body.dash .container { grid-column: 2; grid-row: 3; margin: 0; padding: 20px 20px 36px 36px; }
}

/* ---------- cards: each one a small elbow frame; content sits in open black space ---------- */
.lcars .grid { gap: 28px; }
.lcars .card, .lcars .dialog, .lcars .login-box {
  --c: var(--m47-structure);
  position: relative; background: var(--m47-ground); box-shadow: none; border: 0; border-radius: 0;
  padding: calc(var(--c-bar) + 14px) 4px 16px calc(var(--c-rail) + 16px);
}
.lcars .grid > .card:nth-child(even), .lcars .admin .card:nth-child(even) { --c: var(--m47-secondary); }
/* elbow: rail + top arm, circular inner fillet (no gradients: border box with elliptical outer radius) */
.lcars .card::before, .lcars .dialog::before, .lcars .login-box::before {
  content: ''; position: absolute; left: 0; top: 0;
  width: calc(var(--c-rail) + var(--c-inner)); height: calc(var(--c-bar) + var(--c-inner));
  border-left: var(--c-rail) solid var(--c); border-top: var(--c-bar) solid var(--c);
  border-top-left-radius: calc(var(--c-rail) + var(--c-inner)) calc(var(--c-bar) + var(--c-inner));
  box-sizing: border-box;
}
.lcars .card::after, .lcars .dialog::after, .lcars .login-box::after {
  content: ''; position: absolute; left: 0; width: var(--c-rail); bottom: 0;
  top: calc(var(--c-bar) + var(--c-inner)); background: var(--c);
  border-radius: 0 0 calc(var(--c-rail) / 2) calc(var(--c-rail) / 2);
}
/* title bar, after a 3px gutter */
.lcars .card > h3, .lcars .dialog > h3, .lcars .login-box > h1 {
  position: absolute; top: 0; right: 0; left: calc(var(--c-rail) + var(--c-inner) + var(--frame-gap));
  height: var(--c-bar); margin: 0; padding: 0 14px; background: var(--c); color: #000;
  border-radius: 0 calc(var(--c-bar) / 2) calc(var(--c-bar) / 2) 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  font-size: 19px; font-weight: 600; line-height: 1; white-space: nowrap; overflow: hidden;
}
.lcars .card > div { padding: 0; }
.lcars .card .muted { color: var(--m47-muted); font-size: 14px; }
.lcars .card .error, .lcars .error { color: var(--m47-alert); }

.lcars .row { border-top: 1px solid var(--m47-line); }
.lcars .row:first-child { border-top: none; }
.lcars .row > span:first-child, .lcars .power-line > :first-child { color: var(--m47-muted); }
.lcars .row .value { color: var(--m47-data); font-weight: 500; font-size: 20px; text-transform: none; }   /* units keep their case (µg, ppm) */
.lcars .big-temp { font-size: 56px; font-weight: 400; color: var(--m47-data); }

.lcars .status-pill { background: transparent; color: var(--m47-muted); border: 1px solid var(--m47-muted); border-radius: 12px; font-size: 13px; padding: 2px 12px; font-weight: 600; }
.lcars .status-pill.heating { background: var(--m47-secondary); border-color: var(--m47-secondary); color: #000; }
.lcars .status-pill.on { background: var(--m47-data); border-color: var(--m47-data); color: #000; }

/* stepper: one bank [ - | + ] around the value would split the value; use two capped controls */
.lcars .stepper button {
  width: 56px; height: 44px; border-radius: 22px; border: none; background: var(--m47-interactive);
  color: #000; font: 600 22px/1 var(--display);
}
.lcars .stepper button:active { background: var(--m47-bright); }
.lcars .stepper button:focus-visible { outline: 2px solid #000; outline-offset: -5px; }

/* toggle: 44px tall control, lavender when on */
.lcars .switch { width: 64px; height: 44px; }
.lcars .switch span { inset: 6px 0; background: #000; border: 2px solid var(--m47-interactive); border-radius: 16px; }
.lcars .switch span::before { width: 22px; height: 22px; left: 3px; top: 3px; background: var(--m47-interactive); border-radius: 11px; }
.lcars .switch input:checked + span { background: var(--m47-interactive); }
.lcars .switch input:checked + span::before { transform: translateX(31px); background: #000; }
.lcars .switch input:focus-visible + span { outline: 2px solid var(--m47-bright); outline-offset: 3px; }
/* inside a coloured title bar: black track on the bar colour */
.lcars h3 .switch { height: var(--c-bar); }
.lcars h3 .switch::after { content: ''; position: absolute; inset: -7px -6px; }   /* 44px tap area beyond the bar */
.lcars .card > h3 { overflow: visible; }
.lcars h3 .switch span { inset: 1px 0; border-color: #000; background: transparent; }
.lcars h3 .switch span::before { background: #000; }
.lcars h3 .switch input:checked + span { background: #000; }
.lcars h3 .switch input:checked + span::before { background: var(--c); }

/* power meters: track + solid fill (M47 meter) */
.lcars .bar { height: 10px; background: var(--m47-line); border-radius: 5px; }
.lcars .bar-fill { border-radius: 5px; background: var(--m47-data); }
.lcars .bar-fill.negative { background: var(--m47-bright); }

/* charts */
.lcars .chart-grid { stroke: var(--m47-line); }
.lcars .chart-zero { stroke: var(--m47-muted); }
.lcars .chart-cursor { stroke: var(--m47-bright); }
.lcars .chart-label { fill: var(--m47-muted); font-size: 13px; font-family: var(--display); }
.lcars .chart-readout { color: var(--m47-text); }
.lcars .daily-bar { fill: var(--chart-1); cursor: pointer; }
.lcars .daily-bar.today { opacity: .55; }
.lcars .daily-bar.picked { fill: var(--m47-bright); opacity: 1; }
.lcars .chart-legend { color: var(--m47-muted); font-size: 14px; }
.lcars .chart-select { fill: var(--m47-bright); fill-opacity: .15; stroke: var(--m47-bright); stroke-opacity: .6; }
.lcars .chart-tools { color: var(--m47-muted); font-size: 14px; }
.lcars .chart-stats { font-size: 16px; }
.lcars .chart-stats th { color: var(--m47-secondary); font-weight: 600; }
.lcars .chart-stats td { border-top: 1px solid var(--m47-line); color: var(--m47-data); text-transform: none; }
.lcars .big-temp { text-transform: none; }
.lcars .chart-stats td:first-child { color: var(--m47-muted); text-transform: uppercase; }
.lcars .chart-swatch { border-radius: 4px; width: 16px; height: 8px; vertical-align: 1px; }
.lcars .chart-key i { height: 6px; width: 18px; border-radius: 3px; }

/* power flow: M47 distribution bus. Conduit dashes move towards the bus (supplying) or away from it
   (drawing); their speed and the conduit width are set per row from the power. */
.lcars .pf { width: 100%; display: block; overflow: visible; }
.lcars .pf-spine { stroke: var(--m47-structure); stroke-linecap: round; fill: none; }
.lcars .pf-conduit { stroke: var(--m47-line); stroke-width: 2; fill: none; }
.lcars .pf-flow { fill: none; stroke: var(--m47-secondary); stroke-dasharray: 12 8; animation: pf-move 1s linear infinite; }
.lcars .pf-flow.to-bus { animation-direction: reverse; }
.lcars .pf-arrow { fill: var(--m47-bright); }
.lcars .pf-terminal { fill: var(--m47-bright); }
.lcars .idle .pf-terminal { fill: var(--m47-muted); }
.lcars .pf-name { fill: var(--m47-interactive); }
.lcars .idle .pf-name { fill: var(--m47-muted); }
.lcars .pf-name-text, .lcars .pf-value-text { fill: var(--m47-onShape); font-family: var(--display); text-transform: uppercase; font-weight: 600; letter-spacing: .03em; }
.lcars .pf-value { fill: var(--m47-secondary); }
.lcars .pf-value-text { text-transform: none; }
.lcars .pf-cell { fill: var(--m47-interactive); opacity: .24; }
.lcars .pf-cell.on { fill: var(--m47-data); opacity: 1; }
.lcars .pf-sub { fill: var(--m47-muted); font-family: var(--display); text-transform: uppercase; letter-spacing: .04em; }
.lcars .live .pf-sub { fill: var(--m47-data); }
@keyframes pf-move { to { stroke-dashoffset: -20; } }
.lcars .pf-routing { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 3px 28px; margin-top: 14px;
  font-family: var(--display); text-transform: uppercase; letter-spacing: .03em; }
.lcars .pf-routing[hidden] { display: none; }
.lcars .pf-route { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--m47-line); padding: 6px 0; }
.lcars .pf-route-name { color: var(--m47-muted); }
.lcars .pf-route-value { color: var(--m47-data); text-transform: none; }
.lcars .pf-note { margin-top: 8px; }
/* power Sankey: ribbons coloured by where the power comes from; thin dashes run left to right */
.lcars .ps { width: 100%; display: block; overflow: visible; }
.lcars .ps-ribbon { opacity: .8; }
.lcars .ps-from-solar .ps-ribbon { fill: var(--m47-secondary); }
.lcars .ps-from-battery .ps-ribbon { fill: var(--m47-bright); }
.lcars .ps-from-grid .ps-ribbon { fill: var(--m47-data); }
.lcars .ps-flow { fill: none; stroke: var(--m47-ground); stroke-opacity: .55; stroke-linecap: round; stroke-dasharray: 4 12; animation: ps-move 1s linear infinite; }
@keyframes ps-move { to { stroke-dashoffset: -16; } }
.lcars .ps-node-solar { fill: var(--m47-secondary); }
.lcars .ps-node-battery { fill: var(--m47-bright); }
.lcars .ps-node-grid { fill: var(--m47-data); }
.lcars .ps-node-house { fill: var(--m47-interactive); }
/* third column: devices split off from the house */
.lcars .ps-from-house .ps-ribbon { fill: var(--m47-interactive); opacity: .55; }
.lcars .ps-node-dev { fill: var(--m47-interactive); }
.lcars .ps-node-rest { fill: var(--m47-muted); }
.lcars .ps-label-above { paint-order: stroke; stroke: var(--m47-ground); stroke-width: 4px; stroke-linejoin: round; }
.lcars .ps-name { font-family: var(--display); text-transform: uppercase; letter-spacing: .04em; fill: var(--m47-muted); }
.lcars .ps-value { font-family: var(--display); fill: var(--m47-data); }
.lcars .ps-empty { font-family: var(--display); text-transform: uppercase; letter-spacing: .04em; fill: var(--m47-muted); font-size: 15px; }
@media (prefers-reduced-motion: reduce) { .lcars .ps-flow { animation: none; } }
/* power conduits (graphical): double-walled conduits to a central core; packets flow inside.
   Gold packets = power coming in to the core, blue = going out. Speed/count/size are set per conduit. */
.lcars .pc { width: 100%; max-width: 560px; height: auto; display: block; margin: 0 auto; overflow: visible; }
.lcars .pc-wall { fill: none; stroke: var(--m47-line); stroke-width: 16; stroke-linecap: round; stroke-linejoin: round; }
.lcars .pc-wall.live { stroke: var(--m47-structure); }
.lcars .pc-channel { fill: none; stroke: var(--m47-ground); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.lcars .pc-packet.in { fill: var(--m47-secondary); }
.lcars .pc-packet.out { fill: var(--m47-data); }
.lcars .pc-chevron { fill: none; stroke: var(--m47-bright); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lcars .pc-core { fill: var(--m47-ground); stroke: var(--m47-structure); stroke-width: 10; }
.lcars .pc-ring { fill: none; stroke: var(--m47-line); stroke-width: 4; stroke-dasharray: 10 6; transform-box: fill-box; transform-origin: center; }
.lcars .pc-ring.live { stroke: var(--m47-data); animation: pc-spin 10s linear infinite; }
@keyframes pc-spin { to { transform: rotate(360deg); } }
.lcars .pc-core-name, .lcars .pc-name { font-family: var(--display); text-transform: uppercase; letter-spacing: .04em; fill: var(--m47-muted); font-size: 16px; }
.lcars .pc-core-value, .lcars .pc-value { font-family: var(--display); fill: var(--m47-muted); font-size: 22px; }
.lcars .pc-core-value, .lcars .pc-value.live { fill: var(--m47-data); }
.lcars .pc-fill { fill: var(--m47-muted); }
.lcars .pc-solar.live .pc-fill { fill: var(--m47-secondary); }
.lcars .pc-grid.live .pc-fill { fill: var(--m47-data); }
.lcars .pc-house.live .pc-fill { fill: var(--m47-interactive); }
.lcars .pc-battery.live .pc-fill, .lcars .pc-car.live .pc-fill { fill: var(--m47-bright); }
.lcars .pc-battery .pc-fill { fill: var(--m47-secondary); }
.lcars .pc-car .pc-fill { fill: var(--m47-interactive); }
.lcars .pc-car.idle .pc-fill { fill: var(--m47-muted); }
.lcars .pc-cut { fill: var(--m47-ground); }
.lcars .pc-outline { fill: none; stroke: var(--m47-secondary); stroke-width: 3; }
.lcars .pc-cell { fill: var(--m47-interactive); opacity: .24; }
.lcars .pc-cell.on { fill: var(--m47-data); opacity: 1; }
.lcars .pc-wire { fill: none; stroke: var(--m47-muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lcars .pc-wire.thin { stroke-width: 1.2; opacity: .7; }
.lcars .pc-glow { fill: var(--m47-muted); opacity: .5; }
.lcars .pc-house.live .pc-glow, .lcars .pc-car.live .pc-glow { fill: var(--m47-data); opacity: 1; }
.lcars .pc-wire.dots { stroke-width: 1.6; stroke-dasharray: .1 4; }
.lcars .pc-wire.ground { stroke: var(--m47-line); stroke-dasharray: 3 4; opacity: 1; }
.lcars .pc-house.live .pc-wire:not(.ground) { stroke: var(--m47-interactive); }
.lcars .pc-car.live .pc-wire:not(.ground) { stroke: var(--m47-bright); }
.lcars .pc-glow.bussard { fill: var(--m47-structure); }
.lcars .pc-house.live .pc-glow.bussard { fill: var(--m47-structure); }
.lcars .pc-house.live .pc-wire.grille { stroke: var(--m47-data); }
.lcars .pc-car.idle .pc-cell.on { fill: var(--m47-muted); }
.lcars .pc-wheel { fill: var(--m47-ground); stroke: var(--m47-muted); stroke-width: 3; }
@media (prefers-reduced-motion: reduce) { .lcars .pc-ring.live { animation: none; } }
@media (prefers-reduced-motion: reduce) { .lcars .pf-flow { animation: none; } }

/* ---------- buttons, forms, dialogs ---------- */
.lcars .btn {
  background: var(--m47-interactive); color: #000; border: 0; border-radius: 22px; min-height: 44px;
  padding: 0 20px; font-size: 16px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.lcars .btn:hover { background: var(--m47-bright); }
.lcars .btn:focus-visible { outline: 2px solid #000; outline-offset: -5px; }
/* secondary action: lavender outline on black */
.lcars .btn.light { background: transparent; color: var(--m47-interactive); box-shadow: none; outline: 2px solid var(--m47-interactive); outline-offset: -2px; }
.lcars .btn.light:hover { color: #000; background: var(--m47-interactive); }
.lcars .btn.light:focus-visible { outline: 2px solid var(--m47-bright); outline-offset: 2px; }
.lcars .btn.danger { background: var(--m47-alert); color: #000; }
.lcars .btn.small { padding: 0 14px; font-size: 15px; }
.lcars .btn[hidden] { display: none; }
/* range choice in the history popup: one control bank */
.lcars .range-buttons { gap: var(--frame-gap); }
.lcars .range-buttons .btn { border-radius: 0; outline: none; background: var(--m47-interactive); color: #000; }
.lcars .range-buttons .btn:first-child { border-radius: 22px 0 0 22px; }
.lcars .range-buttons .btn:last-child { border-radius: 0 22px 22px 0; }
.lcars .range-buttons .btn:not(.light) { background: var(--m47-bright); }
.lcars .range-buttons .btn:focus-visible { outline: 2px solid #000; outline-offset: -5px; }

.lcars .field label, .lcars .check { color: var(--m47-muted); font-size: 15px; }
.lcars input[type=text], .lcars input[type=password], .lcars input[type=number], .lcars input[type=email], .lcars select, .lcars textarea,
.lcars .field input[type=text], .lcars .field input[type=password], .lcars .field input[type=number], .lcars .field input[type=email],
.lcars .field select, .lcars .field textarea, .lcars .admin .inline input[type=text], .lcars .admin .inline select,
.lcars .admin .entity-row input {
  background: #000; color: var(--m47-text); border: 2px solid var(--m47-muted); border-radius: 8px; min-height: 44px;
}
.lcars input:focus-visible, .lcars select:focus-visible, .lcars textarea:focus-visible { outline: 2px solid var(--m47-bright); outline-offset: 2px; border-color: var(--m47-bright); }
.lcars input[type=checkbox] { accent-color: var(--m47-interactive); width: 20px; height: 20px; }

.lcars .admin h2 { color: var(--m47-secondary); font-size: 28px; font-weight: 500; }
.lcars .admin th { color: var(--m47-secondary); }
.lcars .admin th, .lcars .admin td { border-top-color: var(--m47-line); }
.lcars .admin .card { margin-bottom: 28px; }
.lcars .row.has-history:hover .value, .lcars .row.has-history:focus-visible .value { color: var(--m47-bright); }
/* light popup: brightness, tone and colour */
.lcars .row.has-controls > span:first-child { cursor: pointer; color: var(--m47-interactive); }   /* lavender = tap for brightness, tone, colour */
.lcars .row.has-controls > span:first-child:hover, .lcars .row.has-controls > span:first-child:focus-visible { color: var(--m47-bright); outline: none; }
.lcars .light-ctl { padding: 10px 0 4px; border-top: 1px solid var(--m47-line); }
.lcars .light-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; color: var(--m47-muted); font-family: var(--display); text-transform: uppercase; font-size: 15px; }
.lcars .light-head .value { color: var(--m47-data); font-size: 20px; }
.lcars input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; }
.lcars input[type=range]::-webkit-slider-runnable-track { height: 8px; background: var(--m47-line); border-radius: 4px; }
.lcars input[type=range]::-moz-range-track { height: 8px; background: var(--m47-line); border-radius: 4px; }
.lcars input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -11px; border-radius: 15px; background: var(--m47-interactive); border: 0; }
.lcars input[type=range]::-moz-range-thumb { width: 30px; height: 30px; border-radius: 15px; background: var(--m47-interactive); border: 0; }
.lcars input[type=range]:focus-visible { outline: none; }
.lcars input[type=range]:focus-visible::-webkit-slider-thumb { background: var(--m47-bright); }
.lcars input[type=range]:focus-visible::-moz-range-thumb { background: var(--m47-bright); }
.lcars .swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; padding: 8px 4px; }
.lcars .swatch { height: 44px; border: 0; border-radius: 22px; background: var(--sw); cursor: pointer; padding: 0; }
.lcars .swatch.on { outline: 3px solid var(--m47-bright); outline-offset: 3px; }
.lcars .swatch:focus-visible { outline: 3px solid var(--m47-text); outline-offset: 3px; }
.lcars .dialog-bg { background: rgba(0, 0, 0, .85); }
.lcars .dialog { padding-right: 12px; }
.lcars .toast { background: var(--m47-bright); color: #000; border-radius: 22px; font-weight: 600; box-shadow: none; }

/* sign in */
.lcars .login-page { background: var(--m47-ground); }
.lcars .login-box { --c: var(--m47-structure); padding-right: 0; }
.lcars .login-box > h1 { font-size: 24px; }
.lcars .login-error { background: transparent; color: var(--m47-alert); border: 2px solid var(--m47-alert); border-radius: 8px; font-family: var(--display); text-transform: uppercase; }
.lcars .login-link { color: var(--m47-secondary); text-transform: uppercase; font-family: var(--display); }
.lcars .login-ok { color: var(--m47-data); border: 2px solid var(--m47-data); border-radius: 8px; padding: 10px; font-size: 14px; margin-bottom: 16px; }
.lcars .login-note { color: var(--m47-muted); font-size: 14px; margin-bottom: 16px; }
.lcars .login-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

/* phones: narrower frame, stacked navigation */
@media (max-width: 799px) {
  .lcars .lc-frame-down { display: none; }   /* phones: tabs are a row of pills, no side rail */
  .lcars { --rail: 64px; --bar: 14px; --arm: 28px; --outer: 28px; --inner: 8px; }
  .lcars .header { min-height: 108px; padding-right: 8px; padding-left: calc(var(--rail) + var(--inner) + 10px); gap: 8px; }
  .lcars .brand { font-size: 32px; }
  .lcars .header-right > .who { font-size: 12px; padding: 0 6px; top: calc(100% - var(--bar) - 26px); }
  .lcars .icon-btn { padding: 0 12px; justify-content: center; align-items: center; }
  .lcars .icon-btn:last-of-type { margin-left: 12px; }
  .lcars .icon-btn svg { display: block; width: 20px; height: 20px; }
  .lcars .icon-btn span { display: none; }
  .lcars .container { padding: 12px 12px 24px; }
  .lcars .big-temp { font-size: 46px; }
  .lcars .chart-stats { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .lcars *, .lcars *::before, .lcars *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* door/window history popup: open periods as blocks on a timeline, then a list */
.lcars .changes-bar { position: relative; height: 22px; background: var(--m47-line); border-radius: 11px; overflow: hidden; }
.lcars .changes-bar span { position: absolute; top: 0; bottom: 0; background: var(--m47-data); }
.lcars .changes-axis { display: flex; justify-content: space-between; color: var(--m47-muted); font-size: .85em; margin: 4px 0 12px; }
.lcars .changes-summary { margin-bottom: 8px; }
.lcars .changes-list { max-height: 50vh; overflow-y: auto; }
.lcars .changes-day { color: var(--m47-secondary); text-transform: uppercase; letter-spacing: .05em; margin-top: 12px; }

/* controls card: a choice list as one connected bank (selected = bright), actions as a second bank;
   on a phone a bank stacks as a whole instead of wrapping into an ambiguous second row */
.lcars .ctl-bank { display: flex; gap: var(--frame-gap); }
.lcars .ctl-bank .btn { flex: 1 1 0; min-height: 44px; border-radius: 0; outline: none; background: var(--m47-interactive); color: #000; }
.lcars .ctl-bank .btn:first-child { border-radius: 22px 0 0 22px; }
.lcars .ctl-bank .btn:last-child { border-radius: 0 22px 22px 0; }
.lcars .ctl-bank .btn:only-child { border-radius: 22px; }
.lcars .ctl-bank:not(.ctl-actions) .btn:not(.light) { background: var(--m47-bright); }
.lcars .ctl-bank .btn:focus-visible { outline: 2px solid #000; outline-offset: -5px; }
.lcars .ctl-bank .btn:disabled { opacity: .5; }
@media (max-width: 599px) {
  .lcars .ctl-bank:not(.ctl-actions) { flex-direction: column; }
  .lcars .ctl-bank:not(.ctl-actions) .btn:first-child { border-radius: 22px 22px 0 0; }
  .lcars .ctl-bank:not(.ctl-actions) .btn:last-child { border-radius: 0 0 22px 22px; }
}

/* two-handle slider (floor and ceiling): two range inputs on one track, only the handles take
   touches; the part between the handles is filled in data blue */
.lcars .dual { position: relative; height: 44px; }
.lcars .dual-track { position: absolute; left: 0; right: 0; top: 18px; height: 8px; background: var(--m47-line); border-radius: 4px; }
.lcars .dual-fill { position: absolute; top: 18px; height: 8px; background: var(--m47-data); }
.lcars .dual input[type=range] { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.lcars .dual input[type=range]::-webkit-slider-runnable-track { background: transparent; }
.lcars .dual input[type=range]::-moz-range-track { background: transparent; }
.lcars .dual input[type=range]::-webkit-slider-thumb { pointer-events: auto; position: relative; z-index: 3; }
.lcars .dual input[type=range]::-moz-range-thumb { pointer-events: auto; }

/* the current value (e.g. the car's charge) on a floor/ceiling slider: a bright pin across the track */
.lcars .dual-now { position: absolute; top: 9px; width: 6px; height: 26px; border-radius: 3px; background: var(--m47-bright); z-index: 0; }
.lcars .light-head .value.now { color: var(--m47-bright); }

/* the current value on a floor/ceiling slider opens its history: lavender name = tappable */
.lcars .now-tap { cursor: pointer; }
.lcars .now-tap > span:first-child { color: var(--m47-interactive); }
.lcars .now-tap:hover > span:first-child, .lcars .now-tap:focus-visible > span:first-child { color: var(--m47-bright); }
