:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #e8eee9;
  background: #080b0a;
  --surface: #121816;
  --border: #303b35;
  --muted: #a9b8ac;
  --accent: #f4c977;
  --frame-ratio: 1;
  --frame-aspect: 1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, input { font: inherit; }

button {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  color: inherit;
  background: #1e2722;
  cursor: pointer;
}

button:hover { background: #2a3730; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { color: #191307; background: var(--accent); border-color: var(--accent); font-weight: 650; }
.primary:hover { background: #ffda96; }

.topbar {
  display: flex;
  align-items: center;
  gap: clamp(0.55rem, 2vw, 1.45rem);
  min-height: 3.6rem;
  padding: 0 0.95rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-size: 0.88rem; font-weight: 800; letter-spacing: 0.12em; color: var(--accent); }
#tabs { display: flex; flex: 1; min-width: 0; align-self: stretch; overflow: auto hidden; }
#tabs a {
  display: flex;
  align-items: center;
  padding: 0.65rem clamp(0.4rem, 1.8vw, 1.1rem);
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.925rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
#tabs a:hover { color: #fff; }
#tabs a[aria-current="page"] { color: #fff; border-color: var(--accent); }
#tabs a:focus-visible { outline-offset: -3px; }
#toggle-panel { flex: none; font-size: 0.875rem; }

.workspace { flex: 1; min-height: 0; display: flex; position: relative; }
.viewport {
  flex: 1;
  min-width: 0;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
  background: #000;
}
.frame { position: relative; width: min(100cqw, calc(100cqh * var(--frame-ratio))); aspect-ratio: var(--frame-aspect); }
.frame canvas { display: block; width: 100%; height: 100%; }
#labels { position: absolute; inset: 0; pointer-events: none; }

aside {
  flex: none;
  width: 18.25rem;
  overflow: auto;
  padding: 1.1rem;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  font-size: 0.9rem;
}
aside section + section { border-top: 1px solid var(--border); margin-top: 1.15rem; padding-top: 1.05rem; }
aside h2 { margin: 0 0 0.7rem; font-size: 0.91rem; font-weight: 750; }
aside p { margin: 0.55rem 0 0; overflow-wrap: anywhere; }
.muted { color: var(--muted); font-size: 0.83rem; }
#photo-status { color: var(--accent); }
aside button { display: block; width: 100%; }
aside button + button { margin-top: 0.5rem; }
.slider + .slider { margin-top: 0.7rem; }
.slider label { display: flex; justify-content: space-between; gap: 0.6rem; }
output { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
input { accent-color: var(--accent); }
input[type="range"] { width: 100%; margin: 0.3rem 0 0; display: block; }
.check { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.75rem; }
.check input { margin: 0; width: 1.03rem; height: 1.03rem; }

#drop-note { position: fixed; inset: 0; z-index: 3; display: grid; place-content: center; background: #191c12e8; color: var(--accent); font-size: 1.5rem; pointer-events: none; }
#error { position: fixed; z-index: 4; top: 4.35rem; left: 50%; transform: translateX(-50%); width: min(48rem, calc(100vw - 2rem)); max-height: 70dvh; overflow: auto; padding: 1rem; border: 1px solid #bb7765; border-radius: 0.55rem; background: #2b1615; }
#error h2 { margin: 0 0 0.55rem; font-size: 1rem; }
#error pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font-size: 0.87rem; }

@media (max-width: 750px) {
  aside { position: absolute; z-index: 2; top: 0; right: 0; bottom: 0; width: min(18.25rem, 100%); }
  .topbar { padding-inline: 0.6rem; }
}
