:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111418;
  color: #eef2f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #111418;
}

button,
input,
output,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px;
  background: #171b20;
  border-bottom: 1px solid #2a3138;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.15rem, 2vw, 1.6rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 6px;
  color: #aab5bf;
  font-size: 0.9rem;
}

.tabs,
.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab,
.command {
  min-height: 36px;
  border: 1px solid #3a424b;
  border-radius: 6px;
  padding: 0 12px;
  color: #edf3f7;
  background: #20262d;
  cursor: pointer;
}

.tab:hover,
.command:hover {
  background: #29313a;
}

.tab.is-active,
.command.is-active {
  color: #081014;
  background: #7dd3fc;
  border-color: #7dd3fc;
}

.viewport-shell {
  position: relative;
  height: calc(100vh - 86px);
  min-height: calc(100vh - 86px);
  overflow: hidden;
}

#sceneCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 86px);
  background: #101418;
}

.webgl-warning {
  position: absolute;
  left: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid #f97316;
  border-radius: 8px;
  background: rgba(24, 18, 14, 0.9);
  color: #fed7aa;
}

.panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: min(330px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(185, 199, 210, 0.24);
  border-radius: 8px;
  background: rgba(18, 22, 27, 0.88);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px);
  z-index: 3;
}

.panel.is-hidden {
  display: none;
}

.panel h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.draggable-panel {
  touch-action: none;
}

.panel-handle {
  cursor: grab;
  user-select: none;
}

.panel-handle:active {
  cursor: grabbing;
}

.field {
  display: grid;
  gap: 7px;
  color: #cbd5dd;
  font-size: 0.86rem;
}

.field output {
  color: #edf3f7;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: #7dd3fc;
}

select {
  min-height: 36px;
  border: 1px solid #3a424b;
  border-radius: 6px;
  padding: 0 10px;
  color: #edf3f7;
  background: #20262d;
}

.legend {
  display: grid;
  gap: 8px;
  color: #cbd5dd;
  font-size: 0.86rem;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.swatch.uncorrected {
  background: #f97316;
}

.swatch.corrected {
  background: #22c55e;
}

#jobReadout,
#perfReadout {
  color: #aab5bf;
  font-variant-numeric: tabular-nums;
}

.label-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.scene-label {
  position: absolute;
  max-width: 190px;
  padding: 5px 8px;
  border: 1px solid rgba(238, 242, 245, 0.2);
  border-radius: 6px;
  background: rgba(9, 13, 18, 0.78);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  color: var(--label-color, #eef2f5);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .viewport-shell,
  #sceneCanvas {
    height: calc(100vh - 146px);
    min-height: calc(100vh - 146px);
  }

  .panel {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 12px;
    width: auto;
  }
}
