@font-face { font-family: "Barlow SC"; src: url(fonts/barlow-sc-Regular.woff) format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow SC"; src: url(fonts/barlow-sc-Medium.woff) format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow SC"; src: url(fonts/barlow-sc-SemiBold.woff) format("woff"); font-weight: 600; font-display: swap; }

/* Anodized-aluminum faceplate: grey metal, screen-printed ink, one amber "energized" signal. */
:root {
  --bg: #DDE2E6;
  --panel: #EEF1F3;
  --panel-2: #E5E9EC;
  --ink: #1D2733;
  --ink-2: #5E6B78;
  --line: #C3CAD1;
  --amber: #E8A10C;
  --amber-soft: #F6DFA8;
  --ok: #2E9E5B;
  --bad: #C2412D;
  --hole: #B7BFC7;
  --cell: 76px;
  --gap: 12px;
  --display: "Barlow SC", "Arial Narrow", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Dark: chosen explicitly, or following the system unless Light was chosen. */
:root[data-theme="dark"] { 
    --bg: #161B20;
    --panel: #1F252C;
    --panel-2: #262D35;
    --ink: #E3E8EC;
    --ink-2: #8E9AA6;
    --line: #313A44;
    --amber: #F0B03A;
    --amber-soft: #5A4519;
    --ok: #47B877;
    --bad: #E0644F;
    --hole: #2C343D;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { 
    --bg: #161B20;
    --panel: #1F252C;
    --panel-2: #262D35;
    --ink: #E3E8EC;
    --ink-2: #8E9AA6;
    --line: #313A44;
    --amber: #F0B03A;
    --amber-soft: #5A4519;
    --ok: #47B877;
    --bad: #E0644F;
    --hole: #2C343D;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
a { color: inherit; }

/* ---------- top bar ---------- */
.bar { display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 56px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20; }
.mark { font: 600 22px/1 var(--display); letter-spacing: .01em; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.mark i { width: 12px; height: 12px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tab { font: 500 16px/1 var(--display); padding: 10px 12px; border-radius: 6px; text-decoration: none; color: var(--ink-2); white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-current] { color: var(--ink); background: var(--panel-2); }
.bar-right { display: flex; gap: 8px; align-items: center; margin-left: auto; }

.btn { text-decoration: none; border: 1px solid var(--line); background: var(--panel); padding: 7px 14px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.btn.on { background: var(--amber); border-color: var(--amber); color: #1D2733; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- pages ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 24px 20px 80px; }
.page h1 { font: 600 30px/1.1 var(--display); margin: 0 0 4px; }
.page .lead { color: var(--ink-2); margin: 0 0 24px; max-width: 60ch; }
.head-row { display: flex; align-items: end; gap: 16px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 20px; }

.auth { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.auth form { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.auth .mark { font-size: 30px; margin-bottom: 6px; }
.auth p { color: var(--ink-2); margin: 0 0 20px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=time], select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
}
input:focus, select:focus { outline: none; border-color: var(--ink); }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 4px 0 8px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- devices ---------- */
.devlist { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.dev { display: grid; grid-template-columns: 18px 1fr auto auto; gap: 14px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line); }
.dev:first-child { border-top: 0; }
.dev .name { font: 500 18px/1.2 var(--display); }
.dev .meta { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--hole); }
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.creds { background: var(--panel); border: 1px solid var(--amber); border-radius: 10px; padding: 18px 20px; margin-bottom: 20px; }
.creds h2 { font: 600 20px/1.2 var(--display); margin: 0 0 4px; }
.creds p { margin: 0 0 12px; color: var(--ink-2); }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow-x: auto; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; margin: 0 0 10px; user-select: all; }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty strong { display: block; font: 600 22px/1.2 var(--display); color: var(--ink); margin-bottom: 6px; }

/* ---------- dashboard grid ---------- */
.board-wrap { position: relative; }
.board { position: relative; display: grid; grid-template-columns: repeat(12, 1fr); grid-auto-rows: var(--cell); gap: var(--gap); min-height: calc(var(--cell) * 6); }
/* Edit mode shows the perfboard: one hole per grid cell. */
.editing .board { background-image: radial-gradient(circle at center, var(--hole) 0 3px, transparent 3.5px); background-size: calc((100% + var(--gap)) / var(--icols, 12)) calc(var(--cell) + var(--gap)); background-position: calc(-1 * var(--gap) / 2) calc(-1 * var(--gap) / 2); }

.w { container-type: size; position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 30px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.w-label { position: absolute; left: 14px; bottom: 9px; right: 50px; font: 500 14px/1 var(--display); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-pin { position: absolute; right: 12px; bottom: 9px; font: 500 12px/1 var(--display); color: var(--ink-2); opacity: .7; font-variant-numeric: tabular-nums; }
.w.offline .w-pin::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--bad); margin-right: 5px; vertical-align: 1px; }
.w-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }

.editing .w { cursor: grab; border-style: dashed; border-color: var(--ink-2); touch-action: none; }
.editing .w.drag { cursor: grabbing; opacity: .85; z-index: 5; box-shadow: 0 8px 24px rgba(20, 30, 40, .2); }
.editing .w.sel { border-color: var(--amber); border-style: solid; box-shadow: 0 0 0 2px var(--amber); }
.editing .w .w-body * { pointer-events: none; }
.editing .w .resize { pointer-events: auto; }
/* inside a tabs widget, its tab buttons and child widgets stay interactive while editing */
.editing .tabsw .tabbar .tab-btn, .editing .tabsw .board > .w, .editing .tabsw .board > .w .resize { pointer-events: auto; }
.editing .tabsw .board > .w .w-body * { pointer-events: none; }
.resize { display: none; position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; }
.resize::after { content: ""; position: absolute; right: 5px; bottom: 5px; width: 8px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); }
.editing .resize { display: block; }
.editing .w-pin { right: 28px; }
/* Tiny widgets (1 cell): drop the pin badge, keep the label readable. */
@container (max-width: 110px) {
  .w-pin { display: none; }
  .w-label { right: 0; font-size: 12px; bottom: 7px; }
}
.ghost-cell { border: 2px dashed var(--amber); border-radius: 8px; pointer-events: none; z-index: 1; }

/* ---------- widgets ---------- */
.w { --w-accent: var(--amber); }
.w-body { color: var(--w-text, inherit); }
.big { font: 500 clamp(16px, min(22cqw, 38cqh), 60px)/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.big small { font-size: .45em; color: var(--ink-2); margin-left: 4px; letter-spacing: 0; }
.na { color: var(--ink-2); }

/* Button: shape-* sets the outline, look-* the style. --k-on / --k-off come from the widget colors. */
.key { --k-on: var(--w-accent); width: 100%; height: 100%; max-height: 120px; border: 1px solid var(--line); border-radius: 8px; background: var(--k-off, var(--panel-2)); color: var(--k-off-text, var(--ink)); cursor: pointer; font: 600 18px/1 var(--display); display: flex; align-items: center; justify-content: center; gap: 10px; transition: background .12s, border-color .12s, box-shadow .12s, transform .06s; user-select: none; touch-action: manipulation; }
.key.shape-square { border-radius: 3px; }
.key.shape-circle { border-radius: 50%; width: auto; max-width: 100%; aspect-ratio: 1; max-height: 100%; }
.key:active { transform: translateY(1px); }
.key.look-indicator::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--hole); transition: background .12s, box-shadow .12s; flex: none; }
.key.look-indicator.on { border-color: var(--k-on); }
.key.look-indicator.on::before { background: var(--k-on); box-shadow: 0 0 0 4px color-mix(in srgb, var(--k-on) 30%, transparent), 0 0 14px var(--k-on); }
.key.look-flat { border-color: transparent; }
.key.look-flat.on { background: var(--k-on); color: var(--k-on-text); }
.key.look-outline { background: transparent; border: 2px solid var(--k-off, var(--line)); color: var(--ink-2); }
.key.look-outline.on { border-color: var(--k-on); color: var(--k-on); background: color-mix(in srgb, var(--k-on) 10%, transparent); }
.key.look-raised { border: 0; box-shadow: 0 5px 0 var(--k-off-edge, var(--line)); margin-bottom: 5px; height: calc(100% - 5px); }
.key.look-raised.on { background: var(--k-on); color: var(--k-on-text); box-shadow: 0 5px 0 var(--k-on-edge); }
.key.look-raised:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--k-off-edge, var(--line)); }
.key.look-raised.on:active { box-shadow: 0 1px 0 var(--k-on-edge); }

.slider { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.slider .big { font-size: clamp(22px, 3vw, 34px); }
input[type=range] { width: 100%; accent-color: var(--w-accent, var(--amber)); height: 28px; }

.gauge { width: 100%; height: 100%; }
.gauge .track { stroke: var(--panel-2); }
.gauge .fill { stroke: var(--w-accent); transition: stroke-dashoffset .3s; }
.gauge text { fill: var(--w-text, var(--ink)); font-family: var(--display); font-variant-numeric: tabular-nums; }
.gauge .lim { fill: var(--ink-2); font-size: 11px; }

.led { width: 40%; max-width: 64px; aspect-ratio: 1; border-radius: 50%; background: var(--hole); border: 3px solid var(--panel-2); transition: background .15s, box-shadow .15s; }
.led.on { background: var(--c, var(--amber)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--amber)) 30%, transparent), 0 0 22px var(--c, var(--amber)); }

