/* Palette taken from the room's own finishes: trim plaster, stone, carpet navy and oak. */
:root {
  --paper: #eeece7;
  --sheet: rgba(255, 255, 253, 0.9);
  --solid: #fbfaf8;
  --line: #ddd9d0;
  --line-soft: #e9e6df;
  --ink: #1e2733;
  --ink-2: #4b5563;
  --muted: #858a90;
  --navy: #2c4168;
  --oak: #a07a52;
  --ok: #3f9a62;
  --warn: #c98516;
  --bad: #c9402d;
  --font: "IBM Plex Sans Thai", "Leelawadee UI", "Noto Sans Thai", Tahoma, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.55 var(--font); color: var(--ink); background: var(--paper); overflow: hidden; font-variant-numeric: tabular-nums; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy); }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Model fills the window; everything else floats on it. */
#viewport { position: fixed; inset: 0; background: var(--paper); }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.bar, .sheet, .viewtools > *, #notice {
  background: var(--sheet); backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid var(--line); box-shadow: 0 1px 0 #ffffff inset, 0 10px 30px -18px #2c416840;
}
.bar { position: fixed; left: 14px; right: 14px; display: flex; align-items: center; gap: 20px; border-radius: 14px; z-index: 3; }

/* Top bar */
.top { top: 14px; height: 52px; padding: 0 10px 0 18px; }
.title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.title strong { font-size: 15.5px; font-weight: 600; letter-spacing: -.005em; white-space: nowrap; }
.sim { font-size: 12px; color: var(--oak); white-space: nowrap; }
.sim::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--oak); margin-right: 6px; vertical-align: 1px; }
.tabs { display: flex; gap: 4px; margin: 0 auto; }
.tabs button { border: 0; background: none; padding: 6px 4px; margin: 0 8px; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 0; }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--navy); }
.now { display: flex; align-items: center; gap: 14px; min-width: 0; }
.now > span { color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.now time { font-size: 20px; font-weight: 500; letter-spacing: .01em; }
.alerts-btn { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--solid); border-radius: 99px; padding: 5px 12px 5px 10px; font-size: 13px; color: var(--ink-2); }
.alerts-btn i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.alerts-btn.warning i { background: var(--warn); }
.alerts-btn.critical i { background: var(--bad); box-shadow: 0 0 0 3px #c9402d26; }
.alerts-btn[aria-expanded=true] { border-color: var(--navy); color: var(--ink); }

/* Side sheets */
.sheet { position: fixed; top: 78px; bottom: 92px; border-radius: 14px; overflow: auto; z-index: 2; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.left { left: 14px; width: 268px; padding: 16px 16px 18px; }
.right { right: 14px; width: 328px; padding: 18px 18px 20px; bottom: 138px; }
h2 { font-size: 14px; font-weight: 600; margin: 0; }
.sheet-head p { margin: 2px 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.field { display: block; font-size: 12.5px; color: var(--ink-2); margin: 12px 0 5px; }
select, input[type=number] { width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--solid); }
.inline { display: flex; gap: 6px; }
.inline > * { flex: 1; min-width: 0; }
input[aria-invalid=true] { border-color: var(--bad); background: #fbeeea; color: var(--bad); }
input[aria-invalid=true]:focus-visible { outline-color: var(--bad); }
.hint { margin: 6px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--bad); }
.hint:empty { display: none; }
.inline button, .wide { border: 1px solid var(--line); background: var(--solid); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.wide { width: 100%; margin-top: 8px; }
.inline button:hover, .wide:hover { border-color: var(--navy); }
button:disabled { opacity: .45; cursor: default; }
.result { margin: 14px 0 4px; padding: 10px 0 10px 12px; border-left: 2px solid var(--navy); }
.result strong, .result span { display: block; }
.result span { font-size: 12.5px; color: var(--muted); }
details { margin-top: 16px; font-size: 12.5px; color: var(--muted); }
summary { cursor: pointer; }
#roomSettings { margin-bottom: 2px; }

/* Collapse and reopen the left sheet */
.collapse { position: sticky; top: 0; float: right; z-index: 1; width: 28px; height: 28px; margin: -4px -4px 0 8px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--solid); border-radius: 8px; padding: 0; }
.collapse svg, .reopen svg { width: 15px; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.collapse:hover, .reopen:hover { border-color: var(--navy); }
.reopen { position: fixed; top: 78px; left: 14px; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 7px 13px 7px 11px; border-radius: 10px; font-size: 13px; color: var(--ink-2);
  background: var(--sheet); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); box-shadow: 0 10px 30px -18px #2c416840; }
body.side-collapsed #sidebar { display: none; }

/* Device list */
.layers { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-soft); }
.layer { border-bottom: 1px solid var(--line-soft); }
.row { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.name { flex: 1; display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; text-align: left; min-width: 0; }
.name b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name .n { color: var(--muted); font-size: 12.5px; }
.name::before { content: ""; width: 0; height: 0; border-left: 4px solid var(--muted); border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .15s; flex: none; }
.layer.open .name::before { transform: rotate(90deg); }
.state { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.state.warning { background: var(--warn); }
.state.offline { background: var(--bad); }
.items { list-style: none; margin: -2px 0 8px; padding: 0 0 0 12px; }
.items button { width: 100%; display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 6px; border-radius: 6px; text-align: left; font-size: 12.5px; color: var(--ink-2); }
.items button:hover { background: #2c41680d; }
.items button[aria-current=true] { background: #2c416814; color: var(--ink); }
.items .code { color: var(--muted); min-width: 58px; font-size: 11.5px; }
.items .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Switches */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--ink-2); padding: 4px 0; }
.switch input, .toggle { appearance: none; width: 30px; height: 17px; border-radius: 99px; background: #d6d2c9; position: relative; margin: 0; flex: none; cursor: pointer; border: 0; padding: 0; transition: background .15s; }
.switch input::after, .toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #0002; transition: transform .15s; }
.switch input:checked, .toggle[aria-pressed=true] { background: var(--navy); }
.switch input:checked::after, .toggle[aria-pressed=true]::after { transform: translateX(13px); }
.overlays { margin-top: 18px; display: grid; gap: 6px; }
.overlays h2 { margin-bottom: 2px; }

.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: #e7e4dd; gap: 2px; }
.seg button { border: 0; background: none; padding: 3px 11px; border-radius: 7px; font-size: 12.5px; color: var(--ink-2); }
.seg button[aria-pressed=true], .seg button[aria-checked=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px #1e273322; }
.heat { margin-top: 4px; width: max-content; }
.legend { font-size: 11.5px; color: var(--muted); }
.legend .ramp { height: 6px; border-radius: 3px; margin: 5px 0 2px; }
.legend .scale { display: flex; justify-content: space-between; }

/* View tools and notices */
.viewtools { position: fixed; right: 14px; bottom: 92px; display: flex; gap: 8px; z-index: 2; }
.viewtools > * { border-radius: 10px; }
.viewtools .seg { padding: 3px; background: var(--sheet); }
.viewtools .switch { padding: 4px 12px 4px 8px; }
#notice { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); max-width: 60vw; padding: 6px 14px; border-radius: 10px; font-size: 13px; z-index: 2; }
#notice:empty { display: none; }

/* Callouts: a leader line from the device up to a small tag, like a drawing annotation. */
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.callout { position: absolute; left: 0; top: 0; pointer-events: none; }
.callout::before { content: ""; position: absolute; left: -2.5px; top: -2.5px; width: 5px; height: 5px; border-radius: 50%; background: var(--ink); }
.callout::after { content: ""; position: absolute; left: 0; bottom: 0; width: 1px; height: 26px; background: var(--ink); opacity: .55; }
.callout span {
  position: absolute; left: -1px; bottom: 26px; pointer-events: auto; cursor: pointer; white-space: nowrap;
  padding: 1px 7px 2px; font-size: 11px; line-height: 1.5; background: #fffffdee; border: 1px solid var(--line); border-left: 2px solid var(--ink); border-radius: 0 5px 5px 0; color: var(--ink);
}
.callout.warning span { border-left-color: var(--warn); }
.callout.offline span { border-left-color: var(--bad); color: var(--bad); }
.callout.focus span { background: var(--navy); color: #fff; border-color: var(--navy); }
.callout.hover span { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Inspector */
.insp-head { display: flex; align-items: flex-start; gap: 10px; }
.insp-head .meta { font-size: 12px; color: var(--muted); }
.insp-head h3 { margin: 2px 0 0; font-size: 17px; line-height: 1.35; font-weight: 600; }
.close { margin-left: auto; width: 28px; height: 28px; flex: none; border: 1px solid var(--line); background: var(--solid); border-radius: 8px; font-size: 16px; line-height: 1; color: var(--ink-2); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; margin-top: 8px; color: var(--ok); }
.status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.warning { color: var(--warn); }
.status.offline { color: var(--bad); }
.block { border-top: 1px solid var(--line-soft); margin-top: 16px; padding-top: 14px; }
.block h4 { margin: 0 0 8px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.reading { font-size: 34px; font-weight: 500; line-height: 1.1; letter-spacing: -.01em; }
.reading em, .facts em { font-style: normal; font-size: 13px; color: var(--muted); margin-left: 4px; font-weight: 400; }
.reading-label { font-size: 12.5px; color: var(--ink-2); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 12px 0 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.spark { width: 100%; height: 58px; display: block; margin-top: 12px; }
.spark-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.spec { margin: 0; padding-left: 16px; font-size: 13px; color: var(--ink-2); }
.spec li + li { margin-top: 2px; }
.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.actions button { flex: 1; border: 1px solid var(--line); background: var(--solid); border-radius: 9px; padding: 8px 10px; font-size: 13px; }
.actions button:hover { border-color: var(--navy); }
.actions .primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.zones { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.zones b { display: block; font-size: 20px; font-weight: 500; }
.zones span { font-size: 12px; color: var(--muted); display: block; }
.events { list-style: none; margin: 0; padding: 0; }
.events button { width: 100%; display: grid; grid-template-columns: 7px 1fr auto; align-items: baseline; gap: 10px; border: 0; background: none; padding: 6px 4px; border-radius: 6px; text-align: left; font-size: 13px; }
.events button:hover { background: #2c41680d; }
.events i { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); transform: translateY(-1px); }
.events .critical i { background: var(--bad); }
.events time { font-size: 12px; color: var(--muted); }
.events .ended { color: var(--muted); }
.empty { color: var(--muted); font-size: 13px; margin: 0; }

/* Bottom bar: readings and the day timeline */
.bottom { bottom: 14px; height: 64px; padding: 0 16px 0 6px; gap: 0; }
.kpis { display: flex; margin: 0; height: 100%; flex: none; }
.kpis div { display: flex; flex-direction: column; justify-content: center; padding: 0 16px; border-right: 1px solid var(--line-soft); min-width: 0; }
.kpis dt { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.kpis dd { margin: 0; font-size: 17px; font-weight: 500; white-space: nowrap; }
.kpis dd em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.kpis .warning dd { color: var(--warn); }
.kpis .offline dd { color: var(--bad); }
.timeline { flex: 1; display: flex; align-items: center; gap: 14px; padding-left: 16px; min-width: 0; }
.play { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 0; background: var(--navy); }
.play svg { width: 14px; fill: #fff; }
.track { position: relative; flex: 1; min-width: 120px; height: 40px; }
.band { position: absolute; left: 0; right: 0; top: 9px; height: 8px; display: flex; border-radius: 2px; overflow: hidden; background: #e4e0d8; }
.band span { height: 100%; }
.band .session { background: #2c416859; }
.band .arrive, .band .close, .band .break, .band .lunch { background: #a07a5250; }
.band .setup { background: #a07a5230; }
#time { position: absolute; left: -7px; right: -7px; width: calc(100% + 14px); top: 0; height: 26px; margin: 0; background: transparent; appearance: none; cursor: pointer; }
#time::-webkit-slider-runnable-track { height: 26px; background: transparent; }
#time::-moz-range-track { height: 26px; background: transparent; }
#time::-webkit-slider-thumb { appearance: none; width: 14px; height: 26px; background: linear-gradient(var(--oak), var(--oak)) center / 2px 100% no-repeat; border: 0; }
#time::-moz-range-thumb { width: 2px; height: 26px; border: 0; border-radius: 0; background: var(--oak); }
.ticks { position: absolute; left: 0; right: 0; top: 23px; font-size: 10.5px; color: var(--muted); }
.ticks span { position: absolute; transform: translateX(-50%); }
.speed { flex: none; }

/* CCTV on-screen display over the camera view */
.osd { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: 92px 360px 104px 300px;
  font: 500 13px/1.3 var(--font); color: #fff; text-shadow: 0 1px 3px #000a;
  background: radial-gradient(ellipse at center, transparent 62%, #0006); }
.osd-top, .osd-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.osd .rec { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e5484d; margin-right: 7px; animation: blink 1.2s steps(2) infinite; }
.osd-bottom span { font-size: 12px; opacity: .85; }
.osd-bottom button { pointer-events: auto; text-shadow: none; padding: 6px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--sheet); color: var(--ink); font-size: 13px; }
.osd-lost { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; letter-spacing: .12em; background: #1e2733e6; color: #fff; }
@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 1240px) {
  .kpis div:nth-child(n+5) { display: none; }
  .now > span { display: none; }
}
@media (max-width: 860px) {
  body { overflow: auto; height: auto; }
  #viewport { position: relative; height: 62dvh; min-height: 340px; }
  .bar, .sheet, .viewtools, #notice, .reopen { position: static; transform: none; margin: 10px 12px; width: auto; max-width: none; }
  .top { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 8px 14px; order: -2; }
  .tabs { margin: 0; }
  body { display: flex; flex-direction: column; }
  #viewport { order: -1; }
  .viewtools { justify-content: flex-end; }
  .sheet { max-height: none; }
  .bottom { height: auto; flex-direction: column; align-items: stretch; padding: 10px 12px; }
  .kpis { flex-wrap: wrap; height: auto; }
  .kpis div { padding: 6px 12px; flex: 1 1 30%; }
  .kpis div:nth-child(n+5) { display: flex; }
  .timeline { padding: 8px 0 0; }
  .speed { display: none; }
  .osd { padding: 16px; }
}
