:root {
  --bg: #101013;
  --panel: #17171b;
  --panel-2: #1c1c22;
  --border: #26262d;
  --border-2: #2c2c33;
  --text: #eeeef1;
  --text-secondary: #c7c7cf;
  --text-tertiary: #8f8f9a;
  --text-quiet: #65656f;
  --accent: #ff8d42;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  overflow: hidden;
}

.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.muted { color: var(--text-quiet); }
.small { font-size: 11px; }
.accent-text { color: var(--accent); }

button { font-family: inherit; }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Top bar */
#topbar {
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #d9631f);
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.vdiv { width: 1px; height: 22px; background: var(--border-2); flex-shrink: 0; }
.file-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 8px;
  padding: 6px 12px; min-width: 0;
}
.file-chip #fileName { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.file-chip #fileSize { font-size: 11px; flex-shrink: 0; }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.ghost-btn {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--border-2); border-radius: 8px;
  color: var(--text-secondary); cursor: pointer; font-size: 13px; font-weight: 500;
  padding: 8px 14px; transition: background .12s;
}
.ghost-btn:hover { background: var(--panel-2); }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 8px;
  color: var(--text-tertiary); cursor: pointer; transition: background .12s, color .12s;
}
.icon-btn:hover:not(:disabled) { background: #26262e; color: var(--text); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: rgba(255,141,66,0.4); }

.status { display: flex; align-items: center; gap: 6px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #5a5a64; }
.status-dot.ready { background: #6bcf8f; }
#statusText { font-size: 12px; color: var(--text-tertiary); }

/* Main area */
#mainArea { flex: 1 1 auto; display: flex; min-height: 0; }

#viewport {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 1.4px 1.4px, #222229 1.4px, transparent 1.4px) 0 0/28px 28px,
    radial-gradient(ellipse at 50% 40%, #17171c 0%, #0d0d10 100%);
  cursor: grab;
}
#viewport:active { cursor: grabbing; }
#renderCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Dropzone (empty state) */
.dropzone {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 40px;
}
.dropzone-card {
  width: 480px; max-width: 90vw; box-sizing: border-box;
  background: var(--panel); border: 2px dashed var(--border-2); border-radius: 16px;
  padding: 48px 40px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px;
  transition: border-color .15s, background .15s;
}
.dropzone-card.drag-over { border-color: var(--accent); background: #1c1712; }
.drop-icon { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,141,66,0.12); display: flex; align-items: center; justify-content: center; }
.drop-text { display: flex; flex-direction: column; gap: 6px; }
.drop-title { font-size: 19px; font-weight: 600; }
.drop-sub { font-size: 14px; color: var(--text-tertiary); }
.primary-btn {
  background: var(--accent); color: #141316; border: none; border-radius: 8px;
  padding: 11px 22px; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: filter .12s;
}
.primary-btn:hover { filter: brightness(1.08); }
.link-btn {
  background: none; border: none; color: var(--text-tertiary); font-size: 12.5px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px; padding: 0;
}
.link-btn:hover { color: var(--accent); }
.drop-divider { width: 100%; height: 1px; background: var(--border); margin-top: 2px; }
.privacy-row { display: flex; align-items: center; gap: 8px; }
.privacy-row span { font-size: 12px; color: var(--text-quiet); }
.feature-row { display: flex; align-items: center; gap: 48px; flex-wrap: wrap; justify-content: center; padding: 0 20px; }
.feature { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.feature span { font-size: 12px; color: var(--text-tertiary); }

/* Viewport overlays */
#viewportOverlay { position: absolute; inset: 0; pointer-events: none; }
.stat-chips { position: absolute; top: 20px; left: 20px; display: flex; gap: 8px; }
.chip { background: rgba(23,23,27,0.9); border: 1px solid var(--border-2); border-radius: 8px; padding: 7px 12px; font-size: 12px; }
.zoom-controls { position: absolute; top: 20px; right: 20px; display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
.hint-text { position: absolute; bottom: 20px; right: 20px; font-size: 11px; color: var(--text-quiet); font-style: italic; }

/* Sidebar */
#sidebar {
  flex: 0 0 320px; background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
.side-section { padding: 18px 20px; border-bottom: 1px solid #232329; display: flex; flex-direction: column; gap: 10px; }
.side-label { font-size: 11px; font-weight: 600; letter-spacing: 0.07em; color: var(--text-quiet); text-transform: uppercase; }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stat-row .k { font-size: 12px; color: var(--text-tertiary); }
.stat-row .v { font-size: 12px; color: var(--text); text-align: right; }
.icon-label { display: flex; align-items: center; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 10px; }
.legend-row span:last-child { font-size: 12.5px; color: var(--text-secondary); }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.swatch.dashed { background: none; border: 1px dashed #5ec8ff; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch-row span { font-size: 13px; color: var(--text-secondary); }
.switch-input {
  appearance: none; -webkit-appearance: none; width: 34px; height: 19px; border-radius: 10px;
  background: #33333c; position: relative; cursor: pointer; outline: none; flex-shrink: 0; transition: background .15s;
}
.switch-input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: #c7c7cf; transition: left .15s;
}
.switch-input:checked { background: var(--accent); }
.switch-input:checked::after { left: 17px; background: #14141a; }

/* Transport bar */
#transport {
  flex: 0 0 96px; background: var(--panel); border-top: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: center; padding: 14px 24px; gap: 12px;
}
.slider-row { display: flex; align-items: center; gap: 16px; }
.slider-label { font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; }
.slider-value { font-size: 13px; color: var(--text); flex-shrink: 0; min-width: 84px; text-align: right; }

.layer-slider {
  -webkit-appearance: none; appearance: none; flex: 1 1 auto; height: 6px; border-radius: 3px;
  background: #2c2c33; outline: none; cursor: pointer;
}
.layer-slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: transparent; }
.layer-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent); cursor: pointer; margin-top: -5px;
}
.layer-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent); cursor: pointer;
}
.layer-slider::-moz-range-track { height: 6px; border-radius: 3px; background: #2c2c33; }

.controls-row { display: flex; align-items: center; justify-content: space-between; }
.elapsed { font-size: 12px; color: var(--text-quiet); min-width: 100px; }
.transport-controls { display: flex; align-items: center; gap: 6px; }
.transport-btn {
  display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px;
  background: transparent; border: none; color: var(--text-tertiary); cursor: pointer; transition: background .12s, color .12s;
}
.transport-btn:hover { background: var(--panel-2); color: var(--text); }
.play-btn {
  display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer; box-shadow: 0 0 0 6px rgba(255,141,66,0.12);
  transition: transform .12s;
}
.play-btn:hover { transform: scale(1.04); }

.right-controls { display: flex; align-items: center; gap: 10px; min-width: 100px; justify-content: flex-end; }
.speed-select {
  background: transparent; border: 1px solid var(--border-2); border-radius: 8px; color: var(--text-secondary);
  font-family: inherit; font-size: 12px; padding: 6px 8px; cursor: pointer; outline: none;
}
.speed-select option { background: var(--panel-2); color: var(--text); }

/* Utility: disabled controls before a file is loaded */
[disabled] { pointer-events: none; }
