:root {
  --bg: #0e0e0f; --glass: rgba(16, 16, 19, 0.78); --ink: #f2f2f0; --muted: #a3a3a8; --line: rgba(255, 255, 255, 0.12);
  --accent: #4d8dff; --r: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 16px/1.35 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif; overflow: hidden;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; }
#c { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

.brand { position: absolute; left: 16px; top: calc(12px + var(--safe-t)); max-width: calc(100% - 32px);
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: none; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

#hint { position: absolute; left: 50%; bottom: calc(206px + var(--safe-b)); transform: translateX(-50%); margin: 0;
  background: var(--glass); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; color: var(--ink); pointer-events: none; white-space: nowrap;
  transition: opacity .5s ease; }
#hint.gone { opacity: 0; }

/* Luca, 2026-10-02: camera presets removed (free navigation only), "Scan floor" toggle removed (always
   on). The dock is now play controls + two labelled rows (Display, Wall paint), ALL constrained by this
   one width so nothing can ever run wider than the glass panel behind it (that mismatch was the earlier
   "faded/disabled" bug: overflowing buttons rendered outside the dock's backdrop-blur, against the plain
   page background, which reads as disabled even though the button works fine). */
#dock { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(16px + var(--safe-b));
  width: min(580px, calc(100% - 32px));   /* 580 (was 520, 2026-10-09): four Display toggles on one line */ background: var(--glass); border: 1px solid var(--line);
  border-radius: 16px; padding: 10px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: grid; gap: 10px; overflow: hidden; }
#now { display: grid; grid-template-columns: 44px 1fr 44px 44px; gap: 8px; align-items: center; }
#nowtext { min-width: 0; display: grid; gap: 2px; }
#nowtext .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
#nowname { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bar { display: block; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .14); overflow: hidden; margin-top: 4px; }
#barfill { display: block; height: 100%; width: 0; background: var(--ink); }

button { font: inherit; color: inherit; background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
  border-radius: 10px; min-height: 44px; min-width: 44px; padding: 8px 12px; cursor: pointer;
  touch-action: manipulation; }
