:root {
  --bg: #0c1b18; --panel: #112620; --line: rgba(234,242,241,.12);
  --fg: #eaf2f1; --muted: #98b3aa; --glow: #52d9c5; --pow: #ffd25a; --warn: #ff9a3d; --bad: #ff5a5a;
}
* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; height: 100dvh; display: grid; grid-template-rows: 76px minmax(0,1fr) auto 32px; background: var(--bg); color: var(--fg); font-family: "Anek Latin",system-ui,sans-serif; }
button, input { font: inherit; }
button { border: 1px solid var(--line); background: transparent; color: var(--fg); cursor: pointer; border-radius: 8px; padding: 9px 13px; font-size: 14px; font-weight: 600; min-height: 40px; transition: background .18s, border-color .18s; }
button:hover { background: rgba(255,255,255,.07); border-color: rgba(234,242,241,.3); }
button.on { background: var(--glow); border-color: var(--glow); color: #0b2720; }
button.warn.on { background: var(--warn); border-color: var(--warn); }
:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; }
#app-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 38px; display: grid; place-items: center; border: 1px solid var(--glow); border-radius: 16px 16px 4px 4px; color: var(--glow); font-weight: 700; font-size: 22px; }
.brand strong { display: block; font-size: 21px; line-height: 1.1; }
.brand div > span { color: var(--muted); font-size: 12px; }
.project-title { font-size: 16px; font-weight: 600; }
.project-title span { color: var(--muted); font-weight: 400; margin-left: 8px; }
.prototype-badge { color: var(--glow); font-size: 12px; }
#workspace { display: grid; grid-template-columns: 300px minmax(0,1fr) 280px; grid-template-areas: "tour viewer dash"; min-height: 0; }
#viewer { grid-area: viewer; position: relative; min-width: 0; min-height: 0; overflow: hidden; isolation: isolate; }
#stage { position: absolute; inset: 0; touch-action: none; }
#stage canvas { display: block; width: 100%; height: 100%; }
#view-heading { position: absolute; top: 20px; left: 22px; pointer-events: none; }
#view-heading span { display: block; font-size: 10px; letter-spacing: .14em; color: var(--glow); margin-bottom: 4px; }
#view-heading b { font-size: 17px; font-weight: 500; }
#view-hint { position: absolute; bottom: 45px; width: 100%; text-align: center; color: #b4cbc3; font-size: 12px; pointer-events: none; }
#legend { position: absolute; left: 16px; right: 16px; bottom: 16px; display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 14px; font-size: 11px; color: #b4cbc3; pointer-events: none; }
#legend i { display: inline-block; height: 6px; width: 6px; border-radius: 50%; margin-right: 5px; }
.panel { background: var(--panel); min-width: 0; min-height: 0; }
#tour { grid-area: tour; display: flex; flex-direction: column; border-right: 1px solid var(--line); overflow: hidden; }
#tour header { padding: 23px 20px 17px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.eyebrow { display: block; font-size: 10px; letter-spacing: .12em; color: var(--glow); margin-bottom: 9px; }
#tour header b { display: block; font-size: 25px; line-height: 1.15; margin-bottom: 5px; }
#tour header > span:last-child { color: var(--muted); font-size: 13px; }
#steps { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; min-height: 0; scrollbar-width: thin; scrollbar-color: #34534a transparent; }
#steps li { padding: 11px 12px; border-radius: 8px; cursor: pointer; display: grid; grid-template-columns: 25px minmax(0,1fr); gap: 4px 10px; outline-offset: -2px; }
#steps li:hover { background: rgba(255,255,255,.04); }
#steps .n { grid-row: span 2; width: 24px; height: 24px; border-radius: 50%; border: 1px solid #456b5f; color: var(--muted); display: grid; place-items: center; font-size: 11px; }
#steps .t { font-size: 14px; font-weight: 600; line-height: 1.5; }
#steps .d { display: none; color: #bed1ca; font-size: 13px; line-height: 1.6; }
#steps .chips { display: none; grid-column: 2; margin-top: 6px; gap: 5px; flex-wrap: wrap; }
#steps li.on { background: rgba(82,217,197,.07); }
#steps li.on .n { border-color: var(--glow); color: #0d1f1b; background: var(--glow); }
#steps li.on .d { display: block; animation: reveal .22s ease-out; }
#steps li.on .chips { display: flex; }
.chip { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,.04); color: var(--muted); }
#tour footer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-shrink: 0; }
#tour footer button { flex: 1; }
#dash { grid-area: dash; padding: 24px 18px 16px; border-left: 1px solid var(--line); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #34534a transparent; }
#dash h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
#dash h3 small { color: var(--muted); font-size: 9px; letter-spacing: .1em; font-weight: 400; }
#clock { font-size: 28px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
#state { display: inline-block; margin: 10px 0 20px; padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: .05em; background: var(--glow); color: #0d1f1b; }
#state.night { background: #3c4a8a; color: #e6e9ff; }
#state.alert { background: var(--warn); }
#state.alarm { background: var(--bad); color: #fff; }
.rows { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 9px 8px; font-size: 12px; }
.rows .k { color: var(--muted); }
.rows .v { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.bar { height: 4px; border-radius: 3px; background: rgba(255,255,255,.08); margin: -2px 0 3px; grid-column: 1/-1; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--pow); }
#log { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 11px; line-height: 1.5; color: var(--muted); max-height: 126px; overflow-y: auto; }
#log div { padding-bottom: 5px; }
#log .a { color: var(--warn); } #log .b { color: var(--bad); }
.simulation-note { font-size: 11px; line-height: 1.5; color: var(--muted); margin: 16px 0 0; }
#toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
#toolbar button { white-space: nowrap; font-size: 13px; }
#toolbar label { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }
#toolbar input { accent-color: var(--glow); width: 115px; min-height: 36px; margin: 0; }
#note { display: flex; justify-content: space-between; align-items: center; padding: 0 24px; color: var(--muted); font-size: 10px; border-top: 1px solid var(--line); }
#loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--bg); z-index: 5; padding: 24px; text-align: center; }
#tag, .model-label { position: absolute; pointer-events: none; padding: 5px 8px; border-radius: 5px; background: rgba(13,31,27,.94); border: 1px solid rgba(82,217,197,.35); font-size: 11px; line-height: 1.3; white-space: nowrap; z-index: 3; }
#tag { display: none; }
.model-label { display: none; }
#panel-tabs { display: none; }
@keyframes reveal { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (min-width: 1500px) { #workspace { grid-template-columns: 340px minmax(0,1fr) 300px; } #steps .t { font-size: 15px; } #steps .d { font-size: 14px; } .rows { font-size: 13px; } }
@media (max-width: 1099px) {
  body { height: auto; min-height: 100dvh; grid-template-rows: 68px auto auto auto; }
  #workspace { display: grid; grid-template-columns: minmax(0,1fr); grid-template-areas: "viewer" "tabs" "tour" "dash"; }
  #viewer { height: clamp(380px,55svh,620px); }
  #panel-tabs { grid-area: tabs; display: flex; gap: 8px; padding: 12px 20px; background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  #panel-tabs button { flex: 1; }
  #tour, #dash { border: 0; }
  #tour { height: 420px; }
  #tour header { padding: 18px 20px 14px; }
  #tour header b { font-size: 22px; }
  #workspace[data-panel="tour"] #dash, #workspace[data-panel="dash"] #tour { display: none; }
  #dash { padding: 22px; }
  .rows { font-size: 14px; }
  #log { max-height: 150px; }
  #toolbar { padding: 16px 20px; }
  #toolbar label { margin-left: 0; }
  #note { min-height: 42px; gap: 12px; flex-wrap: wrap; padding: 10px 20px; }
}
@media (max-width: 540px) {
  #app-header { padding: 0 16px; gap: 12px; }
  .brand strong { font-size: 19px; }
  .project-title { font-size: 12px; text-align: right; }
  .project-title span { display: block; margin-left: 0; margin-top: 2px; }
  .prototype-badge { display: none; }
  #viewer { height: clamp(360px,52svh,500px); }
  #view-heading { top: 16px; left: 16px; }
  #view-heading b { font-size: 15px; }
  #toolbar { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; padding: 14px 16px; }
  #toolbar button { padding: 9px 7px; }
  #toolbar label { justify-content: space-between; gap: 8px; }
  #toolbar input { width: 80px; }
  #panel-tabs { padding: 12px 16px; }
  #note { display: block; padding: 12px 16px; line-height: 1.6; }
  #note span { display: block; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