.prog { width: 100%; }
.prog .big { font-size: clamp(20px, 2.6vw, 30px); margin-bottom: 8px; }
.prog .track { height: 14px; background: var(--panel-2); border-radius: 7px; overflow: hidden; border: 1px solid var(--line); }
.prog .fill { height: 100%; background: var(--w-accent); width: 0; transition: width .3s; }

.graph { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 4px; }
.graph-head { display: flex; justify-content: space-between; align-items: baseline; }
.graph-head .big { font-size: clamp(18px, 2vw, 26px); }
.graph-head .rng { font: 500 13px/1 var(--display); color: var(--ink-2); }
.graph canvas { flex: 1; min-height: 0; width: 100%; }

.term { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 6px; }
.term-out { flex: 1; min-height: 0; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: 13px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.term-out .in { color: var(--ink-2); }
.term input { font: 13px ui-monospace, Menlo, Consolas, monospace; padding: 6px 8px; }

.log { width: 100%; height: 100%; overflow-y: auto; font-size: 13px; }
.log div { display: flex; gap: 10px; padding: 3px 0; border-bottom: 1px solid var(--panel-2); }
.log time { color: var(--ink-2); font-variant-numeric: tabular-nums; flex: none; }
.log span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* input + menu widgets */
.inputw { width: 100%; }
.input-row { display: flex; gap: 6px; align-items: center; }
.input-row input { flex: 1; min-width: 0; font: 500 clamp(16px, min(9cqw, 22cqh), 26px)/1.2 var(--display); font-variant-numeric: tabular-nums; padding: 8px 10px; }
.input-row input:focus { border-color: var(--w-accent); }
.input-row input[aria-invalid=true] { border-color: var(--bad); }
.input-row .unit { color: var(--ink-2); font: 500 16px var(--display); }
.step { flex: none; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); font: 600 20px/1 var(--display); cursor: pointer; }
.step:active { background: var(--w-accent); color: #1D2733; }
.input-msg { min-height: 18px; font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.input-row:has([aria-invalid=true]) + .input-msg { color: var(--bad); }
.segs { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.seg { flex: 1 1 0; min-width: 56px; padding: 10px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); font: 500 15px/1 var(--display); cursor: pointer; }
.seg[aria-pressed=true] { background: var(--w-accent); border-color: var(--w-accent); color: #1D2733; }
.menuw { width: 100%; }

/* multi-pin graph legend */
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
.lg { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 2px 0; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.lg i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.lg b { font: 500 15px var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.lg[aria-pressed=false] { opacity: .4; text-decoration: line-through; }

/* ---------- editor drawer ---------- */
.drawer { position: fixed; top: 56px; right: 0; bottom: 0; width: 320px; background: var(--panel); border-left: 1px solid var(--line); padding: 18px; overflow-y: auto; z-index: 15; }
.drawer h2 { font: 600 20px/1.2 var(--display); margin: 0 0 12px; }
.drawer h3 { font: 500 15px/1.2 var(--display); color: var(--ink-2); margin: 20px 0 8px; }
/* while editing, the board is centred in the space left of the side panel */
.editing .edit-area { padding-right: 320px; }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette button { text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); cursor: pointer; }
.palette button:hover { border-color: var(--ink-2); }
.palette b { display: block; font: 500 16px/1.2 var(--display); }
.palette small { color: var(--ink-2); font-size: 12px; }
.drawer-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.drawer textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; resize: vertical; }
.hint { display: block; color: var(--ink-2); font-size: 12px; margin: 4px 0 8px; }
label.check { display: flex; gap: 8px; align-items: center; margin: 8px 0 14px; font-size: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.sw[aria-pressed=true] { box-shadow: 0 0 0 2px var(--ink); }
.sw-default { background: conic-gradient(var(--amber) 0 50%, var(--panel-2) 0 100%); }
.swatches input[type=color], .range-row input[type=color], .series-row input[type=color] { width: 34px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); cursor: pointer; }
.range-row { display: grid; grid-template-columns: 1fr auto 1fr 40px 30px; gap: 6px; align-items: center; margin-bottom: 6px; }
.range-row .btn, .series-row .btn { padding: 4px 8px; }
.series-row { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; display: grid; gap: 6px; background: var(--bg); }
.series-row .row { align-items: center; }
.series-row select, .series-row input[type=text] { background: var(--panel); }

/* modal dialogs */
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); padding: 22px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(15, 20, 25, .45); }
dialog h2 { font: 600 22px/1.2 var(--display); margin: 0 0 6px; }
dialog p { color: var(--ink-2); margin: 0 0 14px; }
dialog .warn { color: var(--bad); }
dialog .drawer-actions { justify-content: flex-end; }

/* users page */
.badge { display: inline-block; font: 500 12px/1 var(--display); padding: 3px 7px; border-radius: 4px; background: var(--panel-2); color: var(--ink-2); margin-left: 6px; vertical-align: 2px; }
.badge.admin { background: var(--amber-soft); color: var(--ink); }
.badge.off { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.adduser { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 10px; align-items: center; max-width: 720px; }
@media (max-width: 760px) { .adduser { grid-template-columns: 1fr; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 8px; z-index: 50; font-size: 14px; }
.conn { font-size: 13px; color: var(--bad); }

/* ---------- small screens: widgets flow in 4 columns ---------- */
@media (max-width: 760px) {
  :root { --cell: 64px; --gap: 10px; }
  .bar { gap: 4px 10px; padding: 8px 12px 0; height: auto; flex-wrap: wrap; }
  .mark { font-size: 20px; }
  .bar-right { flex-wrap: nowrap; justify-content: flex-end; gap: 4px; margin-left: auto; min-width: 0; }
  .bar-right .btn { padding: 6px 10px; font-size: 15px; }
  .layout-pick { max-width: 120px; }
  .menu-btn { display: inline-flex; font-size: 20px; line-height: 1; padding: 4px 10px !important; }
  .bar-links { display: none; }
  .bar.menu-open .bar-links { display: flex; flex-direction: column; align-items: stretch; position: absolute; top: calc(100% - 2px); right: 8px; min-width: 200px; padding: 6px; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 20, 25, .25); z-index: 30; }
  .bar.menu-open .bar-links .btn { text-align: left; padding: 10px 12px; font-size: 16px; }
  .bar.menu-open .bar-links .theme-btn { width: auto; height: auto; justify-content: flex-start; gap: 8px; }
  .bar.menu-open .bar-links .theme-btn::after { content: 'Theme'; }
  body { overflow-x: hidden; }
  .tabs { order: 3; flex-basis: 100%; padding-bottom: 6px; }
  .drawer { width: 100%; top: auto; height: var(--sheet, 45vh); border-left: 0; border-top: 1px solid var(--line); padding-top: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -8px 24px rgba(15, 20, 25, .18); overscroll-behavior: contain; }
  body.sheet-min .drawer { overflow: hidden; }
  .sheet-handle { display: flex; position: sticky; top: 0; z-index: 2; width: calc(100% + 36px); margin: 0 -18px 12px; height: 46px; align-items: center; gap: 10px; padding: 14px 18px 6px; border: 0; border-bottom: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 600 16px var(--display); cursor: ns-resize; touch-action: none; text-align: left; }
  .sheet-handle .grip { position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--ink-2); opacity: .5; }
  .sheet-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sheet-arrow::before { content: '▾'; color: var(--ink-2); }
  body.sheet-min .sheet-arrow::before { content: '▴'; }
  .editing .edit-area { padding-right: 0; }
  .editing .page { padding-bottom: calc(var(--sheet, 45vh) + 24px); }
  /* the page scrolls when a finger starts on a widget; only the selected one moves */
  .editing .w { touch-action: pan-x pan-y; }
  .editing .w.sel, .editing .resize { touch-action: none; }
  .dev { grid-template-columns: 14px 1fr auto; }
  .dev .meta-wide { display: none; }
  .page { padding: 16px 12px 60px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
a.btn[aria-current] { background: var(--panel-2); }

/* pins page */
.pinrow { display: grid; grid-template-columns: 56px minmax(0, 1fr) 90px minmax(0, 150px) 190px 64px; gap: 12px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--line); }
.pinrow:first-child { border-top: 0; }
.pinhead { font-size: 13px; color: var(--ink-2); padding-top: 12px; padding-bottom: 8px; }
.pin-no { font: 600 17px var(--display); font-variant-numeric: tabular-nums; }
.pin-val { display: flex; flex-direction: column; min-width: 0; font-variant-numeric: tabular-nums; }
.pin-val span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-val small { color: var(--ink-2); font-size: 12px; }
.pinrow .hint { margin: 3px 0 0; }
@media (max-width: 760px) {
  .pinrow { grid-template-columns: 44px 1fr 72px; padding: 10px 12px; }
  .pinrow > :nth-child(4), .pinrow > :nth-child(5), .pinrow > :nth-child(6) { grid-column: 2 / -1; }
  .pinhead { display: none; }
}

/* theme button */
.theme-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 34px; padding: 0; }
.theme-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* full-screen dashboard: no bar, edge to edge, rows sized to fit the screen */
body.kiosk .page { max-width: none; margin: 0; padding: var(--gap); }
body.kiosk { overflow-x: hidden; }
.kiosk-exit { position: fixed; top: 10px; right: 10px; z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.kiosk-exit.show { opacity: 1; pointer-events: auto; }
body.kiosk .board { min-height: 0; }

/* graph widget: expand button, crosshair */
.graph canvas { cursor: crosshair; }
.graph-head .rng { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.expand { border: 1px solid var(--line); background: var(--panel-2); border-radius: 5px; width: 24px; height: 22px; padding: 0; cursor: pointer; color: var(--ink-2); font-size: 13px; line-height: 1; }
.expand:hover { color: var(--ink); border-color: var(--ink-2); }

/* history viewer */
.hv { position: fixed; inset: 0; z-index: 60; background: rgba(15, 20, 25, .55); display: grid; place-items: center; padding: 20px; }
.hv-panel { width: min(1400px, 100%); height: min(860px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.hv-top { display: flex; align-items: center; justify-content: space-between; }
.hv-top h2 { font: 600 22px/1.2 var(--display); margin: 0; }
.hv-top .btn { font-size: 22px; line-height: 1; padding: 4px 12px; }
.hv-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.hv-presets { width: auto; flex-wrap: nowrap; }
.hv-presets .seg { flex: none; min-width: 48px; padding: 8px 10px; }
.hv-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hv-nav input[type=date] { width: auto; padding: 6px 8px; }
.hv-chart { flex: 1; min-height: 0; position: relative; }
.hv-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.hv-canvas:active { cursor: grabbing; }
.hv-status { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; min-height: 18px; }
@media (max-width: 760px) {
  .hv { padding: 0; }
  .hv-panel { border-radius: 0; height: 100%; padding: 12px; }
  .hv-presets { overflow-x: auto; width: 100%; }
}
.hv { --w-accent: var(--amber); }

/* color widget */
.cp { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.cp-head { display: flex; align-items: center; gap: 10px; position: relative; }
.cp-preview { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line), 0 2px 10px rgba(0,0,0,.15); cursor: pointer; flex: none; }
.cp-native { position: absolute; left: 0; top: 0; width: 38px; height: 38px; opacity: 0; pointer-events: none; }
.cp-code { font: 500 16px var(--display); font-variant-numeric: tabular-nums; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp input[type=range] { -webkit-appearance: none; appearance: none; height: 16px; border-radius: 8px; background: var(--track, var(--panel-2)); border: 1px solid var(--line); margin: 0; accent-color: auto; }
.cp-hue { --track: linear-gradient(90deg, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00); }
.cp input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid #1D2733; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: pointer; }
.cp input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid #1D2733; cursor: pointer; }
.cp-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.cp-swatches .sw { width: 22px; height: 22px; }
@container (max-height: 150px) { .cp-swatches { display: none; } }

/* tabs widget */
.w-tabs { padding: 0 0 26px; }
.w-tabs > .w-body { display: block; }
.tabsw { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.tabbar { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.tab-btn { border: 0; background: none; padding: 8px 12px; font: 500 15px/1 var(--display); color: var(--ink-2); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tab-btn[aria-selected=true] { color: var(--ink); border-bottom-color: var(--w-accent); }
.tab-scroll { flex: 1; min-height: 0; overflow: auto; padding: var(--gap); }
.board.inner { min-height: 0; }
.editing .board.inner { background-image: radial-gradient(circle at center, var(--hole) 0 3px, transparent 3.5px); background-size: calc((100% + var(--gap)) / var(--icols, 4)) calc(var(--cell) + var(--gap)); }
.tab-empty { color: var(--ink-2); font-size: 13px; padding: 8px 2px; }
.w-tabs > .w-label { bottom: 6px; }

/* device selector */
.selector { font: 500 16px var(--display); }

/* editor */
.layoutbar { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.layoutbar .field { margin-bottom: 8px; }
.layoutbar .row .btn { flex: 1; }
.layout-pick { width: auto; padding: 6px 8px; font-size: 14px; }
.hidden-list { display: flex; flex-wrap: wrap; gap: 6px; }
.sel-list { margin: 0 0 8px; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.dev-checks .check { margin: 4px 0; }
.tab-row { grid-template-columns: 1fr 34px 34px; }
.w-selector { padding: 8px 12px 24px; }
.w-selector .selector { padding: 4px 8px; height: 34px; }
.w-selector .w-label { bottom: 6px; }

/* dragging into / out of tabs */
.editing .w.drag-out { opacity: .45; }
.editing .w.drop-into { border-color: var(--amber); border-style: solid; box-shadow: 0 0 0 3px var(--amber), 0 0 0 9px color-mix(in srgb, var(--amber) 22%, transparent); }
.editing .w.drop-into .tab-scroll { background: color-mix(in srgb, var(--amber) 10%, transparent); }
.editing .board.drop-into { outline: 3px dashed var(--amber); outline-offset: 4px; border-radius: 8px; }
.tab-btn.drop-into { background: var(--amber); color: #1D2733; border-radius: 6px 6px 0 0; }
.ghost-cell { background: color-mix(in srgb, var(--amber) 18%, transparent); }

/* ---------- settings ---------- */
.settings .card, .card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 20px; max-width: 760px; }
.card h2 { font: 600 20px/1.2 var(--display); margin: 0 0 10px; }
.card h3 { font: 600 16px/1.2 var(--display); margin: 20px 0 6px; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > * { min-width: 200px; }
.tg-ok { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; flex: 1 0 auto !important; }
.tg-ok code, .chat-row code { font: 13px ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.chats { margin-top: 12px; }
.chat-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.chat-row:first-child { border-top: 0; }
.chat-row .name { font: 500 16px/1.2 var(--display); }
.chat-row .meta { color: var(--ink-2); font-size: 13px; }
@media (max-width: 640px) { .chat-row { grid-template-columns: 1fr auto; } }

/* ---------- share dialog ---------- */
.shares { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.share-row { display: grid; grid-template-columns: 1fr 150px auto; gap: 8px; align-items: center; }
.share-add { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; margin-top: 8px; }

/* ---------- server-side widgets ---------- */
.dot.bad { background: var(--bad); }
.srv, .bridge, .notify { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.srv-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.srv-state { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-state .dot { flex: none; width: 8px; height: 8px; }
.srv-test { padding: 3px 10px; font-size: 13px; flex: none; }
.srv-log { flex: 1; }
.log .fail span { color: var(--bad); }
.bridge, .notify { justify-content: center; }
.bridge-route { display: flex; align-items: center; gap: 8px; font: 500 14px/1.2 var(--display); color: var(--ink-2); min-width: 0; }
.bridge-route span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bridge-route b { color: var(--w-accent); font-size: 18px; }
.bridge .big { font-size: clamp(18px, min(16cqw, 30cqh), 40px); }
.notify-last { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notify-last time { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.notify .btn { align-self: flex-start; padding: 4px 10px; font-size: 13px; }
.notify .srv-state { white-space: normal; align-items: flex-start; }
.notify .srv-state .dot { margin-top: 5px; }

/* ---------- background widgets ---------- */
.bg-list { display: flex; flex-direction: column; gap: 6px; }
.bg-item { display: grid; grid-template-columns: 10px 1fr; column-gap: 10px; align-items: center; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); cursor: pointer; color: inherit; font: inherit; }
.bg-item:hover { border-color: var(--ink-2); }
.bg-item b { font: 500 15px/1.2 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bg-item small { grid-column: 2; color: var(--ink-2); font-size: 12px; }
.activity { height: 260px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel); display: flex; container-type: size; --w-accent: var(--amber); }
.activity > * { flex: 1; }
.activity .big { font-size: 28px; }
dialog.wview { width: min(620px, calc(100% - 32px)); }
.wview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.wview-head h2 { margin: 0; }
.wview-head .btn { font-size: 20px; line-height: 1; padding: 4px 10px; }
.activity.popup { height: min(60vh, 440px); }

.w-compact .w-body { align-items: stretch; }
.ctile { width: 100%; height: 100%; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0; border-radius: 6px; }
.ctile:hover { background: var(--panel-2); }
.ct-top { position: relative; display: block; }
.ct-icon { width: 26px; height: 26px; fill: none; stroke: var(--w-accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.w-telegram .ct-icon path { fill: var(--w-accent); stroke: none; }
.ct-top .dot { position: absolute; right: -6px; top: -4px; width: 9px; height: 9px; border: 2px solid var(--panel); box-sizing: content-box; }
.ct-text { font: 500 13px/1 var(--display); color: var(--ink-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.w-compact { padding: 6px 6px 24px; }
.w-compact .w-label { left: 6px; right: 6px; bottom: 7px; font-size: 12px; text-align: center; }
.w-compact .w-pin { display: none; }
.bg-list { margin-bottom: 22px; }

.pin-hist { display: flex; flex-direction: column; font-size: 13px; font-variant-numeric: tabular-nums; align-items: flex-start; }
.pin-hist small { color: var(--ink-2); font-size: 12px; }
.linkish { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; color: var(--ink-2); }
.linkish.danger { color: var(--bad); }

/* ---------- server page ---------- */
.server .card { max-width: none; }
.server-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; align-items: start; }
.server-cols .card { margin-bottom: 0; }
.server-cols + .card { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat span { font: 500 13px/1.2 var(--display); color: var(--ink-2); }
.stat b { font: 500 26px/1.15 var(--display); font-variant-numeric: tabular-nums; }
.stat small { color: var(--ink-2); font-size: 12px; }
.stat.bad { border-color: var(--bad); }
.stat.bad b { color: var(--bad); }
.chart-card canvas { width: 100%; height: 200px; display: block; }
.chart-card .legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); }
.chart-card .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-card .lg i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font: 500 13px var(--display); color: var(--ink-2); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--panel-2); white-space: nowrap; }
.tbl td.actions { text-align: right; }
.tbl td.actions .btn { padding: 4px 9px; font-size: 13px; }
.tbl .dot { display: inline-block; }
.bad-text { color: var(--bad); text-decoration: underline dotted; cursor: help; }
.row.wrap3 { flex-wrap: wrap; }
.row.wrap3 > * { min-width: 120px; }
.staged { border-color: var(--amber); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; word-break: break-all; }
.tbl td small.hint { display: inline; margin: 0; }

/* clock widget */
.clock { width: max-content; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; white-space: nowrap; flex: none; transform-origin: center; }
.clock-time { font: 500 30px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; color: var(--w-text, var(--ink)); }
.clock-date { font: 500 12px/1.2 var(--display); color: var(--ink-2); }
.clock-zone { font-size: 9px; color: var(--ink-2); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack .card { margin-bottom: 0; }
.server-cols + .server-cols { margin-top: 20px; }
select.mini { font-size: 12px; padding: 2px 4px; margin: 3px 0; width: 100%; max-width: 200px; }
.tabs { min-width: 0; overflow: hidden; }
.tab-more { color: var(--ink); white-space: nowrap; }
.proj-menu { position: fixed; z-index: 40; width: 280px; max-height: min(70vh, 480px); display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 20, 25, .2); }
.proj-menu input { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: inherit; }
.proj-list { overflow-y: auto; display: flex; flex-direction: column; }
.proj-list a { padding: 8px 10px; border-radius: 6px; text-decoration: none; font: 500 16px/1.2 var(--display); color: var(--ink); }
.proj-list a:hover, .proj-list a.cur { background: var(--panel-2); }
.help-btn { padding: 4px 10px; font-size: 13px; }
dialog.wide { width: min(760px, calc(100% - 32px)); }
.code-wrap { position: relative; }
.code-wrap pre.code { white-space: pre; max-height: 50vh; overflow: auto; user-select: text; padding-right: 64px; }
.code-copy { position: absolute; top: 6px; right: 6px; padding: 3px 9px; font-size: 12px; background: var(--panel); }
.guide { display: grid; grid-template-columns: 150px 1fr; gap: 16px; min-height: 340px; }
.guide-list { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); padding-right: 10px; overflow-y: auto; max-height: 60vh; }
.guide-list button { text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 6px; cursor: pointer; font: 500 15px/1.2 var(--display); color: var(--ink-2); }
.guide-list button[aria-selected="true"] { background: var(--panel-2); color: var(--ink); }
.guide-body h3 { margin: 0 0 6px; font: 600 18px/1.2 var(--display); }
@media (max-width: 640px) { .guide { grid-template-columns: 1fr; } .guide-list { flex-direction: row; flex-wrap: wrap; border-right: 0; max-height: none; } }

/* ---------- display styles ---------- */
/* 7-segment and LCD */
.segwrap { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 2px; }
.segdisp { flex: 1; height: 100%; max-height: 120px; min-width: 0; display: flex; align-items: center; justify-content: center; border-radius: 6px; padding: 6% 5%; }
.segwrap.seg7 .segdisp { background: #0C0E11; box-shadow: inset 0 2px 6px rgba(0,0,0,.6); }
.seg7 { width: 100%; height: 100%; overflow: visible; }
.segwrap.seg7 .seg7 .on { fill: var(--seg, var(--w-accent)); filter: drop-shadow(0 0 3px var(--seg, var(--w-accent))); }
.segwrap.seg7 .seg7 .off { fill: var(--seg, var(--w-accent)); opacity: .07; }
.segwrap.lcd .segdisp { background: linear-gradient(180deg, #C5D3A4, #AFBF8C); box-shadow: inset 0 2px 5px rgba(0,0,0,.35); border: 2px solid #5D6650; }
.segwrap.lcd .seg7 .on { fill: var(--seg, #1C2614); }
.segwrap.lcd .seg7 .off { fill: #1C2614; opacity: .07; }
.seg-unit { font: 500 clamp(12px, 9cqh, 20px)/1 var(--display); color: var(--ink-2); align-self: flex-end; margin-bottom: 8%; }

/* digit boxes */
.flipwrap { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 100%; }
.flipdigits { display: flex; gap: 4px; align-items: center; font: 600 min(46cqh, 21cqw, 64px)/1 var(--display); }
.flipdigits .cell { position: relative; display: flex; align-items: center; justify-content: center; min-width: .72em; padding: .12em .1em; border-radius: 6px; background: linear-gradient(180deg, #2B323B 0 50%, #232931 50% 100%); color: var(--flip, #F4F6F8); font: inherit; font-variant-numeric: tabular-nums; box-shadow: 0 2px 4px rgba(0,0,0,.25); }
.flipdigits .cell::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0,0,0,.55); }
.flipdigits .sep { display: flex; align-items: center; color: var(--ink-2); }
.flip-unit { font: 500 clamp(12px, 10cqh, 20px)/1 var(--display); color: var(--ink-2); align-self: flex-end; margin-bottom: 6%; }

/* colored tile */
.vtile { width: 100%; height: 100%; border-radius: 6px; background: var(--tile, var(--w-accent)); color: #1D2733; display: flex; align-items: center; justify-content: center; transition: background .3s; }
.vtile .big small { color: inherit; opacity: .75; }

/* gauge styles */
.gauge.dial .face { fill: var(--panel-2); stroke: var(--line); }
.gauge .tick { stroke: var(--ink-2); stroke-width: .8; }
.gauge .tick.major { stroke: var(--ink); stroke-width: 1.6; }
.gauge.dial .lim { font-size: 8px; }
.gauge .needle { transition: transform .5s cubic-bezier(.3, 1.4, .5, 1); }
.gauge .needle path { fill: var(--w-accent); }
.gauge .needle circle { fill: var(--ink); }
.gauge.segs .seg { stroke: var(--panel-2); transition: stroke .2s; }
.gauge.segs .seg.on { stroke: var(--w-accent); }
.gauge.ring .fill, .gauge.half .fill { transition: stroke-dashoffset .3s; }

/* LED styles */
.ledwrap { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.ledicon { height: 90%; width: auto; max-width: 100%; max-height: 120px; overflow: visible; transition: filter .2s; }
.ledwrap.on .ledicon { filter: drop-shadow(0 0 7px var(--c)) drop-shadow(0 0 2px var(--c)); }
.ledicon.icon-led .body, .ledicon.icon-led .rim { fill: color-mix(in srgb, var(--c) 30%, #6B7178); transition: fill .15s; }
.ledicon.icon-led .rim { filter: brightness(.85); }
.ledwrap.on .ledicon.icon-led .body, .ledwrap.on .ledicon.icon-led .rim { fill: var(--c); }
.ledicon .leg { fill: #A3ABB4; }
.ledicon .shine { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; opacity: .45; }
.ledicon.icon-bulb .body { fill: rgba(190, 200, 210, .22); stroke: var(--ink-2); stroke-width: 1.5; transition: fill .15s; }
.ledwrap.on .ledicon.icon-bulb .body { fill: color-mix(in srgb, var(--c) 75%, #fff); stroke: color-mix(in srgb, var(--c) 70%, #000); }
.ledicon.icon-bulb .filament { fill: none; stroke: #7E858D; stroke-width: 1.6; stroke-linejoin: round; }
.ledwrap.on .ledicon.icon-bulb .filament { stroke: #FFF7D6; }
.ledicon.icon-bulb .base { fill: #9AA3AD; }
.lamp { width: min(78%, 74px); aspect-ratio: 1; border-radius: 50%; padding: 12%; background: radial-gradient(circle at 35% 30%, #E9EDF0, #8D959E 60%, #5E656D); box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.lamp i { display: block; width: 100%; height: 100%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.35), transparent 40%), color-mix(in srgb, var(--c) 22%, #1C2128); box-shadow: inset 0 2px 5px rgba(0,0,0,.6); transition: background .15s, box-shadow .15s; }
.ledwrap.on .lamp i { background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.7), transparent 45%), var(--c); box-shadow: inset 0 -2px 6px rgba(0,0,0,.25), 0 0 16px var(--c); }
.ringled { width: min(62%, 64px); aspect-ratio: 1; border-radius: 50%; border: 6px solid color-mix(in srgb, var(--c) 22%, var(--panel-2)); transition: border-color .15s, box-shadow .15s; }
.ledwrap.on .ringled { border-color: var(--c); box-shadow: 0 0 12px var(--c), inset 0 0 10px color-mix(in srgb, var(--c) 60%, transparent); }
.textled { padding: 6px 14px; border-radius: 999px; font: 600 clamp(13px, 22cqh, 22px)/1 var(--display); letter-spacing: .04em; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); transition: background .15s, color .15s; white-space: nowrap; }
.ledwrap.on .textled { background: var(--c); color: #fff; border-color: transparent; box-shadow: 0 0 10px color-mix(in srgb, var(--c) 50%, transparent); text-shadow: 0 1px 1px rgba(0,0,0,.25); }

/* progress */
.prog2 { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 8px; min-height: 0; }
.prog2 .big { font-size: clamp(16px, min(14cqw, 26cqh), 30px); }
.prog2.v { align-items: center; padding-top: 2px; }
.ptrack { position: relative; display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.prog2.h .ptrack { height: 16px; }
.prog2.v .ptrack { flex: 1; width: min(48px, 70%); min-height: 30px; flex-direction: column; }
.pfill { background: var(--w-accent); transition: width .3s, height .3s; position: relative; }
.prog2.h .pfill { height: 100%; width: 0; }
.prog2.v .pfill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; }
.ptrack.segments { background: none; border: 0; gap: 3px; border-radius: 0; overflow: visible; }
.prog2.h .ptrack.segments { height: 18px; }
.ptrack.segments i { flex: 1; background: var(--panel-2); border-radius: 2px; transition: background .15s; }
.ptrack.segments i.on { background: var(--w-accent); box-shadow: 0 0 5px color-mix(in srgb, currentColor 0%, transparent); }
.ptrack.tank { border-radius: 14px; border: 2px solid color-mix(in srgb, var(--ink-2) 60%, transparent); }
.prog2.h .ptrack.tank { height: 26px; }
.ptrack.tank .pfill { background-image: linear-gradient(90deg, rgba(255,255,255,.18), transparent 40%, rgba(0,0,0,.12)); }
.prog2.v .ptrack.tank .wave { position: absolute; top: -5px; left: 0; width: 200%; height: 10px; background: radial-gradient(ellipse 12px 5px at 12px 5px, rgba(255,255,255,.35) 98%, transparent) repeat-x 0 0 / 24px 10px; animation: wave 2.4s linear infinite; }
@keyframes wave { to { transform: translateX(-24px); } }
@media (prefers-reduced-motion: reduce) { .ptrack.tank .wave { animation: none; } }

/* vertical slider */
.slider.vert { height: 100%; align-items: center; }
.slider.vert input[type=range] { writing-mode: vertical-lr; direction: rtl; flex: 1; width: 36px; height: auto; min-height: 50px; }

/* vertical tabs */
.tabsw.left { flex-direction: row; }
.tabsw.left .tabbar { flex-direction: column; border-bottom: 0; border-right: 1px solid var(--line); padding: 8px 0 8px 4px; overflow-x: hidden; overflow-y: auto; max-width: 40%; }
.tabsw.left .tab-btn { border-bottom: 0; border-right: 2px solid transparent; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.tabsw.left .tab-btn[aria-selected=true] { border-right-color: var(--w-accent); background: color-mix(in srgb, var(--w-accent) 8%, transparent); }
.tabsw.left .tab-btn.drop-into { border-radius: 6px 0 0 6px; }

.ledwrap .led { flex: none; }
.ledwrap.on .led { background: var(--c, var(--amber)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--amber)) 30%, transparent), 0 0 22px var(--c, var(--amber)); }
.clock-season { font-size: 9px; color: var(--ink-2); }
.clock-season.summer { color: var(--amber); }

/* two-factor, display links */
.qr { width: 180px; height: 180px; flex: none; border-radius: 6px; image-rendering: pixelated; }
.qr-box { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.qr-box > div { flex: 1; min-width: 200px; }
code.secret { font: 600 14px ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: 2px 6px; border-radius: 4px; word-break: break-all; user-select: all; }
pre.code.recovery { column-count: 2; font-size: 15px; }
.links { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 4px; }
.link-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.link-new { margin-top: 12px; }
code.link-url { display: block; font: 13px ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: 8px; border-radius: 6px; word-break: break-all; user-select: all; }
body.display.nocursor, body.display.nocursor * { cursor: none !important; }
body.display-ro .w-button .key, body.display-ro .w-slider input, body.display-ro .w-input input, body.display-ro .w-input button,
body.display-ro .w-menu button, body.display-ro .w-menu select, body.display-ro .w-color button, body.display-ro .w-color input,
body.display-ro .w-terminal input { pointer-events: none; }
body.display-ro .w-terminal input { display: none; }
dialog:has(.links), dialog:has(.qr-box) { width: min(640px, calc(100% - 32px)); }

@media (min-width: 761px) {
  .menu-btn, .sheet-handle { display: none; }
  .bar-links { display: flex; gap: 8px; align-items: center; }
}
@media (max-width: 760px) {
  .editing .resize { width: 34px; height: 34px; }
}

/* buttons: long presses must not select text or open the callout menu (phones) */
.w-button, .w-button * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.key.push { touch-action: none; }

/* motion widget */
.motion { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink-2); min-height: 0; }
.motion .m-art { flex: 1; min-height: 0; width: 100%; max-height: 100%; overflow: visible; }
.motion.running { color: var(--w-accent); }
.motion .m-state { font: 500 clamp(11px, min(7cqw, 12cqh), 16px)/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: var(--ink-2); }
.motion.running .m-state { color: var(--ink); }
.m-art .m-line { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.m-art .m-line.thin { stroke-width: 1.6; opacity: .6; }
.m-art .m-line.thick { stroke-width: 7; }
.m-art .m-fill { fill: color-mix(in srgb, currentColor 20%, transparent); stroke: currentColor; stroke-width: 2.5; stroke-linejoin: round; }
.m-art .m-solid { fill: currentColor; }
.m-art .m-tire { fill: none; stroke: currentColor; stroke-width: 8; }
.m-art .m-belt { fill: none; stroke: currentColor; stroke-width: 4; stroke-dasharray: 7 5; }
.motion.stopped:not(.stop-calm) { color: var(--bad); }
.motion.stopped:not(.stop-calm) .m-state { color: var(--bad); font-weight: 600; }
.motion.stopped.stop-blink .m-art, .motion.stopped.stop-blink .m-state { animation: m-blink 1s steps(1, end) infinite; }
.motion.stopped.stop-pulse .m-art { animation: m-pulse 2s ease-in-out infinite; }
.motion.stopped:not(.stop-calm) .m-art { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--bad) 55%, transparent)); }
@keyframes m-blink { 50% { opacity: .2; } }
@keyframes m-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .motion.stopped .m-art, .motion.stopped .m-state { animation: none !important; } }

/* button: real switches (slide, rocker, lever), horizontal or vertical */
.key.tg { border: 0; background: none; box-shadow: none; max-height: none; flex-direction: column; gap: 6px; color: var(--ink-2); padding: 0; font: 600 clamp(11px, min(8cqw, 10cqh), 16px)/1.1 var(--display); }
.key.tg:active { transform: none; }
.key.tg.on { color: var(--ink); }
.key.tg:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.tg-body { position: relative; display: block; flex: none; transition: background .15s, box-shadow .15s; }
.tg-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* slide */
.tg-slide.tg-h .tg-body { height: min(calc(var(--av) * .85), calc(var(--bw) * .45), 64px); aspect-ratio: 2 / 1; }
.tg-slide.tg-v .tg-body { width: min(calc(var(--av) * .5), calc(var(--bw) * .7), 52px); aspect-ratio: 1 / 2; }
.tg-slide .tg-body { border-radius: 999px; background: var(--k-off, var(--hole)); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .25); }
.tg-slide.on .tg-body { background: var(--k-on); }
.tg-knob { position: absolute; top: 8%; left: 4%; height: 84%; aspect-ratio: 1; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .35); transition: transform .18s cubic-bezier(.3, .7, .4, 1.2); }
.tg-slide.tg-v .tg-knob { top: auto; bottom: 4%; left: 8%; width: 84%; height: auto; }
.tg-slide.tg-h.on .tg-knob { transform: translateX(119%); }
.tg-slide.tg-v.on .tg-knob { transform: translateY(-119%); }
/* rocker: lit paddle, the pressed side is lower */
.tg-rocker.tg-v .tg-body { height: min(var(--av), calc(var(--bw) * 1.5), 130px); aspect-ratio: 2 / 3; }
.tg-rocker.tg-h .tg-body { width: min(calc(var(--av) * 1.66), var(--bw), 170px); aspect-ratio: 5 / 3; }
.tg-rocker .tg-body { border-radius: 8px; background: #1d232b; padding: 7%; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.tg-paddle { display: flex; width: 100%; height: 100%; border-radius: 5px; overflow: hidden; background: var(--k-off, #5b6570); color: rgba(255, 255, 255, .85); transition: background .15s, box-shadow .15s; }
.tg-v .tg-paddle { flex-direction: column; }
.tg-h .tg-paddle { flex-direction: row-reverse; }
.tg-paddle b { flex: 1; display: grid; place-items: center; font: 700 clamp(10px, 9cqh, 22px)/1 var(--display); transition: background .15s; }
.tg-paddle .tg-o { background: linear-gradient(rgba(0, 0, 0, .35), rgba(0, 0, 0, .05)); }
.tg-paddle .tg-i { background: linear-gradient(rgba(255, 255, 255, .22), rgba(255, 255, 255, 0)); }
.tg-h .tg-paddle .tg-o { background: linear-gradient(90deg, rgba(0, 0, 0, .35), rgba(0, 0, 0, .05)); }
.tg-h .tg-paddle .tg-i { background: linear-gradient(90deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0)); }
.tg-rocker.on .tg-paddle { background: var(--k-on); color: var(--k-on-text); box-shadow: 0 0 14px color-mix(in srgb, var(--k-on) 60%, transparent); }
.tg-rocker.on .tg-paddle .tg-i { background: linear-gradient(rgba(0, 0, 0, .3), rgba(0, 0, 0, .05)); }
.tg-rocker.on .tg-paddle .tg-o { background: linear-gradient(rgba(255, 255, 255, .25), rgba(255, 255, 255, 0)); }
.tg-rocker.tg-h.on .tg-paddle .tg-i { background: linear-gradient(270deg, rgba(0, 0, 0, .3), rgba(0, 0, 0, .05)); }
.tg-rocker.tg-h.on .tg-paddle .tg-o { background: linear-gradient(270deg, rgba(255, 255, 255, .25), rgba(255, 255, 255, 0)); }
/* lever toggle switch on a metal plate */
.tg-lever.tg-v .tg-body { height: min(var(--av), calc(var(--bw) * 1.66), 140px); aspect-ratio: 3 / 5; }
.tg-lever.tg-h .tg-body { width: min(calc(var(--av) * 1.66), var(--bw), 180px); aspect-ratio: 5 / 3; }
.tg-lever .tg-body { border-radius: 8px; background: linear-gradient(135deg, #d9dee3, #9aa3ad); box-shadow: 0 2px 6px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .6); }
.tg-nut { position: absolute; left: 50%; top: 50%; width: 30%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f4f6f8, #7d8792 70%); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.tg-h .tg-nut { width: auto; height: 30%; }
.tg-lever .tg-bat { position: absolute; left: 50%; top: 50%; width: 16%; height: 32%; margin-left: -8%; transform-origin: 50% 100%; transform: translateY(-100%) rotate(180deg); transition: transform .16s ease-out; border-radius: 40% 40% 20% 20%; background: linear-gradient(90deg, #8d97a2, #f5f7f9 45%, #8d97a2); box-shadow: 0 2px 4px rgba(0, 0, 0, .35); }
.tg-lever.tg-v.on .tg-bat { transform: translateY(-100%) rotate(0deg); }
.tg-lever.tg-h .tg-bat { left: 50%; top: 50%; margin: 0; width: 32%; height: 16%; transform-origin: 0 50%; transform: translateY(-50%) rotate(180deg); border-radius: 20% 40% 40% 20%; background: linear-gradient(#8d97a2, #f5f7f9 45%, #8d97a2); }
.tg-lever.tg-h.on .tg-bat { transform: translateY(-50%) rotate(0deg); }
.tg-lbl { position: absolute; font: 700 clamp(8px, 6cqh, 13px)/1 var(--display); color: #3b434c; letter-spacing: .04em; }
.tg-v .tg-lon { top: 6%; left: 0; right: 0; text-align: center; }
.tg-v .tg-loff { bottom: 6%; left: 0; right: 0; text-align: center; }
.tg-h .tg-lon { right: 6%; top: 50%; transform: translateY(-50%); }
.tg-h .tg-loff { left: 6%; top: 50%; transform: translateY(-50%); }
.tg-lamp { position: absolute; width: 9%; aspect-ratio: 1; border-radius: 50%; background: #5d646c; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .5); }
.tg-v .tg-lamp { right: 10%; top: 50%; transform: translateY(-50%); }
.tg-h .tg-lamp { width: auto; height: 9%; left: 50%; top: 9%; transform: translateX(-50%); }
.tg-lever.on .tg-lamp { background: var(--k-on); box-shadow: 0 0 8px var(--k-on), 0 0 2px var(--k-on); }

/* ---------- small tiles: every widget must fit (checked at 1×1 … 4×3 on phone and desktop) ---------- */
/* Space the body really has (container units already exclude the tile padding). */
.w-body { --bw: 100cqw; --bh: 100cqh; }
@container (max-width: 110px) {
  .w-body { margin-inline: -9px; --bw: calc(100cqw + 18px); }
  .w-label { left: 5px; right: 5px; text-align: center; }
}
@container (max-height: 100px) {
  .w-body { margin-top: -7px; margin-bottom: -10px; --bh: calc(100cqh + 17px); }
  .w-label { bottom: 5px; font-size: 11px; }
  .w-pin { bottom: 5px; }
}
.w-compact .w-body, .w-selector .w-body { margin: 0 !important; }
/* buttons */
.key { min-width: 0; overflow: hidden; }
.key .k-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key:not(.tg) { font-size: min(18px, max(11px, calc(var(--bw) * .2))); padding-inline: 4px; }
@container (max-width: 120px) {
  .key.look-indicator { flex-direction: column; gap: 5px; }
  .key.look-indicator::before { width: 10px; height: 10px; }
}
.key.tg { --av: calc(var(--bh) - 26px); }
@container (max-height: 120px) {
  .key.tg { --av: var(--bh); }
  .key.tg .tg-text { display: none; }
}
@container (max-width: 80px) { .tg-lbl { display: none; } }
@container (max-height: 100px) { .tg-lbl { display: none; } }
/* LED */
.led { width: min(40%, 64px, calc(var(--bh) * .8)); }
.lamp { width: min(78%, 74px, var(--bh)); }
.ringled { width: min(62%, 64px, calc(var(--bh) * .85)); }
@container (max-height: 100px) { .ringled { border-width: 4px; } .lamp { padding: 9%; } }
/* big numbers can get smaller in tiny tiles */
.big { font-size: clamp(11px, min(22cqw, 38cqh), 60px); }
/* progress */
@container (max-height: 100px) {
  .prog2 { gap: 3px; }
  .prog2 .big { font-size: 13px; }
  .prog2.h .ptrack, .prog2.h .ptrack.segments { height: 10px; }
  .prog2.h .ptrack.tank { height: 14px; border-width: 1px; }
  .prog2.v .big { display: none; }
  .prog2.v .ptrack { min-height: 0; }
}
@container (max-width: 80px) { .prog2 .big { font-size: 11px; } .prog2 .big small { display: none; } .prog2.v .ptrack { width: 70%; } }
/* slider */
.slider input[type=range] { margin: 0; max-width: 100%; }
.slider.vert input[type=range] { max-width: 100%; }
@container (max-height: 100px) { .slider { gap: 2px; } .slider .big { font-size: 13px; } .slider.vert .big { display: none; } .slider.vert input[type=range] { min-height: 0; } }
@container (max-width: 80px) { .slider .big { font-size: 12px; } }
/* input */
@container (max-height: 100px) { .input-msg { display: none; } .input-row input { padding: 3px 6px; font-size: 14px; } .input-row .unit { font-size: 13px; } }
/* menu: the list replaces buttons that do not fit (set from the script) */
.menu-box { width: 100%; }
.menu-box .menu-alt { display: none; }
.menu-box.as-list .segs { position: absolute; visibility: hidden; pointer-events: none; width: 100%; }
.menu-box.as-list .menu-alt { display: block; }
.menu-box { position: relative; }
@container (max-height: 100px) { .menu-alt { padding: 3px 6px; } }
/* color */
@container (max-height: 160px) { .cp-preview, .cp-native { width: 26px; height: 26px; } .cp { gap: 4px; } .cp input[type=range] { height: 12px; } }
@container (max-width: 150px) { .cp-code { display: none; } }
/* device selector */
@container (max-height: 70px) { .w-selector .selector { height: 28px; padding: 2px 6px; font-size: 14px; } }
/* log: time above the value when narrow */
@container (max-width: 160px) { .log div { flex-direction: column; gap: 0; } .log time { font-size: 11px; } }
/* compact background tiles: status dot in the tile corner, icon shrinks */
.w-compact .ctile { position: relative; }
.w-compact .ct-top { position: static; }
.w-compact .ct-top .dot { right: 2px; top: 2px; width: 7px; height: 7px; }
.ct-icon { width: min(26px, 55cqw, 40cqh); height: auto; aspect-ratio: 1; }
@container (max-width: 70px) { .ct-text { font-size: 11px; } }
@container (max-height: 80px) { .ct-text { display: none; } }
/* motion: drop the text line in tiny tiles, the colour still shows the state */
@container (max-width: 90px) { .motion .m-state { display: none; } }
@container (max-height: 100px) { .motion .m-state { display: none; } }
/* notify (full tile) */
@container (max-height: 170px) { .notify .btn { display: none; } }
@container (max-width: 80px) { .textled { padding: 3px 6px; font-size: 11px; } }
@container (max-height: 100px) { .slider:not(.vert) { flex-direction: row; align-items: center; gap: 6px; } .slider:not(.vert) .big { flex: none; } }
@container (max-height: 100px) and (max-width: 110px) { .slider:not(.vert) .big { display: none; } }
@container (max-height: 170px) { .notify .srv-state, .notify .srv-state * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .notify { gap: 4px; } }
.notify .srv-log, .srv .srv-log { flex: 1; min-height: 0; height: auto; }
/* code example dialogs: wide enough for the code, long lines scroll inside the code box */
dialog:has(.guide) { width: min(980px, calc(100% - 32px)); }
dialog:has(.code-wrap):not(:has(.guide)) { width: min(820px, calc(100% - 32px)); }
.guide-body, .guide > * { min-width: 0; }
dialog:has(.code-wrap) { overflow-x: hidden; }
.code-wrap .btn.code-copy { background: var(--panel-2); border: 1px solid var(--line); z-index: 1; }
@media (max-width: 640px) { .code-wrap pre.code { padding-top: 40px; padding-right: 12px; } }

[hidden] { display: none !important; }
/* fixed screen layouts */
.screen-wrap { position: relative; margin: 0 auto; overflow: hidden; border-radius: 6px; box-shadow: 0 0 0 1px var(--line); }
.board.screen { transform-origin: 0 0; box-sizing: border-box; min-height: 0; overflow: hidden; background-color: var(--bg); }
.editing .board.screen { overflow: visible; background-origin: content-box; }
.screen-edge { position: absolute; left: 0; right: 0; height: 0; border-top: 4px dashed var(--bad); pointer-events: none; z-index: 3; }
.screen-edge span { position: absolute; right: 12px; top: 6px; font: 600 26px var(--display); color: var(--bad); background: var(--bg); padding: 2px 8px; border-radius: 4px; }
body.kiosk .page.has-screen { padding: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
body.kiosk .screen-wrap { box-shadow: none; border-radius: 0; }

.zoombar { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; }
.zoombar > span { font-size: 13px; color: var(--ink-2); margin-right: 2px; }
.zoombar .btn { flex: none; width: 36px; padding: 5px 0; font: 600 18px/1 var(--display); }
.zoombar b { min-width: 52px; text-align: center; font: 600 16px var(--display); font-variant-numeric: tabular-nums; }
.zoombar small { margin-left: auto; color: var(--ink-2); font-size: 12px; }

/* clock styles (base size; the whole clock is scaled to fill the tile) */
.clock { gap: 3px; }
.clock-seg { width: auto; height: auto; padding: 0; gap: 4px; }
.clock-seg .segdisp { flex: none; height: 46px; max-height: none; padding: 7px 9px; }
.clock-seg .seg7 { height: 32px; width: auto; }
.clock-seg .seg-unit { font-size: 11px; margin-bottom: 4px; }
.clock-flip { font: 600 30px/1 var(--display); }
.clock .flipwrap { display: flex; align-items: flex-end; gap: 4px; }
.clock .flip-unit { font: 600 11px var(--display); color: var(--ink-2); margin-bottom: 2px; }
.clock-analog { width: 110px; height: 110px; overflow: visible; }
.ca-face { fill: var(--panel-2); stroke: var(--line); stroke-width: 3; }
.ca-tick { stroke: var(--ink-2); stroke-width: 1.5; opacity: .6; }
.ca-tick.big { stroke: var(--w-text, var(--ink)); stroke-width: 3.5; opacity: 1; stroke-linecap: round; }
.ca-num { font: 600 15px var(--display); fill: var(--w-text, var(--ink)); text-anchor: middle; }
.ca-hand { stroke: var(--w-text, var(--ink)); stroke-linecap: round; }
.ca-hand.hour { stroke-width: 7; }
.ca-hand.min { stroke-width: 4.5; }
.ca-hand.sec { stroke: var(--w-accent); stroke-width: 2; }
.ca-pin { fill: var(--w-accent); }
.clock-analog + .clock-date { margin-top: 2px; }
.clock.colon-off .seg7 .colon { opacity: .08; filter: none; }
.clock.colon-off .flipdigits .sep { visibility: hidden; }
/* tabs: their grid scrolls while editing too */
.editing .tabsw .tab-scroll { pointer-events: auto; overscroll-behavior: contain; }

/* direction (vector) widget */
.vec { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 0; color: var(--w-accent); }
.vec-art { flex: 1; min-height: 0; width: 100%; overflow: visible; }
.vec-rot { transform-box: view-box; transform-origin: 0 0; transition: transform .6s cubic-bezier(.3, .8, .3, 1); }
.vec-fill { fill: currentColor; stroke: color-mix(in srgb, currentColor 70%, #000); stroke-width: 2; stroke-linejoin: round; }
.vec-fill.round { stroke-linejoin: round; stroke-width: 6; stroke: currentColor; }
.vec-back { fill: var(--ink-2); opacity: .5; }
.vec-line { fill: none; stroke: currentColor; stroke-width: 6; stroke-linecap: round; }
.vec-pin { fill: var(--panel); stroke: currentColor; stroke-width: 3; }
.vec-ring { fill: var(--panel-2); stroke: var(--line); stroke-width: 3; }
.vec-ring.faint { fill: none; stroke: color-mix(in srgb, currentColor 18%, transparent); stroke-width: 2; }
.vec-tick { stroke: var(--ink-2); stroke-width: 1.5; opacity: .55; }
.vec-tick.big { stroke: var(--w-text, var(--ink)); stroke-width: 3; opacity: 1; }
.vec-card { font: 700 22px var(--display); fill: var(--w-text, var(--ink)); text-anchor: middle; }
.vec-card.n { fill: var(--bad); }
.vec-text { font: 500 clamp(11px, min(8cqw, 11cqh), 18px)/1.2 var(--display); color: var(--w-text, var(--ink)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; font-variant-numeric: tabular-nums; }
@container (max-height: 100px) { .vec-text { display: none; } }
@media (prefers-reduced-motion: reduce) { .vec-rot { transition: none; } }

/* checkboxes widget */
.chk { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 6px; overflow: auto; min-height: 0; }
.chk-item { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 4px 2px; font: 500 15px/1.2 var(--display); color: var(--ink); cursor: pointer; text-align: left; min-width: 0; border-radius: 6px; }
.chk-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chk-item:hover { background: var(--panel-2); }
.chk-mark { flex: none; width: 20px; height: 20px; border: 2px solid var(--ink-2); border-radius: 5px; position: relative; transition: background .12s, border-color .12s; }
.chk-item[role=radio] .chk-mark { border-radius: 50%; }
.chk-item.on .chk-mark { background: var(--w-accent); border-color: var(--w-accent); }
.chk-item.on .chk-mark::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid #1D2733; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.chk-item[role=radio].on .chk-mark::after { left: 4px; top: 4px; width: 8px; height: 8px; border: 0; border-radius: 50%; background: #1D2733; transform: none; }
.chk-switch .chk-mark { width: 34px; height: 20px; border-radius: 999px; border: 0; background: var(--hole); }
.chk-switch .chk-mark::before { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.chk-switch .chk-item.on .chk-mark { background: var(--w-accent); }
.chk-switch .chk-item.on .chk-mark::before { transform: translateX(14px); }
.chk-switch .chk-item .chk-mark::after { display: none; }
.chk-chip { flex-direction: row; flex-wrap: wrap; align-content: center; }
.chk-chip .chk-item { flex: 1 1 auto; justify-content: center; border: 1px solid var(--line); background: var(--panel-2); padding: 8px 10px; }
.chk-chip .chk-item.on { background: var(--w-accent); border-color: var(--w-accent); color: #1D2733; }
.chk-chip .chk-mark { display: none; }
@container (max-height: 120px) { .chk { gap: 2px; } .chk-item { padding: 1px 2px; font-size: 13px; } .chk-mark { width: 16px; height: 16px; } }
@container (max-width: 90px) { .chk-item span { font-size: 12px; } .chk-item { gap: 5px; } }

/* temperature widget (base size; scaled to fill the tile) */
.tv { --tc: var(--w-accent); display: flex; flex-direction: column; align-items: center; gap: 6px; width: max-content; flex: none; transform-origin: center; }
.tv-val { display: flex; align-items: baseline; gap: 3px; font: 600 30px/1 var(--display); font-variant-numeric: tabular-nums; color: var(--w-text, var(--tc)); white-space: nowrap; }
.tv-unit { font-size: 15px; color: var(--ink-2); font-weight: 500; }
.tv-icon .ti { width: 56px; height: 56px; display: block; color: var(--tc); overflow: visible; }
@container (orientation: landscape) { .tv-icon-row, .tv.tv-icon { flex-direction: row; gap: 10px; } }
.tv.tv-thermo { flex-direction: row; align-items: center; gap: 10px; }
.tv-scale { display: flex; align-items: stretch; gap: 2px; }
.tv-tube { width: 28px; height: 84px; display: block; overflow: visible; }
.tv-ends { display: flex; flex-direction: column; justify-content: space-between; padding: 2px 0 22px; }
.tv-end { font-size: 8px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tv-glass { fill: var(--panel-2); stroke: var(--ink-2); stroke-width: 2; }
.tv-fill, .tv-bulb { fill: var(--tc); transition: y .4s, height .4s, fill .4s; }
.tv-tick { stroke: var(--ink-2); stroke-width: 1.2; }
.ti-line { fill: none; stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.ti-solid { fill: currentColor; stroke: none; }
.ti-tint { fill: color-mix(in srgb, currentColor 22%, transparent); }
.ti-core { fill: color-mix(in srgb, #FFE9A8 80%, currentColor); }
.ti-flame { transform-origin: 32px 58px; animation: ti-flicker 1.4s ease-in-out infinite; filter: drop-shadow(0 0 4px currentColor); }
.ti-flame + .ti-core { transform-origin: 32px 58px; animation: ti-flicker 1.1s ease-in-out infinite reverse; }
@keyframes ti-flicker { 0%, 100% { transform: scale(1, 1); } 30% { transform: scale(.96, 1.05); } 60% { transform: scale(1.03, .97); } }
.ti-wave { animation: ti-rise 2.2s ease-in-out infinite; }
@keyframes ti-rise { 0%, 100% { transform: translateY(2px); opacity: .7; } 50% { transform: translateY(-2px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ti-flame, .ti-flame + .ti-core, .ti-wave { animation: none; } }

/* Modbus */
.mb-add { margin-top: 6px; }
.mb-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 14px; }
.mb-status .dot.bad, .mb-srv-row .dot.bad { background: var(--bad); }
.mb-error { flex-basis: 100%; color: var(--bad); font-size: 13px; }
.mb-conn { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr 1fr 1fr; gap: 0 12px; }
@media (max-width: 900px) { .mb-conn { grid-template-columns: 1fr 1fr; } }
.mb-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0 8px; }
.mb-tools select { width: auto; }
.mb-table-wrap { overflow-x: auto; }
.mb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mb-table th { text-align: left; font: 500 12px var(--display); color: var(--ink-2); padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mb-table td { padding: 4px; border-bottom: 1px solid var(--panel-2); vertical-align: middle; }
.mb-table input[type=text], .mb-table input[type=number], .mb-table select { padding: 5px 6px; font-size: 13px; min-width: 0; }
.mb-table td:nth-child(1) select { width: 68px; }
.mb-table td:nth-child(2) input { min-width: 120px; }
.mb-table td:nth-child(3) select { width: 96px; }
.mb-table td:nth-child(4) input { width: 76px; }
.mb-table td:nth-child(5) select { width: 140px; }
.mb-table td:nth-child(6) select { width: 72px; }
.mb-table .narrow { width: 64px; }
.mb-table td.c { text-align: center; }
.mb-live { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; min-width: 70px; }
.mb-actions { white-space: nowrap; text-align: right; }
.mb-actions .btn { padding: 4px 8px; }
.mb-decode tr.current td { background: color-mix(in srgb, var(--amber) 14%, transparent); }
.mb-decode .mb-num { font-variant-numeric: tabular-nums; font-weight: 600; }
dialog:has(.mb-decode) { width: min(640px, calc(100% - 32px)); }
.mb-srv-list { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
.mb-srv-row { display: flex; align-items: center; gap: 8px; text-decoration: none; padding: 6px 8px; border-radius: 6px; flex-wrap: wrap; }
.mb-srv-row:hover { background: var(--panel-2); }
.back { color: var(--ink-2); text-decoration: none; font-size: 14px; }
.mb-page .card { max-width: none; }
.mb-tools select { max-width: 280px; }
/* split value (whole + decimal part) settings under a register */
.mb-table tr.mb-has-sub td { border-bottom: 0; }
.mb-table tr.mb-sub td { padding-top: 0; }
.mb-split { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: 13px; background: var(--panel-2); padding: 6px 10px; border-radius: 8px; margin-bottom: 2px; }
.mb-split span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.mb-table tr.mb-sub select { width: auto !important; }
.mb-table tr.mb-sub input { min-width: 0 !important; width: 76px !important; }
.mb-table tr.mb-sub small { display: block; margin: 2px 0 4px 10px; }

/* Sensor widget: more pictures */
.ti .thin, .ti-line.thin { stroke-width: 2.2; }
.ti-text { fill: currentColor; font: 700 13px var(--display); }
.ti-level { transition: y .4s, height .4s; }
.ti-needle { transition: transform .5s; }
.ti-fall { animation: ti-fall 1.2s linear infinite; }
@keyframes ti-fall { 0% { transform: translateY(-3px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(4px); opacity: 0; } }
.ti-move { animation: ti-move 1.6s ease-in-out infinite; }
@keyframes ti-move { 0%, 100% { transform: translateX(-2px); } 50% { transform: translateX(2px); } }
.ti-sway { transform-origin: 10px 22px; animation: ti-sway 2.4s ease-in-out infinite; }
@keyframes ti-sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(4deg); } }
.ti-pulse { animation: ti-pulse 1.6s ease-in-out infinite; }
@keyframes ti-pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.ti-blink { animation: ti-pulse 1s steps(2) infinite; }
.ti-glow { filter: drop-shadow(0 0 5px currentColor); }
@media (prefers-reduced-motion: reduce) { .ti-fall, .ti-move, .ti-sway, .ti-pulse, .ti-blink { animation: none; } }
.tv-icon .ti-img { width: 56px; height: 56px; display: block; object-fit: contain; -webkit-user-drag: none; user-select: none; }
.tv-tube.tv-bar { height: 76px; }
.tv-scale-bar .tv-ends { padding-bottom: 2px; }

/* picture chooser */
.pic-chooser h3 { margin: 14px 0 6px; font-size: 13px; }
.pic-chooser h3:first-child { margin-top: 0; }
.pic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.pic-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); cursor: pointer; font: inherit; min-width: 0; }
.pic-tile:hover { border-color: var(--accent); }
.pic-tile.current { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.pic-art { display: flex; align-items: center; justify-content: center; height: 40px; color: var(--accent); }
.pic-art .ti, .pic-art .pic-img { width: 38px; height: 38px; object-fit: contain; }
.pic-auto { display: flex; gap: 1px; }
.pic-auto .ti, .pic-auto .pic-img { width: 24px !important; height: 24px !important; }
.pic-name { font-size: 11px; line-height: 1.2; text-align: center; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.pic-del, .pic-ren { position: absolute; top: 2px; width: 20px; height: 20px; line-height: 20px; border-radius: 50%; font-size: 13px; text-align: center; color: var(--ink-2); background: var(--panel-2); opacity: 0; }
.pic-del { right: 2px; color: var(--bad, #C83728); }
.pic-ren { left: 2px; }
.pic-tile:hover .pic-del, .pic-tile:hover .pic-ren, .pic-tile:focus-within .pic-del, .pic-tile:focus-within .pic-ren { opacity: 1; }
@media (hover: none) { .pic-del, .pic-ren { opacity: 1; } }
.pic-btn { display: flex; align-items: center; gap: 10px; width: 100%; justify-content: flex-start; text-align: left; padding: 6px 10px; }
.pic-btn .pic-art { height: 32px; width: 40px; flex: none; }
.pic-btn .pic-art .ti, .pic-btn .pic-art .pic-img { width: 30px; height: 30px; }
.pic-btn .pic-change { margin-left: auto; color: var(--ink-2); font-size: 12px; }
.pic-auto-fields .grid2 { align-items: end; }
.pic-btn .pic-art:has(.pic-auto) { width: auto; }
.pic-btn > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* per-pin color ranges in the graph settings */
.series-rng-btn { justify-self: start; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 6px !important; }
.rng-dots { display: inline-flex; gap: 2px; }
.rng-dots i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.series-rng { display: grid; gap: 6px; border-top: 1px dashed var(--line); padding-top: 6px; }
.mb-adv { margin-top: 10px; }
.mb-adv summary { cursor: pointer; font-weight: 500; color: var(--ink-2); }
.mb-adv .mb-conn { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .mb-adv .mb-conn { grid-template-columns: 1fr; } }

/* Logic (rules) page */
.logic-page .card.rule { max-width: none; padding: 14px 16px; }
.rules { display: grid; gap: 14px; }
.rule.off { opacity: .6; }
.rule-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rule-head .rule-name { flex: 1 1 200px; font: 600 17px var(--display); padding: 6px 8px; }
.rule-head .btn { padding: 5px 9px; }
.rule-badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); max-width: 340px; }
.rule-badge.live { background: color-mix(in srgb, #2E9E5B 18%, transparent); color: #2E9E5B; }
.rule-badge.warn { background: color-mix(in srgb, #E8A10C 20%, transparent); color: #B87F06; }
.rule-badge.bad { background: color-mix(in srgb, #C2412D 16%, transparent); color: #C2412D; }
.rule-block { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; display: grid; gap: 6px; justify-items: start; }
.rule-block h3 { margin: 0; font: 600 14px var(--display); display: flex; align-items: center; gap: 6px; }
.rule-block h3 select { width: auto; padding: 2px 6px; }
.rule-row, .rule-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%; }
.rule-row select, .rule-row input, .rule-line select, .rule-line input { width: auto; min-width: 0; padding: 5px 7px; font-size: 14px; }
.rule-row select { max-width: 220px; }
.rule-val { width: 110px !important; }
.rule-n { width: 20px; height: 20px; border-radius: 50%; background: var(--panel-2); font-size: 11px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); flex: none; }
.rule-live { font-size: 12px; font-variant-numeric: tabular-nums; margin-left: auto; white-space: nowrap; }
.rule-live.ok { color: #2E9E5B; } .rule-live.no { color: var(--ink-2); }
.rule-x { padding: 2px 8px !important; }
.rule-days { display: inline-flex; gap: 2px; }
.rule-days .day { border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); border-radius: 5px; padding: 3px 5px; font-size: 12px; cursor: pointer; }
.rule-days .day.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.rule-action { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; gap: 6px; background: var(--bg); }
.rule-action .field { margin: 0; flex: 1 1 180px; }
.rule-msg { display: grid; gap: 4px; }
.rule-msg textarea { width: 100%; font-family: inherit; font-size: 14px; line-height: 1.4; padding: 6px 8px; }
.rule-chips { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 1px 8px; font-size: 12px; cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--accent); }
.rule-times { gap: 14px; color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.rule-times input.narrow { width: 70px !important; }
.rule-activity { margin-top: 8px; }
.rule-activity summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.rule-log .log-row { display: flex; gap: 10px; font-size: 13px; padding: 3px 0; border-bottom: 1px solid var(--panel-2); }
.rule-log .log-row time { color: var(--ink-2); white-space: nowrap; }
.rule-log .log-row.bad span { color: #C2412D; }
.logic-page .head-row { flex-wrap: wrap; }
.logic-page .head-row select { width: auto; max-width: 100%; }
@media (max-width: 640px) { .rule-live { margin-left: 26px; width: 100%; } .rule-badge { max-width: 100%; } }
.hm { width: 76px !important; font-variant-numeric: tabular-nums; }

/* Logic: groups (brackets) and and/or between conditions */
.rule-join { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); padding-left: 26px; line-height: 1; }
.rule-group { width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-left: 3px solid var(--accent, #E8A10C); border-radius: 8px; padding: 6px 8px 8px; display: grid; gap: 6px; justify-items: start; background: var(--panel-2); }
.rule-group-head { display: flex; align-items: center; gap: 6px; width: 100%; font: 600 13px var(--display); white-space: nowrap; }
.rule-group-head select { width: auto; padding: 2px 6px; font-size: 13px; }
.rule-group-head .rule-live { margin-left: 8px; font-weight: 400; }
.rule-group .btn.small { padding: 3px 8px; font-size: 13px; }

/* tiles without the label/pin line at the bottom (default for tabs and graphs) */
.w.nofoot { padding-bottom: 12px; }
.w-tabs.nofoot { padding: 0; }
.w-graph { padding: 8px 10px 30px; }
.w-graph.nofoot { padding: 8px 8px 6px; }
.w.nofoot.offline::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); z-index: 2; }