button:hover { background: rgba(255, 255, 255, .12); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#now button { padding: 0; font-size: 20px; }
/* Every group row: same wrapping flex layout, same gap, same label style -- "one coherent grid" (never a
   fixed-track grid that can force itself wider than the row, which is what #views used to do). A row that
   does not fit wraps onto a second line inside the SAME glass panel; it never scrolls and never clips. */
.dockrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.grouplabel { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
.dockrow button { font-size: 14px; white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 8px; }
.dockrow button[aria-pressed="true"] { background: var(--ink); color: #111; border-color: var(--ink); }
.dockrow button[aria-pressed="true"] .icon { color: #111; }
/* projector row: size select, position slider, and a wrapping readout line under them */
#projrow select { font: inherit; font-size: 14px; color: inherit; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 10px; min-height: 44px; padding: 0 8px; }
#projrow input[type="range"] { flex: 1 1 120px; min-width: 0; min-height: 44px; accent-color: var(--ink); }
#projInfo { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--muted); }
/* Now / Planned: one segmented switch, the pressed side filled */
.seg { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
/* short labels and the colours (palette) button exist for phones only; desktop shows every row and the long labels */
.short, #colours { display: none; }
.icon { width: 15px; height: 15px; flex: none; color: var(--muted); }
#paints, #carpets { display: flex; flex-wrap: wrap; gap: 0; }
/* wall paint = colour dots, no text (aria-label/title carry the name). The visible dot is 22px; the button around it
   is 44x44 so the touch target meets the guideline while the row stays slim. Selected = a ring, not a fill. */
.dockrow #paints button, .dockrow #carpets button, .pick { width: 44px; height: 44px; min-width: 44px; padding: 0; background: transparent; border: 0; border-radius: 50%;
  display: inline-grid; place-items: center; gap: 0; }
.dockrow #paints button:hover, .dockrow #carpets button:hover, .pick:hover { background: rgba(255, 255, 255, .08); }
.dockrow #paints button[aria-pressed="true"], .dockrow #carpets button[aria-pressed="true"] { background: transparent; }
.chip { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .45); flex: none;
  box-shadow: 0 0 0 0 var(--ink), 0 1px 2px rgba(0, 0, 0, .4); transition: box-shadow .15s ease; }
#paints button[aria-pressed="true"] .chip, #carpets button[aria-pressed="true"] .chip, .pick.on .chip, .pick:has(input:focus-visible) .chip { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }
/* moquette row: "any colour" is a colour-wheel dot over a native colour input */
.chip.rainbow { background: conic-gradient(#e0533d, #e6c34a, #5cb85c, #3fa7d6, #7b5ce0, #e0533d); }
.pick { position: relative; display: inline-grid; place-items: center; border-radius: 50%; cursor: pointer; height: 44px; min-width: 44px; padding: 0; border: 0; }
.pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
@media (prefers-reduced-motion: reduce) { .chip { transition: none; } }

#loading, #nojs, #fail { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg);
  color: var(--muted); font-size: 18px; text-align: center; padding: 24px; transition: opacity .4s ease; }
#loading.gone { opacity: 0; pointer-events: none; }

/* floor plan overlay: a native <dialog> for free Esc-to-close and focus handling (semantic HTML first) */
#floorplan { position: fixed; inset: 0; margin: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  border: none; padding: 0; background: var(--bg); color: var(--ink); overscroll-behavior: contain; }
#floorplan::backdrop { background: rgba(0, 0, 0, .6); }
#floorplan header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(10px + var(--safe-t)) 14px 10px; background: var(--glass); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 1; }
#floorplan h2 { font-size: 16px; margin: 0; letter-spacing: -0.01em; }
#floorplan #fp-close { min-width: 44px; min-height: 44px; font-size: 16px; }
#fp-svg-wrap { padding: 16px; max-width: 1100px; margin: 0 auto; }
#fp-svg-wrap svg { width: 100%; height: auto; display: block; border-radius: 8px; box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 8px 24px rgba(0, 0, 0, .35); }
#fp-dims { max-width: 1100px; margin: 0 auto 8px; padding: 0 16px; color: var(--muted); font-size: 13px; }
#fp-dims summary { cursor: pointer; color: var(--ink); padding: 6px 0; min-height: 44px; display: flex; align-items: center; }
#fp-dims ul { margin: 0 0 12px; padding-left: 18px; display: grid; gap: 4px; }
#floorplan footer { position: sticky; bottom: 0; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px calc(10px + var(--safe-b)); background: var(--glass); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#fp-pdf { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
#fp-pdf:hover { filter: brightness(1.08); }
#fp-pdf-status { font-size: 13px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { #floorplan, #floorplan * { transition: none !important; } }

/* phones: the rows already wrap (see .dockrow above), so this is just spacing/typography */
@media (max-width: 640px) {
  #dock { width: calc(100% - 16px); bottom: calc(8px + var(--safe-b)); padding: 8px; gap: 8px; border-radius: 14px; }
  .brand { left: 8px; top: calc(8px + var(--safe-t)); padding: 8px 12px; }
  .brand h1 { font-size: 15px; }
  .brand p { font-size: 12px; }
}
/* short screens (phones held sideways): trim the now-playing row, nudge the hint up */
@media (max-height: 480px) {
  #dock { bottom: calc(8px + var(--safe-b)); padding: 6px; gap: 6px; }
  #nowtext .label { display: none; }
  #hint { bottom: calc(128px + var(--safe-b)); }
  .brand { padding: 6px 10px; } .brand p { display: none; }
}
@media (max-width: 640px) and (min-height: 481px) { #hint { bottom: calc(190px + var(--safe-b)); white-space: normal; width: max-content; max-width: calc(100% - 32px); text-align: center; } }
/* Phone, thinner panels (Luca 2026-10-07: "make the top and bottom grey boxes thinner"). The title card is one
   short line; the dock puts Display and Wall paint side by side and drops their visible labels (the groups keep
   aria-label / aria-labelledby, so screen readers still hear them). Tap targets stay 44px. */
@media (max-width: 640px) {
  .brand { padding: 6px 10px; border-radius: 10px; }
  .brand h1 { font-size: 14px; }
  .brand p { display: none; }
  #dock { grid-template-columns: auto auto; justify-content: space-between; column-gap: 6px; row-gap: 4px; padding: 6px 8px; }
  #now { grid-column: 1 / -1; }
  #nowtext .label { display: none; }
  #nowname { font-size: 14px; }
  .dockrow { flex-wrap: nowrap; gap: 4px; }
  .dockrow .grouplabel { display: none; }
  .dockrow button { font-size: 13px; padding: 0 8px; gap: 6px; }
  .dockrow #paints button { padding: 0; }
  /* 2026-10-09 (Luca, iPhone: "the bottom bar is way too high"): the dock is the now-playing row plus ONE line of
     toggles with short labels; the two colour rows fold away behind the palette button and open as full-width rows
     with their labels back on. Collapsed it is as thin as before the moquette and mirror were added. */
  .long { display: none; } .short { display: inline; }
  #colours { display: inline-flex; padding: 0; width: 44px; justify-content: center; }
  #colours[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); }
  #colours[aria-expanded="true"] .icon { color: #111; }
  .dockrow[aria-label="Display options"], .dockrow[aria-label="Wall paint"], .dockrow[aria-label="Moquette"] { grid-column: 1 / -1; }
  /* the toggles SHRINK to fit, whatever font the phone uses (iOS sets these wider than Chrome did): a single track
     that cannot grow past the dock, buttons that give up width before the row overflows */
  #dock { grid-template-columns: minmax(0, 1fr); }
  .dockrow[aria-label="Display options"] { flex-wrap: nowrap; gap: 4px; }
  .dockrow[aria-label="Display options"] button { flex: 1 1 auto; min-width: 0; padding: 0 6px; justify-content: center; overflow: hidden; }
  .dockrow[aria-label="Display options"] #colours { flex: 0 0 44px; }
  .dockrow[aria-label="Display options"] .seg { flex: 1 1 auto; min-width: 0; }
  .dockrow[aria-label="Display options"] .seg button { flex: 1 1 0; }
  .dockrow[aria-label="Wall paint"], .dockrow[aria-label="Moquette"] { display: none; }
  #dock.colours-open .dockrow[aria-label="Wall paint"], #dock.colours-open .dockrow[aria-label="Moquette"] { display: flex; flex-wrap: wrap; row-gap: 0; }
  #dock.colours-open .dockrow:not([aria-label="Display options"]) .grouplabel { display: block; flex-basis: 100%; margin: 2px 0 -4px; padding-left: 4px; }
  #hint { bottom: calc(126px + var(--safe-b)); }
}
@media (prefers-reduced-motion: reduce) { #hint, #loading { transition: none; } }
/* phones held sideways (wider than 640, under 480 tall): the same fold-away colours and short labels as portrait */
@media (max-height: 480px) and (min-width: 641px) {
  .long { display: none; } .short { display: inline; }
  #colours { display: inline-flex; padding: 0; width: 44px; justify-content: center; }
  #colours[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); }
  #colours[aria-expanded="true"] .icon { color: #111; }
  .dockrow .grouplabel { display: none; }
  #dock { grid-template-columns: 1fr; }
  .dockrow[aria-label="Wall paint"], .dockrow[aria-label="Moquette"] { display: none; }
  #dock.colours-open .dockrow[aria-label="Wall paint"], #dock.colours-open .dockrow[aria-label="Moquette"] { display: flex; }
}

/* phones: the planned row and the projector row take the full width; the readout wraps */
@media (max-width: 640px) {
  #plannedrow, #projrow { grid-column: 1 / -1; }
  #projrow { flex-wrap: wrap; }
  #plannedrow .grouplabel, #projrow .grouplabel { display: none; }
  #plannedrow #projBtn { margin-left: auto; }
}

/* [hidden] must win over the .dockrow display rules (the planned and projector rows hide this way) */
[hidden] { display: none !important; }

/* projector setups (2026-10-09): a wrapping row of option buttons, the chosen one filled, and one info line */
#projopts { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; min-width: 0; }
#projopts button { font-size: 13px; padding: 0 10px; min-height: 40px; }
#projopts button[aria-pressed="true"] { background: var(--ink); color: #111; border-color: var(--ink); }
@media (max-width: 640px) { #projopts button { min-height: 44px; padding: 0 8px; } }

/* phones (portrait and sideways): the five setups become one dropdown, the info line two short lines */
#projSelect { display: none; font: inherit; font-size: 14px; color: inherit; background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line); border-radius: 10px; min-height: 44px; padding: 0 8px; flex: 1 1 auto; min-width: 0; }
@media (max-width: 640px), (max-height: 480px) {
  #projopts { display: none; }
  #projSelect { display: block; }
  #projrow { flex-wrap: wrap; }
  #projInfo { font-size: 11px; line-height: 1.3; }
}
@media (max-width: 640px), (max-height: 480px) {
  #plannedrow { flex-wrap: nowrap; gap: 4px; }
  #plannedrow #projSelect { font-size: 13px; padding: 0 6px; }
  #plannedrow #projBtn { margin-left: 0; flex: none; padding: 0 10px; }
  #projrow .grouplabel { display: none; }
}
@media (max-width: 640px), (max-height: 480px) { #plannedrow #carpets { flex-wrap: nowrap; flex: none; } }

/* phones: the projector info is one line (tap to read it all), so the panel stays thin */
@media (max-width: 640px), (max-height: 480px) {
  #projInfo { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
  #projInfo.open { display: block; }
  #projInfo::before { content: "ⓘ "; }
}

/* ceiling spots row (2026-10-09): colour dot (a native colour input under it), dimmer, percentage */
#spotrow input[type="range"], #amarow input[type="range"] { flex: 1 1 140px; min-width: 0; min-height: 44px; accent-color: var(--ink); }
#spotVal, #amaVal { font-size: 13px; color: var(--muted); min-width: 3.2em; text-align: right; }
#spotsBtn[aria-expanded="true"], #amaBtn[aria-expanded="true"] { background: var(--ink); color: #111; border-color: var(--ink); }
@media (max-width: 640px), (max-height: 480px) { #spotrow, #amarow { grid-column: 1 / -1; flex-wrap: nowrap; } #spotrow .grouplabel, #amarow .grouplabel { display: none; } #plannedrow #amaBtn { margin-left: auto; flex: none; } #plannedrow #spotsBtn { flex: none; } }
