:root {
  --blue: #1565C0;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1d2733;
  --muted: #66707c;
  --border: #dde2e8;
  --danger: #c62828;
  --ok: #2e7d32;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }

/* Sign-in gate */
.gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.gate-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 48px;
  text-align: center;
  max-width: 420px;
}
.gate-card h1 { margin: 0 0 8px; }
.gate-card p { color: var(--muted); }

/* Header */
header {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 17px; cursor: pointer; }
.spacer { flex: 1; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.user-email { color: var(--muted); font-size: 13px; }
.api-status { font-size: 12px; padding: 3px 8px; border-radius: 10px; background: var(--bg); }
.api-status.ok { color: var(--ok); }
.api-status.bad { color: var(--danger); }

/* Buttons */
button {
  font: inherit;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
}
button:hover { background: var(--bg); }
button.primary {
  background: var(--blue); color: white; border-color: var(--blue);
  font-size: 15px; padding: 10px 20px;
}
button.primary:hover { filter: brightness(1.1); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #fdeaea; }

main { max-width: 1080px; margin: 24px auto; padding: 0 20px; }
.placeholder { text-align: center; color: var(--muted); margin-top: 80px; }
.error { color: var(--danger); }
.muted { color: var(--muted); font-size: 13px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.toolbar h2 { margin: 0; }

/* Project cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  display: flex; flex-direction: column;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.card.archived { opacity: .65; }
.card-thumb {
  height: 140px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  font-size: 42px;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 12px 14px 6px; }
.card-name { font-weight: 600; }
.card-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.card-actions { display: flex; gap: 6px; padding: 8px 14px 12px; }
.card-actions button { padding: 4px 10px; font-size: 14px; }
.tag {
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 8px; padding: 1px 7px;
  vertical-align: middle;
}

/* Editor */
.editable { cursor: pointer; }
.editable:hover::after { content: " ✏️"; font-size: 14px; }
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
}
.panel.dragging { outline: 2px dashed var(--blue); }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-head h3 { margin: 0; }
.drop-hint { color: var(--muted); font-size: 12px; text-align: center; padding-top: 10px; }

.photo-list { display: flex; flex-direction: column; gap: 8px; }
.photo-row {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px;
  background: var(--card);
}
.drag-handle { cursor: grab; color: var(--muted); font-size: 18px; }
.pick { flex: none; width: 15px; height: 15px; cursor: pointer; }

/* A group is ONE stop on the map: its photos play as a slideshow with no
   travel between them, so it reads as a single indented block. */
.photo-group {
  border: 1px solid var(--blue); border-radius: 10px;
  background: #f3f7fd; overflow: hidden;
}
.group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.group-icon { font-size: 16px; flex: none; }
.group-name {
  flex: 1; min-width: 0; font: inherit; font-size: 14px; font-weight: 500;
  border: 1px solid transparent; border-radius: 6px; padding: 4px 6px;
  background: transparent;
}
.group-name:focus { border-color: var(--blue); outline: none; background: white; }
.group-name.saved { border-color: var(--ok); }
.group-stat { flex: none; font-size: 12px; white-space: nowrap; }
.group-head input[type="number"] { width: 60px; }
.group-pin.is-set { background: #e7effa; border-color: var(--blue); }
.group-members {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 12px 10px 30px; min-height: 20px;
}
.photo-row.in-group { background: var(--card); }
.photo-thumb {
  width: 72px; height: 54px; border-radius: 6px; overflow: hidden;
  background: var(--bg); flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-main { flex: 1; min-width: 0; }
.photo-name { font-size: 14px; font-weight: 500; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.caption {
  width: 100%; font: inherit; font-size: 13px;
  border: 1px solid transparent; border-radius: 6px; padding: 4px 6px;
  background: var(--bg);
}
.caption:focus { border-color: var(--blue); outline: none; background: white; }
.caption.saved { border-color: var(--ok); }
.badge { font-size: 11px; border-radius: 8px; padding: 1px 7px; margin-left: 6px; }
.badge.ok { background: #e6f4e7; color: var(--ok); }
.badge.warn { background: #fdeeee; color: var(--danger); }
.badge.manual { background: #e7effa; color: var(--blue); }
.leg-label select { font: inherit; font-size: 13px; }
.pin-btn, .remove-btn { padding: 4px 9px; }

/* Advanced timing */
.panel.advanced > summary {
  display: flex; align-items: baseline; gap: 10px;
  cursor: pointer; list-style: none;
}
.panel.advanced > summary::-webkit-details-marker { display: none; }
.panel.advanced > summary::before { content: "▸"; color: var(--muted); }
.panel.advanced[open] > summary::before { content: "▾"; }
.panel.advanced > summary h3 { margin: 0; display: inline; font-size: 16px; }
.timing-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px 16px; margin: 14px 0 4px;
}
.timing-field { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.timing-field > span:first-child { flex: 1; color: var(--muted); }
.timing-field .unit { color: var(--muted); }
.timing-field input { width: 68px; }
.timing-field input, .photo-timing input {
  font: inherit; font-size: 13px; text-align: right;
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px;
  background: var(--card);
}
.timing-field input:focus, .photo-timing input:focus { border-color: var(--blue); outline: none; }
.timing-field input.saved, .photo-timing input.saved { border-color: var(--ok); }
#ceiling-warn:empty { display: none; }

/* Framing picker */
.frame-btn { padding: 4px 9px; }
.frame-btn.is-set { border-color: var(--blue); background: #e7effa; }
.framing-modal { width: min(880px, 96vw); }
.framing-legname { padding: 2px 14px 8px; font-size: 13px; }
/* Locked to the video's aspect: what fills this box fills the rendered frame. */
.framing-mapwrap { position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--bg); }
.framing-map { position: absolute; inset: 0; }
.framing-readout {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--border);
}
.framing-readout strong { color: var(--text); }
.pill {
  font-size: 11px; border-radius: 8px; padding: 1px 7px;
  background: #e7effa; color: var(--blue);
}
.pill.auto { background: var(--bg); color: var(--muted); }

.photo-timing { display: flex; flex-direction: column; gap: 4px; flex: none; }
.photo-timing label { display: flex; align-items: center; gap: 4px; }
.photo-timing input { width: 60px; }

/* Pin-drop modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--card); border-radius: 12px;
  width: min(720px, 94vw);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head, .modal-foot, .modal-search {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
}
.modal-head { border-bottom: 1px solid var(--border); }
.modal-foot { border-top: 1px solid var(--border); }
.modal-search input { flex: 1; font: inherit; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; }
.modal-map { height: min(420px, 55vh); }

/* Frame shape picker: each option draws its own aspect, so the choice is
   visible rather than something you decode from "9:16". */
.aspect-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.aspect-opt {
  display: flex; align-items: center; gap: 10px;
  font: inherit; font-size: 13px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px 8px 10px;
}
.aspect-opt:hover { border-color: var(--muted); }
.aspect-opt.is-on { border-color: var(--blue); background: #f3f7fd; }
.aspect-opt b { display: block; font-weight: 600; }
.aspect-dims { font-size: 11px; }
.aspect-box {
  flex: none; width: calc(var(--w) * 1.6px); height: calc(var(--h) * 1.6px);
  border: 2px solid var(--muted); border-radius: 2px;
}
.aspect-opt.is-on .aspect-box { border-color: var(--blue); background: #dce8f8; }

/* Beat sheet: a copyable document, so the body is monospace and scrolls. */
.beats-panel { width: min(860px, 94vw); }
.beats-status { margin: 10px 14px 0; }
.beats-body {
  margin: 10px 14px 14px; padding: 12px;
  background: var(--bg); border-radius: 8px;
  max-height: 60vh; overflow: auto;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; word-break: break-word;
}

/* Versions */
.version-list { display: flex; flex-direction: column; gap: 8px; }
.version-row { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.version-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.version-line progress { width: 180px; }
.version-extra { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.version-extra video { width: 100%; max-height: 420px; border-radius: 8px; background: black; }
.version-extra table { border-collapse: collapse; font-size: 13px; width: 100%; }
.version-extra td, .version-extra th { text-align: left; padding: 3px 10px 3px 0; vertical-align: top; }
.version-extra tr.fallback td { color: #9a6700; }
.version-extra h4 { margin: 8px 0 4px; }

/* Presentation options */
.pres-head { margin: 16px 0 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.pres-grid { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; font-size: 13px; margin-bottom: 12px; }
.pres-field { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.pres-field input[type="number"] {
  width: 62px; font: inherit; font-size: 13px; text-align: right;
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px;
}
.pres-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.pres-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px; font-size: 13px;
}
.pres-card .card-text {
  font: inherit; font-size: 13px; border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 6px; background: var(--bg);
}
.pres-card .card-secs { width: 62px; font: inherit; font-size: 13px; text-align: right;
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; }
.pres-card button { padding: 4px 10px; font-size: 13px; align-self: flex-start; }

/* Preview modal */
.preview-modal { width: min(1100px, 96vw); }
.preview-mount { background: black; }
.preview-mount > div { margin: 0 auto; }

/* Preview editor */
.pv-body { display: flex; gap: 0; }
/* Definite height so portrait and square compositions letterbox inside the
   modal instead of growing it past the viewport and hiding the controls. */
.preview-mount {
  flex: 1; min-width: 0; background: black;
  height: 58vh; display: flex; align-items: center; justify-content: center;
}
.pv-inspector {
  width: 250px; flex: none; padding: 12px 14px; font-size: 13px;
  border-left: 1px solid var(--border); overflow-y: auto;
}
.pv-inspector h4 { margin: 0 0 8px; }
.pv-field { display: block; margin: 10px 0; color: var(--muted); }
.pv-field input, .pv-field select {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 7px;
}
.pv-apply { margin-top: 10px; font-size: 13px; padding: 7px 14px; }
.pv-strip {
  display: flex; gap: 2px; padding: 8px 10px; border-top: 1px solid var(--border);
  background: var(--bg); min-height: 40px;
}
.pv-block {
  flex-basis: 0; min-width: 6px; border-radius: 4px; cursor: pointer;
  color: white; font-size: 11px; display: flex; align-items: center;
  justify-content: center; overflow: hidden; white-space: nowrap;
  opacity: 0.85; transition: opacity .1s;
}
.pv-block:hover { opacity: 1; }
.pv-block.sel { outline: 3px solid #ff9800; opacity: 1; }

.pv-strip { position: relative; }
.pv-block.now { opacity: 1; box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); }
.pv-playhead {
  position: absolute; top: 4px; bottom: 4px; width: 2px;
  background: #ff5722; border-radius: 1px; pointer-events: none;
}
