:root {
  /* Macon Apps palette (maconapps.com): burnt orange on near-black, off-white text */
  --bg: #1c1c1c;
  --bg-panel: #242424;
  --bg-panel2: #2e2e2e;
  --fg: #fafafa;
  --fg-dim: #a9a9a9;
  --accent: #d2711f;
  --accent-hover: #b9611a;
  --accent2: #e08a3c;
  --border: #3a3a3a;
  --radius: 8px;
  --font-serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
}
.screen { height: 100vh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  background: var(--bg-panel2); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 14px; font-size: 14px; cursor: pointer;
}
.btn:hover { background: #383838; }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: #c97a2f; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.accent:hover { background: var(--accent-hover); }
.btn.big { font-size: 17px; padding: 14px 22px; }
.btn.small { font-size: 12.5px; padding: 5px 10px; }
.btn.icon { width: 40px; padding: 8px 0; text-align: center; font-size: 18px; }
.btn.danger:hover { background: #6e2430; border-color: #a33; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- start screen ---------- */
#startScreen { align-items: center; overflow-y: auto; }
.start-inner { width: min(680px, 92vw); padding: 6vh 0 40px; }
.brand { text-align: center; margin-bottom: 34px; }
.brand-mark { font-size: 0; width: 96px; height: 96px; margin: 0 auto; background: url(icons/icon-192.png) center/contain no-repeat; border-radius: 22px; }
.brand h1 { margin: 8px 0 4px; font-size: 36px; letter-spacing: .2px; font-family: var(--font-serif); font-weight: 400; }
.brand h1::before { content: ""; display: block; width: 56px; height: 4px; background: var(--accent); margin: 0 auto 14px; }
.tagline { color: var(--fg-dim); margin: 0; }
.start-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 44px; }
.recent-title { font-size: 15px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 1px; }
.recent-list { display: flex; flex-direction: column; gap: 10px; }
.recent-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; cursor: pointer;
}
.recent-item:hover { background: var(--bg-panel2); }
.recent-thumb {
  width: 72px; height: 46px; border-radius: 6px; object-fit: cover;
  background: #000; flex: none;
}
.recent-meta { flex: 1; min-width: 0; }
.recent-meta .name { font-weight: 600; font-family: var(--font-serif); font-size: 15px; }
.recent-meta .sub { color: var(--fg-dim); font-size: 12.5px; }
.recent-del { flex: none; }
.recent-empty { color: var(--fg-dim); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--bg-panel);
  border-bottom: 1px solid var(--border); flex: none;
}
.project-name {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--fg); font-size: 16px; font-weight: 600; padding: 4px 8px; width: 220px;
}
.project-name:hover, .project-name:focus { border-color: var(--border); background: var(--bg); outline: none; }
.save-status { color: #6fce8f; font-size: 12px; }
.spacer { flex: 1; }
.ctl { display: flex; align-items: center; gap: 6px; color: var(--fg-dim); }
select {
  background: var(--bg-panel2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px; font-size: 13.5px; max-width: 100%;
}

/* ---------- stage + sidebar ---------- */
.stage-wrap { flex: 1; display: flex; min-height: 0; }
.stage {
  flex: 1; position: relative; background: #000; margin: 14px;
  border-radius: var(--radius); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
#cameraVideo, #playCanvas, #onionCanvas, #gridOverlay {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
#onionCanvas, #gridOverlay { pointer-events: none; }
#gridOverlay line { stroke: rgba(255,255,255,.5); stroke-width: 2; vector-effect: non-scaling-stroke; }
.stage.mirrored #cameraVideo { transform: scaleX(-1); }
.camera-msg {
  position: relative; z-index: 2; text-align: center; color: var(--fg-dim);
  max-width: 420px; padding: 20px;
}
.playback-badge {
  position: absolute; top: 10px; left: 12px; z-index: 3;
  background: rgba(0,0,0,.6); color: #fff; border-radius: 6px;
  padding: 4px 10px; font-size: 12.5px;
}
.sidebar {
  width: 250px; flex: none; overflow-y: auto;
  padding: 14px 14px 14px 0; display: flex; flex-direction: column; gap: 12px;
}
.panel {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
}
.panel h3 {
  margin: 0 0 10px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--fg-dim);
}
.row { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.slider-row input[type=range] { flex: 1; }
.hint { color: var(--fg-dim); font-size: 12px; line-height: 1.45; margin: 6px 0 0; }
.cam-ctl { margin: 8px 0; }
.cam-ctl label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--fg-dim); }
.cam-ctl input[type=range] { width: 100%; }
#cameraSelect { width: 100%; }
#voicePlayer { width: 100%; margin-top: 8px; height: 34px; }

/* ---------- bottom bar / timeline ---------- */
.bottombar {
  flex: none; background: var(--bg-panel); border-top: 1px solid var(--border);
  padding: 10px 12px; display: flex; align-items: center; gap: 14px;
}
.transport { display: flex; align-items: center; gap: 10px; flex: none; }
.btn.capture {
  width: 54px; height: 54px; border-radius: 50%; font-size: 24px;
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn.capture:hover { background: var(--accent-hover); }
.loop-row { color: var(--fg-dim); font-size: 12.5px; }
.frame-counter { color: var(--fg-dim); font-size: 12.5px; min-width: 70px; }
.timeline {
  flex: 1; display: flex; gap: 6px; overflow-x: auto; padding: 6px;
  background: var(--bg); border-radius: 8px; min-height: 76px; outline: none;
}
.tl-frame {
  position: relative; flex: none; width: 100px; height: 64px;
  border-radius: 6px; overflow: hidden; cursor: grab;
  border: 2px solid transparent;
}
.tl-frame img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.tl-frame.selected { border-color: var(--accent); }
.tl-frame .idx {
  position: absolute; bottom: 2px; left: 4px; font-size: 11px;
  color: #fff; text-shadow: 0 1px 2px #000;
}
.tl-frame.dragging { opacity: .4; }
.tl-frame.drop-before { box-shadow: -4px 0 0 var(--accent2); }
.tl-frame.drop-after { box-shadow: 4px 0 0 var(--accent2); }
.frame-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }

/* ---------- dialog ---------- */
dialog {
  background: var(--bg-panel); color: var(--fg);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 26px; width: min(420px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 14px; font-size: 21px; font-family: var(--font-serif); font-weight: 400; }
.export-opts .row { justify-content: space-between; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
progress { width: 100%; margin-top: 12px; }
.start-foot { color: var(--fg-dim); font-size: 12.5px; text-align: center; margin-top: 40px; }
.start-foot a { color: var(--accent2); }
