:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card2: #22262f;
  --text: #e8eaf0;
  --muted: #9aa1ad;
  --accent: #4da3ff;
  --green: #34c759;
  --red: #ff3b30;
  --border: #2c313c;
}

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

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 4px;
  max-width: 920px;
  margin: 0 auto;
}
h1 { font-size: 22px; margin: 0; }
.tag { font-size: 12px; color: var(--muted); font-weight: 400; }
.mode-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.mode-badge.live { color: var(--green); border-color: var(--green); }
.mode-badge.mock { color: #ffb000; border-color: #ffb000; }

.tabs { max-width: 920px; margin: 8px auto 0; padding: 0 24px; display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  background: none; border: none; color: var(--muted);
  font-size: 15px; padding: 8px 14px; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

main { max-width: 920px; margin: 12px auto 80px; padding: 0 24px; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.row { margin-bottom: 12px; }
.row:last-child { margin-bottom: 0; }
.controls { display: flex; gap: 20px; flex-wrap: wrap; }
.controls label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

select, input[type="text"], textarea {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  width: 100%;
}
select { width: auto; }

.file-label {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s;
}
.file-label:hover { border-color: var(--accent); }
.file-label.has-file { border-color: var(--green); color: var(--text); }
.file-label input { display: none; }

button.primary {
  background: var(--accent);
  color: #08111f;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 15px;
  cursor: pointer;
}
button.primary:disabled { opacity: 0.4; cursor: not-allowed; }
button.ghost {
  background: none;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  margin-left: 8px;
}
button.ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.status {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-bottom: 16px;
}
.status.error { color: var(--red); border-color: var(--red); }
/* #status id keeps these ahead of .ghost.small (equal class specificity would lose on source order) */
#status .stop-btn { margin-left: 12px; border-color: var(--red); color: var(--red); vertical-align: middle; }
#status .stop-btn:hover { background: var(--red); color: #fff; }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--muted); border-top-color: transparent;
  border-radius: 50%; margin-right: 8px; vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  padding: 10px 14px;
  border-radius: 10px;
  background: #332b00;
  border: 1px solid #ffb000;
  color: #ffd866;
  font-size: 13px;
  margin-bottom: 16px;
}

.review-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 6px; }
#summaryCard h2 { margin: 0; font-size: 18px; }
.review-title-sep { color: var(--muted); font-size: 18px; }
.review-video-name { flex: 1 1 220px; min-width: 150px; width: auto !important; padding: 4px 8px !important; font-size: 17px !important; font-weight: 600; background: transparent !important; border-color: transparent !important; }
.review-video-name:hover, .review-video-name:focus { border-color: var(--accent) !important; background: var(--card2) !important; outline: none; }
.review-title-row .ghost.small { margin-left: 0; padding: 5px 9px; }
.review-title-row .saved-flag { font-size: 12px; }
.summary-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.pill {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--card2); border: 1px solid var(--border); color: var(--muted);
}
.pill.good { color: var(--green); border-color: var(--green); }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 12px 0 4px; }
ul { margin: 4px 0; padding-left: 20px; }
li { margin-bottom: 3px; font-size: 14px; }

.moment-card h3 { margin: 0 0 4px; font-size: 16px; }
.moment-time { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.moment-card canvas {
  width: 100%;
  border-radius: 8px;
  display: block;
  margin-bottom: 12px;
  background: #000;
}
.moment-text p { margin: 6px 0; font-size: 14px; line-height: 1.5; }
.moment-text b { color: var(--accent); }
.dl-row { margin-top: 10px; }

.overlay-video { width: 100%; border-radius: 8px; display: block; background: #000; }


.hint-text { color: var(--muted); font-size: 13px; line-height: 1.5; }
.prompts-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.prompts-bar .hint-text { margin: 0; }
.prompts-layout { display: grid; grid-template-columns: 264px 1fr; gap: 18px; align-items: start; }
@media (max-width: 760px) { .prompts-layout { grid-template-columns: 1fr; } }
.prompt-nav { position: sticky; top: 12px; }
.prompt-nav .wide { width: 100%; margin-bottom: 12px; }
.prompt-list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 150px); overflow-y: auto; padding-right: 4px; }
.prompt-group-head { margin: 15px 2px 4px; }
.prompt-group-head:first-child { margin-top: 0; }
.prompt-group-title { display: block; font-size: 11px; font-weight: 800; letter-spacing: 0.04em; color: var(--accent); text-transform: uppercase; }
.prompt-group-head small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.prompt-item {
  text-align: left; background: var(--card); border: 1px solid var(--border);
  border-left: 3px solid transparent; border-radius: 9px; padding: 9px 11px;
  color: var(--text); cursor: pointer; font-size: 13.5px;
  transition: border-color .12s, background .12s;
}
.prompt-item:hover { border-color: var(--accent); }
.prompt-item.active { border-color: var(--accent); border-left-color: var(--accent); background: rgba(28,109,208,0.10); }
.prompt-item.disabled-prompt { opacity: 0.5; }
.prompt-item small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; line-height: 1.3; }
.prompt-item .edited { color: #ffb000; }
/* nested folders */
.folder-head { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); cursor: pointer; padding: 5px 4px; font-size: 12.5px; font-weight: 600; }
.folder-head:hover { color: var(--accent); }
.folder-caret { width: 12px; color: var(--muted); font-size: 10px; }
.folder-name { flex: 1; }
.folder-count { color: var(--muted); font-size: 11px; font-weight: 500; background: rgba(255,255,255,0.06); padding: 1px 7px; border-radius: 999px; }
.folder-body { border-left: 1px solid var(--border); margin-left: 9px; padding-left: 8px; display: flex; flex-direction: column; gap: 6px; }
.meta-edit label.grow { flex: 1 1 100%; }
.meta-edit input[type=text] { width: 100%; box-sizing: border-box; background: var(--card); border: 1px solid var(--border); border-radius: 7px; color: var(--text); padding: 6px 9px; font-size: 13px; }

/* report provenance trace (admin) */
.prov-row { display: grid; grid-template-columns: 220px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); align-items: start; }
.prov-row:first-of-type { border-top: none; }
.prov-section { font-size: 13px; font-weight: 600; color: var(--text); }
.prov-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.prov-prompt { font-size: 12px; padding: 3px 9px; border-radius: 7px; background: var(--card); border: 1px solid var(--border); border-left-width: 3px; color: var(--text); }
.prov-folder { color: var(--muted); font-size: 11px; }
@media (max-width: 640px) { .prov-row { grid-template-columns: 1fr; gap: 4px; } }

