/* Roomi. Calm and neutral: warm white panels, thin borders, soft shadows,
   one muted blue for selection and measurements. The room colours in
   src/world.js match these. */

:root {
  --bg: #e7e4de;
  --panel: #fbfaf8;
  --panel-2: #f2f0ec;
  --line: #d9d5ce;
  --line-2: #c4bfb6;
  --text: #24272b;
  --muted: #6b6f76;
  --accent: #3b6ea5;
  --accent-soft: #e3ecf6;
  --danger: #b3423a;
  --warn: #9a6a12;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px rgb(0 0 0 / .08);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg); color: var(--text);
  font: 400 13px/1.4 var(--font);
  --tray-h: 88px;
}
h2 {
  margin: 0; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}

/* ---------- controls ---------- */
button {
  font: 500 13px var(--font); color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 11px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover { background: #fff; border-color: var(--line-2); }
button:active { background: var(--panel-2); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button svg, a svg { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
button.icon { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; }
button.icon.small { width: 28px; height: 28px; }
button.icon.small svg { width: 15px; height: 15px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #335f8f; }
button.danger:hover { color: var(--danger); border-color: #e2b4af; background: #fbefee; }
button[aria-pressed="true"] { background: var(--accent-soft); border-color: #b7cbe2; color: var(--accent); }

input {
  font: 400 13px var(--font); color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; min-width: 0;
}
input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input.attention { border-color: var(--warn); box-shadow: 0 0 0 3px #f5e6c8; }

/* ---------- room ---------- */
main { position: fixed; inset: 0; }
canvas { width: 100%; height: 100%; display: block; }
main::after {
  content: ""; position: absolute; inset: 10px; pointer-events: none;
  border: 2px dashed var(--accent); border-radius: 14px; opacity: 0; transition: opacity .15s;
}
main.dropping::after { opacity: .8; }
main.grabbable canvas { cursor: grab; }
main.carrying canvas { cursor: grabbing; }

/* Measurement pills over the room. */
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dim {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  font: 600 11px/1 var(--font); font-variant-numeric: tabular-nums;
  color: #fff; background: rgb(36 39 43 / .86); padding: 4px 6px; border-radius: 4px;
}
.dim.gap { background: var(--accent); }
.dim[hidden] { display: none; }

#hint {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%); pointer-events: none;
  max-width: calc(100% - 32px); text-align: center;
  font-size: 13px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; box-shadow: var(--shadow);
}
#hint[hidden] { display: none; }

/* ---------- top bar ---------- */
.bar-top {
  position: fixed; left: 14px; right: 14px; top: 14px; z-index: 10; pointer-events: none;
  display: flex; justify-content: space-between; align-items: center;
}
.bar-top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 7px;
  font-size: 15px; font-weight: 600; letter-spacing: -.01em;
  padding: 6px 12px 6px 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow);
}
.brand svg { width: 18px; height: 18px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.corner, .bar-top .left { display: flex; gap: 6px; }
#roomBtn {
  display: flex; align-items: center; gap: 4px; max-width: 240px; height: 34px; padding: 0 8px 0 12px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
}
#roomName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#roomBtn svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
#roomBtn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
.corner button { box-shadow: var(--shadow); font-weight: 600; font-size: 15px; }
#settingsBtn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
#helpBtn.new { border-color: var(--accent); color: var(--accent); }

/* ---------- settings ---------- */
.pop {
  position: fixed; right: 14px; top: 58px; z-index: 11; width: 300px;
  max-height: calc(100% - 72px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pop[hidden] { display: none; }
.pop h2:not(:first-child) { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.pop label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.pop .row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pop .row { display: flex; align-items: center; gap: 14px; }
.pop .lbl { font-size: 12px; color: var(--muted); }
.pop label.radio, .pop label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.plist button {
  width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; text-align: left;
  padding: 6px 9px; font-weight: 400;
}
.plist b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist span { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plist button[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.pop button.add::before { content: "+ "; color: var(--muted); }
.pop .lbl.look { width: 44px; }
input[type="color"] { width: 44px; height: 30px; padding: 2px 3px; cursor: pointer; }
#deleteRoom { align-self: flex-start; color: var(--danger); }
#deleteRoom.sure { color: #fff; background: var(--danger); border-color: var(--danger); }

/* Rooms menu, under the room name; shapes menu, over the tray (placed in viewer.js). */
#rooms { left: 14px; right: auto; width: 280px; z-index: 12; }
#shapes { top: auto; right: auto; width: 290px; z-index: 12; }
.pop .addrow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.pop .addrow button { padding: 6px 4px; }
.pop .addrow button::before { content: "+ "; color: var(--muted); }
.pop p.muted { margin: 0; font-size: 12px; color: var(--muted); }
.pop [hidden] { display: none; }
#allowance { margin: 0; font-size: 12px; color: var(--muted); }
#allowance.empty { color: var(--danger); }
#allowance[hidden], #serverRow[hidden] { display: none; }

/* ---------- details card ---------- */
/* A side panel on the right, so the room's middle and the measurement labels stay in view. */
#selected, #opening {
  position: fixed; right: 14px; top: 58px; z-index: 10;
  width: min(400px, calc(100% - 28px));
  display: flex; flex-direction: column; gap: 10px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
#selected[hidden], #opening[hidden] { display: none; }
#selected .head { display: flex; align-items: center; gap: 6px; }
#selName {
  flex: 1; padding: 4px 6px; margin-left: -6px;
  font-size: 15px; font-weight: 600; text-overflow: ellipsis;
  background: transparent; border-color: transparent;
}
#selName:hover { border-color: var(--line); }
#selName:focus { background: #fff; border-color: var(--accent); }
#selName[readonly] { cursor: default; border-color: transparent; box-shadow: none; }
#sourceLink { color: var(--muted); padding: 6px; border-radius: 6px; }
#sourceLink:hover { color: var(--accent); background: var(--accent-soft); }
#sourceLink[hidden] { display: none; }

.dims { display: flex; align-items: center; gap: 6px; }
.dims label {
  flex: 1; display: flex; align-items: center; gap: 0;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; overflow: hidden;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.dims label:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dims label { padding-left: 8px; }
.dims input { flex: 1; width: 100%; border: 0; box-shadow: none; padding: 6px 4px; font-variant-numeric: tabular-nums; }
.dims input:focus { box-shadow: none; }
#dimSource { margin: -2px 0 0; font-size: 12px; color: var(--muted); }
#dimSource.warn { color: var(--warn); }
#dimSource q { color: var(--text); font-style: normal; }
#dimSource q::before { content: "“"; }
#dimSource q::after { content: "”"; }
.find { display: flex; gap: 6px; }
.find input { flex: 1; }
.actions { display: flex; align-items: center; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.actions .spacer { flex: 1; }
.actions [hidden] { display: none; }
#selected.many .dims, #selected.many #dimSource, #selected.many .find, #selected.many #duplicate, #selected.many #sourceLink { display: none; }
#mountFields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#mountFields[hidden], #selected.many #mountFields { display: none; }
#mountFields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
#mountFields label:first-child { grid-column: 1 / -1; }
#mountFields input { font-variant-numeric: tabular-nums; }
/* Options: other products tried in the same spot */
.opts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.opts[hidden], #selected.many .opts { display: none; }
.opts .lbl { font-size: 12px; color: var(--muted); }
.opts .lbl b { color: var(--text); font-weight: 600; margin-left: 4px; }
.optlist { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.optw { position: relative; display: inline-flex; }
.opt {
  width: 34px; height: 34px; padding: 0; overflow: hidden; border-radius: 7px;
  background: var(--c, #fff); border: 1px solid var(--line-2);
}
.opt img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.opt:hover { background: var(--c, #fff); border-color: var(--text); }
.opt[aria-pressed="true"] { background: var(--c, #fff); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.opt.add { display: grid; place-items: center; font-size: 16px; color: var(--muted); background: var(--panel-2); }
.opt.add[aria-pressed="true"] { color: var(--accent); background: var(--panel-2); }
.optx {
  position: absolute; right: -6px; top: -6px; width: 16px; height: 16px; padding: 0;
  display: none; place-items: center; border-radius: 99px; border: 1px solid var(--line-2);
  background: #fff; color: var(--muted); font-size: 11px; line-height: 1;
}
.optw:hover .optx, .optw:focus-within .optx { display: grid; }
.optx:hover { color: var(--danger); border-color: var(--danger); background: #fff; }
#hitNote { margin: 0; font-size: 12px; color: var(--warn); }
#hitNote[hidden] { display: none; }
#lib.picking li.tile.ready { outline: 2px dashed var(--accent); outline-offset: 2px; }
li.tile.option { border-color: var(--accent); border-style: dashed; }
.tile .count.alt { background: var(--accent); }
/* Finishes */
.finish { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.finish[hidden], .fedit[hidden], #selected.many .finish, #selected.many .fedit { display: none; }
.finish .lbl, .fedit .lbl { font-size: 12px; color: var(--muted); }
.finish .lbl b { color: var(--text); font-weight: 600; margin-left: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.chip {
  width: 26px; height: 26px; padding: 0; border-radius: 99px;
  background: var(--c, #fff); border: 1px solid var(--line-2);
  box-shadow: inset 0 0 0 2px #fff;
}
.chip:hover { background: var(--c, #fff); border-color: var(--text); }
.chip[aria-pressed="true"] { background: var(--c, #fff); border-color: var(--accent); box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--accent-soft); }
.chip.orig { background: linear-gradient(135deg, #e8e4dc 50%, #9b8b78 50%); }
.chip.add { display: grid; place-items: center; font-size: 15px; color: var(--muted); background: var(--panel-2); }
button.link { border: 0; background: none; padding: 2px 4px; color: var(--accent); font-size: 12px; }
button.link:hover { background: none; text-decoration: underline; }
button.link[hidden] { display: none; }
.fedit { display: flex; flex-direction: column; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.fedit .frow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.fedit .frow[hidden], .fedit [hidden] { display: none; }
.fedit label.inline { display: flex; align-items: center; gap: 6px; }
.fedit .grow { flex: 1; }
.fedit .grow input { flex: 1; }
.fedit input[type="range"] { flex: 1; accent-color: var(--accent); }
.fedit .spacer { flex: 1; }
.fedit p.muted { margin: 0; font-size: 12px; color: var(--muted); }
.fedit .sw { width: 22px; height: 22px; border-radius: 99px; border: 1px solid var(--line-2); flex: none; }
#fDelete.sure { color: #fff; background: var(--danger); border-color: var(--danger); }
main.picking canvas { cursor: crosshair; }
.tile .fdots { position: absolute; left: 50%; bottom: 4px; translate: -50% 0; display: flex; gap: 3px; pointer-events: none; }
.tile .fdots i { width: 7px; height: 7px; border-radius: 99px; border: 1px solid #fff; box-shadow: 0 0 0 .5px rgb(0 0 0 / .25); }
.colorrow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
#selected:not(.box) .colorrow, #selected.many .colorrow, #selected.box .find, #selected.box #sourceLink { display: none; }
#deleteRec.sure { color: #fff; background: var(--danger); border-color: var(--danger); }

/* ---------- door and window card ---------- */
#opening { width: min(360px, calc(100% - 28px)); }
#opening .head { display: flex; gap: 6px; }
select {
  font: 400 13px var(--font); color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#opKind { flex: 1; font-size: 15px; font-weight: 600; }
#opening .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
#opening .fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
#opening .fields input { font-variant-numeric: tabular-nums; }
#opening [hidden], #opening .fields label[hidden], #opening .toggles[hidden] { display: none; }
#opening .toggles { display: flex; flex-wrap: wrap; gap: 8px 16px; }
#opening .toggles > div { display: flex; flex-direction: column; gap: 4px; }
#opening .lbl { font-size: 12px; color: var(--muted); }
.seg { display: inline-flex; }
.seg button { border-radius: 0; padding: 5px 10px; }
.seg button:first-child { border-radius: 7px 0 0 7px; }
.seg button:last-child { border-radius: 0 7px 7px 0; margin-left: -1px; }
#opNote { margin: -2px 0 0; font-size: 12px; color: var(--muted); }
#opNote.warn { color: var(--warn); }

/* ---------- catalog tray ---------- */
#tray {
  position: fixed; left: 50%; bottom: 14px; z-index: 10; translate: -50% 0;
  height: var(--tray-h); max-width: calc(100% - 28px);
  display: flex; align-items: center; padding: 0 0 0 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
}
#lib {
  list-style: none; margin: 0; padding: 12px 10px; display: flex; gap: 8px;
  overflow-x: auto; scrollbar-width: thin; scroll-behavior: smooth;
}
#lib:empty { display: none; }
.tile {
  position: relative; flex: none; width: 64px; height: 64px; padding: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  transition: border-color .12s, transform .12s;
}
button.tile.add { display: grid; place-items: center; background: var(--panel-2); color: var(--muted); }
button.tile.add:hover { color: var(--accent); border-color: var(--accent); }
button.tile.add svg { width: 24px; height: 24px; }
li.tile { cursor: pointer; }
li.tile.ready { cursor: grab; }
li.tile:hover { border-color: var(--line-2); transform: translateY(-1px); }
li.tile.has-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tile img, .tile .ph {
  width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 7px; background: #fff;
  -webkit-user-drag: none; pointer-events: none;
}
li.tile:not(.ready) img { filter: grayscale(.7) opacity(.55); }
.tile .ph.box { display: grid; place-items: center; background: var(--c); color: rgb(0 0 0 / .4); }
.tile .ph.box.dark { color: rgb(255 255 255 / .55); }
.tile .ph.box svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
#tray .tile.add + .tile.add { margin-left: 6px; }
.tile .bar {
  position: absolute; left: 6px; right: 6px; bottom: 6px; height: 4px; overflow: hidden;
  border-radius: 99px; background: var(--line);
}
.tile .bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .6s ease; }
.tile .flag { position: absolute; inset: 0; display: grid; place-items: center; font-size: 18px; font-weight: 600; color: var(--muted); }
li.tile.failed { border-color: #e2b4af; }
li.tile.failed .flag { color: var(--danger); }
.tile .count {
  position: absolute; right: -6px; top: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 99px; border: 0; background: var(--text); color: #fff;
  font-size: 11px; font-weight: 600;
}
.tile .count[hidden] { display: none; }
.tile .nosize {
  position: absolute; left: -6px; top: -6px; width: 18px; height: 18px; border-radius: 99px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: #f5e6c8; color: var(--warn); border: 1px solid #e6cf9c;
}
.tile .pen {
  position: absolute; left: -6px; bottom: -6px; width: 22px; height: 22px; padding: 0;
  border-radius: 99px; display: grid; place-items: center; opacity: 0; transition: opacity .1s;
  box-shadow: var(--shadow);
}
.tile .pen svg { width: 12px; height: 12px; }
li.tile:hover .pen, .tile .pen:focus-visible { opacity: 1; }
#empty { margin: 0 16px 0 12px; max-width: 420px; font-size: 13px; color: var(--muted); }
#empty[hidden] { display: none; }

#tip {
  position: fixed; z-index: 12; pointer-events: none; max-width: 260px;
  padding: 6px 10px; translate: -50% -100%;
  background: var(--text); color: #fff; border-radius: 6px; box-shadow: var(--shadow);
}
#tip[hidden] { display: none; }
#tip b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tip span { display: block; font-size: 11px; opacity: .8; font-variant-numeric: tabular-nums; }

/* ---------- new object: name and size before it is made ---------- */
#addPop {
  position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 24px;
  background: rgb(36 39 43 / .28);
}
#addPop[hidden] { display: none; }
#addPop .sheet {
  width: min(520px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 18px 20px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
#addPop header { display: flex; align-items: baseline; gap: 10px; }
#addPop h2 { margin: 0; font-size: 17px; color: var(--text); text-transform: none; letter-spacing: 0; }
#addMore { font-size: 12px; color: var(--muted); }
.addtop { display: flex; gap: 14px; align-items: flex-start; }
#addImg {
  flex: none; width: 112px; height: 112px; object-fit: contain; background: #fff;
  border: 1px solid var(--line); border-radius: 8px;
}
.addfields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
#addPop .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
#addPop .field input { width: 100%; }
#addNote { margin: 0; min-height: 16px; font-size: 12px; color: var(--muted); }
#addNote.warn { color: var(--warn); }
#addPop .actions { padding-top: 12px; }
/* The count: a lighter band that shrinks to nothing as the time runs out. */
#addGo.auto { background-image: linear-gradient(90deg, rgb(255 255 255 / .2) calc(var(--left, 1) * 100%), transparent 0); font-variant-numeric: tabular-nums; }

/* ---------- help ---------- */
/* Settings opens over the card. */
#settings { z-index: 12; }

#help {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: rgb(36 39 43 / .28);
}
#help[hidden] { display: none; }
#help .sheet {
  width: min(980px, 100%); max-height: 100%; overflow-y: auto; padding: 18px 20px 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
#help header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
#help h2 { font-size: 17px; color: var(--text); text-transform: none; letter-spacing: 0; }
#help .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
#help section { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
#help h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
#help dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 12.5px; }
#help dt { font-weight: 600; white-space: nowrap; }
#help dd { margin: 0; color: var(--muted); }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 5px; margin-right: 2px; text-align: center;
  font: 600 11px var(--font); background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px;
}

/* ---------- daylight ---------- */
#sunBtn[aria-pressed="true"] { background: #fbf1dc; border-color: #e5cf9f; color: #9a6a12; }
.dbar {
  position: fixed; left: 50%; translate: -50% 0; bottom: calc(14px + var(--tray-h) + 10px); z-index: 10;
  width: min(680px, calc(100% - 28px));
  display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  --rise: 25%; --set: 75%;
}
.dbar[hidden] { display: none; }
.dbar .dlabel { display: flex; flex-direction: column; min-width: 150px; line-height: 1.25; }
.dbar .dlabel b { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dbar .dlabel span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.dbar svg [hidden], .dbar svg[hidden] { display: none; }
#dlPlay svg { fill: currentColor; stroke: none; }
#dlTime {
  flex: 1; min-width: 80px; height: 22px; margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent;
  -webkit-appearance: none; appearance: none; cursor: pointer;
}
#dlTime::-webkit-slider-runnable-track {
  height: 8px; border-radius: 4px; border: 1px solid var(--line);
  background: linear-gradient(to right, #46506a 0, #46506a var(--rise), #f1dfb8 var(--rise), #f6e7c4 50%, #f1dfb8 var(--set), #46506a var(--set), #46506a 100%);
}
#dlTime::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 2px solid var(--warn); box-shadow: 0 1px 3px rgb(0 0 0 / .2);
}
#dlTime:focus { box-shadow: none; }
#dlTime:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 1px; }
#dlNow, #dlDate { padding: 5px 9px; font-size: 12px; white-space: nowrap; }
#datePop { top: auto; right: auto; width: 260px; z-index: 12; }
#datePop .days button::before { content: none; }

.sunrow { display: flex; align-items: center; gap: 12px; }
#compassSvg { width: 112px; height: 112px; flex: none; touch-action: none; cursor: grab; user-select: none; }
#compassSvg .ring { fill: none; stroke: var(--line-2); stroke-width: 1.2; }
#compassSvg .tick { stroke: var(--line-2); stroke-width: 1.2; }
#compassSvg .plan { fill: var(--panel-2); stroke: var(--muted); stroke-width: 1.4; }
#compassSvg .win { stroke: var(--accent); stroke-width: 3; }
#compassSvg .door { stroke: var(--panel); stroke-width: 3; }
#compassSvg .wl { font: 600 7px var(--font); fill: var(--muted); text-anchor: middle; dominant-baseline: middle; }
#compassSvg .north circle { fill: var(--warn); }
#compassSvg .north text { font: 700 9px var(--font); fill: #fff; text-anchor: middle; dominant-baseline: middle; }
.sunfields { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.sunfields select { font: 400 13px var(--font); padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); }
.placerow { gap: 8px !important; }
.placerow input { flex: 1; }

/* ---------- lights ---------- */
#lightCard {
  position: fixed; right: 14px; top: 58px; z-index: 10;
  width: min(400px, calc(100% - 28px));
  display: flex; flex-direction: column; gap: 10px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
#lightCard[hidden], #lightCard [hidden], #lightCard .fields label[hidden] { display: none; }
#lightCard .head { display: flex; gap: 6px; }
#lkKind { flex: 1; font-size: 15px; font-weight: 600; }
#lightCard .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
#lightCard .fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
#lightCard .fields input { font-variant-numeric: tabular-nums; }
#lkNote { margin: -2px 0 0; font-size: 12px; color: var(--muted); }
button.power { min-width: 52px; }
button.power[aria-pressed="true"] { background: #fbf1dc; border-color: #e5cf9f; color: #9a6a12; }
.bulbctl { display: flex; flex-direction: column; gap: 8px; }
.bulbctl[hidden] { display: none; }
.bulbctl .frow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bulbctl .frow > .lbl { width: 66px; flex: none; }
.bulbctl input[type="range"] { flex: 1; accent-color: var(--warn); }
.bulbctl .num { min-width: 52px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.bulbctl .opts { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 0; }
.bulbctl .opts button { padding: 4px 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.bulbctl .opts button i { display: inline-block; width: 9px; height: 9px; border-radius: 99px; margin-right: 4px; vertical-align: -1px; background: var(--c); border: 1px solid rgb(0 0 0 / .15); }
.bulbctl input.lm { width: 70px; padding: 4px 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.lamp { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.lamp label.check { display: flex; align-items: center; gap: 6px; }
.lamp .spacer { flex: 1; }
#selected.many .lamp, #selected.many .bulbctl { display: none; }
#selected.library #lampPower { display: none; }
.pop .addrow.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#dlLights[aria-pressed="true"] { background: #fbf1dc; border-color: #e5cf9f; color: #9a6a12; }
#dlHours[aria-pressed="true"] { background: #fbf1dc; border-color: #e5cf9f; color: #9a6a12; }
#hoursLegend {
  position: fixed; left: 50%; translate: -50% 0; bottom: calc(14px + var(--tray-h) + 10px + 52px); z-index: 10;
  display: grid; grid-template-columns: 150px auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  padding: 7px 12px; font-size: 12px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
#hoursLegend[hidden] { display: none; }
#hoursLegend .ramp { grid-row: 1; height: 8px; border-radius: 4px; background: linear-gradient(to right, rgb(250 214 90 / .55), rgb(222 98 18 / .9)); border: 1px solid var(--line); }
#hoursLegend .ticks { grid-row: 2; grid-column: 1; display: flex; justify-content: space-between; font-size: 10px; font-variant-numeric: tabular-nums; }
#hoursLegend .ticks i { font-style: normal; }
#hoursText { grid-row: 1 / 3; grid-column: 2; color: var(--text); }
#stillPop {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  background: var(--still-bg, #e7e4de);
}
#stillPop[hidden] { display: none; }
#stillPop .stillbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--panel); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
#stillPop h2 { margin: 0; font-size: 14px; color: var(--text); }
#stillCount { font-variant-numeric: tabular-nums; color: var(--text); min-width: 9em; }
#stillNote { flex: 1; }
#stillCanvas { flex: 1; min-height: 0; width: 100%; height: 100%; object-fit: contain; }
