:root {
  color-scheme: dark;
  --bg: #090e17;
  --card: #111a28;
  --card-2: #0d1521;
  --line: #26364c;
  --muted: #8fa4bc;
  --text: #eef7ff;
  --cyan: #51d7ff;
  --cyan-soft: rgba(81, 215, 255, .16);
  --orange: #ffb454;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at 20% -10%, #152840 0, var(--bg) 38%);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

header {
  height: 74px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 14, 23, .9);
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; letter-spacing: -.02em; }
header p { color: var(--muted); font-size: 12px; margin-top: 2px; }
header > div { flex: 1; }

#fileInput { position: fixed; left: -10000px; }
.file-button, button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #162234;
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.file-button:hover, button:hover { border-color: var(--cyan); background: #1b2b42; }
button:active, .file-button:active { transform: translateY(1px); }
button.primary { width: 100%; background: #0e6480; border-color: #2ec9f7; font-weight: 650; }

main {
  height: calc(100% - 74px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 12px;
  padding: 12px;
}
.viewport-card {
  min-width: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(#101b2a, #080d15);
}
.viewport-card.dragging { border-color: var(--cyan); box-shadow: inset 0 0 0 2px var(--cyan-soft); }
#viewport { display: block; width: 100%; height: 100%; cursor: grab; }
#viewport:active { cursor: grabbing; }
.drop-hint {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 7px;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}
.drop-hint strong { color: var(--text); font-size: 22px; }
.drop-hint.hidden { display: none; }
.viewport-badges { position: absolute; left: 12px; top: 12px; display: flex; gap: 7px; pointer-events: none; }
.viewport-badges span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 13, 21, .82);
  padding: 5px 9px;
  color: #c8d7e7;
  font-variant-numeric: tabular-nums;
}
.playbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 9px 14px 11px;
  background: linear-gradient(rgba(8, 13, 21, 0), rgba(8, 13, 21, .86) 30%);
  pointer-events: none;
}
.playbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}
.playbar-row button { min-width: 42px; padding: 4px 9px; }
.playbar-row label { flex: 1; text-align: right; }
.playbar input[type="range"] { pointer-events: auto; }

aside { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 2px; }
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(145deg, var(--card), var(--card-2));
  padding: 13px;
}
.panel.compact { display: grid; gap: 9px; }
.file-panel h2 { margin: 2px 0 5px; font-size: 16px; overflow-wrap: anywhere; }
.eyebrow { color: var(--cyan); text-transform: uppercase; font-size: 10px; font-weight: 750; letter-spacing: .12em; }
.meta, .hint, #status { color: var(--muted); font-size: 12px; }
#status { margin-top: 8px; min-height: 17px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.button-row { display: flex; gap: 5px; }
.button-row button { min-width: 45px; padding: 5px 8px; }
h3 { font-size: 13px; margin-bottom: 10px; }
label { color: #b8c8d9; font-size: 12px; display: block; }
output { float: right; color: var(--cyan); font-variant-numeric: tabular-nums; }

input[type="range"] { width: 100%; accent-color: var(--cyan); margin: 8px 0 6px; }
input[type="number"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #08111d;
  color: var(--text);
  padding: 7px 8px;
  font: 13px ui-monospace, SFMono-Regular, Consolas, monospace;
}
textarea { min-height: 62px; resize: vertical; margin: 5px 0 8px; }
.range-grid { display: grid; grid-template-columns: 1fr 58px; gap: 8px; align-items: end; margin-bottom: 11px; }
.range-grid button { padding: 7px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { accent-color: var(--cyan); }
#heightPlot { width: 100%; height: 92px; display: block; border-radius: 6px; background: #07101b; cursor: crosshair; }

@media (max-width: 850px) {
  body { overflow: auto; }
  main { height: auto; grid-template-columns: 1fr; }
  .viewport-card { height: 60vh; }
  aside { overflow: visible; }
}
