/* The panel echoes the hardware control panel's design language (Control/design): near-black
   cells with hairline borders, small letterspaced mono labels, heavy sans values, one hot
   orange for "selected", green for "on", amber for "hold". The ceiling's light is the hero, so
   the interface itself never glows. */
:root {
  --bg: #0b0a09; --panel: #100f0e; --cell: #191816; --cell-hi: #22201e; --line: #2b2927;
  --text: #f3f0ea; --dim: #8f8a83; --faint: #5d5953;
  --accent: #ff5a36; --on: #7ddc84; --amber: #f5a623;
  --sans: "Inter Tight", "Inter", "Segoe UI Variable Display", "Helvetica Neue", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --panel-w: 400px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); overscroll-behavior: none; }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

.app { position: fixed; inset: 0; display: grid; grid-template-rows: minmax(240px, 54svh) 1fr; grid-template-columns: 100%; }
.stage { position: relative; overflow: hidden; background: #000; min-height: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#view:active { cursor: grabbing; }

/* ---------- heads-up layer over the 3D view ---------- */
.hud { position: absolute; pointer-events: none; z-index: 2; transition: opacity .4s; }
.hud > *, .hud button { pointer-events: auto; }
.hud-top { top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 12px 28px;
  background: linear-gradient(#000a, #0000); }
.brand { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; pointer-events: none; }
.brand-mark { display: inline-grid; gap: 3px; width: 18px; }
.brand-mark i { height: 2px; border-radius: 1px; background: var(--accent); }
.brand-mark i:nth-child(2) { background: #ff2f8e; } .brand-mark i:nth-child(3) { background: #7a5cff; }
.brand-mark.big { width: 44px; gap: 7px; } .brand-mark.big i { height: 4px; border-radius: 2px; }
.brand-name { font-weight: 800; letter-spacing: -0.01em; font-size: 16px; }
.tag { font: 600 9.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
  border: 1px solid #ffffff2b; padding: 4px 6px 3px; border-radius: 2px; background: #0006; }
.tag-warn { color: #1a1206; background: var(--amber); border-color: var(--amber); }
.hud-actions { display: flex; gap: 6px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid #ffffff26; background: #0008; border-radius: 3px; color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: #fff2; }
#btnPanel { display: none; }

.now { left: 14px; bottom: 58px; max-width: min(70%, 520px); text-shadow: 0 1px 12px #000c; pointer-events: none; }
.now-label { font: 600 9.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: #ffffffa0; margin-bottom: 5px; }
.now-name { font-weight: 800; font-size: clamp(22px, 4.2vw, 46px); line-height: 1; letter-spacing: -0.025em; }
.now-desc { display: none; margin-top: 8px; font-size: 14px; line-height: 1.35; color: #ffffffb8; max-width: 44ch; }

.hud-bottom { left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; padding: 26px 12px 10px;
  background: linear-gradient(#0000, #000b); }
.cams { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { font: 600 10.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; padding: 9px 10px 8px; border-radius: 2px;
  border: 1px solid #ffffff30; background: #0009; color: #ffffffc8; }
.chip.is-on { background: var(--text); color: #111; border-color: var(--text); }
.chip.auto.is-on { background: var(--on); border-color: var(--on); }
.stat { display: none; top: 52px; left: 12px; font: 500 10px/1 var(--mono); letter-spacing: .06em; color: #ffffffa0; padding: 6px 7px 5px; white-space: nowrap;
  text-transform: uppercase; background: #0009; border: 1px solid #ffffff22; border-radius: 2px; pointer-events: auto; }
.app.debug .stat { display: block; }
#tagLive { pointer-events: auto; cursor: pointer; }
.sound-btn { height: 36px; padding: 0 11px 0 9px; display: flex; align-items: center; gap: 7px; border: 1px solid #ffffff40; background: #000a; border-radius: 3px;
  color: var(--text); font: 600 10.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.sound-btn svg { width: 18px; height: 18px; }
.sound-btn .cross { display: none; }
.sound-btn.is-on { background: var(--amber); border-color: var(--amber); color: #1a1206; }
.sound-btn.is-on .waves { display: none; } .sound-btn.is-on .cross { display: block; }
.room-toggles { margin-top: 6px; }

/* ---------- control panel ---------- */
.panel { background: var(--panel); border-top: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 2px 14px calc(18px + var(--safe-b)); min-height: 0; scrollbar-width: thin; scrollbar-color: #333 transparent; }
.sec { padding: 14px 0 6px; }
.sec-h { margin: 0 0 9px; display: flex; align-items: baseline; gap: 10px; font: 600 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--dim); padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.sec-h b { color: var(--text); font-weight: 700; letter-spacing: .2em; }
.sec-h.accent { border-color: var(--accent); } .sec-h.accent b { color: var(--accent); }
.sec-h.on { border-color: #7ddc8480; } .sec-h.on b { color: var(--on); }
.sec-h span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.pad { position: relative; min-height: 62px; padding: 20px 7px 7px; text-align: left; background: var(--cell); border: 1px solid var(--line); border-radius: 2px;
  font-weight: 700; font-size: 13px; line-height: 1.08; letter-spacing: -0.01em; display: flex; align-items: flex-end; transition: background .12s, transform .08s; }
.pad::before { content: attr(data-n); position: absolute; top: 6px; left: 7px; font: 600 9px/1 var(--mono); color: var(--faint); }
.pad:active { transform: scale(.97); }
.pad.is-on { background: var(--accent); border-color: var(--accent); color: #160703; }
.pad.is-on::before { color: #16070399; }
.pads-more { margin-top: 5px; }
.pads-more .pad { min-height: 46px; padding-top: 8px; font-size: 12px; font-weight: 600; }
.pads-more .pad::before { display: none; }
.link-btn { margin-top: 9px; font: 600 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); padding: 8px 0; }
.link-btn:hover { color: var(--text); }

.trigger { width: 100%; min-height: 64px; margin-bottom: 12px; border: 1px solid var(--amber); border-radius: 2px; background: #f5a62312; color: var(--amber);
  display: flex; align-items: center; justify-content: center; gap: 12px; font-weight: 800; font-size: 22px; letter-spacing: -0.01em; text-transform: uppercase;
  user-select: none; -webkit-user-select: none; touch-action: none; transition: background .08s, color .08s, transform .08s; }
.trigger small { font: 600 9.5px/1 var(--mono); letter-spacing: .18em; opacity: .75; }
.trigger.is-down { background: var(--amber); color: #1a1206; transform: scale(.985); }

.row { padding: 7px 0 9px; }
.row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.row-name { font-size: 13.5px; font-weight: 600; color: #e3dfd8; }
.row-val { font: 600 12.5px/1 var(--mono); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-desc { font-size: 11.5px; line-height: 1.3; color: var(--faint); margin-top: 1px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; margin: 0; background: transparent; display: block; cursor: pointer; touch-action: pan-y; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--text) 0 var(--p, 50%), #34312e var(--p, 50%) 100%); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: #34312e; }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--text); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: var(--text); border: 4px solid var(--panel); box-shadow: 0 0 0 1px #5a5650; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 3px solid var(--panel); box-shadow: 0 0 0 1px #5a5650; }
input[type=range]:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.row.hot .row-val { color: var(--accent); }
.row.hot input[type=range]::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--accent) 0 var(--p, 50%), #34312e var(--p, 50%) 100%); }

.toggles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-bottom: 6px; }
.toggles:empty { display: none; }
.toggle { min-height: 46px; padding: 7px; text-align: left; background: var(--cell); border: 1px solid var(--line); border-radius: 2px; display: flex; flex-direction: column; justify-content: space-between;
  font-weight: 600; font-size: 12px; line-height: 1.1; }
.toggle small { font: 600 9px/1 var(--mono); letter-spacing: .14em; color: var(--faint); }
.toggle.is-on { background: var(--on); border-color: var(--on); color: #08210b; }
.toggle.is-on small { color: #08210b99; }

.palettes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.swatch { display: block; text-align: left; }
.swatch i { display: block; height: 34px; border-radius: 2px; border: 1px solid #ffffff14; }
.swatch span { display: block; font: 600 9px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin: 5px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swatch.is-on i { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--text); }
.swatch.is-on span { color: var(--text); }
.families { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.dot { width: 28px; height: 28px; border-radius: 50%; border: 1px solid #ffffff1c; }
.dot.is-on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--text); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.seg button { padding: 12px 4px 11px; font: 600 10.5px/1.1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); background: var(--cell); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.is-on { background: var(--text); color: #111; }
.spectrum-wrap { position: relative; margin-top: 8px; }
.spectrum { width: 100%; height: 64px; display: block; background: #0c0b0a; border: 1px solid var(--line); border-radius: 2px; }
.mute { position: absolute; top: 6px; right: 6px; font: 600 9.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; padding: 6px 7px 5px; border: 1px solid #ffffff30; border-radius: 2px; background: #000a; color: var(--dim); }
.mute.is-on { background: var(--amber); color: #1a1206; border-color: var(--amber); }
.note { font-size: 12px; line-height: 1.4; color: var(--amber); margin: 8px 0 0; }
.foot { padding: 16px 0 4px; border-top: 1px solid var(--line); margin-top: 12px; }
.foot p { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--faint); }

/* ---------- start overlay ---------- */
.start { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; text-align: center;
  background: radial-gradient(120% 90% at 50% 40%, #0b0a09b8, #0b0a09f2); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: opacity .6s, visibility .6s; }
.start.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.start-card { max-width: 440px; display: flex; flex-direction: column; align-items: center; }
.start h1 { font-size: clamp(40px, 11vw, 72px); line-height: .95; letter-spacing: -0.04em; font-weight: 800; margin: 22px 0 12px; }
.start-tag { font-size: 17px; color: #ffffffb0; margin: 0 0 30px; }
.start-btn { min-width: 230px; padding: 19px 28px 18px; background: var(--accent); color: #160703; font-weight: 800; font-size: 18px; letter-spacing: -0.01em; border-radius: 3px;
  transition: transform .1s, filter .2s; }
.start-btn:not(:disabled):hover { filter: brightness(1.1); } .start-btn:active { transform: scale(.97); }
.start-btn:disabled { background: var(--cell-hi); color: var(--dim); cursor: default; }
.start-note { font: 500 11px/1.5 var(--mono); letter-spacing: .06em; color: var(--dim); margin: 18px 0 0; text-transform: uppercase; }
.start-fine { font-size: 12px; line-height: 1.45; color: var(--faint); margin: 14px 0 0; max-width: 36ch; }

.toast { position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); z-index: 12; max-width: min(92vw, 460px);
  background: #1f1d1b; border: 1px solid var(--amber); color: var(--text); padding: 11px 14px; border-radius: 3px; font-size: 13px; line-height: 1.35; box-shadow: 0 8px 30px #000a; }

/* ---------- phones: one tight row of camera chips, the effect name above it ---------- */
@media (max-width: 859px) {
  .cams { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-width: 0; }
  .cams::-webkit-scrollbar { display: none; }
  .cams { flex: 1 1 auto; gap: 4px; }
  .chip { padding: 9px 6px 8px; font-size: 9px; letter-spacing: .04em; white-space: nowrap; }
  .now { bottom: 50px; left: 12px; }
  .now-label { display: none; }
  .stat { top: 80px; }
  .hud-bottom { padding: 22px 10px 9px; }
}

/* ---------- laptop / projector: big view, panel at the side ---------- */
@media (min-width: 860px) and (min-aspect-ratio: 11/10) {
  .app { grid-template-rows: 100%; grid-template-columns: 1fr var(--panel-w); }
  .panel { border-top: 0; border-left: 1px solid var(--line); padding: 6px 20px 24px; }
  #btnPanel { display: grid; }
  .hud-top { padding: 18px 18px 40px; }
  .brand-name { font-size: 19px; }
  .now { left: 26px; bottom: 76px; }
  .stat { top: 62px; left: 18px; }
  .now-desc { display: block; }
  .hud-bottom { padding: 40px 22px 18px; }
  .app.clean { grid-template-columns: 1fr 0; }
  .app.clean .panel { display: none; }
}
/* Clean shot: no chrome at all after a moment without the pointer (press H or the button to return). */
.app.clean.quiet .hud { opacity: 0; }
.app.clean.quiet #view { cursor: none; }
/* Short landscape phones: side-by-side, narrower panel. */
@media (max-height: 520px) and (min-aspect-ratio: 11/10) {
  .app { grid-template-rows: 100%; grid-template-columns: 1fr min(46vw, 360px); }
  .panel { border-top: 0; border-left: 1px solid var(--line); }
  .now-name { font-size: 22px; } .now { bottom: 52px; }
}
@media (max-width: 380px) { .pad { font-size: 12px; } .palettes { grid-template-columns: repeat(5, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
