:root {
  --bg: #12141a;
  --panel: #1a1d26;
  --line: #2c3140;
  --text: #e8e6e1;
  --muted: #9a958c;
  --accent: #d4a35c;
  --ours: #c45c26;
  --partial: #c9a227;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

#app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
}

.side {
  background: var(--panel);
  padding: 0.75rem 0.7rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.side:hover { scrollbar-color: #3a4050 transparent; }

.brand {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}
h1 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0.15rem 0 0;
}
.warn {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  line-height: 1.3;
  color: var(--partial);
}
.hint {
  margin: 0.15rem 0 0;
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.3;
}
code {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--accent);
}

section.params { display: flex; flex-direction: column; gap: 0.15rem; }
h2 {
  margin: 0.15rem 0 0.1rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 500;
}

label.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
}
label.row output {
  font-family: var(--mono);
  color: var(--text);
  font-size: 0.7rem;
}
.row-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  justify-self: end;
}
/* Persistent param warning — hover/focus shows data-tip. */
.param-warn {
  position: relative;
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--partial);
  color: #1a1208;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.param-warn:hover,
.param-warn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
.param-warn::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  width: max(180px, 16rem);
  max-width: 240px;
  padding: 0.45rem 0.5rem;
  border-radius: 3px;
  background: #0e1016;
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 20;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.param-warn:hover::after,
.param-warn:focus-visible::after {
  opacity: 1;
}
label.row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 14px;
  margin: -2px 0 1px;
  accent-color: var(--accent);
}
label.check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.1rem 0;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.4rem;
  padding: 0.4rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #14171f;
}
.stats div { display: flex; justify-content: space-between; gap: 0.3rem; }
.stats div.span2 { grid-column: 1 / -1; }
.stats span { font-size: 0.62rem; color: var(--muted); text-transform: uppercase; }
.stats strong { font-family: var(--mono); font-size: 0.78rem; font-weight: 500; }

footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
button {
  font-family: var(--font);
  font-size: 0.75rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  background: #222632;
  color: var(--text);
  border-radius: 3px;
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:not(:disabled):hover { filter: brightness(1.06); }
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.btn-row button { flex: 1 1 auto; min-width: 0; }

#views {
  display: grid;
  grid-template-columns: auto 1fr;
  min-width: 0;
  min-height: 0;
}

.layer-rail {
  width: 168px;
  padding: 0.55rem 0.45rem;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: auto;
}
.layer-rail h2 {
  margin: 0 0 0.1rem;
}
.layer-rail label.check {
  font-size: 0.68rem;
  line-height: 1.25;
}

.viewport {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.vp-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.35rem 0.6rem;
  background: #161922;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
}
.vp-label span {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  color: var(--ours);
}
.vp-label em {
  font-style: normal;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
}
.canvas-host {
  flex: 1;
  min-height: 0;
  position: relative;
  background:
    radial-gradient(ellipse at 30% 20%, #1c2230 0%, transparent 55%),
    linear-gradient(180deg, #0e1016 0%, #151820 100%);
}
.canvas-host canvas { display: block; width: 100%; height: 100%; }

@media (max-width: 960px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #views { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .layer-rail {
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .side { max-height: 36vh; border-right: none; border-bottom: 1px solid var(--line); }
}
