:root {
  --bg: #0f1215;
  --surface: #171b20;
  --surface-2: #1f242b;
  --line: #2a3038;
  --ink: #e8eaed;
  --muted: #9aa3ad;
  --accent: #5aa9e6;
  --ok: #3fb68b;
  --warn: #e0a526;
  --bad: #e5606f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--accent);
  color: #0b1218;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
input[type="email"], input[type="search"], textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
textarea { resize: vertical; }
.muted { color: var(--muted); }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 13px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* Sign-in */
body.auth { display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}
.auth-card form { display: grid; gap: 10px; margin: 16px 0 8px; }
.auth-card a { color: var(--accent); }

/* App shell */
body.app { display: flex; flex-direction: column; overflow: hidden; }
.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { letter-spacing: 0.04em; }
.search { flex: 1; max-width: 420px; }
.layout { flex: 1; display: flex; min-height: 0; }
.stage {
  flex: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  background: #07090b;
  overflow: hidden;
}
/* The frame always has the model's output ratio; app.ts sets its pixel size. */
.frame { position: relative; overflow: hidden; background: #000; }
#map { position: absolute; inset: 0; }
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.badge {
  position: absolute;
  left: 10px;
  top: 52px;
  background: rgba(15, 18, 21, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  pointer-events: none;
}
.badge.warn { border-color: var(--warn); color: var(--warn); }

.panel {
  width: 340px;
  flex: none;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row input[type="range"] { flex: 1; }
.switch { display: inline-flex; gap: 6px; align-items: center; }
.field { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
select { font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); font-weight: 500; padding: 4px 10px; border-radius: 999px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.job { display: grid; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.job .prompt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .state { font-size: 12px; }
.state.queued { color: var(--muted); }
.state.rendering { color: var(--accent); }
.state.done { color: var(--ok); }
.state.failed { color: var(--bad); }
.job button { justify-self: start; padding: 4px 10px; }
.empty { font-size: 13px; }

.frames { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.frame-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.frame-item.active { border-color: var(--accent); }
.frame-item img { display: block; width: 100%; aspect-ratio: 2752 / 1536; object-fit: cover; background: #000; cursor: pointer; }
.frame-item .meta { padding: 6px 8px; display: grid; gap: 6px; }
.frame-item .renders { display: flex; flex-wrap: wrap; gap: 4px; }
.frame-item .renders button {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 500;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 999px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.frame-item .renders button.active { border-color: var(--accent); color: var(--accent); }

@media (max-width: 860px) {
  body.app { overflow: auto; }
  .layout { flex-direction: column; }
  .stage { min-height: 56vw; }
  .panel { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  .bar { flex-wrap: wrap; }
  #who { display: none; }
}

/* Controls and progress live on the frame, so checking a render never needs the panel. */
.frame-tools {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: rgba(15, 18, 21, 0.86);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.frame-tools input[type="range"] { width: 140px; }
.ft-btn { background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-weight: 600; }
.ft-btn.on { background: var(--accent); color: #0b1218; border-color: var(--accent); }
.frame-progress { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.frame-progress .scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(90, 169, 230, 0.18) 45%, rgba(90, 169, 230, 0.32) 50%, rgba(90, 169, 230, 0.18) 55%, transparent 100%);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  animation: d66-scan 2.2s linear infinite;
}
@keyframes d66-scan { from { background-position: -60% 0; } to { background-position: 160% 0; } }
.fp-card {
  position: absolute;
  right: 12px;
  top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 18, 21, 0.86);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
}
.fp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: d66-pulse 1s ease-in-out infinite alternate; }
@keyframes d66-pulse { from { opacity: 0.3; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .frame-progress .scan, .fp-dot { animation: none; } }
.hint { font-size: 12px; margin: 0; }

/* Outlines and paths: above the render, never catching the mouse. */
.overlay3d { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.frame-actions {
  position: absolute;
  left: 10px;
  top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.frame-actions .ft-btn { background: rgba(15, 18, 21, 0.86); backdrop-filter: blur(6px); }
.frame-actions .ft-btn.on { background: rgb(255, 190, 70); border-color: rgb(255, 190, 70); color: #1a1205; }
.map-info {
  background: rgba(15, 18, 21, 0.86);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
}

/* Controls stay above the outline canvas. */
.overlay3d { z-index: 1; }
.frame-actions, .frame-tools, .badge, .frame-progress { z-index: 2; }