/* editor — prose first */
#promptText {
  width: 100%; min-height: 440px; box-sizing: border-box;
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 14px; line-height: 1.6;
  padding: 13px 15px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text);
  resize: vertical; margin: 6px 0 14px;
}
#promptText:focus { border-color: var(--accent); outline: none; }
.title-input { flex: 1; background: transparent; border: none; color: var(--text); font-size: 18px; font-weight: 700; padding: 2px 0; }
.title-input:focus { outline: none; }
.prompt-subhead { display: flex; align-items: center; gap: 12px; margin: 6px 0 9px; flex-wrap: wrap; }
.meta-chip { font-size: 12px; font-weight: 600; color: var(--muted); background: rgba(255,255,255,0.06); padding: 4px 11px; border-radius: 999px; }
.enable-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.linkish { background: none; border: none; color: var(--accent); font-size: 12px; cursor: pointer; padding: 0; text-decoration: underline; }
.hint-input { width: 100%; box-sizing: border-box; background: transparent; border: none; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; padding: 5px 0; margin-bottom: 12px; }
.hint-input:focus { outline: none; border-bottom-color: var(--accent); color: var(--text); }
.meta-edit { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 14px; padding: 11px 13px; background: rgba(255,255,255,0.03); border-radius: 9px; }
.meta-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.editor-modes { display: flex; align-items: center; gap: 0; }
.seg { padding: 5px 13px; font-size: 12px; font-weight: 600; background: var(--card); border: 1px solid var(--border); color: var(--muted); cursor: pointer; }
.seg:first-of-type { border-radius: 8px 0 0 8px; }
.seg:nth-of-type(2) { border-radius: 0 8px 8px 0; border-left: none; }
.seg.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.editor-modes .muted { margin-left: 10px; font-size: 11px; color: var(--muted); }
.editor-actions { display: flex; gap: 10px; margin-top: 4px; }
/* line-by-line editor */
.line-modes { gap: 6px; align-items: center; margin-top: 8px; }
button.small { padding: 4px 10px; font-size: 12px; }
button.small.active { border-color: var(--accent); color: var(--accent); }
.prompt-lines { display: flex; flex-direction: column; gap: 5px; margin: 8px 0 12px; max-height: 460px; overflow-y: auto; padding-right: 4px; }
.line-row { display: flex; align-items: flex-start; gap: 6px; }
.line-input {
  flex: 1; width: 100%; box-sizing: border-box;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; line-height: 1.45;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); resize: none; overflow: hidden;
}
.line-input:focus { border-color: var(--accent); outline: none; }
.line-ctrl { display: flex; gap: 3px; flex-shrink: 0; padding-top: 2px; }
.icon-btn {
  width: 26px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1;
}
.icon-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn.danger:hover { border-color: var(--danger, #e5484d); color: var(--danger, #e5484d); }
.add-line { align-self: flex-start; margin-top: 2px; }

/* report anatomy map */
.report-map-head { display: flex; align-items: center; justify-content: space-between; }
.report-mock { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.rm-block, .rm-shot {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  padding: 8px 11px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); border-left-width: 4px;
  background: var(--card); color: var(--text); font-size: 13px;
}
.rm-block:hover, .rm-shot:hover { filter: brightness(1.15); }
.rm-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; opacity: 0.85; }
.rm-what { font-size: 13px; }
.step-analyze { border-left-color: #00A7E1; } .step-analyze .rm-tag { color: #4cc4f0; }
.step-coach   { border-left-color: #34C759; } .step-coach .rm-tag { color: #34C759; }
.step-report  { border-left-color: #a87ffb; } .step-report .rm-tag { color: #b794ff; }
.rm-moment { border: 1px dashed var(--border); border-radius: 10px; padding: 8px; }
.rm-moment-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.rm-moment-label span { opacity: 0.7; }
.rm-moment-body { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; align-items: start; }
.rm-shot { height: 100%; justify-content: center; }
.rm-text { display: flex; flex-direction: column; gap: 8px; }
.rm-foot { margin-top: 6px; }
.prompt-editor-head { display: flex; align-items: center; justify-content: space-between; }
.prompt-editor-head h3 { margin: 0; font-size: 16px; }
.saved-flag { font-size: 12px; color: var(--green); }
.saved-flag.err { color: var(--red); }

/* API key manager */
.key-pill { display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 10px; background: rgba(255,255,255,0.08); color: #8e8e93; font-size: 11px; font-weight: 600; vertical-align: 1px; }
.key-pill.on { background: rgba(48,209,88,0.16); color: #30d158; }
.key-row { align-items: flex-end; gap: 10px; }
.key-row label { flex: 1; }
.key-row input { width: 100%; }
.prov-item { justify-content: space-between; align-items: center; padding: 6px 0; border-top: 1px solid rgba(255,255,255,0.07); }
.prov-desc { font-size: 13px; color: #c7c7cc; word-break: break-all; }

/* side-by-side problem clip vs ideal reference (per coaching moment) */
.sxs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 4px; }
.sxs-col { display: flex; flex-direction: column; gap: 5px; }
.sxs-tag { font-size: 12px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; padding: 4px 9px; border-radius: 7px; align-self: flex-start; border: 1px solid currentColor; }
.sxs-tag.bad { color: #ff3b30; } .sxs-tag.good { color: #34c759; }
.sxs-vid { width: 100%; border-radius: 10px; background: #0a1420; aspect-ratio: 16/9; object-fit: cover; }
.sxs-missing { width: 100%; aspect-ratio: 16/9; border-radius: 10px; background: #14202e; color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.sxs-note { font-size: 11px; color: var(--muted); text-align: center; margin-bottom: 8px; font-style: italic; }

/* looping marked clip (good/bad) */
.moment-card.q-good { border-left: 4px solid #34c759; }
.moment-card.q-bad { border-left: 4px solid #ff3b30; }
.clip-wrap { position: relative; border-radius: 11px; overflow: hidden; margin: 10px 0 4px; background: #0a1420; }
.moment-clip { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.q-badge { position: absolute; top: 9px; left: 9px; font-weight: 800; font-size: 13px; letter-spacing: .02em; padding: 5px 13px; border-radius: 999px; color: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.4); }
.q-badge.good { background: rgba(52,199,89,.94); }
.q-badge.bad { background: rgba(255,59,48,.94); }
.clip-note { font-size: 11px; color: var(--muted); margin: 3px 2px 8px; }

/* ---------- header account + login gate ---------- */
.header-right { display: flex; align-items: center; gap: 10px; }
.admin-who { font-size: 12px; color: var(--muted); }
.wide { width: 100%; }

#loginGate { max-width: 920px; margin: 0 auto; padding: 0 24px; }
.login-card { max-width: 420px; margin: 56px auto; }
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
.login-field { display: block; font-size: 13px; color: var(--muted); margin-top: 14px; }
.login-field input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 15px;
}
.login-card .primary.wide { margin-top: 18px; }
.login-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.login-msg { font-size: 13px; color: var(--accent); min-height: 18px; margin-top: 14px; }
.login-foot { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; margin-bottom: 0; }
.linkish.muted { color: var(--muted); }

.app-version { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }

/* ---------- library ---------- */
.lib-controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-top: 8px; }
.lib-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.lib-controls label.grow { flex: 1; min-width: 160px; }
.lib-controls select, .lib-controls input {
  background: var(--card2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px; padding: 7px 9px;
}
.lib-list { display: grid; gap: 10px; }
.lib-card {
  width: 100%; text-align: left; cursor: pointer; display: block;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  color: var(--text); transition: border-color .12s, background .12s;
}
.lib-card:hover { border-color: var(--accent); background: var(--card2); }
.lib-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.lib-sport { font-weight: 600; text-transform: capitalize; }
.lib-date { margin-left: auto; font-size: 12px; color: var(--muted); }
.lib-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); text-transform: capitalize; }
.lib-chip.level { color: var(--green); border-color: var(--green); }
.lib-chip.mock { color: #ffb000; border-color: #ffb000; }
.lib-chip.grade { color: #9fc8ff; border-color: rgba(77,163,255,.55); text-transform: none; white-space: nowrap; }
.lib-chip.grade.complete { color: var(--green); border-color: var(--green); }
.lib-summary { font-size: 14px; line-height: 1.4; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-meta { font-size: 12px; color: var(--muted); }

/* report→prompt click-through (provenance chips are buttons now) */
.prov-prompt { cursor: pointer; border: 1px solid var(--border); background: var(--card2);
  color: var(--text); border-radius: 999px; padding: 3px 10px; font-size: 12px; line-height: 1.4; }
.prov-prompt:hover { border-color: var(--accent); }
.prov-prompt.step-analyze { border-left: 3px solid #4da3ff; }
.prov-prompt.step-coach { border-left: 3px solid #34c759; }
.prov-prompt.step-report { border-left: 3px solid #ffb000; }
.prov-add { cursor: pointer; background: none; border: 1px dashed var(--border); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.prov-add:hover { border-color: var(--accent); color: var(--accent); }

/* prompt version history */
.prompt-history { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.hist-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 0; border-top: 1px solid var(--border); }
.hist-row:first-of-type { border-top: none; }
.hist-meta { display: flex; flex-direction: column; gap: 2px; }
.hist-when { font-size: 13px; }
.hist-note { font-size: 11px; color: var(--muted); }
.hist-actions { display: flex; gap: 12px; flex-shrink: 0; }

/* slow-motion controls on moment clips */
.clip-speed { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; }
.speed-btn { cursor: pointer; background: var(--card2); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px; padding: 3px 9px; font-size: 12px; }
.speed-btn:hover { border-color: var(--accent); }
.speed-btn.active { background: var(--accent); border-color: var(--accent); color: #03162e; font-weight: 600; }

/* ---------- prompts: full-width list, sport sections, drag, modal ---------- */
.prompt-list.full { max-height: none; overflow: visible; padding-right: 0; }

.sport-filter { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
.sf-label { font-size: 12px; color: var(--muted); }
.sport-tab {
  background: var(--card2); border: 1px solid var(--border); color: var(--muted);
  font-size: 13px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.sport-tab.active { color: var(--text); border-color: var(--accent); background: rgba(28,109,208,0.12); }
.sport-filter .primary.small { margin-left: auto; padding: 6px 12px; font-size: 13px; }

.sport-section { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; background: rgba(255,255,255,0.015); }
.sport-section.sport-snowboard { border-left: 4px solid #4da3ff; }
.sport-section.sport-mtb { border-left: 4px solid #34c759; }
.sport-section.sport-all { border-left: 4px solid var(--muted); }
.sport-section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.sport-section-title { font-size: 16px; font-weight: 700; }
.sport-section-head small { color: var(--muted); font-size: 12px; }
.prompt-step-group { margin: 8px 0 4px; }
.prompt-step-items { display: flex; flex-direction: column; gap: 6px; min-height: 8px; }

.prompt-item { display: flex; align-items: flex-start; gap: 8px; }
.prompt-item-body { flex: 1; min-width: 0; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 14px; line-height: 1.4; user-select: none; padding-top: 1px; }
.prompt-item.dragging { opacity: 0.45; border-style: dashed; }
.prompt-item-title { font-weight: 600; }
.badge.folder { background: none; color: var(--muted); border: 1px solid var(--border); }

/* editor popup */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center;
  background: rgba(0,0,0,0.55); padding: 40px 16px; overflow-y: auto;
}
.modal-card {
  position: relative; width: 100%; max-width: 720px; background: var(--card);
  border: 1px solid var(--border); border-radius: 14px; padding: 22px 22px 18px; margin: auto;
}
.modal-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-card textarea#promptText { min-height: 260px; }
.rerun-editor { max-width: 640px; }
.rerun-controls { align-items: flex-end; }
.rerun-controls label { flex: 1 1 170px; }
.rerun-controls select { width: 100%; }
.rerun-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.rerun-actions .saved-flag { margin-right: auto; }
.rerun-actions .ghost { margin-left: 0; }
.rerun-editor input[type="text"] { width: 100%; }
@media (max-width: 640px) {
  .rerun-controls { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .rerun-actions { flex-wrap: wrap; }
  .rerun-actions .saved-flag { flex-basis: 100%; }
}

/* ---------- version changelog + feature self-checks ---------- */
.app-version { cursor: pointer; }
.app-version:hover { color: var(--text); border-color: var(--accent); }
.vm-actions { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.vm-body { display: flex; flex-direction: column; gap: 14px; max-height: 60vh; overflow-y: auto; }
.vm-version { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.vm-version-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.vm-ver { font-weight: 700; font-variant-numeric: tabular-nums; border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.vm-sum { font-size: 13px; }
.vm-date { margin-left: auto; font-size: 11px; color: var(--muted); }
.vm-feat { display: flex; align-items: center; gap: 9px; padding: 5px 4px; }
.vm-num { font-weight: 700; width: 20px; text-align: center; color: var(--muted); font-size: 13px; flex-shrink: 0; }
.vm-feat-label { font-size: 13.5px; }
.vm-feat-label small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }

/* ---------- live skeleton overlay on clips ---------- */
.clip-wrap { position: relative; }
.skeleton-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; transition: opacity .15s; }

/* ---------- version panel: user sign-off marks ---------- */
.vm-user { margin-left: auto; display: inline-flex; gap: 4px; flex-shrink: 0; align-self: center; }
.vm-um { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border); background: var(--card2); color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1; }
.vm-um:hover { border-color: var(--accent); }
.vm-um.ok.on { background: rgba(52,199,89,0.18); border-color: var(--green); color: var(--green); }
.vm-um.no.on { background: rgba(255,59,48,0.18); border-color: var(--red); color: var(--red); }

/* ---------- timeline view (skeleton video + scrubbable highlights) ---------- */
.tl-card { padding: 14px; }
/* viewport keeps the video's REAL uploaded aspect (set by JS on metadata) — no
   cover-crop that cuts the rider off. overflow:hidden clips the zoom transform. */
.tl-wrap { position: relative; overflow: hidden; max-width: 100%; margin: 0 auto 10px; aspect-ratio: 16/9; background: #0a1420; border-radius: 10px; cursor: pointer; }
.tl-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: center center; will-change: transform; transition: transform 0.16s linear; }
/* big center play/pause flash on toggle (YouTube-style feedback) */
.tl-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 3; opacity: 0; pointer-events: none; }
.tl-center span { display: flex; align-items: center; justify-content: center; width: 84px; height: 84px; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff; font-size: 40px; line-height: 1; }
.tl-center.show { animation: tlpop 0.48s ease-out; }
@keyframes tlpop { 0% { opacity: 0; transform: scale(0.75); } 25% { opacity: 1; } 100% { opacity: 0; transform: scale(1.3); } }
.tl-spacer { flex: 1 1 auto; }
.tl-speedwrap { display: inline-flex; align-items: center; gap: 6px; }
.tl-play { min-width: 42px; font-size: 15px; }
.tl-optrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; width: var(--player-w, 100%); max-width: 100%; margin: 0 auto 6px; }
/* fullscreen: fill the screen, video contained, coaching text floating at the bottom */
.tl-wrap:fullscreen { aspect-ratio: auto; width: 100%; height: 100%; border-radius: 0; cursor: default; background: #000; }
.tl-wrap:fullscreen .tl-video { object-fit: contain; transform: none !important; } /* full video in fullscreen, no zoom */
.tl-fs-text { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 22px; z-index: 4;
  background: linear-gradient(to top, rgba(0,0,0,0.82), rgba(0,0,0,0)); color: #fff; display: none; }
.tl-wrap:fullscreen .tl-fs-text { display: block; }
.tl-fs-text .fst-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.tl-fs-text .fst-body { font-size: 15px; line-height: 1.45; max-width: 900px; opacity: 0.95; }
.tl-fs-text .fst-q { font-weight: 700; }
.tl-fs-btn { position: absolute; top: 10px; right: 10px; z-index: 4; background: rgba(0,0,0,0.55); color: #fff;
  border: none; border-radius: 8px; width: 34px; height: 34px; font-size: 16px; cursor: pointer; }
.tl-zoom-pill { position: absolute; bottom: 10px; right: 10px; z-index: 3; background: rgba(0,0,0,0.55); color: #fff;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.tl-bar { position: relative; height: 16px; background: var(--card2); border-radius: 999px; cursor: pointer; margin: 6px auto 4px; touch-action: none; width: var(--player-w, 100%); max-width: 100%; }
/* second markers under the scrub bar — so the timeline reads in real seconds */
.tl-ticks { position: relative; height: 13px; width: var(--player-w, 100%); max-width: 100%; margin: 0 auto 8px; }
.tl-tick { position: absolute; transform: translateX(-50%); font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-tick:first-child { transform: none; }
.tl-tick:last-child { transform: translateX(-100%); }
.tl-row { width: var(--player-w, 100%); max-width: 100%; margin-left: auto; margin-right: auto; }
.tl-hint { width: var(--player-w, 100%); max-width: 100%; margin-left: auto; margin-right: auto; }
.tl-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 999px; width: 0; opacity: 0.5; pointer-events: none; }
.tl-marker { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; transform: translate(-50%, -50%);
  border: 2px solid var(--bg); cursor: pointer; padding: 0; }
.tl-marker.good { background: var(--green); }
.tl-marker.bad { background: var(--red); }
.tl-marker.active { width: 19px; height: 19px; box-shadow: 0 0 0 3px rgba(77,163,255,0.4); }
.tl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.tl-time { font-variant-numeric: tabular-nums; color: var(--muted); }
.tl-speed { background: var(--card2); border: 1px solid var(--border); color: var(--muted); border-radius: 7px; padding: 4px 9px; font-size: 12px; cursor: pointer; }
.tl-speed.active { color: var(--text); border-color: var(--accent); background: rgba(77,163,255,0.12); }
.tl-hint { font-size: 11px; margin-left: auto; }
.tl-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.tl-chip { background: var(--card2); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.tl-chip.good { border-left: 3px solid var(--green); }
.tl-chip.bad { border-left: 3px solid var(--red); }
.tl-chip.active { border-color: var(--accent); background: rgba(77,163,255,0.12); }
.tl-detail { background: var(--card2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.tl-detail-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tl-detail p { margin: 6px 0; font-size: 14px; }

/* timeline: auto slow-mo pill + prominent controls */
.tl-slow-pill { position: absolute; top: 10px; left: 10px; z-index: 3; background: rgba(0,0,0,0.62); color: #fff; font-size: 12px; font-weight: 700; padding: 5px 11px; border-radius: 999px; }
/* live timecode on the video, matching the coaching's "at X.Xs" — big + high
   contrast so you can read the exact second at a glance while scrubbing/paused */
.tl-timecode { position: absolute; bottom: 12px; left: 12px; z-index: 3;
  background: rgba(0,0,0,0.78); color: #fff; font-size: 20px; font-weight: 800;
  font-variant-numeric: tabular-nums; padding: 6px 12px; border-radius: 8px;
  letter-spacing: 0.01em; line-height: 1; border: 1px solid rgba(255,255,255,0.18);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6); pointer-events: none; }
.tl-wrap:fullscreen .tl-timecode { bottom: 78px; font-size: 26px; } /* clear of the fullscreen coaching caption */
.tl-ctl { background: var(--card2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 11px; font-size: 13px; cursor: pointer; }
.tl-ctl:hover { border-color: var(--accent); }
.tl-ctl.on { color: var(--green); border-color: var(--green); background: rgba(52,199,89,0.12); }

/* inline prompt provenance: clickable report sentences + edit popover */
.prov-s { cursor: pointer; border-bottom: 1px dashed transparent; transition: border-color 0.12s, background 0.12s; border-radius: 3px; }
.prov-s:hover, .prov-s:focus { border-bottom-color: var(--accent); background: rgba(77,163,255,0.10); outline: none; }
.prov-pop { position: absolute; z-index: 60; min-width: 240px; max-width: 340px; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); padding: 6px; }
.prov-pop-head { font-size: 12px; color: var(--muted); padding: 6px 8px 8px; }
.prov-pop-item { display: block; width: 100%; text-align: left; background: var(--card2); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 8px 10px; font-size: 13px; cursor: pointer; margin-bottom: 5px; }
.prov-pop-item:hover { border-color: var(--accent); background: rgba(77,163,255,0.12); }
.prov-pop-item.subtle { color: var(--muted); font-size: 12px; }
.prov-pop-item .prov-folder { color: var(--muted); font-size: 11px; }

/* model A/B compare */
.cmp-toggle { flex-direction: row !important; align-items: center; gap: 8px; cursor: pointer; color: var(--text) !important; }
.cmp-toggle input { width: auto; }
#compareModels label { flex: 1; }
.cmp-card { padding: 14px; }
.cmp-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 14px; }
.linkish { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; text-decoration: underline; }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .cmp-grid { grid-template-columns: 1fr; } }
.cmp-col { background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.cmp-head { font-size: 14px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.cmp-summary { font-size: 13px; line-height: 1.5; }
.cmp-moment { border-left: 3px solid var(--border); padding: 6px 0 6px 10px; margin: 8px 0; }
.cmp-moment.good { border-left-color: var(--green); }
.cmp-moment.bad { border-left-color: var(--red); }
.cmp-m-head { font-size: 13px; margin-bottom: 3px; }
.cmp-moment p { margin: 3px 0; font-size: 12.5px; line-height: 1.45; }
.cmp-cost-note { color: var(--red); font-size: 12px; margin: 2px 0 6px; }
/* compare-mode sub-panels (models vs prompt-version), each a row of selects */
.cmp-sub { display: flex; gap: 12px; flex: 1; }
.cmp-sub label { flex: 1; }
/* report recipe (prompt fingerprint) */
.prov-recipe { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; margin: 0 0 8px; padding: 6px 8px; background: var(--card2); border: 1px solid var(--border); border-radius: 8px; }
.recipe-detail { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; margin-top: 4px; }
.recipe-chip { font-size: 11px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 6px; font-family: ui-monospace, monospace; }

/* auto-zoom amount slider */
.tl-zoomlevel { display: inline-flex; align-items: center; gap: 6px; }
.tl-zoomlevel input[type=range] { width: 90px; accent-color: var(--accent); cursor: pointer; padding: 0; }
.tl-zoomlevel .muted { font-variant-numeric: tabular-nums; min-width: 34px; }

/* refined provenance: primary prompt emphasized, others demoted */
.prov-pop-item.primary { border-color: var(--accent); background: rgba(77,163,255,0.14); font-weight: 600; }
.prov-pop-sub { font-size: 10px; color: var(--muted); padding: 9px 8px 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- pool (reusable clips) + standard-set generate ---------- */
.pool-list { display: flex; flex-direction: column; gap: 8px; }
.pool-card { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--card, #1b2230); border: 1px solid var(--border, #2b3548); border-radius: 10px; padding: 10px 14px; }
.pool-card.is-standard { border-color: #f5c84b; box-shadow: inset 0 0 0 1px rgba(245,200,75,.25); }
.pool-card-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pool-name { font-weight: 600; }
.pool-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.pool-star.on { color: #f5c84b; border-color: #f5c84b; }
.pool-results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.gen-row { padding: 8px 10px; background: var(--card, #1b2230); border: 1px solid var(--border, #2b3548); border-radius: 8px; font-size: 14px; }
.gen-state { color: var(--muted, #9aa7bd); }

/* prompt/model A/B — highlight exactly what changed between the two runs */
.diff-chg { background: rgba(245,200,75,0.30); color: #ffe08a; border-radius: 3px; padding: 0 2px; font-weight: 600; }

/* "Compare with a previous run" picker on the result page */
.cmp-prev-head b { font-size: 14px; }
.cmp-prev-controls { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.cmp-prev-controls select { flex: 1; min-width: 220px; }
button.primary.small { padding: 7px 14px; font-size: 13px; }

/* master prompt-set version bar (Prompts tab) */
.version-bar { display: block; }
.version-now { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ver-pill { font-size: 15px; font-weight: 800; color: var(--accent); background: rgba(77,163,255,0.12); border: 1px solid var(--accent); border-radius: 999px; padding: 2px 12px; }
.ver-dirty { font-size: 12px; color: #ffb000; }
.version-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.version-list { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.ver-row { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 7px; font-size: 13px; }
.ver-row.live { background: rgba(77,163,255,0.08); }
.ver-row-n { font-weight: 700; min-width: 70px; }
.ver-row-meta { color: var(--muted); flex: 1; font-size: 12px; }

/* library card version badge */
.lib-chip.ver { background: rgba(77,163,255,0.14); color: var(--accent); border: 1px solid var(--accent); font-weight: 700; }

/* Library grouped by video */
.lib-group { background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.lib-group-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--card2); border-bottom: 1px solid var(--border); }
.lib-group-title { font-weight: 700; font-size: 15px; flex: 0 1 auto; }
.lib-group-head .muted { flex: 1; font-size: 12px; }
.lib-group-runs { display: flex; flex-direction: column; }
.lib-run { display: flex; align-items: center; gap: 10px; padding: 4px 12px; border-top: 1px solid var(--border); }
.lib-run:first-child { border-top: none; }
.lib-pick { width: 16px; height: 16px; flex: 0 0 auto; cursor: pointer; }
.lib-pick-spacer { width: 16px; flex: 0 0 auto; }
.lib-run-open { flex: 1; display: flex; align-items: center; gap: 8px; text-align: left; background: none; border: none; color: var(--text); cursor: pointer; padding: 7px 4px; border-radius: 7px; font-size: 13px; }
.lib-run-open:hover { background: rgba(255,255,255,0.04); }
.lib-run-date { color: var(--muted); white-space: nowrap; font-size: 12px; min-width: 130px; }
.lib-run-sum { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* Library multi-select delete bar (sticky) */
.lib-actionbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  background: var(--card2); border: 1px solid var(--accent); border-radius: 10px; padding: 8px 14px; margin-bottom: 12px; }
.lib-actionbar #libSelCount { font-weight: 600; flex: 1; }
button.ghost.small.danger, button.danger { color: var(--red); border-color: var(--red); }

/* compare column subheader (date · prompt version · level · cost) */
.cmp-head b { font-size: 14px; }
.cmp-sub { font-size: 11.5px; margin-top: 2px; line-height: 1.3; }

/* compare: "what changed + did it land" panel (the real signal) */
.cmp-change { background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; font-size: 13px; }
.cmp-change-head { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.cmp-change-head.ok { color: var(--green); }
.cmp-change-row { padding: 7px 0; border-top: 1px solid var(--border); }
.cmp-change-row:first-of-type { border-top: none; }
.ccr-title { margin-bottom: 4px; }
.cmp-change-diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ccd-col { background: var(--card); border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; font-size: 12.5px; line-height: 1.45; }
.ccd-lbl { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 3px; }
.cmp-effect { margin-top: 10px; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); line-height: 1.45; }
.cmp-effect.ok { border-color: var(--green); background: rgba(52,199,89,0.08); }
.cmp-effect.bad { border-color: var(--red); background: rgba(255,59,48,0.08); }
.cmp-effect.warn { border-color: #ffb000; background: rgba(255,176,0,0.08); }
@media (max-width: 640px) { .cmp-change-diff { grid-template-columns: 1fr; } }

/* Gold: form builder */
.gold-field { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.gold-field:first-child { border-top: none; }
.gf-type { font-size: 11px; color: var(--accent); background: rgba(77,163,255,0.12); border: 1px solid var(--accent); border-radius: 999px; padding: 2px 8px; white-space: nowrap; min-width: 92px; text-align: center; }
.gf-label { flex: 1; min-width: 140px; }
.gf-options { flex: 1; min-width: 160px; }
.gf-scale { font-size: 12px; color: var(--muted); } .gf-scale input { width: 56px; }
.gf-actions { display: flex; gap: 6px; }
.gold-builder-add { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
/* Gold: fill form */
.gold-fill { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.gold-fl { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.gold-fl.gold-bool { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.gold-fl.gold-scale { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.gold-section { margin: 10px 0 2px; font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.gold-chks { display: flex; flex-wrap: wrap; gap: 12px; }
.gold-chk { display: flex; align-items: center; gap: 5px; color: var(--text); font-size: 13px; }
.gold-moments { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.gold-moment-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.gold-moment-row .gm-time { width: 64px; } .gold-moment-row select { width: auto; }
.gold-moment-row input:not(.gm-time) { flex: 1; min-width: 120px; }
/* Gold: examples list */
.gold-ex { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.gold-ex:first-child { border-top: none; }
.gold-ex-name { font-weight: 600; } .gold-ex .muted { flex: 1; font-size: 12px; }

/* Gold: generate / closeness results */
.gold-gen-results { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.gold-gen-row { padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.gold-gen-row:first-child { border-top: none; }
.gg-score { font-weight: 800; border-radius: 999px; padding: 2px 10px; }
.gg-score.ok, .gg-f-s.ok { color: var(--green); } .gg-score.ok { background: rgba(52,199,89,0.12); border: 1px solid var(--green); }
.gg-score.warn, .gg-f-s.warn { color: #ffb000; } .gg-score.warn { background: rgba(255,176,0,0.10); border: 1px solid #ffb000; }
.gg-score.bad, .gg-f-s.bad { color: var(--red); } .gg-score.bad { background: rgba(255,59,48,0.10); border: 1px solid var(--red); }
.gg-fields { margin: 8px 0 2px; padding-left: 8px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 5px; }
.gg-f { display: flex; align-items: baseline; gap: 8px; font-size: 12px; flex-wrap: wrap; }
.gg-f-k { font-weight: 600; min-width: 110px; }
.gg-f-s { font-weight: 700; min-width: 42px; }
.gg-f-v { flex: 1; overflow: hidden; }

/* ---------- Prompt Lab (stability ×N + batch) ---------- */
.pool-pick-wrap { display: inline-flex; align-items: center; margin-right: 2px; }
.pool-pick { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.lab-box { background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 10px; font-size: 13px; }
.lab-runs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.lab-run { background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.lab-run.done { border-color: var(--green); }
.lab-run.error, .lab-run.lost { border-color: var(--red); color: var(--red); }
.lab-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px; }
.lab-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.lab-table th, .lab-table td { border-bottom: 1px solid var(--border); padding: 6px 8px; vertical-align: top; }
.lab-chip { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--border); white-space: nowrap; }
.lab-chip.ok { color: var(--green); background: rgba(52,199,89,0.1); border-color: var(--green); }
.lab-chip.wob { color: #facc15; background: rgba(250,204,21,0.08); border-color: #a16207; }
.lab-chip.bad { color: var(--red); background: rgba(255,69,58,0.08); border-color: var(--red); }
.lab-chip.na { color: var(--muted); background: transparent; }
.lab-recent-row { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; }
.lab-recent { background: var(--card2); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.lab-recent:hover { border-color: var(--accent); }
.lab-recent-head { flex-basis: 100%; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.lab-recent-chip { border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 2px; }
.lab-recent-chip.ok { background: rgba(52,199,89,0.16); color: var(--green); }
.lab-recent-chip.bad { background: rgba(255,69,58,0.16); color: var(--red); }
.lab-recent-chip.run { background: rgba(255,214,10,0.16); color: var(--amber, #e0a800); }
.lab-resume { margin-top: 10px; }
.pool-stab { display: inline-flex; align-items: stretch; }
.pool-stab .ghost { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.pool-runs { background: var(--card2); border: 1px solid var(--border); border-left: none; color: var(--text); border-radius: 0 7px 7px 0; font-size: 12px; padding: 0 4px; cursor: pointer; }
.pool-runs:hover { border-color: var(--accent); }
.lab-flip { color: var(--red); font-size: 11px; font-weight: 700; }
.lab-judge { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.lab-judge ul { margin: 6px 0 0; padding-left: 18px; }
.lab-judge li { margin: 3px 0; }
/* summary-first result view */
.lab-result .lab-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.lab-verdict { margin: 10px 0 6px; padding: 12px 14px; border-radius: 10px; font-size: 17px; font-weight: 800; letter-spacing: 0.01em; }
.lab-verdict.ok { color: var(--green); background: rgba(52,199,89,0.12); border: 1px solid var(--green); }
.lab-verdict.wob { color: #facc15; background: rgba(250,204,21,0.10); border: 1px solid #a16207; }
.lab-verdict.bad { color: var(--red); background: rgba(255,69,58,0.10); border: 1px solid var(--red); }
.lab-takeaway { margin: 0 0 6px; font-size: 13.5px; }
.lab-details { margin-top: 6px; }
.lab-details > summary { cursor: pointer; color: var(--accent); font-size: 12.5px; font-weight: 600; padding: 4px 0; user-select: none; }
.lab-details[open] > summary { margin-bottom: 4px; }
/* batch: section × clip matrix + per-clip drill-down */
.lab-matrix-scroll { overflow-x: auto; margin: 6px 0 4px; }
.lab-matrix th, .lab-matrix td { white-space: nowrap; }
.lab-matrix td:first-child, .lab-matrix th:first-child { font-weight: 600; color: var(--muted); position: sticky; left: 0; background: var(--card2); }
.lab-clip-col { background: transparent; border: none; color: var(--accent); font-weight: 700; font-size: 12.5px; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.lab-clip-col:hover { background: rgba(77,163,255,0.12); }
.lab-clip-col.active { background: rgba(77,163,255,0.18); color: var(--text); }
.lab-matrix-hint { font-size: 11.5px; margin: 2px 0 6px; }
.lab-clip-detail { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--bg); }
.clipd p { margin: 4px 0; font-size: 13px; }
.clipd-moments { margin-top: 8px; display: grid; gap: 8px; }
.clipd-moment { border-left: 3px solid var(--border); padding: 6px 10px; border-radius: 0 8px 8px 0; background: var(--card2); font-size: 12.5px; }
.clipd-moment.good { border-left-color: var(--green); }
.clipd-moment.bad { border-left-color: var(--red); }
.clipd-mhead { margin-bottom: 3px; }
.clipd-moment div { margin: 2px 0; }

/* ==================== Pipelines (realms) ==================== */
/* objective chips on the Analyze form */
/* #objectiveRow is a plain .row, so it never picked up .controls' flex layout —
   which is why .obj-label's align-self did nothing and the per-run pickers next
   to the chips were left to size themselves in normal flow. */
#objectiveRow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.obj-label { color: var(--muted); font-size: 13px; align-self: center; }
.obj-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
/* Per-run AI + frame-rate pickers. Same stacked label/control shape as the other
   controls on this form. The model select is sized for the longest id the
   catalogue can offer (gemini-3.1-flash-lite-preview, 29 chars) plus the
   dropdown arrow, so you can read the choice before making it. The pair is
   grouped so they wrap together onto their own line, rather than the frame-rate
   picker being orphaned below the model one when the card runs out of width. */
.run-opts { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; }
.run-opt { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#runModel { min-width: 16rem; }
#runFps { min-width: 13rem; }
.obj-chip { background: var(--card2); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.obj-chip:hover { border-color: var(--accent); }
.obj-chip.active { border-color: var(--accent); background: rgba(77,163,255,0.14); font-weight: 700; }
.pill-realm { border-color: var(--accent); }

/* designer lanes on the Prompts page */
.pipe-lane { border: 1px solid var(--border); border-radius: 10px; background: var(--card2); padding: 10px 12px; margin: 10px 0; }
.pipe-lane.off { opacity: 0.55; }
.pipe-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pipe-icon { background: transparent; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; padding: 2px 6px; cursor: pointer; }
.pipe-name { cursor: text; font-size: 14px; }
.pipe-name:hover, .pipe-hint:hover { text-decoration: underline dotted; }
.pipe-hint { color: var(--muted); font-size: 12px; cursor: text; }
.pipe-spacer { flex: 1 1 auto; }
.pipe-en { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.pipe-runclip { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 7px; font-size: 12px; padding: 3px 6px; max-width: 140px; }
.pipe-inline { background: var(--bg); border: 1px solid var(--accent); color: var(--text); border-radius: 6px; font-size: 13px; padding: 3px 8px; min-width: 180px; }
.pipe-flow { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; overflow-x: auto; padding-bottom: 2px; }
.pipe-node { align-self: center; color: var(--muted); font-size: 12px; white-space: nowrap; }
.pipe-arrow { align-self: center; color: var(--muted); font-size: 14px; }
.pipe-mini-arrow { align-self: center; color: var(--muted); font-size: 11px; padding: 0 1px; }
.pipe-step { border: 1px dashed var(--border); border-radius: 8px; padding: 6px 8px; background: var(--bg); min-width: 120px; }
.pipe-step-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 5px; }
.pipe-chips { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pipe-chip { display: inline-flex; align-items: center; background: var(--card2); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.pipe-chip-name { background: transparent; border: none; color: var(--text); font-size: 11.5px; padding: 4px 6px; cursor: pointer; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-chip-name:hover { color: var(--accent); }
.pipe-mv, .pipe-rm { background: transparent; border: none; color: var(--muted); font-size: 12px; padding: 3px 4px; cursor: pointer; }
.pipe-mv:disabled { opacity: 0.25; cursor: default; }
.pipe-mv:hover:not(:disabled) { color: var(--accent); }
.pipe-rm:hover { color: var(--red); }
.pipe-default { color: var(--muted); font-size: 11.5px; font-style: italic; }
.pipe-addblock { background: transparent; border: 1px dashed var(--border); color: var(--muted); border-radius: 7px; font-size: 12px; padding: 3px 8px; cursor: pointer; }
.pipe-addblock:hover { border-color: var(--accent); color: var(--accent); }
.pipe-addselect { background: var(--bg); border: 1px solid var(--accent); color: var(--text); border-radius: 7px; font-size: 12px; padding: 3px 6px; max-width: 220px; }

/* ---- pipeline designer: palette + drag&drop + map ---- */
.pipe-designer { display: grid; grid-template-columns: 215px 1fr; gap: 12px; align-items: start; }
@media (max-width: 900px) { .pipe-designer { grid-template-columns: 1fr; } }
.pipe-palette { position: sticky; top: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card2); padding: 10px; max-height: 70vh; overflow-y: auto; }
.pal-head { font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.pal-head small { color: var(--muted); font-weight: 400; }
.pal-group { margin-bottom: 10px; }
.pal-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; margin: 6px 0 4px; }
.pal-label.analyze { color: var(--accent); }
.pal-label.coach { color: var(--green); }
.pal-label.report { color: #ff9f0a; }
.pal-block { display: flex; align-items: center; gap: 5px; background: var(--card); border: 1px solid var(--border); border-radius: 7px; padding: 5px 7px; margin: 4px 0; font-size: 11.5px; cursor: grab; user-select: none; }
.pal-block:hover { border-color: var(--accent); }
.pal-block:active { cursor: grabbing; }
.pipe-grip { color: var(--muted); font-size: 10px; cursor: grab; }
.pipe-chip { cursor: grab; }
.pipe-chip.dragging { opacity: 0.4; }
.pipe-chips.dropping { outline: 1px dashed var(--accent); outline-offset: 2px; border-radius: 6px; }
.pipe-drop-ind { display: inline-block; width: 3px; height: 22px; background: var(--accent); border-radius: 2px; margin: 0 1px; box-shadow: 0 0 6px var(--accent); }
.pipe-flash { animation: pipeflash 1.2s ease-out; }
@keyframes pipeflash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }
/* map */
.pipe-map { border: 1px solid var(--border); border-radius: 10px; background: var(--card2); padding: 10px 12px; margin-bottom: 12px; overflow-x: auto; }
.pipe-map-head { font-size: 10.5px; font-weight: 800; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 6px; }
.pipe-map-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; white-space: nowrap; }
.pipe-map-row.off { opacity: 0.45; }
.map-name { background: transparent; border: none; color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0 6px 0 0; min-width: 110px; text-align: left; }
.map-name:hover { color: var(--accent); }
.map-vid { font-size: 10px; color: var(--muted); }
.map-group { display: inline-flex; gap: 3px; padding: 3px 5px; border: 1px dashed var(--border); border-radius: 6px; }
.map-arrow { color: var(--muted); font-size: 11px; }
.map-seg { display: inline-block; width: 16px; height: 12px; border-radius: 3px; border: none; padding: 0; cursor: pointer; }
.map-seg.analyze { background: var(--accent); }
.map-seg.coach { background: var(--green); }
.map-seg.report { background: #ff9f0a; }
.map-seg.realm { box-shadow: inset 0 0 0 2px #ffd866; }
.map-seg.default { background: transparent; border: 1px dashed var(--border); cursor: default; }
.map-seg:hover:not(.default) { transform: scale(1.25); }

/* ---- pipeline flowchart canvas (Lucidchart-style) ---- */
.pipe-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.pipe-tab { background: var(--card2); border: 1px solid var(--border); color: var(--text); border-radius: 8px 8px 0 0; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.pipe-tab.active { border-color: var(--accent); border-bottom-color: transparent; background: var(--card); font-weight: 700; }
.pipe-tab.off { opacity: 0.55; }
.pipe-tab.add { color: var(--accent); border-style: dashed; }
.pipe-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card2); margin-bottom: 10px; }
.pipe-toolbar .pipe-runclip { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 7px; font-size: 12px; padding: 3px 6px; max-width: 150px; }
.pipe-editor { display: grid; grid-template-columns: 210px 1fr; gap: 12px; align-items: start; }
@media (max-width: 900px) { .pipe-editor { grid-template-columns: 1fr; } }
.pipe-canvas-wrap { border: 1px solid var(--border); border-radius: 10px; background:
  radial-gradient(circle, #ffffff10 1px, transparent 1px) 0 0 / 20px 20px, var(--bg);
  max-height: 68vh; overflow: auto; outline: none; }
.pipe-canvas-wrap:focus-within { border-color: var(--accent); }
.pipe-canvas { display: block; min-width: 100%; touch-action: none; }
/* nodes */
.fc-node { cursor: grab; }
.fc-node:active { cursor: grabbing; }
.fc-node rect, .fc-node polygon { stroke: var(--border); stroke-width: 1.5; }
.fc-node.fc-start rect, .fc-node.fc-end rect { fill: #2b3340; stroke: var(--muted); }
.fc-node.fc-process.step-analyze rect { fill: #12385f; stroke: var(--accent); }
.fc-node.fc-process.step-coach rect { fill: #123a24; stroke: var(--green); }
.fc-node.fc-process.step-report rect { fill: #3a2a10; stroke: #ff9f0a; }
.fc-node.fc-decision polygon { fill: #3a2140; stroke: #c77dff; }
.fc-node.realm rect { stroke: #ffd866; stroke-width: 2.5; }
.fc-node.sel rect, .fc-node.sel polygon { stroke: #fff; stroke-width: 2.5; filter: drop-shadow(0 0 4px var(--accent)); }
.fc-t { fill: var(--text); font-size: 11px; text-anchor: middle; dominant-baseline: middle; pointer-events: none; font-family: -apple-system, sans-serif; }
.fc-port { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; cursor: crosshair; opacity: 0.55; }
.fc-node:hover .fc-port { opacity: 1; r: 7px; }
/* edges */
.fc-edge { fill: none; stroke: var(--muted); stroke-width: 1.6; }
.fc-edge.sel { stroke: #fff; stroke-width: 2.4; }
.fc-edge-hit { fill: none; stroke: transparent; stroke-width: 12; cursor: pointer; }
.fc-arrowhead { fill: var(--muted); }
.fc-temp { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-dasharray: 5 4; }
.fc-elbl { fill: var(--text); font-size: 10.5px; text-anchor: middle; font-weight: 700; pointer-events: none; }
.fc-elbl-bg { fill: var(--card2); stroke: var(--border); }
.fc-node.dead rect, .fc-node.dead polygon { opacity: 0.4; stroke-dasharray: 4 3; }
.fc-node.dead .fc-t { opacity: 0.5; }
.fc-dead-mark { fill: #ffb000; font-size: 12px; text-anchor: middle; }
/* "won't run" is meant to be impossible to miss, not a subtle dashed outline */
.fc-dead-label { fill: #ffb000; font-size: 9px; font-weight: 700; letter-spacing: .5px; text-anchor: middle; }
.fc-node.dead rect, .fc-node.dead polygon { stroke: #ffb000; }
/* run-order number badge — the true execution position of each block */
.fc-badge circle { fill: #0e1726; stroke: #4ea1ff; stroke-width: 1.5; }
.fc-badge text { fill: #9fd0ff; font-size: 11px; font-weight: 700; text-anchor: middle; }

/* ---- terminology library ---- */
.term-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.term-add .grow { flex: 1 1 240px; }
#termDef { width: 100%; }
.pt-cost { font-size: 11px; opacity: .55; white-space: nowrap; }
.pt-cost.hot { color: #ffb454; opacity: .95; }
.term-addwrap { margin: 6px 0 10px; }
.term-addwrap > summary { cursor: pointer; font-size: 13px; opacity: .8; padding: 4px 0; }
.term-addwrap > summary:hover { opacity: 1; }
.term-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line, #22304a); }
.term-filters .grow { flex: 1 1 260px; }
.term-count { font-size: 12px; opacity: .55; margin-left: auto; white-space: nowrap; }
.term-kind { font-size: 11px; padding: 1px 4px; opacity: .75; }
.term-head .badge { font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,0.07); opacity: .7; }
.term-head .badge.custom { background: rgba(78,161,255,0.18); opacity: .9; }
.term-clash { border: 1px solid rgba(255,107,107,0.5); background: rgba(255,107,107,0.09);
  border-radius: 8px; padding: 8px 12px; margin: 8px 0; font-size: 13px; }
.term-clash ul { margin: 4px 0 0; padding-left: 20px; }
.term-clash code { background: rgba(255,255,255,0.08); padding: 0 4px; border-radius: 3px; }
.term-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.term-row { border: 1px solid var(--line, #22304a); border-radius: 8px; padding: 8px 10px; }
.term-row.off { opacity: .5; }
.term-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.term-name { font-weight: 700; }
.term-sport { font-size: 11px; opacity: .6; }
.term-on { font-size: 12px; opacity: .8; display: inline-flex; align-items: center; gap: 4px; }
.term-head .danger { margin-left: auto; }
.term-aliases { width: 100%; margin-bottom: 5px; font-size: 13px; }
.term-def { width: 100%; font-size: 13px; }
/* live "this prompt pulls in these meanings" strip under the editor */
.prompt-terms { margin: 6px 0 2px; font-size: 12px; line-height: 1.7; }
.pt-label { opacity: .7; margin-right: 4px; }
.pt-none { opacity: .5; }
.pt-chip { display: inline-block; background: rgba(78,161,255,0.14); border: 1px solid rgba(78,161,255,0.35);
  border-radius: 999px; padding: 1px 9px; margin-right: 5px; cursor: pointer; color: inherit; font: inherit; }
.pt-chip:hover { background: rgba(78,161,255,0.28); }
/* term title is editable in place */
input.term-name { font-weight: 700; font-size: 14px; background: transparent; border: 1px solid transparent;
  border-radius: 6px; padding: 2px 6px; min-width: 160px; color: inherit; }
input.term-name:hover { border-color: var(--line, #22304a); }
input.term-name:focus { border-color: rgba(78,161,255,0.6); background: rgba(255,255,255,0.04); }
.term-f { display: block; margin-bottom: 6px; }
.term-f > span { display: block; font-size: 11px; opacity: .6; margin-bottom: 2px; }
.term-f input, .term-f textarea { width: 100%; font-size: 13px; }
/* the prompt with terms highlighted (read-only view) */
.prompt-marked { white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: 13px; line-height: 1.6;
  border: 1px solid var(--line, #22304a); border-radius: 8px; padding: 10px; max-height: 420px; overflow: auto; }
.prompt-marked mark.tm { background: rgba(78,161,255,0.26); color: inherit; border-bottom: 1px solid rgba(78,161,255,0.7);
  border-radius: 3px; padding: 0 2px; cursor: pointer; }
.prompt-marked mark.tm:hover { background: rgba(78,161,255,0.45); }
/* inspector: how a term is composed */
.term-inspect { margin-top: 8px; border: 1px solid rgba(78,161,255,0.35); border-radius: 8px; padding: 10px 12px;
  background: rgba(78,161,255,0.05); }
.ti-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ti-note { font-size: 11px; opacity: .6; }
.ti-head .linkish { margin-left: auto; }

/* ---- "What the AI actually receives" panel ---- */
.ai-plan { margin-top: 12px; border: 1px solid var(--line, #22304a); border-radius: 10px; padding: 12px 14px; background: rgba(255,255,255,0.02); }
.ai-plan-head { font-weight: 700; margin-bottom: 8px; }
.ai-plan-head small { font-weight: 400; opacity: .6; margin-left: 6px; }
.ai-plan-calls { display: flex; gap: 16px; flex-wrap: wrap; }
.ai-plan-call { flex: 1 1 280px; min-width: 260px; }
.ai-plan-call h5 { margin: 0 0 6px; font-size: 13px; }
.ai-plan-call h5 small { font-weight: 400; opacity: .6; margin-left: 6px; }
.ai-plan-list { list-style: none; margin: 0; padding: 0; }
.ai-plan-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 6px; border-radius: 6px; font-size: 13px; }
.ai-plan-row + .ai-plan-row { margin-top: 2px; }
.ai-plan-n { flex: none; width: 20px; text-align: right; opacity: .6; font-variant-numeric: tabular-nums; }
.ai-plan-title { flex: 1 1 auto; }
.ai-plan-src { flex: none; font-size: 11px; opacity: .7; }
.ai-plan-step { flex: none; font-size: 10px; opacity: .45; text-transform: uppercase; letter-spacing: .4px; }
.ai-plan-row.src-router { background: rgba(78,161,255,0.10); }
.ai-plan-row.src-finish { background: rgba(255,176,0,0.10); }
.ai-plan-row.src-default { opacity: .72; font-style: italic; }
.ai-plan-empty { font-size: 13px; color: #ff6b6b; padding: 4px 6px; }
.pipe-dead-warn { color: #ffb000; font-size: 12px; }

/* library: timeline (flat) view + per-video rename */
.lib-day { font-size: 11px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); margin: 14px 2px 6px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.lib-day:first-child { margin-top: 0; }
.lib-flat-run { margin: 4px 0; }
.lib-flat-run .lib-run-open { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lib-flat-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 52px; }
.lib-flat-name { font-weight: 700; font-size: 13px; }
.lib-rename { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0 4px; }
.lib-rename:hover { color: var(--accent); }

/* prompt lab: verdict-agent editor + moment-timing detail */
.lab-judge-edit { margin: 8px 0; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; background: var(--card2); }
.lab-judge-edit > summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; user-select: none; }
.lab-jl { display: block; font-size: 12px; color: var(--muted); margin: 8px 0; }
.lab-jl textarea { width: 100%; margin-top: 4px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: 12.5px/1.5 -apple-system, sans-serif; resize: vertical; }
.lab-times { font-size: 11.5px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.lab-spread { border-radius: 999px; padding: 0 6px; font-weight: 700; }
.lab-spread.tight { color: var(--green); background: rgba(52,199,89,0.12); }
.lab-spread.ok { color: #facc15; background: rgba(250,204,21,0.10); }
.lab-spread.loose { color: var(--red); background: rgba(255,69,58,0.10); }

/* prompt lab: tuner (3rd agent) — proposals + auto-tune */
.lab-tune-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
#labAutoRounds { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; font-size: 11px; margin-left: 4px; }
.lab-tune { border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; margin-top: 8px; background: rgba(77,163,255,0.06); }
.tune-strategy { margin: 0 0 8px; font-size: 13px; }
.tune-prop { border-top: 1px solid var(--border); padding: 8px 0; }
.tune-prop:first-of-type { border-top: none; }
.tune-prop-head { font-size: 13px; }
.tune-why { font-size: 12.5px; color: var(--muted); margin: 2px 0 4px; }
.tune-diff > summary { cursor: pointer; color: var(--accent); font-size: 12px; }
.tune-diff pre { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 11.5px; max-height: 220px; overflow: auto; }

/* Prompt Lab agents card (visible on the Prompts tab, pipeline-editor style) */
#labAgentsCard h3 { margin: 0 0 4px; }
/* 🗺 System map — the whole review journey on one screen */
.system-map { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 18px 12px; }
.map-node { background: var(--card2); border: 1px solid var(--border); border-radius: 999px; padding: 8px 22px; font-weight: 700; font-size: 14px; }
.map-arrow { color: var(--muted); font-size: 16px; line-height: 1.1; }
.map-diamond { color: var(--accent); border: 1px dashed var(--accent); border-radius: 10px; padding: 6px 18px; font-size: 13px; }
.map-lane { width: min(640px, 96%); background: var(--card2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.map-lane.off { opacity: 0.55; }
.map-lane.missing { text-align: center; border-style: dashed; }
.map-lane-head { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 13px; margin-bottom: 7px; }
.map-lane-head .pipe-en { margin-left: auto; font-weight: 400; }
.map-lane-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.map-lane-empty { font-size: 12px; }
.map-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; font-size: 12.5px; cursor: pointer; }
.map-chip:hover { border-color: var(--accent); }
.map-chip-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0 1px; }
.map-chip-x:hover { color: var(--red); }
.map-lane[data-map-lane]:hover { border-color: var(--accent); }
.map-realms { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: min(720px, 98%); }
.map-realm { display: flex; flex-direction: column; align-items: center; gap: 3px; background: var(--card2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 16px; color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer; max-width: 190px; }
.map-realm small { color: var(--muted); font-weight: 400; font-size: 11px; line-height: 1.3; }
.map-realm:hover { border-color: var(--accent); }
.map-realm.off { opacity: 0.55; }
.map-realm.add { border-style: dashed; color: var(--muted); }

.sbx-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
#sbxPrompt, #sbxTestClip { background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 5px 8px; font-size: 13px; max-width: 60%; }
#sbxContent { width: 100%; box-sizing: border-box; background: var(--card2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 10px; font: 13px/1.5 ui-monospace, monospace; }
.sbx-changed { margin: 8px 0; font-size: 12px; }
.sbx-changed-head { color: var(--muted); }
.sbx-chip { background: rgba(255,214,10,0.16); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 2px 9px; font-size: 12px; cursor: pointer; }
.sbx-chip:hover { border-color: var(--accent); }
.sandbox-actions { border-color: rgba(22,214,163,.45); background: linear-gradient(135deg, rgba(22,214,163,.07), var(--card)); }
.sandbox-actions-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; }
.sandbox-actions-head h3, .live-prompts-head h2 { margin:0 0 4px; }
.sandbox-conflict { color:#ff8e8e; border:1px solid rgba(255,92,92,.45); background:rgba(255,92,92,.1); border-radius:999px; padding:5px 10px; font-size:12px; font-weight:700; }
.sbx-deleted { color:#ff9a9a; font-size:12px; }

/* Read-only production prompt recipes (available to signed-in members). */
.live-prompts-head { align-items:flex-start; margin-bottom:14px; }
.live-prompts-head p { margin:0; }
.live-scenarios { display:grid; gap:14px; }
.live-scenario { margin:0; }
.live-scenario-head { display:grid; grid-template-columns:auto 1fr auto; align-items:start; gap:10px; padding-bottom:12px; border-bottom:1px solid var(--border); }
.live-scenario-head h3 { margin:0 0 3px; }
.live-scenario-head p { margin:0; color:var(--muted); font-size:12px; }
.live-scenario-icon { font-size:24px; line-height:1; }
.live-step { margin-top:14px; }
.live-step h4 { margin:0 0 6px; color:var(--muted); font-size:12px; letter-spacing:.04em; text-transform:uppercase; }
.live-step h4 span { display:inline-block; min-width:18px; margin-left:4px; padding:1px 5px; border-radius:999px; background:var(--card2); text-align:center; }
.live-prompt { border:1px solid var(--border); border-radius:8px; background:var(--card2); margin:6px 0; overflow:hidden; }
.live-prompt summary { cursor:pointer; display:flex; align-items:baseline; gap:10px; padding:9px 11px; }
.live-prompt summary span { font-weight:650; }
.live-prompt summary small { color:var(--muted); }
.live-prompt pre { margin:0; padding:12px; border-top:1px solid var(--border); background:rgba(0,0,0,.16); color:var(--text); white-space:pre-wrap; word-break:break-word; font:12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; max-height:420px; overflow:auto; }
@media (min-width: 1050px) { .live-scenarios { grid-template-columns:repeat(2, minmax(0, 1fr)); } }
.agent-block { margin: 12px 0; }
.agent-models { background: var(--card2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.agent-model-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 6px 0; }
.agent-model-pick select { background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 4px 8px; font-size: 13px; }
.agent-label { font-size: 13px; color: var(--text); margin-bottom: 5px; display: flex; align-items: center; gap: 8px; }
.agent-badge { font-size: 11px; font-weight: 800; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--border); white-space: nowrap; }
.agent-badge.judge { color: var(--accent); background: rgba(77,163,255,0.12); border-color: var(--accent); }
.agent-badge.tuner { color: var(--green); background: rgba(52,199,89,0.12); border-color: var(--green); }
#labAgentsCard textarea { width: 100%; background: var(--card2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font: 12.5px/1.55 -apple-system, sans-serif; resize: vertical; }
#labAgentsCard textarea:focus { border-color: var(--accent); outline: none; }

/* prompt blocks are click-to-edit — signal it */
.fc-node.fc-process { cursor: pointer; }
.fc-node.fc-process:hover rect { filter: brightness(1.25); }

/* Quick model switcher — the review model is changed constantly, so it lives in
   the header on every tab instead of only in Settings. */
.model-quick { position: relative; align-self: center; }
.model-quick > button { display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: rgba(78,161,255,0.12); border: 1px solid rgba(78,161,255,0.35); color: inherit;
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.model-quick > button:hover { background: rgba(78,161,255,0.24); }
.mq-dot { width: 7px; height: 7px; border-radius: 50%; background: #16d6a3; flex: none; }
.model-quick.stale .mq-dot { background: #ffb020; }
.mq-caret { opacity: .6; font-size: 10px; }
.model-quick-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 300px;
  background: var(--card, #111a2b); border: 1px solid var(--line, #22304a); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45); padding: 6px; }
.mq-head { font-size: 11px; opacity: .6; padding: 6px 8px; }
.mq-warn { color: #ffb020; }
.mq-row { display: flex; width: 100%; align-items: center; gap: 8px; cursor: pointer; text-align: left;
  background: transparent; border: 0; color: inherit; padding: 7px 8px; border-radius: 7px; font-size: 13px; }
.mq-row:hover { background: rgba(255,255,255,0.06); }
.mq-row.on { background: rgba(78,161,255,0.18); font-weight: 700; }
.mq-row.on .mq-name::after { content: ' ✓'; color: #16d6a3; }
.mq-name { flex: 1; }
.mq-speed { font-size: 11px; opacity: .55; font-variant-numeric: tabular-nums; }
.mq-empty { padding: 10px 8px; font-size: 12px; opacity: .7; }
.mq-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border-top: 1px solid var(--line, #22304a); margin-top: 4px; padding: 6px 8px 2px; font-size: 11px; opacity: .7; }

/* Money meter — sits beside the model switcher, because the model chosen is the
   main thing that moves this number. */
.spend-meter { position: relative; align-self: center; }
.spend-meter > button { display: inline-flex; align-items: baseline; gap: 5px; cursor: pointer;
  background: rgba(22,214,163,0.12); border: 1px solid rgba(22,214,163,0.35); color: inherit;
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.spend-meter > button:hover { background: rgba(22,214,163,0.24); }
.spend-meter.warn > button { background: rgba(255,176,32,0.14); border-color: rgba(255,176,32,0.45); }
.sm-amount { font-variant-numeric: tabular-nums; }
.sm-label { font-size: 10px; opacity: .6; font-weight: 600; }
.spend-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; width: 480px; max-width: 92vw;
  background: var(--card, #111a2b); border: 1px solid var(--line, #22304a); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45); padding: 10px; }
.sm-head { display: flex; gap: 14px; padding: 4px 4px 10px; border-bottom: 1px solid var(--line, #22304a); }
.sm-head > div { display: flex; flex-direction: column; }
.sm-big { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sm-sub { font-size: 10px; opacity: .6; }
.sm-warn { color: #ffb020; }
.sm-scroll { max-height: 46vh; overflow-y: auto; }
.sm-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.sm-table th { text-align: left; font-size: 10px; opacity: .55; font-weight: 600; padding: 4px 6px;
  position: sticky; top: 0; background: var(--card, #111a2b); }
.sm-table td { padding: 4px 6px; border-top: 1px solid rgba(255,255,255,0.05); }
.sm-num { text-align: right; font-variant-numeric: tabular-nums; }
.sm-model { font-size: 11px; opacity: .7; }
.sm-empty { opacity: .6; text-align: center; padding: 10px; }
.sm-foot { font-size: 10px; opacity: .5; padding: 8px 4px 2px; border-top: 1px solid var(--line, #22304a); margin-top: 6px; }

/* ---------- human grading of AI output ---------- */
.ai-grade-intro {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin: 12px 0; padding: 10px 12px; border: 1px solid rgba(77,163,255,.42);
  border-radius: 10px; background: rgba(77,163,255,.07);
}
.ai-grade-intro > div { display: flex; flex-direction: column; gap: 2px; }
.ai-grade-intro strong { font-size: 13px; color: var(--accent); }
.ai-grade-intro div span { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.grade-coverage {
  flex: none; border: 1px solid var(--accent); color: var(--accent); border-radius: 999px;
  padding: 4px 9px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.grade-coverage.complete { border-color: var(--green); color: var(--green); }
.grade-coverage.err { border-color: var(--red); color: var(--red); }
.gradeable-list > li { margin-bottom: 9px; }
.ai-grade {
  margin: 6px 0 10px; padding: 7px 8px; border: 1px solid var(--border);
  border-radius: 9px; background: rgba(255,255,255,.018);
}
.ai-grade-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ai-grade-label { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .025em; text-transform: uppercase; }
.ai-grade-state { margin-left: auto; color: var(--muted); font-size: 10.5px; }
.ai-grade-state.correct { color: var(--green); }
.ai-grade-state.incorrect, .ai-grade-state.err { color: var(--red); }
.ai-grade-state.unjudgeable { color: #f4c44e; }
.ai-grade-choices { display: flex; flex-wrap: wrap; gap: 5px; }
.ai-grade-choice {
  border: 1px solid var(--border); background: var(--card2); color: var(--muted);
  border-radius: 7px; padding: 4px 8px; font-size: 11.5px; cursor: pointer;
}
.ai-grade-choice:hover { border-color: var(--accent); color: var(--text); }
.ai-grade-choice:disabled { opacity: .5; cursor: wait; }
.ai-grade-choice.correct.on { border-color: var(--green); color: var(--green); background: rgba(52,199,89,.11); }
.ai-grade-choice.incorrect.on { border-color: var(--red); color: #ff8a84; background: rgba(255,59,48,.11); }
.ai-grade-choice.unjudgeable.on { border-color: #d5a92d; color: #f4c44e; background: rgba(244,196,78,.1); }
.ai-grade-editor {
  display: grid; grid-template-columns: minmax(160px, .7fr) minmax(190px, 1fr);
  gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
}
.ai-grade-editor label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; }
.ai-grade-editor label span { opacity: .7; }
.ai-grade-editor label:last-of-type { grid-column: 1 / -1; }
.ai-grade-editor select, .ai-grade-editor input, .ai-grade-editor textarea { width: 100%; font-size: 12px; padding: 6px 8px; }
.ai-grade-editor .ai-grade-save { justify-self: start; }
.tl-detail .ai-grade { margin-left: 0; margin-right: 0; }
@media (max-width: 640px) {
  .ai-grade-intro { align-items: flex-start; flex-direction: column; }
  .ai-grade-editor { grid-template-columns: 1fr; }
  .ai-grade-editor label:last-of-type { grid-column: auto; }
}

/* ---------- Improvement control room ---------- */
.improve-hero { border-color: rgba(22,214,163,.42); background: linear-gradient(135deg, rgba(22,214,163,.07), var(--card) 55%); }
.improve-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.improve-head h2 { margin: 0 0 4px; font-size: 21px; }
.improve-head p { margin: 0; max-width: 680px; }
.improve-head .ghost { margin-left: 0; }
.improve-safety {
  display: flex; align-items: flex-start; gap: 9px; margin: 13px 0 8px; padding: 9px 11px;
  border: 1px solid rgba(52,199,89,.42); border-radius: 9px; color: var(--green);
  background: rgba(52,199,89,.065); font-size: 12.5px; line-height: 1.4;
}
.improve-safety span { color: var(--muted); font-size: 11.5px; }
.improve-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.improve-metric {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card2);
}
.improve-metric strong { font-size: 21px; font-variant-numeric: tabular-nums; }
.improve-metric span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.improve-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.improve-panel { margin: 0; min-width: 0; }
.improve-experiments, .improve-controls-panel { grid-column: 1 / -1; }
.improve-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.improve-panel-head > div { display: flex; align-items: center; gap: 8px; }
.improve-panel-head h3 { margin: 0; font-size: 16px; }
.improve-panel-head .primary, .improve-panel-head .ghost { margin-left: 0; }
.improve-step {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: rgba(77,163,255,.15); color: var(--accent); font-size: 11px; font-weight: 800;
}
.improve-list { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.improve-row {
  display: flex; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--border);
}
.improve-row:first-child { border-top: none; }
.improve-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.improve-row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.improve-row-main span, .improve-insight span, .improve-candidate-head span { color: var(--muted); font-size: 11px; }
.improve-row .ghost { flex: none; margin-left: 0; }
.improve-empty { color: var(--muted); font-size: 12.5px; margin: 8px 0 2px; }
.improve-insight {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px;
  padding: 9px 0; border-top: 1px solid var(--border);
}
.improve-insight:first-child { border-top: none; }
.improve-insight > div { display: flex; flex-direction: column; min-width: 0; }
.improve-insight strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.improve-insight small { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.improve-rate { align-self: center; color: var(--green) !important; font-weight: 700; white-space: nowrap; }
.improve-rate.warn { color: #ffb000 !important; }
.improve-candidate { border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; background: var(--card2); }
.improve-candidate-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.improve-candidate-head > div { display: flex; flex-direction: column; min-width: 0; }
.improve-candidate p { margin: 8px 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.improve-status {
  flex: none; border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px;
  color: var(--muted); font-size: 10.5px; font-weight: 700; text-transform: capitalize;
}
.improve-status.approval_ready, .improve-status.ready, .improve-status.passed { color: var(--green); border-color: var(--green); }
.improve-status.evaluating { color: #f4c44e; border-color: #d5a92d; }
.improve-status.rejected, .improve-status.blocked { color: var(--red); border-color: var(--red); }
.improve-gate { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 7px 9px; border-radius: 7px; background: rgba(0,0,0,.16); font-size: 11.5px; }
.improve-gate > span { color: var(--muted); }
.improve-gate small { margin-left: auto; color: var(--muted); }
.improve-eval-reviews {
  display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding: 8px 9px;
  border: 1px solid var(--border); border-radius: 8px; background: rgba(0,0,0,.09);
}
.improve-eval-reviews > div:first-child { display: flex; justify-content: space-between; gap: 8px; }
.improve-eval-reviews small, .improve-eval-wait { color: var(--muted); font-size: 10.5px; }
.improve-eval-review { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 5px; border-top: 1px solid var(--border); }
.improve-eval-review > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.improve-eval-review .ghost { flex: none; margin-left: 0; }
.improve-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.improve-actions .ghost, .improve-actions .primary { margin-left: 0; }
.improve-controls { margin-top: 8px; }
.improve-control-form { display: flex; flex-direction: column; gap: 13px; }
.improve-control-toggles { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--card2); }
.improve-control-toggles .check-label { margin: 0; font-size: 12px; }
.improve-control-toggles .credit-toggle { color: #f4c44e; }
.improve-control-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 9px; }
.improve-control-grid > label {
  display: flex; flex-direction: column; gap: 5px; min-width: 0;
  color: var(--muted); font-size: 11px;
}
.improve-control-grid input { width: 100%; }
.money-input { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 5px; color: var(--muted); }
.improve-prompt-scope { margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; }
.improve-prompt-scope legend { padding: 0 5px; color: var(--muted); font-size: 11px; }
.improve-prompt-all { margin: 0 0 8px; font-weight: 700; }
.improve-prompt-options {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px 12px;
  max-height: 190px; overflow-y: auto; padding: 8px; border-radius: 7px; background: rgba(0,0,0,.12);
}
.improve-prompt-options .check-label { align-items: flex-start; margin: 0; min-width: 0; font-size: 11px; }
.improve-prompt-options .check-label > span { display: flex; flex-direction: column; min-width: 0; }
.improve-prompt-options strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.improve-prompt-options small { color: var(--muted); font-size: 10px; text-transform: capitalize; }
.improve-credit-warning {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 9px; padding: 9px 11px;
  border: 1px solid rgba(244,196,78,.45); border-radius: 9px; background: rgba(244,196,78,.06);
}
.improve-credit-warning strong { color: #f4c44e; font-size: 12px; white-space: nowrap; }
.improve-credit-warning span { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.improve-control-safety { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.improve-control-safety > div { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card2); }
.improve-control-safety span { color: var(--muted); font-size: 10px; }
.improve-control-safety strong { font-size: 11.5px; }
.improve-control-actions { display: flex; align-items: center; gap: 9px; }
.improve-control-actions .primary { margin-left: 0; }
@media (max-width: 720px) {
  .improve-grid { grid-template-columns: 1fr; }
  .improve-experiments, .improve-controls-panel { grid-column: auto; }
  .improve-metrics { grid-template-columns: 1fr; }
  .improve-row { align-items: flex-start; flex-wrap: wrap; }
  .improve-row-main { flex-basis: 100%; }
  .improve-control-grid, .improve-prompt-options, .improve-control-safety { grid-template-columns: 1fr; }
  .improve-credit-warning { grid-template-columns: 1fr; }
}
@media (min-width: 721px) and (max-width: 1050px) {
  .improve-control-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .improve-prompt-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Turn Lab: continuous ribbon + 10/10 wave comparisons ---------- */
.turn-lab-card { overflow: hidden; }
.turn-lab-source {
  display: grid; grid-template-columns: minmax(150px, .35fr) minmax(300px, 1fr);
  align-items: start; gap: 12px; margin-bottom: 15px; padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}
.turn-lab-source > div:first-child { display: flex; flex-direction: column; gap: 3px; }
.turn-lab-source > div:first-child span { color: var(--muted); font-size: 11px; line-height: 1.4; }
.turn-lab-video {
  display: block; width: 100%; max-height: min(58vh, 520px); border-radius: 9px;
  background: #05090f; object-fit: contain;
}
.turn-lab-video-missing {
  padding: 18px; border: 1px dashed var(--border); border-radius: 9px;
  color: var(--muted); font-size: 12px; text-align: center;
}

/* Experimental turn-SIZE HUD (corridor between apexes). Sits over the video,
   never in front of the native controls along the bottom edge. */
.turn-lab-stage { position: relative; }
.size-hud {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  min-width: 108px; padding: 8px 11px 9px; border-radius: 10px;
  background: rgba(8, 14, 22, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  color: #eef4ff; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  pointer-events: none; /* never steal a click from the scrubber */
  transition: opacity .18s ease;
}
.size-hud[hidden] { display: none; }
.size-hud-label {
  font-size: 9px; letter-spacing: .10em; text-transform: uppercase;
  opacity: .72; display: flex; align-items: baseline; gap: 5px;
}
.size-hud-est {
  font-size: 8px; letter-spacing: .06em; padding: 1px 4px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.16); opacity: .95;
}
.size-hud-value { display: flex; align-items: baseline; gap: 3px; line-height: 1; margin: 3px 0 2px; }
.size-hud-value [data-radius-value] { font-size: 27px; font-weight: 650; }
.size-hud-unit { font-size: 12px; opacity: .75; }
.size-hud-meta {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 9.5px; opacity: .78;
}
.size-hud-conf { letter-spacing: .04em; }
/* Confidence colours the number, so a rough estimate never reads as a fact. */
.size-hud[data-conf="good"] .size-hud-conf { color: #58e2b0; }
.size-hud[data-conf="fair"] .size-hud-conf { color: #ffd479; }
.size-hud[data-conf="rough"] .size-hud-conf,
.size-hud[data-conf="very rough"] .size-hud-conf { color: #ff9f7a; }
.size-hud[data-conf="rough"] .size-hud-value [data-radius-value],
.size-hud[data-conf="very rough"] .size-hud-value [data-radius-value] { opacity: .72; }
.size-hud-off { max-width: 190px; }
.size-hud-none { font-size: 14px; font-weight: 600; opacity: .8; margin: 3px 0 2px; }
.size-hud-why { font-size: 9.5px; line-height: 1.35; opacity: .68; }
.turn-lab-launch { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.turn-lab-launch h3, .turn-lab-head h3 { margin: 0 0 4px; }
.turn-lab-launch p, .turn-lab-head p { margin: 0; }
.turn-lab-launch .primary, .turn-lab-head .ghost { flex: none; margin-left: 0; }
.turn-lab-spinner {
  flex: none; width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: turn-lab-spin .8s linear infinite;
}
@keyframes turn-lab-spin { to { transform: rotate(360deg); } }
.turn-lab-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.turn-lab-stats { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.turn-lab-stats span {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); font-size: 11px; background: var(--card2);
}
.turn-lab-stats b { color: var(--text); }
.turn-validation-warning, .turn-wave-coverage {
  margin: 8px 0; padding: 7px 9px; border: 1px solid rgba(244,196,78,.38);
  border-radius: 7px; background: rgba(244,196,78,.055); color: #f4c44e;
}
.turn-wave-coverage { border-color: var(--border); background: rgba(255,255,255,.025); color: var(--muted); }
.turn-ribbon { margin: 13px 0 15px; }
.turn-ribbon-track {
  position: relative; height: 48px; border: 1px solid var(--border); border-radius: 9px;
  background: linear-gradient(90deg, rgba(255,255,255,.02), rgba(255,255,255,.07), rgba(255,255,255,.02));
  overflow: hidden;
}
.turn-ribbon-segment {
  position: absolute; inset-block: 0; min-width: 5px; margin: 0; padding: 0;
  border: 0; border-right: 1px solid rgba(0,0,0,.35); border-radius: 0;
  background: rgba(150,160,175,.46); color: #fff; cursor: pointer;
}
.turn-ribbon-segment:hover { filter: brightness(1.3); z-index: 2; }
.turn-ribbon-segment span { font-size: 9px; opacity: .85; }
.turn-ribbon-segment.side-heel, .turn-ribbon-segment.side-A { background: rgba(22,214,163,.68); }
.turn-ribbon-segment.side-toe, .turn-ribbon-segment.side-B { background: rgba(139,124,255,.72); }
/* Ticks are placed by time, not spread evenly, so a label sits exactly above the
   moment it names — the ribbon now spans the whole clip and has to read like a
   ruler rather than just a start and an end. */
.turn-ribbon-axis { position: relative; height: 13px; color: var(--muted); font-size: 10px; margin-top: 3px; }
.turn-ribbon-tick { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.turn-ribbon-tick:first-child { transform: none; }
.turn-ribbon-tick:last-child { transform: translateX(-100%); }

/* Follows the video as it plays. Positioned by percentage so it stays correct
   when the panel is resized, with no width bookkeeping in JS. */
.turn-ribbon-playhead {
  position: absolute; inset-block: 0; left: 0; width: 2px; margin-left: -1px;
  background: var(--accent); box-shadow: 0 0 6px 1px rgba(77,163,255,.55);
  pointer-events: none; z-index: 3;
}
.turn-ribbon-playhead[hidden] { display: none; }
.turn-ribbon-playhead::before {
  content: ''; position: absolute; top: -3px; left: 50%; transform: translateX(-50%);
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--accent);
}
.turn-calibration {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; padding: 10px;
  border: 1px solid rgba(244,196,78,.35); border-radius: 9px; background: rgba(244,196,78,.045);
}
.turn-calibration > div { display: flex; flex-direction: column; flex: 1 1 260px; }
.turn-calibration > div span { color: var(--muted); font-size: 11px; }
.turn-calibration label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 10px; }
.turn-calibration .cmp-toggle { flex-direction: row; align-items: center; padding-bottom: 7px; }
.turn-calibration button { margin-left: 0; }
.turn-viz-toolbar { display: flex; justify-content: space-between; gap: 10px; align-items: flex-end; margin: 16px 0 8px; }
.turn-viz-toolbar label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 10px; }
.turn-legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.turn-legend .group-0 { color: #16d6a3; }
.turn-legend .group-1 { color: #8b7cff; }
.turn-viz-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr); gap: 12px; }
.turn-viz-panel { min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--card2); }
.turn-viz-panel h4 { margin: 0 0 3px; }
.turn-viz-panel p { margin: 0 0 6px; }
.turn-wave-svg { display: block; width: 100%; height: auto; color: var(--muted); }
.turn-heatmap { display: flex; flex-direction: column; gap: 3px; max-height: 330px; overflow: auto; }
.turn-heat-row {
  display: grid; grid-template-columns: 24px 112px minmax(160px, 1fr) 34px; align-items: center;
  gap: 5px; width: 100%; margin: 0; padding: 2px 3px; border: 0; border-radius: 4px;
  background: transparent; color: var(--text); text-align: left;
}
.turn-heat-row:hover { background: rgba(255,255,255,.05); }
.turn-heat-row small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the per-turn peak: amplitude as a number you can scan down, beside the shape */
.turn-heat-row i {
  font-style: normal; font-size: 11px; color: var(--muted);
  text-align: right; font-variant-numeric: tabular-nums;
}
/* 2px of surface between fills, and a rounder cell — the gap is what stops
   neighbouring bands bleeding into one another and reading as a single block. */
.turn-heat-cells { display: grid; grid-template-columns: repeat(20, 1fr); height: 18px; gap: 2px; }
.turn-heat-cells span { min-width: 2px; border-radius: 3px; }
/* No pose data is a hatch, never a gap: against a dark surface an empty cell
   read as "the lowest value", so a hole looked like a turn that never engaged. */
.turn-heat-gap {
  background: repeating-linear-gradient(135deg,
    var(--border) 0 2px, transparent 2px 4px);
  border: 1px solid var(--border); border-radius: 3px;
}
.turn-relaxed-note { color: var(--accent); }
.turn-heatmap-wrap { display: flex; flex-direction: column; gap: 8px; }
.turn-heat-tally {
  display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted);
}
.turn-heat-tally em { font-style: normal; color: var(--text); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; }
/* NOTE: .turn-legend already exists above for the wave-fan group legend. These
   are the VALUE-SCALE key and must not share that class — same specificity means
   the later rule silently wins and restyles the other legend. */
.turn-scale-legend { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 14px; font-size: 11px; color: var(--muted); }
/* the ends sit UNDER the ramp and share its width, so each number lands on the
   step it names — side by side they just read as two loose figures. */
.turn-scale-ramp-wrap { display: inline-flex; flex-direction: column; gap: 3px; }
.turn-scale-ramp { display: flex; gap: 2px; }
.turn-scale-ramp span { width: 22px; height: 10px; border-radius: 3px; }
.turn-scale-ends { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.turn-scale-mid { color: var(--text); }
.turn-scale-key { display: inline-flex; align-items: center; gap: 5px; }
.turn-scale-key i { width: 14px; height: 10px; display: inline-block; }
.turn-table-wrap { overflow-x: auto; margin-top: 12px; }
.turn-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.turn-table th, .turn-table td { padding: 6px 7px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.turn-table th { color: var(--muted); font-weight: 600; }
.turn-table select { min-width: 132px; }
@media (max-width: 820px) {
  .turn-viz-grid { grid-template-columns: 1fr; }
  .turn-lab-source { grid-template-columns: 1fr; }
  .turn-lab-launch, .turn-lab-head, .turn-viz-toolbar { align-items: flex-start; flex-direction: column; }
  .turn-heat-row { grid-template-columns: 22px 88px minmax(140px, 1fr) 30px; }
}

/* ---------- Competency profile: the seven CASI scores as a chart ---------- */
.cp-wrap { margin: 14px 0 4px; }
.cp-hint { margin-left: 8px; font-weight: 400; color: var(--muted); font-size: 10.5px; }
.cp-withheld { margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 10.5px; font-style: italic; }
.cp-chart { display: grid; gap: 5px; }
.cp-row { display: grid; grid-template-columns: minmax(96px, 150px) 1fr 46px; align-items: center; gap: 10px; }
.cp-name { font-size: 11.5px; color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-track { height: 9px; border-radius: 5px; background: rgba(127, 143, 166, 0.18); overflow: hidden; }
.cp-fill { height: 100%; border-radius: 5px; transition: width .35s ease; }
.cp-strong { background: linear-gradient(90deg, #2fb98b, #58e2b0); }
.cp-ok     { background: linear-gradient(90deg, #4b93d1, #6fc0ef); }
.cp-mid    { background: linear-gradient(90deg, #c9963a, #ffd479); }
.cp-weak   { background: linear-gradient(90deg, #c9553a, #ff9f7a); }
.cp-score { font-size: 12px; font-variant-numeric: tabular-nums; text-align: left; }
.cp-max { color: var(--muted); font-size: 10px; }
/* The weakest score is the one to coach — make it findable without reading. */
.cp-row-focus .cp-name { color: var(--text); font-weight: 600; }
.cp-row-focus .cp-track { box-shadow: 0 0 0 1px rgba(255, 159, 122, 0.55); }
@media (max-width: 620px) {
  .cp-row { grid-template-columns: minmax(78px, 110px) 1fr 42px; gap: 7px; }
  .cp-name { font-size: 10.5px; }
}

.size-hud-typical { margin-top: 4px; font-size: 9.5px; opacity: .6; letter-spacing: .02em; }

/* Run timeline: full-width panel + axis labels */
.turn-viz-wide { margin-bottom: 14px; }
.rt-tick { font-size: 9px; fill: currentColor; opacity: .5; }
.turn-clock-svg { width: 100%; max-width: 340px; height: auto; display: block; margin: 0 auto; color: var(--muted); }
.tc-role { font-size: 8px; fill: currentColor; opacity: .38; letter-spacing: .04em; }
.tc-centre { font-size: 9px; fill: currentColor; opacity: .35; }
.rt-side { font-size: 9.5px; font-weight: 600; letter-spacing: .04em; }

/* Turn size (corridor) readout */
.ts-panel { margin: 10px 0 14px; }
.ts-head { margin: 4px 0 8px; font-size: 14px; }
.ts-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ts-chip { font-size: 11px; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--border); }
.ts-chip.ts-ok i { color: var(--muted); font-style: normal; margin-left: 3px; }
.ts-chip.ts-off { opacity: .75; border-style: dashed; }

/* Human turn labelling */
.label-tools { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.label-editor { border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; margin: 8px 0; display: grid; gap: 8px; }
.label-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.turn-validation-ok { color: #58e2b0; }
.human-label-row { position: relative; height: 14px; margin: 2px 0 10px 0; }
.human-label-tag { position: absolute; left: -2px; top: 0; font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.human-label { position: absolute; top: 3px; height: 8px; border-radius: 4px; background: #ffd479; opacity: .55; }
.human-label i { position: absolute; top: -3px; width: 2px; height: 14px; background: #ffd479; }
.human-label.hl-heel { background: #16d6a3; } .human-label.hl-heel i { background: #16d6a3; }
.human-label.hl-toe { background: #8b7cff; } .human-label.hl-toe i { background: #8b7cff; }

/* Competency /10: pass mark, fundamentals, run score as the EIGHTH bar */
.cp-track { position: relative; }
.cp-pass { position: absolute; top: -2px; bottom: -2px; width: 0; border-left: 1.5px dashed rgba(127,143,166,.55); z-index: 1; }
.cp-fund { box-shadow: inset 0 0 0 1px rgba(255,212,121,.35); }
.cp-run-row { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.cp-run-row .cp-name { color: var(--text); display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.cp-run-row .cp-name i { font-style: normal; font-size: 10px; color: var(--muted); font-weight: 400; }
.cp-run-track { height: 12px; border-radius: 6px; }
.cp-run-fill { border-radius: 6px; }
.cp-ghost { position: absolute; top: 0; height: 100%; border-radius: 6px; border: 1px dashed rgba(255,255,255,.35); pointer-events: none; }
.cp-run-row .cp-score { font-size: 14px; }
.cp-run-pass .cp-score b { color: #58e2b0; }
.cp-run-fail .cp-score b { color: #ff9f7a; }

/* ---------- Run Logger review tab ---------- */
.rl-entries { display: flex; flex-direction: column; gap: 10px; }
.rl-entry { padding: 14px 16px; }
.rl-entry-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rl-flag { color: #ff9f43; font-size: 12px; font-weight: 600; }
.rl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rl-chip { border: 1px solid #2c5f66; border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.rl-chip-custom { border-color: #b98a2f; background: rgba(185, 138, 47, 0.12); }
.rl-text { margin: 8px 0 0; white-space: pre-wrap; }
.rl-voice { margin-top: 8px; }
.rl-laps { margin-top: 12px; border-top: 1px solid rgba(127, 127, 127, 0.25); padding-top: 8px; }
.rl-laps-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.rl-lap { border-left: 3px solid #2c5f66; padding: 6px 0 6px 10px; margin-top: 6px; }
.rl-lap-head { font-size: 13px; }

/* ---------- grouped tabs: sub-nav + the Turn Lab picker ---------- */
.subtabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  max-width: 920px; margin: 0 auto; padding: 0 24px 4px;
}
.subtab {
  background: transparent; border: 1px solid transparent; border-radius: 999px;
  color: var(--muted); font-size: 12px; padding: 4px 12px; cursor: pointer;
}
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--text); background: var(--card2); border-color: var(--border); }
.turn-lab-picker-card { display: flex; flex-direction: column; gap: 12px; }
.turn-lab-picker { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.turn-lab-picker label { flex: 1 1 260px; }
.turn-lab-picker select { width: 100%; }
.turn-lab-add {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  border-top: 1px dashed var(--border); padding-top: 12px;
}
.turn-lab-add .hint-text { flex-basis: 100%; margin: 0; }

.turn-chain-svg { width: 100%; height: auto; display: block; color: var(--muted); }
.turn-viz-wide { grid-column: 1 / -1; }
