:root {
  --bg: #101211;
  --panel: #171a18;
  --panel-raised: #1e221f;
  --panel-soft: #222722;
  --canvas: #747570;
  --canvas-deep: #5d5f5b;
  --line: rgba(239, 242, 234, .11);
  --line-strong: rgba(239, 242, 234, .22);
  --text: #f1f2ed;
  --muted: #a7aaa2;
  --subtle: #92988f;
  --blue: #a9c8ff;
  --blue-deep: #5379b9;
  --green: #9bd9af;
  --amber: #f0cb82;
  --red: #f3988c;
  --violet: #ccb8ff;
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "DM Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --library-width: 282px;
  --inspector-width: 364px;
  --topbar-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
}

/* Les liens secondaires quittent la barre étroite, mais restent accessibles
   dans le menu …, ce qui évite de surcharger l’atelier sur mobile. */
@media (max-width: 760px) {
  .calm-topbar .topbar-guide-link,
  .calm-topbar .topbar-account-link { display: none; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  overflow: hidden;
}
button, select, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.eyebrow {
  display: block;
  color: var(--subtle);
  font: 500 10px/1.2 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: rgba(16, 18, 17, .96);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 4;
}
.brand {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--text);
  font-size: 11px;
  line-height: 1.05;
  letter-spacing: .01em;
  text-decoration: none;
}
.brand b { font-size: 12px; letter-spacing: .035em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font: 500 10px var(--mono);
  letter-spacing: -.06em;
}
.project-switcher { display: flex; align-items: center; gap: 6px; min-width: 0; }
.project-switcher select {
  width: min(240px, 30vw);
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 7px 24px 7px 6px;
  font-weight: 600;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 12px) 52%, calc(100% - 8px) 52%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.project-switcher select option, .library-panel select, .generation-select option { background: var(--panel); }
.topbar-spacer { flex: 1; }
.connection-state { color: var(--muted); font-size: 12px; white-space: nowrap; }
.connection-state.ok { color: var(--green); }
.connection-state.bad { color: var(--red); }

.workspace {
  height: calc(100dvh - var(--topbar-height));
  display: grid;
  grid-template-columns: var(--library-width) minmax(420px, 1fr) var(--inspector-width);
  min-width: 0;
}
.library-panel, .inspector-panel {
  min-width: 0;
  background: var(--panel);
  overflow: auto;
}
.library-panel { border-right: 1px solid var(--line); }
.inspector-panel { border-left: 1px solid var(--line); }

.library-section { padding: 18px 15px; }
.library-section + .library-section { border-top: 1px solid var(--line); }
.shots-section { min-height: 188px; }
.refs-section { min-height: calc(100% - 188px); }
.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}
.section-heading h2, .composer h2, .viewer h2, .help-dialog h2 {
  margin: 3px 0 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -.015em;
}
.small { padding: 5px 8px !important; font-size: 11px !important; }
.quiet-button, .icon-button {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  border-radius: 7px;
  transition: background .16s ease, border-color .16s ease;
}
.quiet-button { padding: 7px 10px; font-size: 12px; }
a.quiet-button { text-decoration: none; }
a.icon-button { display: inline-grid; place-items: center; text-decoration: none; }
.icon-button { width: 30px; height: 30px; padding: 0; font-size: 18px; line-height: 1; }
.quiet-button:hover, .icon-button:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.38); }
.quiet-button:focus-visible, .icon-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.primary-button {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--text);
  color: #161816;
  font-weight: 700;
  font-size: 12px;
  transition: transform .16s ease, background .16s ease;
}
.primary-button:hover:not(:disabled) { background: #fff; transform: translateY(-1px); }
.add-reference {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--bg);
  background: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.add-reference:hover { background: #fff; }
.add-reference.is-disabled { cursor: not-allowed; opacity: .42; pointer-events: none; }
.select-label {
  display: block;
  margin: 0 0 6px;
  color: var(--subtle);
  font-size: 11px;
}
.library-panel select, .generation-select {
  width: 100%;
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.shot-list { display: grid; gap: 5px; }
.shot-item {
  width: 100%;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.shot-item:hover { background: rgba(255,255,255,.045); }
.shot-item.is-active { background: var(--panel-soft); border-color: var(--line-strong); }
.shot-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255,255,255,.07);
  color: var(--muted);
  font: 500 10px var(--mono);
}
.shot-item.is-active .shot-index { background: var(--text); color: var(--bg); }
.shot-copy { min-width: 0; }
.shot-copy strong, .shot-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-copy strong { font-size: 12px; }
.shot-copy span { color: var(--muted); font-size: 10px; margin-top: 1px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--subtle); }
.status-dot.running, .status-dot.queued { background: var(--blue); box-shadow: 0 0 0 4px rgba(169,200,255,.12); }
.status-dot.awaiting_decision, .status-dot.needs_human { background: var(--amber); }
.status-dot.accepted { background: var(--green); }
.status-dot.failed, .status-dot.interrupted { background: var(--red); }

.reference-list { display: grid; gap: 8px; margin-top: 12px; }
.reference-card {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.reference-card.selectable { cursor: pointer; }
.reference-card.selectable:hover { background: rgba(255,255,255,.045); }
.reference-card.is-selected { background: var(--panel-soft); border-color: var(--line-strong); }
.reference-thumb { width: 52px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--panel-soft); }
.reference-copy { min-width: 0; }
.reference-role { display: block; color: var(--text); font-size: 11px; font-weight: 650; text-transform: capitalize; }
.reference-note { display: block; color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reference-state { color: var(--subtle); font: 10px var(--mono); }
.reference-state.ready { color: var(--green); }
.reference-locked { color: var(--subtle); font-size: 10px; }
.empty-library { color: var(--muted); font-size: 12px; padding: 9px 2px; }

.stage-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--canvas);
}
.context-bar {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(16,18,17,.26);
  border-bottom: 1px solid rgba(0,0,0,.16);
}
.context-title { font-size: 12px; font-weight: 700; }
.context-detail { color: rgba(255,255,255,.7); font-size: 11px; }
.context-spacer { flex: 1; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: rgba(255,255,255,.92);
  background: rgba(16,18,17,.24);
  font-size: 10px;
  white-space: nowrap;
}
.status-chip.good { border-color: rgba(155,217,175,.6); color: #d5ffe0; }
.status-chip.warn { border-color: rgba(240,203,130,.66); color: #ffe0a1; }
.status-chip.bad { border-color: rgba(243,152,140,.7); color: #ffd1ca; }
.execution-band { min-height: 0; }
.execution-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 11px 20px;
  background: rgba(14, 17, 15, .88);
  border-bottom: 1px solid rgba(255,255,255,.11);
}
.execution-card.awaiting_decision { background: rgba(72, 58, 28, .88); }
.execution-card.failed, .execution-card.interrupted { background: rgba(79, 37, 33, .9); }
.execution-diagnostic {
  padding: 7px 20px 10px 57px;
  background: rgba(79, 37, 33, .9);
  border-bottom: 1px solid rgba(255,255,255,.11);
  color: rgba(255,255,255,.78);
  font-size: 11px;
}
.execution-diagnostic summary { cursor: pointer; color: var(--red); }
.execution-diagnostic pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; font: 10px/1.45 var(--mono); }
.execution-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  color: var(--blue);
}
.execution-copy { min-width: 0; }
.execution-copy strong, .execution-copy span { display: block; }
.execution-copy strong { font-size: 12px; }
.execution-copy span { color: rgba(255,255,255,.72); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.execution-meta { color: rgba(255,255,255,.62); font: 10px var(--mono); text-align: right; }
.progress-line { height: 2px; background: rgba(255,255,255,.13); overflow: hidden; }
.progress-line i { display: block; height: 100%; background: var(--blue); transition: width .25s ease; }

.scene {
  min-height: 0;
  overflow: auto;
  padding: clamp(18px, 3vw, 36px);
  scroll-behavior: smooth;
}
.scene-inner { width: min(1050px, 100%); margin: 0 auto; }
.empty-state {
  min-height: 360px;
  display: grid;
  place-content: center;
  max-width: 560px;
  margin: auto;
  text-align: center;
  color: rgba(255,255,255,.87);
}
.empty-state .eyebrow { color: rgba(255,255,255,.55); }
.empty-state h1 { margin: 8px 0 9px; font-size: clamp(24px, 3vw, 35px); line-height: 1.12; letter-spacing: -.05em; }
.empty-state p { margin: 0; color: rgba(255,255,255,.7); max-width: 48ch; }
.brief-preview, .error-card, .recommendation-card, .generation-card {
  border: 1px solid rgba(255,255,255,.17);
  border-radius: var(--radius);
  background: rgba(25, 28, 26, .82);
  color: var(--text);
  box-shadow: 0 18px 44px rgba(0,0,0,.12);
}
.brief-preview { padding: 19px; text-align: left; margin-top: 20px; }
.brief-preview p { margin: 8px 0 0; color: var(--muted); }
.scene-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.scene-heading h1 { margin: 3px 0 0; font-size: 20px; line-height: 1.12; letter-spacing: -.035em; }
.scene-heading p { margin: 5px 0 0; color: rgba(255,255,255,.68); font-size: 11px; }
.error-card, .recommendation-card, .generation-card { padding: 15px; margin: 0 0 16px; }
.error-card { border-color: rgba(243,152,140,.64); background: rgba(74,35,31,.93); }
.recommendation-card { border-color: rgba(240,203,130,.68); background: rgba(69,57,30,.92); }
.card-title { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 12px; }
.error-card p, .recommendation-card p, .generation-card p { margin: 7px 0 0; color: rgba(255,255,255,.8); font-size: 12px; }
.error-detail { margin-top: 10px; color: rgba(255,255,255,.66); font: 10px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.candidate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(225px, 1fr)); gap: 13px; }
.candidate-card {
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: rgba(20,22,20,.25);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform .17s ease, background .17s ease, border-color .17s ease;
}
.candidate-card:hover { transform: translateY(-2px); background: rgba(20,22,20,.45); }
.candidate-card.is-best { border-color: rgba(255,255,255,.92); }
.candidate-card.is-recommended { border-color: var(--amber); }
.candidate-card.is-approved { border-color: var(--green); }
.candidate-image { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--panel); border-radius: 6px; }
.candidate-footer { display: flex; align-items: center; gap: 8px; padding: 7px 3px 2px; }
.candidate-index { font: 500 10px var(--mono); color: var(--muted); }
.candidate-label { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.candidate-score { margin-left: auto; font-weight: 700; font-size: 12px; }
.run-history { margin-top: 18px; }
.run-history details { border-top: 1px solid rgba(255,255,255,.2); padding-top: 10px; }
.run-history summary { color: rgba(255,255,255,.72); cursor: pointer; font-size: 11px; }
.history-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; overflow: auto; }
.history-row img { width: 64px; height: 42px; border-radius: 4px; object-fit: cover; cursor: pointer; opacity: .75; }
.history-row img:hover { opacity: 1; }

.composer {
  margin: 0 16px 16px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.17);
  border-radius: var(--radius);
  background: rgba(17,20,18,.94);
  box-shadow: 0 14px 36px rgba(0,0,0,.22);
}
.composer.is-busy { opacity: .72; }
.composer-header { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 11px; }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 67px;
  resize: vertical;
  border: 0;
  outline: 0;
  border-radius: 8px;
  padding: 10px;
  background: rgba(255,255,255,.055);
  color: var(--text);
  line-height: 1.45;
}
.composer textarea::placeholder { color: var(--subtle); }
.composer-footer { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-top: 10px; }
.composer-footer span { color: var(--subtle); font-size: 10px; }
.rerun-control { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.rerun-control input { accent-color: var(--blue); }

.inspector-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 14px 5px 11px;
  font-size: 11px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--text); }
.inspector-content { padding: 17px; }
.inspector-empty { color: var(--muted); font-size: 12px; line-height: 1.6; padding-top: 6px; }
.inspector-section + .inspector-section { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; }
.inspector-section h3 { margin: 0 0 9px; font-size: 12px; letter-spacing: -.01em; }
.intent-text { margin: 0; color: var(--text); font-size: 13px; line-height: 1.55; }
.fact-list { display: grid; gap: 10px; margin: 0; }
.fact-list div { display: grid; gap: 2px; }
.fact-list dt { color: var(--subtle); font: 500 9px var(--mono); letter-spacing: .07em; text-transform: uppercase; }
.fact-list dd { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.reference-summary { display: grid; gap: 8px; }
.reference-summary-item { padding: 9px; border-radius: 8px; background: rgba(255,255,255,.045); }
.reference-summary-item strong { display: block; font-size: 11px; text-transform: capitalize; }
.reference-summary-item span { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.generation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--subtle); font-size: 10px; }
.field input { width: 100%; background: var(--panel-raised); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 8px; }
.generation-search { margin-bottom: 1px; }
.model-filter-note { color: var(--subtle); font-size: 10px; line-height: 1.35; }
.generation-summary {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(169,200,255,.08);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}
.generation-summary.bad { background: rgba(243,152,140,.1); color: #ffd0ca; }
.generation-estimate { margin: 8px 1px 0; color: var(--subtle); font-size: 10px; line-height: 1.45; }
.action-stack { display: grid; gap: 8px; margin-top: 13px; }
.action-stack .primary-button, .action-stack .quiet-button { width: 100%; text-align: center; }
.activity-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.activity-list li { display: grid; grid-template-columns: 45px 1fr; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.activity-list time { color: var(--subtle); font: 9px var(--mono); }
.activity-list li.warn { color: var(--amber); }
.activity-list li.error { color: var(--red); }
.activity-list li:first-child { border-top: 1px solid var(--line); }
.technical-details summary { color: var(--muted); cursor: pointer; font-size: 11px; }
.technical-details pre {
  margin: 9px 0 0;
  padding: 9px;
  overflow: auto;
  border-radius: 7px;
  background: #0e100f;
  color: #c8cec5;
  font: 9px/1.5 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}
.expert-editor { width: 100%; min-height: 190px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #101211; color: var(--text); font: 9px/1.5 var(--mono); }

.viewer {
  width: min(1180px, calc(100vw - 36px));
  max-width: none;
  height: min(760px, calc(100dvh - 36px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  overflow: hidden;
}
.viewer::backdrop, .help-dialog::backdrop { background: rgba(0,0,0,.76); backdrop-filter: blur(3px); }
.viewer[open] { display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.viewer-media { position: relative; display: grid; place-items: center; min-width: 0; overflow: hidden; padding: 20px; background: #0c0d0c; --zoom-x: 50%; --zoom-y: 50%; }
.viewer-media img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 5px; transform-origin: var(--zoom-x) var(--zoom-y); }
.viewer-zoom-hint { position: absolute; left: 30px; bottom: 30px; z-index: 1; padding: 6px 8px; border: 1px solid rgba(255,255,255,.14); border-radius: 6px; background: rgba(11,13,11,.76); color: var(--muted); font: 10px var(--mono); pointer-events: none; }
.viewer-info { overflow: auto; padding: 18px; }
.viewer-head, .dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.viewer-toolbar { display: flex; gap: 7px; }
.viewer-download svg { width: 16px; height: 16px; }
.viewer-summary { color: var(--muted); font-size: 12px; line-height: 1.55; }
.score-list { display: grid; gap: 8px; margin: 15px 0; }
.score-row { display: grid; grid-template-columns: 84px 1fr 28px; gap: 7px; align-items: center; color: var(--muted); font-size: 10px; }
.score-bar { height: 5px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.score-bar i { display: block; height: 100%; background: var(--text); border-radius: inherit; }
.defect-list { display: grid; gap: 5px; color: var(--amber); font-size: 11px; }
.defect-list span::before { content: "— "; }
.viewer-actions { display: grid; gap: 8px; margin-top: 19px; }
.viewer-note { color: var(--subtle); font-size: 10px; line-height: 1.5; }
.help-dialog { width: min(430px, calc(100vw - 36px)); border: 1px solid var(--line-strong); border-radius: 12px; padding: 18px; background: var(--panel); color: var(--text); }
.help-dialog dl { display: grid; grid-template-columns: 130px 1fr; gap: 10px; margin: 18px 0 0; }
.help-dialog dt { color: var(--text); font: 10px var(--mono); }
.help-dialog dd { margin: 0; color: var(--muted); font-size: 11px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 10;
  max-width: min(560px, calc(100vw - 28px));
  padding: 10px 13px;
  transform: translate(-50%, 18px);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 9px;
  background: #232723;
  color: var(--text);
  box-shadow: 0 14px 35px rgba(0,0,0,.35);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (hover: hover) and (pointer: fine) {
  .viewer-media { cursor: zoom-in; }
  .viewer-media img { transition: transform .18s ease; }
  .viewer-media:hover img { transform: scale(1.8); cursor: zoom-out; }
  .viewer-media:hover .viewer-zoom-hint { opacity: 0; }
}
@media (hover: none), (pointer: coarse) {
  .viewer-zoom-hint { display: none; }
}

@media (max-width: 1180px) {
  :root { --library-width: 238px; --inspector-width: 310px; }
  .connection-state { display: none; }
}
@media (max-width: 930px) {
  body { overflow: auto; }
  .workspace { height: auto; min-height: calc(100dvh - var(--topbar-height)); grid-template-columns: 220px minmax(0, 1fr); }
  .inspector-panel { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; max-height: none; }
  .inspector-content { min-height: 220px; }
  .stage-panel { min-height: 720px; }
}
@media (max-width: 680px) {
  :root { --topbar-height: 58px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .brand > span:last-child, #btnHelp { display: none; }
  .project-switcher { flex: 1; }
  .project-switcher select { width: 100%; }
  .workspace { display: block; height: auto; }
  .library-panel { border-right: 0; }
  .shots-section { min-height: 0; }
  .library-section { padding: 14px; }
  .shot-list { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
  .reference-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reference-card { grid-template-columns: 42px minmax(0, 1fr); }
  .reference-thumb { width: 42px; height: 42px; }
  .reference-state, .reference-locked { display: none; }
  .stage-panel { min-height: 0; }
  .scene { min-height: 420px; padding: 18px 13px; }
  .composer { margin: 0 10px 10px; }
  .composer-header { display: block; }
  .rerun-control { margin-top: 9px; }
  .viewer[open] { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; height: min(920px, calc(100dvh - 20px)); }
  .viewer-info { max-height: 45dvh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Refined workbench: keep the creative direction and the images in focus.
   Supporting information lives in the drawer instead of occupying a third
   of the canvas all the time. */
:root {
  --library-width: 270px;
  --inspector-width: 392px;
  --topbar-height: 62px;
  --dock-shadow: 0 18px 42px rgba(0, 0, 0, .28);
}

.topbar {
  gap: 12px;
  padding: 0 16px;
  background: rgba(16, 18, 17, .98);
}
.project-switcher { gap: 8px; }
.project-switcher-label {
  color: var(--subtle);
  font: 500 9px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.project-switcher select {
  width: min(235px, 24vw);
  padding-left: 0;
  font-size: 12px;
}
.new-project-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease;
}
.new-project-button > span:first-child { color: var(--blue); font-size: 15px; line-height: .8; }
.new-project-button:hover { border-color: rgba(255,255,255,.38); background: rgba(255,255,255,.08); }
.new-project-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.topbar-settings { display: none; }

.workspace {
  position: relative;
  grid-template-columns: var(--library-width) minmax(0, 1fr);
  height: calc(100dvh - var(--topbar-height));
}
.library-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #151816;
}
.library-section { padding: 15px 13px; }
.shots-section {
  flex: 0 1 auto;
  min-height: 156px;
  max-height: 42%;
  overflow: auto;
}
.refs-section {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.section-heading { margin-bottom: 10px; }
.section-heading h2 { font-size: 13px; }
.shot-list { gap: 3px; }
.shot-item { padding: 7px; }
.reference-list { gap: 6px; margin-top: 9px; }
.reference-card { grid-template-columns: 45px minmax(0, 1fr) auto; gap: 8px; padding: 5px; }
.reference-thumb { width: 45px; height: 42px; }
.library-utilities {
  display: grid;
  gap: 4px;
  flex: none;
  margin-top: auto;
  padding: 9px 10px 11px;
  border-top: 1px solid var(--line);
  background: rgba(8, 10, 9, .2);
}
.utility-button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 37px;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}
.utility-button:hover,
.utility-button:focus-visible {
  border-color: var(--line);
  background: rgba(255,255,255,.055);
  color: var(--text);
}
.utility-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--subtle);
  font: 13px/1 var(--mono);
}
.utility-button b,
.utility-button small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.utility-button b { color: currentColor; font-size: 11px; font-weight: 650; }
.utility-button small { margin-top: 1px; color: var(--subtle); font-size: 9px; }

.stage-panel {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at 52% 32%, rgba(255,255,255,.07), transparent 42%),
    linear-gradient(145deg, var(--canvas), var(--canvas-deep));
}
.context-bar {
  min-height: 42px;
  padding: 8px 20px;
  background: rgba(14,16,15,.3);
}
.context-title { font-size: 11px; }
.context-detail { font-size: 10px; }
.execution-card { padding: 9px 20px; }
.scene {
  padding: clamp(16px, 2.8vw, 34px) clamp(16px, 3.8vw, 48px) 14px;
}
.scene-inner { width: min(1380px, 100%); }
.scene-heading {
  align-items: center;
  margin: 0 0 13px;
  padding: 0 2px;
}
.scene-heading h1 {
  margin-top: 2px;
  color: rgba(255,255,255,.78);
  font: 500 10px/1.25 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.scene-heading p {
  max-width: 82ch;
  margin-top: 5px;
  color: rgba(255,255,255,.9);
  font-size: 12px;
  line-height: 1.5;
}
.scene-direction-copy {
  display: -webkit-box;
  max-width: 82ch;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.scene-heading-actions { display: flex; flex: none; align-items: center; gap: 6px; }
.scene-heading .eyebrow { display: none; }
.scene-heading > .quiet-button { flex: none; padding: 6px 9px; font-size: 10px; }
.candidate-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(390px, 100%), 1fr));
  gap: 15px;
}
.candidate-card {
  padding: 5px;
  border-width: 1px;
  border-radius: 10px;
  background: rgba(13, 15, 14, .28);
}
.candidate-card:hover { transform: translateY(-1px); background: rgba(13,15,14,.46); }
.candidate-image {
  aspect-ratio: 16 / 10;
  border-radius: 7px;
  object-fit: contain;
  background: rgba(8,10,9,.58);
}
.candidate-footer { padding: 7px 4px 3px; }
.generation-card,
.recommendation-card,
.error-card { margin-bottom: 13px; padding: 12px; }
.scene .generation-card p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.run-history { margin-top: 14px; }

.composer {
  margin: 0 20px 18px;
  padding: 14px;
  border-color: rgba(255,255,255,.2);
  border-radius: 13px;
  background: rgba(15,18,16,.96);
  box-shadow: var(--dock-shadow);
}
.composer-header { margin-bottom: 10px; }
.composer h2 { font-size: 13px; }
.composer textarea {
  min-height: 118px;
  max-height: 220px;
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: rgba(255,255,255,.065);
  font-size: 13px;
  line-height: 1.55;
  transition: border-color .16s ease, background .16s ease;
}
.composer textarea:focus {
  border-color: rgba(169,200,255,.7);
  background: rgba(255,255,255,.08);
}
.shot-title-field {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 0 0 9px;
}
.shot-title-field[hidden],
.generation-dock[hidden],
.generation-dock-details[hidden] { display: none !important; }
.shot-title-field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}
.shot-title-field label span { color: var(--subtle); font-weight: 400; }
.shot-title-field input {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255,255,255,.055);
  color: var(--text);
  font-size: 12px;
}
.shot-title-field input:focus { border-color: var(--blue); outline: 0; }
.generation-dock[hidden] { display: none; }
.generation-dock {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}
.generation-dock-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
  padding: 5px 6px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}
.generation-dock-summary:empty { display: none; }
.generation-summary-copy {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  gap: 7px;
}
.generation-dock-summary > span:first-child,
.generation-dock-summary .generation-summary-copy {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.generation-profile-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  width: auto;
  min-height: 30px;
  margin-left: auto;
  padding: 4px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--blue);
  text-align: left;
  font-size: 10px;
  font-weight: 650;
  transition: border-color .16s ease, background .16s ease;
}
.generation-profile-button:hover { border-color: var(--line-strong); background: rgba(255,255,255,.06); }
.generation-profile-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.generation-profile-label { color: var(--subtle); font-size: 9px; white-space: nowrap; }
.generation-summary-copy strong {
  min-width: 0;
  max-width: 160px;
  overflow: hidden;
  color: var(--text);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.generation-summary-meta { color: var(--muted); white-space: nowrap; }
.generation-review-status { color: var(--subtle); white-space: nowrap; }
.generation-profile-warning { flex-basis: 100%; margin: 1px 0 0; color: var(--red); font-size: 9px; }
.generation-dock-summary .quiet-button,
.generation-dock-summary button {
  flex: none;
  margin-left: auto;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 10px;
}
.generation-dock-details[hidden] { display: none; }
.generation-dock-details {
  display: grid;
  grid-template-columns: minmax(150px, 1.6fr) minmax(96px, .7fr) minmax(96px, .7fr);
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,.12);
}
.generation-dock-details .field { gap: 3px; }
.generation-dock-details .field label { color: var(--subtle); font-size: 9px; }
.generation-dock-details > label {
  display: grid;
  gap: 3px;
  color: var(--subtle);
  font-size: 9px;
}
.generation-dock-details select,
.generation-dock-details input {
  min-width: 0;
  width: 100%;
  height: 30px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 10px;
}
.generation-dock-details #dockModelSearch { display: none; }
.generation-dock-details .generation-estimate,
.generation-dock-details .generation-controls-note {
  grid-column: 1 / -1;
  margin: 0;
}
.generation-dock-details .generation-estimate {
  color: var(--subtle);
  font-size: 9px;
  line-height: 1.35;
}
.generation-dock-details .generation-controls-note {
  padding-top: 2px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}
.composer-footer { margin-top: 9px; }
.composer-footer .primary-button { padding: 8px 11px; font-size: 11px; }
.rerun-control { padding: 4px 6px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.035); }

.inspector-backdrop {
  position: fixed;
  inset: var(--topbar-height) 0 0;
  z-index: 19;
  background: rgba(0,0,0,.44);
  opacity: 0;
  transition: opacity .2s ease;
}
.inspector-backdrop:not([hidden]),
.inspector-backdrop.is-visible { opacity: 1; }
.inspector-panel {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: min(var(--inspector-width), calc(100vw - 36px));
  min-width: 0;
  border: 0;
  border-left: 1px solid var(--line-strong);
  background: #171a18;
  box-shadow: -20px 0 50px rgba(0,0,0,.3);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(104%);
  transition: transform .22s ease, opacity .18s ease;
}
.inspector-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
.inspector-head {
  display: flex;
  flex: none;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 13px;
  border-bottom: 1px solid var(--line);
}
.inspector-head h2 { margin: 3px 0 0; font-size: 14px; letter-spacing: -.015em; }
.inspector-tabs { flex: none; }
.tab { padding: 11px 5px 9px; font-size: 10px; }
.inspector-content { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.inspector-section + .inspector-section { margin-top: 15px; padding-top: 15px; }
.intent-text { font-size: 12px; }
.fable-review-toggle {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  cursor: pointer;
}
.fable-review-toggle:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.fable-review-toggle input { width: 15px; height: 15px; margin: 2px 0 0; accent-color: var(--blue); }
.fable-review-toggle b,
.fable-review-toggle small { display: block; }
.fable-review-toggle b { color: var(--text); font-size: 11px; }
.fable-review-toggle small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.45; }

.project-dialog {
  width: min(460px, calc(100vw - 32px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 75px rgba(0,0,0,.42);
}
.project-dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(3px); }
.project-dialog form { padding: 18px; }
.project-dialog p { margin: 14px 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.dialog-field { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.project-dialog input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 13px;
}
.project-dialog input:focus { border-color: var(--blue); outline: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }

@media (max-width: 1080px) {
  :root { --library-width: 236px; --inspector-width: 360px; }
  .candidate-grid { grid-template-columns: repeat(auto-fit, minmax(min(310px, 100%), 1fr)); }
  .project-switcher-label { display: none; }
  .project-switcher select { width: min(210px, 28vw); }
}

@media (max-width: 760px) {
  body { overflow: hidden; }
  .topbar { gap: 7px; padding: 0 10px; }
  .brand > span:last-child,
  .guide-link,
  .topbar-settings,
  #btnHelp { display: none; }
  .project-switcher { flex: 1; min-width: 0; }
  .project-switcher select { width: 100%; max-width: none; }
  .new-project-button { width: 31px; justify-content: center; padding: 0; }
  .new-project-button > span:last-child { display: none; }
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 112px minmax(0, 1fr);
    height: calc(100dvh - var(--topbar-height));
    min-height: 0;
  }
  .library-panel {
    display: grid;
    grid-template-columns: minmax(130px, .9fr) minmax(160px, 1.2fr) 42px;
    grid-row: 1;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .library-section,
  .shots-section,
  .refs-section {
    min-height: 0;
    max-height: none;
    padding: 9px;
    overflow: hidden;
  }
  .shots-section { border-top: 0; }
  .refs-section { border-top: 0; border-left: 1px solid var(--line); }
  .library-section .section-heading { min-height: 23px; margin-bottom: 4px; }
  .library-section .section-heading .eyebrow { display: none; }
  .library-section .section-heading h2 { margin: 0; font-size: 11px; }
  .library-section .section-heading .small { padding: 3px 5px !important; font-size: 9px !important; }
  .refs-section .select-label,
  .refs-section #refRole { display: none; }
  .shot-list,
  .reference-list {
    display: flex;
    gap: 5px;
    margin-top: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .shot-list::-webkit-scrollbar,
  .reference-list::-webkit-scrollbar { display: none; }
  .shot-item { flex: 0 0 116px; grid-template-columns: 24px minmax(0, 1fr) 6px; gap: 5px; padding: 5px; }
  .shot-index { width: 24px; height: 24px; font-size: 9px; }
  .shot-copy strong { font-size: 10px; }
  .shot-copy span { display: none; }
  .reference-card { flex: 0 0 58px; display: block; padding: 3px; }
  .reference-thumb { display: block; width: 52px; height: 49px; }
  .reference-copy,
  .reference-state { display: none; }
  .library-utilities {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    margin: 0;
    padding: 5px 3px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }
  .utility-button { display: grid; grid-template-columns: 1fr; min-height: 0; padding: 2px; place-items: center; }
  .utility-button > span:last-child { display: none; }
  .utility-icon { width: 22px; height: 22px; }
  .stage-panel { grid-row: 2; min-height: 0; }
  .context-bar { min-height: 37px; padding: 7px 10px; }
  .context-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .execution-card { padding: 8px 10px; }
  .execution-meta { display: none; }
  .scene { min-height: 0; padding: 13px 10px 9px; }
  .scene-heading { align-items: flex-start; margin-bottom: 9px; }
  .scene-heading p { font-size: 11px; line-height: 1.43; }
  .scene-direction-copy { -webkit-line-clamp: 2; }
  .scene-heading > .quiet-button { padding: 5px 6px; font-size: 9px; }
  .scene .generation-card { margin-bottom: 9px; padding: 10px; }
  .scene .generation-card p { -webkit-line-clamp: 3; font-size: 11px; line-height: 1.42; }
  .candidate-grid { grid-template-columns: 1fr; gap: 10px; }
  .candidate-image { aspect-ratio: 16 / 10; }
  .composer { margin: 0 8px 8px; padding: 10px; border-radius: 11px; }
  .composer-header { margin-bottom: 8px; }
  .composer h2 { font-size: 12px; }
  .composer textarea { min-height: 108px; max-height: 165px; padding: 11px; font-size: 12px; }
  .shot-title-field { grid-template-columns: 1fr; gap: 4px; margin-bottom: 7px; }
  .generation-dock-details { grid-template-columns: 1fr 1fr; }
  .generation-dock-details > :first-child { grid-column: 1 / -1; }
  .generation-profile-button { gap: 4px; min-height: 28px; }
  .generation-profile-label,
  .generation-review-status { display: none; }
  .composer-footer { align-items: center; gap: 8px; }
  .composer-footer span { max-width: 45%; line-height: 1.35; }
  .rerun-control { margin-top: 0; }
  .inspector-backdrop { inset: var(--topbar-height) 0 0; }
  .inspector-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(78dvh, 680px);
    border-top: 1px solid var(--line-strong);
    border-left: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -18px 48px rgba(0,0,0,.34);
    transform: translateY(105%);
  }
  .inspector-panel.is-open { transform: translateY(0); }
  .inspector-head { padding: 13px 14px 10px; }
  .inspector-content { padding: 14px; }
}

@media (max-width: 430px) {
  .connection-state { display: none; }
  .brand-mark { width: 26px; height: 26px; }
  .project-switcher select { font-size: 11px; }
  .library-panel { grid-template-columns: minmax(120px, .85fr) minmax(135px, 1.15fr) 38px; }
  .shot-item { flex-basis: 108px; }
  .composer-footer > span { display: none; }
  .composer-footer { justify-content: flex-end; }
}

/* Three-pane direction workbench ------------------------------------------------
   The left rail holds material, the middle is the written direction, and the
   widest panel is reserved for visual decisions.  These rules intentionally
   come last: they replace the earlier two-pane presentation without changing
   any existing controls or data flows. */
:root {
  --workbench-library: clamp(244px, 18vw, 286px);
  --workbench-direction: clamp(338px, 27vw, 438px);
}

.workbench.workspace {
  display: grid;
  grid-template-columns: var(--workbench-library) var(--workbench-direction) minmax(520px, 1fr);
  height: calc(100dvh - var(--topbar-height));
  min-height: 0;
  overflow: hidden;
  background: var(--canvas-deep);
}
.workbench .library-panel {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #151816;
}
.workbench .direction-panel {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #181c19, #131614 42%);
}
.direction-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 17px 12px;
  border-bottom: 1px solid var(--line);
}
.direction-panel-head h2 { margin: 3px 0 0; font-size: 14px; letter-spacing: -.02em; }
.direction-close { display: none; }
.direction-panel .context-bar {
  min-height: 0;
  padding: 9px 17px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.018);
}
.direction-content {
  min-height: 0;
  overflow: auto;
  padding: 16px 17px 10px;
  scrollbar-gutter: stable;
}
.direction-work-object {
  display: grid;
  gap: 13px;
  padding-bottom: 8px;
}
.direction-work-head,
.direction-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.direction-work-head h2 {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -.035em;
}
.direction-work-head p {
  margin: 5px 0 0;
  color: var(--subtle);
  font-size: 10px;
  line-height: 1.45;
}
.direction-brief,
.direction-edit-section,
.direction-spec-section,
.direction-references {
  padding: 12px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 10px;
  background: rgba(255,255,255,.025);
}
.direction-brief > span,
.direction-spec-section > .eyebrow,
.direction-references > .eyebrow {
  color: var(--subtle);
  font: 500 9px/1.2 var(--mono);
  letter-spacing: .09em;
  text-transform: uppercase;
}
.direction-brief p {
  margin: 7px 0 0;
  color: rgba(255,255,255,.86);
  font-size: 12px;
  line-height: 1.58;
}
.direction-section-head { margin-bottom: 9px; }
.direction-section-head h3 {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 13px;
  letter-spacing: -.02em;
}
.direction-edit-state,
.direction-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid rgba(155,217,175,.32);
  border-radius: 999px;
  color: #c9f5d4;
  background: rgba(72,132,89,.13);
  font: 500 9px/1.2 var(--mono);
  white-space: nowrap;
}
.direction-edit-state[data-unsaved="true"] {
  border-color: rgba(240,203,130,.48);
  color: #ffe0a1;
  background: rgba(120,84,22,.18);
}
.direction-status[data-phase="drafting"],
.direction-status[data-phase="patching"] {
  border-color: rgba(180,151,255,.45);
  color: #e2d8ff;
  background: rgba(105,77,182,.18);
}
.direction-intent-editor {
  display: block;
  width: 100%;
  min-height: 208px;
  resize: vertical;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  outline: 0;
  background: rgba(7,9,8,.34);
  color: var(--text);
  font: 500 13px/1.62 var(--font);
}
.direction-intent-editor:focus {
  border-color: rgba(169,200,255,.72);
  background: rgba(255,255,255,.055);
}
.direction-intent-editor:disabled { opacity: .7; resize: none; }
.direction-work-note,
.direction-empty {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}
.direction-summary-list {
  display: grid;
  gap: 7px;
  margin: 9px 0 0;
}
.direction-summary-list > div {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.direction-summary-list > div:first-child { padding-top: 0; border-top: 0; }
.direction-summary-list dt {
  color: var(--subtle);
  font: 500 9px/1.35 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.direction-summary-list dd {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.47;
}
.direction-references .reference-summary { margin-top: 9px; }
.direction-references .reference-summary-item {
  padding: 8px;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.025);
}
.direction-work-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.direction-work-actions .primary-button,
.direction-work-actions .quiet-button { padding: 7px 9px; font-size: 10px; }
.direction-history {
  padding: 1px 1px 0;
  color: var(--muted);
  font-size: 10px;
}
.direction-history summary { cursor: pointer; color: var(--muted); }
.direction-history .activity-list { margin: 8px 0 0; }
.direction-empty-state {
  padding: 14px 2px;
  color: var(--muted);
}
.direction-empty-state h3 { margin: 6px 0 8px; color: var(--text); font-size: 16px; }
.direction-empty-state p { margin: 0; font-size: 12px; line-height: 1.6; }
.direction-panel .composer {
  margin: 0;
  padding: 12px 14px 14px;
  border: 0;
  border-top: 1px solid var(--line-strong);
  border-radius: 0;
  background: rgba(15,18,16,.98);
  box-shadow: 0 -16px 38px rgba(0,0,0,.18);
}
.direction-panel .composer textarea { min-height: 120px; max-height: 218px; }
.direction-panel .generation-dock-details { grid-template-columns: 1fr 1fr; }
.direction-panel .generation-dock-details > :first-child { grid-column: 1 / -1; }

.workbench .image-panel {
  grid-column: 3;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 22%, rgba(116,144,151,.10), transparent 42%),
    linear-gradient(145deg, #202421 0%, #111412 72%);
}
.image-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(10,12,11,.2);
}
.image-panel-head .eyebrow { margin: 0 0 3px; }
.image-panel-head h2 { margin: 0; font-size: 15px; }
.image-panel-head p { margin: 0; color: var(--subtle); font-size: 10px; }
.image-panel .scene {
  min-height: 0;
  padding: clamp(16px, 2.2vw, 32px);
  overflow: auto;
  scrollbar-gutter: stable;
}
.image-panel .scene-inner { width: min(1440px, 100%); margin: 0 auto; }
.image-panel .candidate-grid { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); }
.image-panel .candidate-image { aspect-ratio: 4 / 3; }
.image-panel .scene-heading { margin-bottom: 13px; }
.image-panel .scene-heading > div:first-child { min-width: 0; }
.image-panel .scene-direction-copy { display: none; }
.image-panel .scene-heading .eyebrow,
.image-panel .scene-heading h1 { display: none; }
.image-panel .scene-heading { justify-content: flex-end; }
.image-panel .scene-heading-actions { margin-left: auto; }

/* A long library should feel like a library: independent, searchable regions. */
.library-search {
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  margin: 0 0 9px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(0,0,0,.14);
  color: var(--subtle);
}
.library-search:focus-within { border-color: rgba(184,205,252,.65); background: rgba(255,255,255,.045); }
.library-search svg { width: 14px; height: 14px; }
.library-search input {
  width: 100%;
  min-width: 0;
  height: 28px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 11px var(--font);
}
.library-search input::placeholder { color: var(--subtle); }
.library-search-count { color: var(--subtle); font: 9px var(--mono); white-space: nowrap; }
.workbench .shots-section,
.workbench .refs-section { scrollbar-gutter: stable; }
.workbench .shot-list,
.workbench .reference-list { padding-right: 2px; }
.utility-resource { text-decoration: none; }
.utility-resource:hover { color: var(--text); }

/* Clear operational colour language: colour is backed by wording and icon. */
.execution-band[data-phase="drafting"] .execution-card,
.execution-band[data-phase="patching"] .execution-card,
.execution-band.is-fable-active .execution-card {
  border-color: rgba(180,151,255,.46);
  background: linear-gradient(90deg, rgba(105,77,182,.27), rgba(35,28,62,.14));
}
.execution-band[data-phase="generating"] .execution-card,
.execution-band[data-phase="downloading"] .execution-card,
.execution-band.is-flora-active .execution-card {
  border-color: rgba(102,208,205,.42);
  background: linear-gradient(90deg, rgba(28,122,130,.26), rgba(19,45,47,.13));
}
.execution-band[data-phase="judging"] .execution-card,
.execution-band.is-reviewing .execution-card {
  border-color: rgba(122,181,255,.44);
  background: linear-gradient(90deg, rgba(49,99,169,.26), rgba(20,38,66,.14));
}
.execution-band[data-phase="awaiting_decision"] .execution-card { background: rgba(118,82,20,.24); }
.execution-band[data-phase="failed"] .execution-card,
.execution-band[data-phase="interrupted"] .execution-card { background: rgba(115,38,34,.23); }
.execution-band[data-phase="drafting"] .execution-icon,
.execution-band[data-phase="patching"] .execution-icon,
.execution-band.is-fable-active .execution-icon {
  color: #e2d8ff;
  background: rgba(180,151,255,.18);
}
.execution-band[data-phase="generating"] .execution-icon,
.execution-band[data-phase="downloading"] .execution-icon,
.execution-band.is-flora-active .execution-icon {
  color: #b5f4f1;
  background: rgba(102,208,205,.16);
}
.execution-band[data-phase="judging"] .execution-icon,
.execution-band.is-reviewing .execution-icon {
  color: #d3e5ff;
  background: rgba(122,181,255,.17);
}
.execution-band[data-phase="drafting"] .progress-line i,
.execution-band[data-phase="patching"] .progress-line i { background: var(--violet); }
.execution-band[data-phase="generating"] .progress-line i,
.execution-band[data-phase="downloading"] .progress-line i { background: #75dcd7; }
.execution-band[data-phase="judging"] .progress-line i { background: #8fc1ff; }
/* The status band already names the active service and shows its real progress.
   Avoid decorative ripples or spinners: they look like a generic page loader
   and can distract from the images being created. */

.direction-toggle { display: none; }
.direction-backdrop { display: none; }

@media (max-width: 1279px) {
  .workbench.workspace { grid-template-columns: minmax(230px, 270px) minmax(0, 1fr); }
  .workbench .image-panel { grid-column: 2; }
  .direction-toggle { display: inline-flex; }
  .workbench .direction-panel {
    position: fixed;
    z-index: 24;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    width: min(430px, calc(100vw - 34px));
    border-left: 1px solid var(--line-strong);
    border-right: 0;
    box-shadow: -22px 0 55px rgba(0,0,0,.38);
    opacity: 0;
    pointer-events: none;
    transform: translateX(105%);
    transition: transform .22s ease, opacity .18s ease;
  }
  .workbench .direction-panel.is-open { opacity: 1; pointer-events: auto; transform: translateX(0); }
  .direction-close { display: inline-grid; }
  .direction-backdrop {
    position: fixed;
    z-index: 23;
    inset: var(--topbar-height) 0 0;
    background: rgba(0,0,0,.45);
    opacity: 0;
    transition: opacity .18s ease;
  }
  .direction-backdrop.is-visible { display: block; opacity: 1; }
}

@media (max-width: 760px) {
  .direction-toggle { display: inline-flex; }
  .workbench.workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 112px minmax(0, 1fr);
    overflow: hidden;
  }
  .workbench .library-panel { grid-column: 1; grid-row: 1; }
  .workbench .image-panel { grid-column: 1; grid-row: 2; }
  .workbench .direction-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(84dvh, 760px);
    border-top: 1px solid var(--line-strong);
    border-left: 0;
    border-radius: 16px 16px 0 0;
    transform: translateY(105%);
    box-shadow: 0 -18px 48px rgba(0,0,0,.4);
  }
  .workbench .direction-panel.is-open { transform: translateY(0); }
  .image-panel-head { min-height: 42px; padding: 8px 10px; }
  .image-panel-head h2 { font-size: 12px; }
  .image-panel-head p { display: none; }
  .image-panel .scene { padding: 12px 10px; }
  .image-panel .candidate-image { aspect-ratio: 16 / 10; }
  .library-search { display: none; }
  .workbench .library-utilities { grid-template-rows: repeat(4, 1fr); }
  .utility-resource .utility-icon { font-size: 14px; }
}

/* Calm workbench -------------------------------------------------------------
   The studio has one visible job per surface: find the plan, shape its
   direction, then make a visual decision.  This final layer deliberately
   neutralises the former dashboard-like treatment while retaining every
   existing control for the application logic. */
:root {
  --bg: #101211;
  --panel: #151816;
  --panel-raised: #1b201d;
  --panel-soft: #202520;
  --canvas: #111512;
  --canvas-deep: #0d100e;
  --line: rgba(241, 244, 238, .09);
  --line-strong: rgba(241, 244, 238, .17);
  --text: #f5f6f1;
  --muted: #a9afa7;
  --subtle: #7f887e;
  --topbar-height: 58px;
  --quiet-rail: 232px;
  --direction-column: 372px;
  --radius: 10px;
}

body { background: var(--bg); }

.calm-topbar.topbar {
  height: var(--topbar-height);
  gap: 8px;
  padding: 0 14px;
  border-bottom-color: var(--line);
  background: rgba(16, 18, 17, .98);
}
.calm-topbar .brand { flex: none; gap: 8px; }
.calm-topbar .brand-mark {
  width: 27px;
  height: 27px;
  border-radius: 7px;
  font-size: 9px;
}
.calm-topbar .brand-name { color: var(--muted); font-size: 10px; }
.calm-topbar .brand-name b { color: var(--text); font-size: 11px; }
.calm-topbar .project-switcher { min-width: 0; max-width: min(280px, 27vw); }
.calm-topbar .project-switcher select {
  width: 100%;
  min-width: 120px;
  padding: 6px 24px 6px 7px;
  color: var(--text);
  font-size: 12px;
}
.topbar-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.topbar-action > span:first-child { color: var(--text); font-size: 15px; font-weight: 400; line-height: 1; }
.topbar-action:hover:not(:disabled), .topbar-action:focus-visible {
  border-color: var(--line-strong);
  background: rgba(255,255,255,.055);
  color: var(--text);
}
.topbar-plan-action { color: var(--text); }
.topbar-spacer { min-width: 8px; }
.calm-topbar .quiet-button {
  min-height: 30px;
  padding: 5px 9px;
  border-color: transparent;
  color: var(--muted);
  font-size: 11px;
}
.calm-topbar .quiet-button:hover,
.calm-topbar .quiet-button:focus-visible {
  border-color: var(--line-strong);
  background: rgba(255,255,255,.055);
  color: var(--text);
}
.calm-topbar .topbar-help { text-decoration: none; }
.more-menu-wrap { position: relative; flex: none; }
.topbar-more[aria-expanded="true"] { border-color: var(--line-strong) !important; background: rgba(255,255,255,.07) !important; color: var(--text) !important; }
.more-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  right: 0;
  width: 228px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #1a1e1b;
  box-shadow: 0 18px 52px rgba(0,0,0,.36);
}
.more-menu[hidden] { display: none !important; }
.more-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 34px;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: 500 11px var(--font);
  text-align: left;
  text-decoration: none;
}
.more-menu-item:hover, .more-menu-item:focus-visible { background: rgba(255,255,255,.07); color: var(--text); outline: 0; }
.more-menu-separator { height: 1px; margin: 5px 2px; background: var(--line); }
.more-connection { margin: 6px 8px 3px; color: var(--subtle); font-size: 10px; line-height: 1.35; white-space: normal; }
.more-connection.ok { color: var(--green); }
.more-connection.bad { color: var(--red); }

.workbench.workspace {
  grid-template-columns: var(--quiet-rail) var(--direction-column) minmax(0, 1fr);
  height: calc(100dvh - var(--topbar-height));
  min-height: 0;
  background: var(--canvas-deep);
}

/* One searchable library at a time, rather than two competing lists. */
.workbench .library-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: #151816;
}
.library-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 9px 10px 8px;
  border-bottom: 1px solid var(--line);
}
.library-tab {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--subtle);
  font: 650 11px var(--font);
  transition: background .16s ease, color .16s ease;
}
.library-tab:hover, .library-tab:focus-visible { color: var(--text); background: rgba(255,255,255,.045); outline: 0; }
.library-tab.is-active, .library-tab[aria-selected="true"] { background: var(--panel-soft); color: var(--text); }
.library-pane {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 16px 11px 12px;
  scrollbar-gutter: stable;
}
.library-pane.is-active:not([hidden]) { display: block; }
.library-pane[hidden] { display: none !important; }
.library-pane-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin: 0 3px 11px;
}
.library-pane-heading h2 { margin: 3px 0 0; font-size: 14px; letter-spacing: -.02em; }
.library-pane-count {
  max-width: 92px;
  padding-top: 3px;
  color: var(--subtle);
  font: 9px/1.35 var(--mono);
  text-align: right;
}
.library-search {
  min-height: 31px;
  margin: 0 0 10px;
  padding: 0 7px;
  border-color: transparent;
  border-radius: 6px;
  background: rgba(255,255,255,.045);
}
.library-search:focus-within { border-color: rgba(169,200,255,.42); background: rgba(255,255,255,.07); }
.library-search input { height: 30px; color: var(--text); font-size: 11px; }
.library-search-count { display: none; }
.shot-list { gap: 2px; }
.shot-item {
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 7px;
  min-height: 44px;
  padding: 6px;
  border-radius: 7px;
}
.shot-item:hover { background: rgba(255,255,255,.045); }
.shot-item.is-active { border-color: transparent; background: var(--panel-soft); }
.shot-index { width: 26px; height: 26px; border-radius: 6px; background: rgba(255,255,255,.055); font-size: 9px; }
.shot-item.is-active .shot-index { background: var(--text); color: #151816; }
.shot-copy strong { font-size: 11px; font-weight: 650; }
.shot-copy span { font-size: 9px; }
.status-dot { width: 6px; height: 6px; }
.empty-library { margin: 7px 3px; color: var(--subtle); font-size: 11px; line-height: 1.55; }
.reference-import-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; margin: 0 0 10px; }
.reference-role-field { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px; min-width: 0; }
.reference-role-field > span { color: var(--subtle); font-size: 10px; }
.reference-role-field select {
  min-width: 0;
  height: 31px;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: rgba(255,255,255,.045);
  color: var(--muted);
  font-size: 10px;
}
.reference-role-field select:focus { border-color: rgba(169,200,255,.42); outline: 0; }
.add-reference {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 31px;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--text);
  color: #151816;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.reference-list { gap: 3px; margin-top: 0; }
.reference-card { grid-template-columns: 43px minmax(0, 1fr) auto; gap: 7px; padding: 5px; border-radius: 7px; }
.reference-card:hover { background: rgba(255,255,255,.045); }
.reference-card.is-selected { border-color: transparent; background: var(--panel-soft); }
.reference-thumb { width: 43px; height: 39px; border-radius: 5px; }
.reference-role { font-size: 10px; }
.reference-note { font-size: 9px; }
.reference-state, .reference-locked { font-size: 8px; }
.library-footer {
  display: flex;
  align-items: center;
  min-height: 43px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
}
.library-resource { color: var(--subtle); font-size: 10px; text-decoration: none; }
.library-resource:hover, .library-resource:focus-visible { color: var(--text); text-decoration: underline; outline: 0; }

/* Direction is a quiet writing surface. Supporting data remains available in
   the secondary inspector instead of competing with the text. */
.workbench .direction-panel {
  grid-column: 2;
  grid-row: 1;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  border-right-color: var(--line);
  background: #171b18;
}
.direction-panel-head { padding: 14px 17px 12px; border-bottom-color: var(--line); }
.direction-panel-head h2 { margin-top: 3px; font-size: 14px; font-weight: 650; }
.direction-close { display: none; }
.direction-panel .context-bar {
  min-height: 39px;
  padding: 8px 17px;
  background: rgba(255,255,255,.018);
  border-bottom-color: var(--line);
}
.context-title { font-size: 11px; }
.context-detail { color: #8b9389; font-size: 10px; }
.status-chip { min-height: 21px; padding: 3px 6px; font-size: 9px; }
.direction-content { padding: 19px 17px 12px; }
.direction-work-object { gap: 18px; max-width: 620px; }
.direction-work-head { padding-bottom: 1px; }
.direction-work-head h2 { margin-top: 4px; font-size: 17px; line-height: 1.2; }
.direction-work-head p { color: var(--subtle); font-size: 10px; }
.direction-work-head .quiet-button { padding: 5px 7px; border-color: transparent; color: var(--subtle); font-size: 10px; }
.direction-work-head .quiet-button:hover { border-color: var(--line-strong); color: var(--text); }
.direction-brief,
.direction-edit-section,
.direction-spec-section,
.direction-references {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.direction-brief { padding-left: 10px; border-left: 2px solid rgba(169,200,255,.42); }
.direction-brief > span { color: var(--subtle); font-size: 9px; }
.direction-brief p { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.direction-section-head { margin-bottom: 8px; }
.direction-section-head h3 { font-size: 13px; }
.direction-edit-state, .direction-status { min-height: 20px; padding: 3px 6px; font-size: 8px; }
.direction-intent-editor {
  min-height: 226px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 500 14px/1.68 var(--font);
}
.direction-intent-editor:focus { border: 0; background: transparent; outline: 0; }
.direction-edit-section:focus-within { box-shadow: inset 0 -1px 0 rgba(169,200,255,.72); }
.direction-work-note { color: var(--subtle); font-size: 9px; }
/* Facts, source reference cards and a patch log are deliberately moved to
   “Plus > Détails”; the middle column is kept for wording. */
.direction-panel .direction-spec-section,
.direction-panel .direction-references,
.direction-panel .direction-history { display: none; }
.direction-work-actions { gap: 7px; padding-top: 1px; }
.direction-work-actions .primary-button { padding: 8px 10px; font-size: 10px; }
.direction-work-actions .quiet-button { padding: 7px 8px; border-color: transparent; color: var(--subtle); font-size: 10px; }
.direction-work-actions .quiet-button:hover { border-color: var(--line-strong); color: var(--text); }
.direction-empty-state { max-width: 300px; padding: 21px 2px; }
.direction-empty-state h3 { margin: 7px 0 8px; font-size: 17px; line-height: 1.2; }
.direction-empty-state p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.direction-panel .composer {
  margin: 0;
  padding: 12px 14px 13px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: #151816;
  box-shadow: 0 -12px 30px rgba(0,0,0,.12);
}
.composer-header { margin-bottom: 8px; }
.composer h2 { font-size: 12px; }
.rerun-control { display: none; }
.composer textarea {
  min-height: 102px;
  max-height: 198px;
  padding: 10px 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
}
.composer textarea:focus { box-shadow: inset 0 -1px 0 rgba(169,200,255,.72); }
.composer-footer { margin-top: 8px; }
.composer-footer span { color: var(--subtle); font-size: 9px; }
.composer-footer .primary-button { min-height: 31px; padding: 7px 10px; font-size: 10px; }
.generation-dock { margin-top: 6px; }
.generation-dock-summary { min-height: 27px; padding: 4px 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }
.generation-profile-button { min-height: 25px; padding: 3px 5px; border-color: transparent; background: transparent; color: var(--subtle); }
.generation-profile-button:hover { border-color: var(--line-strong); background: rgba(255,255,255,.04); color: var(--text); }
.generation-dock-details { margin-top: 5px; padding: 8px; border-radius: 7px; background: rgba(255,255,255,.035); }

/* The right side is purposefully image-first. */
.workbench .image-panel {
  grid-column: 3;
  grid-row: 1;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: radial-gradient(circle at 55% 19%, rgba(119,149,142,.08), transparent 39%), #101311;
}
.image-panel-head {
  min-height: 56px;
  padding: 11px 19px;
  border-bottom-color: var(--line);
  background: rgba(12,15,13,.27);
}
.image-panel-head .eyebrow { margin-bottom: 2px; }
.image-panel-head h2 { font-size: 14px; }
.stage-action-bar { display: flex; align-items: center; justify-content: flex-end; min-height: 30px; }
.stage-action-bar .primary-button { min-height: 30px; padding: 6px 10px; font-size: 10px; }
.stage-action-bar .primary-button[hidden] { display: none; }
.image-panel .scene { padding: clamp(14px, 2vw, 28px); }
.image-panel .scene-inner { width: min(1320px, 100%); }
.image-panel .scene-heading { min-height: 0; margin: 0 0 12px; }
.image-panel .scene-heading .scene-direction-copy,
.image-panel .scene-heading .eyebrow,
.image-panel .scene-heading h1 { display: none; }
.image-panel .scene-heading-actions { margin-left: auto; }
.image-panel .scene-heading .quiet-button { padding: 5px 7px; border-color: transparent; color: var(--subtle); font-size: 10px; }
.image-panel .scene-heading .quiet-button:hover { border-color: var(--line-strong); color: var(--text); }
.image-panel .brief-preview,
.image-panel .error-card,
.image-panel .recommendation-card,
.image-panel .generation-card {
  max-width: 680px;
  margin: 0 auto 15px;
  padding: 12px 13px;
  border-color: rgba(255,255,255,.09);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  box-shadow: none;
}
.image-panel .brief-preview p,
.image-panel .error-card p,
.image-panel .recommendation-card p,
.image-panel .generation-card p { color: var(--muted); font-size: 11px; }
.image-panel .recommendation-card { border-color: rgba(240,203,130,.28); background: rgba(105,78,25,.15); }
.image-panel .error-card { border-color: rgba(243,152,140,.32); background: rgba(97,42,37,.18); }
.image-panel .stage-secondary-actions { display: none; }
.image-panel .empty-state { min-height: 340px; max-width: 430px; }
.image-panel .empty-state h1 { font-size: clamp(22px, 2.5vw, 30px); }
.candidate-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 12px;
}
.candidate-card {
  position: relative;
  display: block;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255,255,255,.02);
  color: var(--text);
  text-align: left;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
button.candidate-card { width: 100%; }
.candidate-card:hover { transform: translateY(-1px); background: rgba(255,255,255,.04); }
.candidate-card.is-selected, .candidate-card.is-approved { border-color: var(--text); }
.candidate-card.is-best:not(.is-selected) { border-color: rgba(169,200,255,.65); }
.candidate-card.is-recommended:not(.is-selected) { border-color: rgba(240,203,130,.7); }
.candidate-select {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.candidate-select:focus-visible, .candidate-card:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.candidate-image { aspect-ratio: 4 / 3; border-radius: 0; background: #090b0a; }
.candidate-card:hover .candidate-image { opacity: .97; }
.candidate-footer { min-height: 32px; padding: 7px 8px; }
.candidate-index { color: var(--subtle); font-size: 9px; }
.candidate-label { color: var(--muted); font-size: 9px; }
.candidate-score { font-size: 11px; }
.candidate-enlarge {
  position: absolute;
  right: 6px;
  bottom: 5px;
  min-height: 23px;
  padding: 3px 6px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 5px;
  background: rgba(12,15,13,.76);
  color: var(--text);
  font-size: 9px;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease;
}
.candidate-card:hover .candidate-enlarge, .candidate-card:focus-within .candidate-enlarge { opacity: 1; }
.candidate-enlarge:hover, .candidate-enlarge:focus-visible { background: rgba(24,29,26,.96); outline: 0; }
.run-history { max-width: 100%; margin-top: 16px; }
.run-history details { border-top-color: var(--line); }
.run-history summary { color: var(--subtle); }
.history-row { padding-bottom: 4px; }
.history-row img { width: 56px; height: 38px; border-radius: 4px; }
.history-more { margin-top: 9px; }

/* One readable system status, with a distinct operational colour. */
.execution-band:not(:empty) { border-bottom: 1px solid var(--line); }
.execution-card { min-height: 46px; padding: 8px 18px; background: rgba(255,255,255,.035); border-bottom: 0; }
.execution-icon { width: 24px; height: 24px; background: rgba(255,255,255,.07); }
.execution-copy strong { font-size: 11px; }
.execution-copy span { color: var(--muted); font-size: 9px; }
.execution-meta { color: var(--subtle); font-size: 9px; }
.execution-band[data-phase="drafting"] .execution-card,
.execution-band[data-phase="patching"] .execution-card,
.execution-band.is-fable-active .execution-card { background: linear-gradient(90deg, rgba(107,78,180,.29), rgba(43,31,68,.13)); }
.execution-band[data-phase="generating"] .execution-card,
.execution-band[data-phase="downloading"] .execution-card,
.execution-band.is-flora-active .execution-card { background: linear-gradient(90deg, rgba(28,126,128,.27), rgba(19,51,49,.12)); }
.execution-band[data-phase="judging"] .execution-card,
.execution-band.is-reviewing .execution-card { background: linear-gradient(90deg, rgba(50,95,158,.27), rgba(22,41,64,.13)); }
.execution-band[data-phase="awaiting_decision"] .execution-card { background: rgba(110,79,22,.22); }
.execution-band[data-phase="failed"] .execution-card,
.execution-band[data-phase="interrupted"] .execution-card { background: rgba(105,42,37,.25); }
.execution-band[data-phase="drafting"] .execution-icon,
.execution-band[data-phase="patching"] .execution-icon,
.execution-band.is-fable-active .execution-icon { color: #e3d9ff; background: rgba(179,151,255,.16); }
.execution-band[data-phase="generating"] .execution-icon,
.execution-band[data-phase="downloading"] .execution-icon,
.execution-band.is-flora-active .execution-icon { color: #b9f3ed; background: rgba(91,209,199,.15); }
.execution-band[data-phase="judging"] .execution-icon,
.execution-band.is-reviewing .execution-icon { color: #d3e5ff; background: rgba(117,184,255,.16); }

/* Details are intentionally a voluntary layer, never a fourth persistent column. */
.inspector-panel {
  z-index: 60;
  top: var(--topbar-height);
  width: min(386px, calc(100vw - 26px));
  border-left-color: var(--line-strong);
  background: #171b18;
}
.inspector-backdrop { z-index: 59; top: var(--topbar-height); }
.inspector-head { padding: 15px 16px 11px; }
.inspector-head h2 { margin: 3px 0 0; font-size: 14px; }
.inspector-close { min-height: 29px; padding: 5px 8px; border-color: transparent; color: var(--muted); font-size: 10px; }
.inspector-close:hover { border-color: var(--line-strong); color: var(--text); }
.inspector-tabs { background: #171b18; }
.tab { padding: 11px 5px 9px; font-size: 10px; }
.inspector-content { padding: 15px; }

@media (max-width: 1279px) {
  .workbench.workspace { grid-template-columns: minmax(208px, 244px) minmax(0, 1fr); }
  .workbench .library-panel { grid-column: 1; }
  .workbench .image-panel { grid-column: 2; }
  .calm-topbar .direction-toggle { display: inline-flex; }
  .workbench .direction-panel {
    top: var(--topbar-height);
    width: min(402px, calc(100vw - 26px));
    border-left: 1px solid var(--line-strong);
    border-right: 0;
  }
  .workbench .direction-panel.is-open { transform: translateX(0); }
  .direction-close { display: inline-flex; }
  .direction-backdrop { z-index: 24; inset: var(--topbar-height) 0 0; }
  .workbench .direction-panel { z-index: 25; }
}

@media (max-width: 760px) {
  :root { --topbar-height: 94px; }
  .calm-topbar.topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-rows: 47px 39px;
    gap: 0 7px;
    padding: 3px 10px 5px;
  }
  .calm-topbar .brand { grid-column: 1; grid-row: 1; }
  .calm-topbar .brand-name { display: none; }
  .calm-topbar .project-switcher { grid-column: 2; grid-row: 1; max-width: none; }
  .calm-topbar .project-switcher select { min-width: 0; font-size: 11px; }
  .calm-topbar .topbar-spacer { display: none; }
  .calm-topbar .topbar-help { display: none; }
  .calm-topbar .direction-toggle { grid-column: 3; grid-row: 1; justify-content: center; }
  .calm-topbar .more-menu-wrap { grid-column: 4; grid-row: 1; }
  .calm-topbar .topbar-project-action { grid-column: 1 / span 2; grid-row: 2; justify-self: start; }
  .calm-topbar .topbar-plan-action { grid-column: 3 / span 2; grid-row: 2; justify-self: end; }
  .calm-topbar .topbar-action { min-height: 31px; padding: 5px 7px; font-size: 10px; }
  .more-menu { width: min(250px, calc(100vw - 20px)); }

  .workbench.workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 126px minmax(0, 1fr);
    height: calc(100dvh - var(--topbar-height));
  }
  .workbench .library-panel {
    grid-column: 1;
    grid-row: 1;
    grid-template-columns: 1fr;
    grid-template-rows: 37px minmax(0, 1fr);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .library-tabs, .library-pane { grid-column: 1; }
  .library-tabs { gap: 4px; padding: 5px 10px 4px; }
  .library-tab { min-height: 27px; }
  .library-pane { padding: 7px 9px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .library-pane::-webkit-scrollbar { display: none; }
  .library-pane-heading, .library-search { display: none; }
  .library-pane .shot-list, .library-pane .reference-list { display: flex; gap: 6px; min-height: 57px; overflow: visible; }
  .library-pane .shot-item { flex: 0 0 145px; grid-template-columns: 24px minmax(0, 1fr) 6px; min-height: 52px; padding: 5px; }
  .library-pane .shot-index { width: 24px; height: 24px; }
  .library-pane .shot-copy strong { font-size: 10px; }
  .library-pane .shot-copy span { display: none; }
  .library-pane .reference-card { flex: 0 0 60px; display: block; padding: 3px; }
  .library-pane .reference-thumb { width: 54px; height: 51px; }
  .library-pane .reference-copy, .library-pane .reference-state { display: none; }
  .library-references-pane { display: grid; grid-template-rows: 31px minmax(0, 1fr); gap: 6px; }
  .library-references-pane.is-active:not([hidden]) { display: grid; }
  .reference-import-bar { grid-row: 1; width: max-content; margin: 0; }
  .reference-role-field select { width: 118px; }
  .reference-list { grid-row: 2; }
  .library-footer { display: none; }

  .workbench .image-panel { grid-column: 1; grid-row: 2; }
  .workbench .direction-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(86dvh, 760px);
    border-top: 1px solid var(--line-strong);
    border-left: 0;
    border-radius: 15px 15px 0 0;
    transform: translateY(105%);
  }
  .workbench .direction-panel.is-open { transform: translateY(0); }
  .direction-backdrop { inset: 0; }
  .direction-panel-head { padding: 13px 14px 10px; }
  .direction-panel .context-bar { padding: 7px 14px; }
  .direction-content { padding: 14px; }
  .direction-intent-editor { min-height: 175px; font-size: 13px; }
  .direction-panel .composer { padding: 10px 12px 11px; }
  .composer textarea { min-height: 86px; max-height: 145px; }
  .composer-footer > span { display: none; }
  .composer-footer { justify-content: flex-end; }

  .image-panel-head { min-height: 46px; padding: 8px 10px; }
  .image-panel-head h2 { font-size: 12px; }
  .stage-action-bar .primary-button { min-height: 28px; font-size: 9px; }
  .image-panel .scene { padding: 11px 10px 16px; }
  .candidate-grid { grid-template-columns: 1fr; gap: 10px; }
  .candidate-image { aspect-ratio: 16 / 10; }
  .candidate-enlarge { opacity: 1; }
  .execution-card { padding: 8px 10px; }
  .execution-meta { display: none; }
  .execution-copy span { white-space: normal; }

  .inspector-panel { top: auto; right: 0; bottom: 0; left: 0; width: 100%; max-height: min(80dvh, 680px); border-top: 1px solid var(--line-strong); border-left: 0; border-radius: 15px 15px 0 0; transform: translateY(105%); }
  .inspector-panel.is-open { transform: translateY(0); }
  .inspector-backdrop { inset: 0; }
}

@media (max-width: 390px) {
  .calm-topbar.topbar { grid-template-columns: auto minmax(0, 1fr) auto auto; padding-left: 7px; padding-right: 7px; }
  .calm-topbar .direction-toggle { padding-left: 6px; padding-right: 6px; font-size: 10px; }
  .calm-topbar .topbar-more { padding-left: 6px; padding-right: 6px; }
  .library-pane .shot-item { flex-basis: 132px; }
}

@media (prefers-reduced-motion: reduce) {
  .candidate-card, .candidate-enlarge, .topbar-action, .more-menu-item { transition: none; }
}

/* Reference atelier ----------------------------------------------------------
   This is the canonical visual layer for the workbench.  Earlier styles keep
   legacy controls functional; this layer gives all of those controls one calm,
   editorial system based on the validated atelier mock-up. */
:root {
  --atelier-rail: clamp(272px, 19.8vw, 304px);
  --atelier-direction: clamp(408px, 30.1vw, 462px);
  --bg: #0d100e;
  --panel: #121613;
  --panel-raised: #181d19;
  --panel-soft: #1d231f;
  --canvas: #0f1411;
  --canvas-deep: #0b0e0c;
  --line: rgba(235, 241, 233, .105);
  --line-strong: rgba(235, 241, 233, .205);
  --text: #f2f4ef;
  --muted: #b3bbb0;
  --subtle: #929b90;
  --topbar-height: 66px;
  --radius: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
}

/* No generic activity animation is allowed to cover a creative workspace.
   Progress is conveyed by precise text, colour and the real progress line. */
.status-dot.running,
.status-dot.queued,
.execution-card.is-working .execution-icon,
.execution-band.is-working .execution-icon {
  animation: none !important;
}
.status-dot.running,
.status-dot.queued { box-shadow: none; }
.execution-card.is-working .execution-icon::after,
.execution-band.is-working .execution-icon::after {
  content: none !important;
  animation: none !important;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid #a9c8ff;
  outline-offset: 3px;
}

/* Header: one quiet project context, not a toolbar of equal-weight buttons. */
.calm-topbar.topbar {
  height: var(--topbar-height);
  gap: 16px;
  padding: 0 26px;
  background: rgba(13, 16, 14, .985);
  border-bottom: 1px solid var(--line);
}
.calm-topbar .brand {
  gap: 11px;
  color: var(--text);
}
.calm-topbar .brand-mark {
  width: 29px;
  height: 29px;
  border: 1px solid rgba(245, 247, 241, .72);
  border-radius: 50%;
  background: linear-gradient(90deg, #f1f3ee 0 48%, transparent 48% 100%);
  color: transparent;
  font-size: 0;
}
.calm-topbar .brand-name {
  color: transparent;
  font-size: 0;
  line-height: 1;
}
.calm-topbar .brand-name::after {
  content: "Storyboard Director";
  color: var(--text);
  font: 600 16px/1 var(--font);
  letter-spacing: -.025em;
  white-space: nowrap;
}
.calm-topbar .project-switcher,
.topbar-project-context {
  min-width: 0;
  max-width: none;
}
.calm-topbar .project-switcher select {
  width: min(216px, 22vw);
  min-width: 176px;
  min-height: 39px;
  padding: 8px 30px 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background-color: rgba(255, 255, 255, .018);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}
.calm-topbar .project-switcher select:hover { border-color: rgba(235, 241, 233, .34); }
.topbar-action,
.calm-topbar .quiet-button {
  min-height: 36px;
  padding: 7px 9px;
  border-color: transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.topbar-action > span:first-child {
  color: currentColor;
  font-size: 18px;
  font-weight: 400;
}
.topbar-action:hover:not(:disabled),
.topbar-action:focus-visible,
.calm-topbar .quiet-button:hover,
.calm-topbar .quiet-button:focus-visible {
  border-color: rgba(235, 241, 233, .18);
  background: rgba(255, 255, 255, .045);
  color: var(--text);
}
.topbar-plan-action { display: none; }
.topbar-spacer { min-width: 0; }
.topbar-service-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 28px;
  padding-right: 18px;
  border-right: 1px solid var(--line);
  color: #a6d9b1;
  font-size: 11px;
  white-space: nowrap;
}
.topbar-service-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #70dfa0;
  box-shadow: 0 0 12px rgba(112, 223, 160, .42);
}
.topbar-service-status .connection-state,
.topbar-service-status.connection-state { color: inherit; font-size: inherit; }
.topbar-guide-link,
.calm-topbar .topbar-help {
  color: var(--text);
  text-decoration: none;
}
.calm-topbar .topbar-more,
.topbar-utility {
  width: 37px;
  padding-right: 5px;
  padding-left: 5px;
  font-size: 0;
  text-align: center;
}
.calm-topbar .topbar-more::before,
.topbar-utility::before {
  content: "•••";
  color: currentColor;
  font-size: 14px;
  letter-spacing: 2px;
}
.topbar-utility::before { content: none; }
.more-menu {
  top: calc(100% + 10px);
  width: 244px;
  padding: 7px;
  border-color: var(--line-strong);
  border-radius: 10px;
  background: #171c18;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .42);
}
.more-menu-item {
  min-height: 37px;
  padding: 8px 9px;
  color: var(--muted);
  font-size: 11px;
}
.more-menu-item:hover,
.more-menu-item:focus-visible {
  background: rgba(255, 255, 255, .065);
  color: var(--text);
}
.more-connection { color: var(--subtle); font-size: 10px; }

/* Desktop workbench: source material / written direction / visual decision. */
.workbench.workspace {
  grid-template-columns: var(--atelier-rail) var(--atelier-direction) minmax(0, 1fr);
  height: calc(100dvh - var(--topbar-height));
  min-height: 0;
  overflow: hidden;
  background: #0d110e;
}

/* Left rail ---------------------------------------------------------------- */
.workbench .library-panel {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #101411 0%, #111612 100%);
}
.library-rail-scroll {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  gap: 31px;
  padding: 28px 18px 22px;
  scrollbar-gutter: stable;
}
.library-section {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
}
.library-section + .library-section { border-top: 0; }
.library-section-head,
.library-pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 25px;
  margin: 0 0 14px;
}
.library-section-title,
.library-pane-heading h2 {
  margin: 0;
  color: #e3e7df;
  font: 500 15px/1.2 var(--mono);
  letter-spacing: -.03em;
}
.library-section-head .eyebrow,
.library-pane-heading .eyebrow { display: none; }
.library-section-action,
.library-section-head .small {
  display: inline-grid;
  place-items: center;
  width: 31px;
  height: 31px;
  min-height: 31px;
  padding: 0 !important;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0 !important;
}
.library-section-action::before,
.library-section-head .small::before {
  content: "+";
  color: var(--text);
  font-size: 19px;
  font-weight: 300;
  line-height: 1;
}
.library-section-action:hover,
.library-section-action:focus-visible,
.library-section-head .small:hover,
.library-section-head .small:focus-visible {
  border-color: rgba(235, 241, 233, .34);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
}

/* Fallback kept for the present tabbed DOM; the same typography is used once
   the rail receives its simultaneous Plans / Références structure. */
.library-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 18px 18px 4px;
  border-bottom: 0;
}
.library-tab {
  min-height: 34px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--subtle);
  font: 500 13px/1 var(--mono);
  text-align: left;
}
.library-tab + .library-tab { padding-left: 14px; }
.library-tab:hover,
.library-tab:focus-visible { background: transparent; color: var(--text); }
.library-tab.is-active,
.library-tab[aria-selected="true"] {
  border-bottom-color: rgba(235, 241, 233, .7);
  background: transparent;
  color: var(--text);
}
.library-pane {
  min-height: 0;
  padding: 18px;
  overflow: auto;
  scrollbar-gutter: stable;
}
.library-pane-heading { margin-bottom: 13px; }
.library-pane-count { color: var(--subtle); font: 10px/1.35 var(--mono); }
.library-search {
  min-height: 38px;
  margin: 0 0 15px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, .014);
  color: var(--subtle);
}
.library-search:focus-within {
  border-color: rgba(169, 200, 255, .7);
  background: rgba(255, 255, 255, .035);
}
.library-search input { height: 36px; font-size: 12px; }
.library-search input::placeholder { color: #7e887d; }
.shot-list { display: grid; gap: 5px; }
.shot-item {
  grid-template-columns: 46px minmax(0, 1fr) 7px;
  gap: 10px;
  min-height: 57px;
  padding: 5px 7px 5px 5px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}
.shot-item:hover { background: rgba(255, 255, 255, .045); }
.shot-item.is-active {
  border-color: rgba(235, 241, 233, .10);
  background: rgba(255, 255, 255, .095);
}
.shot-index {
  width: 42px;
  height: 46px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, .075);
  color: var(--text);
  font: 500 10px/1 var(--mono);
}
.shot-item.is-active .shot-index {
  background: rgba(255, 255, 255, .14);
  color: var(--text);
}
.shot-copy strong { font-size: 12px; font-weight: 600; }
.shot-copy span { margin-top: 2px; color: var(--subtle); font-size: 10px; }
.status-dot { width: 7px; height: 7px; }
.empty-library { color: var(--subtle); font-size: 12px; line-height: 1.55; }

.library-reference-support,
.reference-import-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 0 0 12px;
}
.reference-role-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}
.reference-role-field > span {
  color: var(--subtle);
  font-size: 11px;
}
.reference-role-field select {
  min-width: 0;
  height: 34px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, .025);
  color: var(--muted);
  font-size: 11px;
}
.add-reference {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: transparent;
  font-size: 0;
}
.add-reference::before {
  content: "+";
  color: var(--text);
  font-size: 20px;
  font-weight: 300;
  line-height: 1;
}
.add-reference:hover { background: rgba(255, 255, 255, .05); }
.reference-list { gap: 8px; margin-top: 0; }
.reference-card {
  grid-template-columns: 1fr;
  gap: 5px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
}
.reference-card:hover { background: transparent; }
.reference-card.is-selected { border-color: rgba(235, 241, 233, .55); background: transparent; }
.reference-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 1.14 / 1;
  border-radius: 6px;
  background: #1a201c;
}
.reference-copy { display: block; padding: 0 1px; }
.reference-role { color: var(--text); font-size: 11px; font-weight: 500; }
.reference-note,
.reference-state,
.reference-locked { display: none; }
.library-footer,
.library-footer-actions {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 0 27px;
  border-top: 0;
}
.library-resource {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--muted);
  font-size: 12px;
}
.library-resource::before {
  content: "•••";
  color: var(--text);
  font-size: 15px;
  letter-spacing: 3px;
}

/* Direction column --------------------------------------------------------- */
.workbench .direction-panel {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #111612 0%, #101411 100%);
}
.direction-panel-head {
  min-height: 77px;
  padding: 24px 27px 17px;
  border-bottom: 0;
}
.direction-panel-head .eyebrow { display: none; }
.direction-panel-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.035em;
}
.direction-close { display: none; }
.direction-panel .context-bar,
.direction-context-region {
  min-height: 47px;
  padding: 11px 27px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .012);
}
.context-title { color: var(--text); font-size: 12px; font-weight: 600; }
.context-detail { color: var(--subtle); font-size: 11px; }
.status-chip,
.direction-status,
.direction-source,
.direction-edit-state {
  min-height: 23px;
  padding: 4px 7px;
  border: 1px solid rgba(112, 223, 160, .38);
  border-radius: 999px;
  background: rgba(55, 124, 80, .12);
  color: #b7eec6;
  font: 500 9px/1.15 var(--mono);
}
.direction-status[data-phase="drafting"],
.direction-status[data-phase="patching"] {
  border-color: rgba(190, 162, 255, .42);
  background: rgba(114, 79, 190, .16);
  color: #e1d6ff;
}
.direction-content,
.direction-main-region {
  min-height: 0;
  padding: 25px 26px 18px;
  overflow: auto;
  scrollbar-gutter: stable;
}
.direction-workspace,
.direction-work-object {
  display: grid;
  gap: 22px;
  width: min(100%, 620px);
}
.direction-work-head,
.direction-plan-identity,
.direction-heading-copy {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 13px;
}
.direction-work-head h2,
.direction-plan-identity h2 {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -.03em;
}
.direction-work-head p,
.direction-plan-identity p {
  margin: 5px 0 0;
  color: var(--subtle);
  font-size: 11px;
}
.direction-work-head .eyebrow,
.direction-plan-identity .eyebrow {
  color: #9aa499;
  font-size: 10px;
}
.direction-work-head .quiet-button {
  min-height: 31px;
  padding: 6px 8px;
  border-color: transparent;
  color: var(--muted);
  font-size: 11px;
}
.direction-work-head .quiet-button:hover { border-color: var(--line-strong); color: var(--text); }
.direction-brief {
  padding: 0 0 0 14px;
  border: 0;
  border-left: 1px solid rgba(235, 241, 233, .28);
  border-radius: 0;
  background: transparent;
}
.direction-brief > span {
  color: #b8c0b6;
  font: 500 12px/1.25 var(--font);
  letter-spacing: 0;
  text-transform: none;
}
.direction-brief p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}
.direction-read-section,
.direction-edit-section {
  padding: 18px;
  border: 1px solid rgba(235, 241, 233, .12);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .02));
}
.direction-read-section > .eyebrow,
.direction-edit-section .eyebrow {
  color: #9ca79a;
  font-size: 10px;
}
.direction-intent-readable {
  margin: 10px 0 0;
  color: #eef1eb;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.62;
  letter-spacing: -.012em;
}
.direction-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.direction-section-head h3 { margin: 3px 0 0; color: var(--text); font-size: 15px; }
.direction-intent-editor {
  min-height: 216px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 500 14px/1.62 var(--font);
}
.direction-intent-editor:focus {
  border: 0;
  background: transparent;
  outline: 0;
}
.direction-edit-section:focus-within { border-color: rgba(169, 200, 255, .62); }
.direction-work-note {
  margin: 9px 0 0;
  color: #98a197;
  font-size: 11px;
  line-height: 1.5;
}
.direction-work-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}
.direction-work-actions .primary-button,
.direction-work-actions .quiet-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 11px;
}
.direction-read-section .direction-work-actions .quiet-button {
  border-color: rgba(235, 241, 233, .16);
  color: var(--text);
}
.direction-details,
.direction-references,
.direction-history {
  margin: 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.direction-details summary,
.direction-references summary,
.direction-history summary {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #d9ded6;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  list-style: none;
}
.direction-details summary::-webkit-details-marker,
.direction-references summary::-webkit-details-marker,
.direction-history summary::-webkit-details-marker { display: none; }
.direction-details summary::after,
.direction-references summary::after,
.direction-history summary::after {
  content: "⌄";
  margin-left: auto;
  color: var(--subtle);
  font-size: 15px;
  transition: transform .16s ease;
}
.direction-details[open] summary::after,
.direction-references[open] summary::after,
.direction-history[open] summary::after { transform: rotate(180deg); }
.direction-details .direction-brief,
.direction-references .reference-summary,
.direction-history .activity-list {
  margin-top: 14px;
}
.direction-summary-list { gap: 8px; margin-top: 13px; }
.direction-summary-list > div { grid-template-columns: 84px minmax(0, 1fr); gap: 10px; }
.direction-summary-list dt { color: var(--subtle); font-size: 10px; }
.direction-summary-list dd { color: var(--muted); font-size: 11px; line-height: 1.5; }
.direction-empty-state {
  max-width: 330px;
  padding: 28px 2px;
}
.direction-empty-state h2,
.direction-empty-state h3 {
  margin: 8px 0 10px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -.035em;
}
.direction-empty-state p { color: var(--muted); font-size: 13px; line-height: 1.62; }

/* The note composer is a precise writing object, then one compact profile
   and one workflow action. It is deliberately not a settings dashboard. */
.direction-panel .composer,
.direction-composer-region {
  margin: 0;
  padding: 19px 26px 24px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: #121713;
  box-shadow: 0 -13px 34px rgba(0, 0, 0, .15);
}
.composer-header { margin-bottom: 10px; }
.composer-header .eyebrow { color: #a0ab9f; font-size: 10px; }
.composer h2 { margin-top: 4px; color: var(--text); font-size: 14px; }
.shot-title-field {
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 0 0 11px;
}
.shot-title-field label { color: var(--muted); font-size: 11px; }
.shot-title-field input {
  min-height: 38px;
  padding: 9px 10px;
  border-color: var(--line-strong);
  border-radius: 8px;
  background: #101410;
  color: var(--text);
  font-size: 12px;
}
.composer textarea {
  min-height: 166px;
  max-height: 270px;
  padding: 15px 16px;
  border: 1px solid rgba(235, 241, 233, .18);
  border-radius: 10px;
  background: #0d110e;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}
.composer textarea::placeholder { color: #899388; opacity: 1; }
.composer textarea:focus {
  border-color: rgba(169, 200, 255, .78);
  background: #101512;
  box-shadow: 0 0 0 3px rgba(169, 200, 255, .08);
}
.rerun-control { display: none; }
.composer-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 11px;
}
.composer-footer span { color: var(--subtle); font-size: 10px; }
.composer-footer .primary-button {
  min-height: 37px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px;
}
.composer[data-mode="new"] .composer-footer {
  display: block;
  margin-top: 14px;
}
.composer[data-mode="new"] .composer-footer > span { display: none; }
.composer[data-mode="new"] .composer-footer .primary-button {
  width: 100%;
  min-height: 51px;
  font-size: 13px;
}
.generation-dock {
  display: grid;
  gap: 0;
  margin-top: 13px;
}
.generation-dock[hidden],
.generation-dock-details[hidden],
.generation-controls[hidden] { display: none !important; }
.generation-dock-summary {
  display: block;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(235, 241, 233, .14);
  border-radius: 10px;
  background: rgba(255, 255, 255, .02);
}
.generation-dock-summary:empty { display: none; }
.generation-profile-trigger,
.generation-profile-button {
  display: grid;
  grid-template-columns: 39px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 51px;
  margin: 0;
  padding: 7px 12px 7px 7px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.generation-profile-trigger:hover,
.generation-profile-button:hover {
  background: rgba(255, 255, 255, .04);
}
.generation-profile-trigger::after,
.generation-profile-button::after {
  content: "⌄";
  color: var(--subtle);
  font-size: 15px;
  line-height: 1;
  transition: transform .16s ease;
}
.generation-profile-trigger[aria-expanded="true"]::after,
.generation-profile-button[aria-expanded="true"]::after { transform: rotate(180deg); }
.generation-profile-icon {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  color: #dbe1d9;
}
.generation-profile-icon svg { width: 21px; height: 21px; }
.generation-profile-main,
.generation-summary-copy {
  display: flex;
  align-items: baseline;
  min-width: 0;
  gap: 7px;
  overflow: hidden;
}
.generation-profile-label { display: none; }
.generation-summary-copy strong,
.generation-profile-main strong {
  min-width: 0;
  max-width: none;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.generation-profile-meta,
.generation-summary-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.generation-profile-state,
.generation-review-status {
  display: none;
  color: var(--subtle);
  font-size: 10px;
}
.generation-profile-warning {
  display: block;
  padding: 0 12px 9px 46px;
  color: #f3aa9f;
  font-size: 10px;
}
.generation-dock-details,
.generation-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, .028);
}
.generation-dock-details > :first-child,
.generation-controls > :first-child,
.generation-dock-details .field.full { grid-column: 1 / -1; }
.generation-dock-details .field,
.generation-controls .field,
.generation-dock-details > label,
.generation-controls > label {
  display: grid;
  gap: 5px;
  color: #aab3a8;
  font-size: 11px;
}
.generation-dock-details .field label,
.generation-controls .field label { color: inherit; font-size: inherit; }
.generation-dock-details select,
.generation-dock-details input,
.generation-controls select,
.generation-controls input {
  width: 100%;
  min-width: 0;
  height: 37px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #111612;
  color: var(--text);
  font-size: 11px;
}
.generation-dock-details .generation-estimate,
.generation-dock-details .generation-controls-note,
.generation-controls .generation-estimate,
.generation-controls .generation-controls-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--subtle);
  font-size: 10px;
  line-height: 1.45;
}
.workflow-action {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}
.workflow-action .primary-button,
#workflowActionHost .primary-button {
  width: 100%;
  min-height: 52px;
  padding: 11px 16px;
  border-radius: 9px;
  background: #f2f3ee;
  color: #111511;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.015em;
}
.workflow-action .primary-button:hover:not(:disabled),
#workflowActionHost .primary-button:hover:not(:disabled) {
  background: #fff;
  transform: none;
}
.workflow-action .primary-button.is-working,
#workflowActionHost[data-state="working"] .primary-button {
  color: #737a71;
  background: #d5d8d1;
}
.workflow-action-hint {
  color: var(--subtle);
  font-size: 10px;
  line-height: 1.4;
}

/* Variants are the visual decision surface. */
.workbench .image-panel {
  grid-column: 3;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0e120f;
}
.image-panel-head {
  min-height: 69px;
  padding: 16px 25px 13px;
  border-bottom: 1px solid var(--line);
  background: #0f1411;
}
.image-panel-head .eyebrow { display: none; }
.image-panel-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.035em;
}
.stage-heading-copy,
.image-panel-head > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.stage-title-meta {
  color: var(--muted);
  font-size: 13px;
}
.stage-toolbar,
.stage-action-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 32px;
}
.stage-action-bar[hidden] { display: none !important; }
.stage-action-bar .primary-button {
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}
.image-panel .scene {
  min-height: 0;
  padding: 16px 24px 30px;
  overflow: auto;
  background: radial-gradient(circle at 50% 0, rgba(106, 130, 121, .055), transparent 42%);
  scrollbar-gutter: stable;
}
.image-panel .scene-inner { width: min(100%, 1280px); margin: 0 auto; }
.image-panel .scene-heading {
  min-height: 0;
  margin: 0 0 13px;
}
.image-panel .scene-heading .eyebrow,
.image-panel .scene-heading h1,
.image-panel .scene-direction-copy { display: none; }
.image-panel .scene-heading-actions { margin-left: auto; }
.image-panel .scene-heading .quiet-button {
  min-height: 30px;
  padding: 5px 7px;
  border-color: transparent;
  color: var(--subtle);
  font-size: 10px;
}
.image-panel .generation-card,
.image-panel .recommendation-card,
.image-panel .error-card,
.image-panel .brief-preview {
  max-width: 650px;
  margin: 0 auto 15px;
  padding: 13px 14px;
  border-color: var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, .035);
  box-shadow: none;
}
.image-panel .generation-card p,
.image-panel .recommendation-card p,
.image-panel .error-card p,
.image-panel .brief-preview p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.image-panel .empty-state {
  min-height: 400px;
  max-width: 440px;
}
.image-panel .empty-state h1 { font-size: clamp(24px, 2.4vw, 32px); }
.candidate-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.candidate-card {
  position: relative;
  display: block;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(235, 241, 233, .18);
  border-radius: 8px;
  background: #101511;
  color: var(--text);
  text-align: left;
  transition: border-color .16s ease, background .16s ease;
}
button.candidate-card { width: 100%; }
.candidate-card:hover {
  background: #131914;
  transform: none;
}
.candidate-card.is-selected,
.candidate-card.is-approved {
  border: 2px solid #f0f2ed;
  box-shadow: 0 0 0 1px rgba(240, 242, 237, .15), 0 12px 28px rgba(0, 0, 0, .18);
}
.candidate-card.is-best:not(.is-selected) { border-color: rgba(169, 200, 255, .7); }
.candidate-card.is-recommended:not(.is-selected) { border-color: rgba(240, 203, 130, .72); }
.candidate-card.is-selected::before,
.candidate-card.is-approved::before {
  content: "✓";
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border-radius: 50%;
  background: #f4f4ef;
  color: #20241f;
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
}
.candidate-select {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.candidate-select:focus-visible,
.candidate-card:focus-visible { outline: 2px solid #a9c8ff; outline-offset: 3px; }
.candidate-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 0;
  background: #090c0a;
  object-fit: cover;
}
.candidate-footer {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 52px;
  padding: 10px 37px 10px 2px;
}
.candidate-index {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.candidate-label {
  color: var(--muted);
  font-size: 11px;
}
.candidate-score {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}
.candidate-enlarge {
  position: absolute;
  right: 7px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  min-height: 27px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: transparent;
  font-size: 0;
  opacity: 1;
}
.candidate-enlarge::before {
  content: "•••";
  color: var(--text);
  font-size: 12px;
  letter-spacing: 1px;
}
.candidate-enlarge:hover,
.candidate-enlarge:focus-visible { background: rgba(255, 255, 255, .09); outline: 0; }
.run-history { margin-top: 20px; }
.run-history details { border-top-color: var(--line); }
.run-history summary { color: var(--muted); font-size: 11px; }
.history-row { gap: 8px; }
.history-row img { width: 66px; height: 44px; border-radius: 5px; }

/* Operational status stays in the visual surface, but is compact and
   unmistakably service-specific. */
.execution-band:not(:empty) { border-bottom: 0; }
.execution-card {
  min-height: 50px;
  padding: 10px 25px;
  border: 0;
  background: rgba(255, 255, 255, .045);
}
.execution-icon {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.execution-copy strong { color: var(--text); font-size: 12px; }
.execution-copy span { color: #c0c8bd; font-size: 11px; }
.execution-meta { color: #c0b4eb; font-size: 10px; }
.progress-line { height: 2px; background: rgba(255, 255, 255, .1); }
.execution-band[data-phase="drafting"] .execution-card,
.execution-band[data-phase="patching"] .execution-card,
.execution-band.is-fable-active .execution-card,
.execution-card.actor-fable {
  background: linear-gradient(90deg, rgba(87, 61, 147, .48), rgba(43, 31, 74, .42));
}
.execution-band[data-phase="generating"] .execution-card,
.execution-band[data-phase="downloading"] .execution-card,
.execution-band.is-flora-active .execution-card,
.execution-card.actor-flora {
  background: linear-gradient(90deg, rgba(23, 112, 112, .48), rgba(19, 54, 50, .42));
}
.execution-band[data-phase="judging"] .execution-card,
.execution-band.is-reviewing .execution-card,
.execution-card.actor-fable-review {
  background: linear-gradient(90deg, rgba(50, 91, 151, .44), rgba(25, 45, 73, .38));
}
.execution-band[data-phase="failed"] .execution-card,
.execution-band[data-phase="interrupted"] .execution-card { background: rgba(102, 44, 39, .45); }
.execution-band[data-phase="awaiting_decision"] .execution-card { background: rgba(102, 76, 25, .37); }
.execution-band[data-phase="drafting"] .execution-icon,
.execution-band[data-phase="patching"] .execution-icon,
.execution-band.is-fable-active .execution-icon { color: #ecddff; background: rgba(211, 190, 255, .18); }
.execution-band[data-phase="generating"] .execution-icon,
.execution-band[data-phase="downloading"] .execution-icon,
.execution-band.is-flora-active .execution-icon { color: #bdf5ef; background: rgba(91, 209, 199, .18); }

/* Voluntary secondary detail, never a permanent fourth workspace column. */
.inspector-panel {
  top: var(--topbar-height);
  z-index: 60;
  width: min(400px, calc(100vw - 28px));
  border-left: 1px solid var(--line-strong);
  background: #131813;
}
.inspector-backdrop { z-index: 59; inset: var(--topbar-height) 0 0; }
.inspector-head { padding: 20px 20px 14px; border-bottom-color: var(--line); }
.inspector-head h2 { font-size: 17px; }
.inspector-content { padding: 20px; }
.tab { min-height: 41px; padding: 10px 6px; color: var(--muted); font-size: 11px; }
.tab.is-active { color: var(--text); border-bottom-color: #f1f3ee; }
.fable-review-toggle { border-color: var(--line); background: rgba(255, 255, 255, .025); }
.field label,
.fact-list dt { color: var(--subtle); font-size: 10px; }
.field input,
.generation-select { border-color: var(--line-strong); background: #111612; }

/* Viewer / dialogs inherit the same dense, legible restraint. */
.viewer,
.project-dialog,
.help-dialog {
  border-color: var(--line-strong);
  background: #151a16;
}
.viewer-info { padding: 22px; }
.viewer-summary { color: var(--muted); font-size: 13px; line-height: 1.6; }
.viewer-note { color: var(--subtle); font-size: 11px; }
.viewer-zoom-hint { color: var(--muted); }
.project-dialog form { padding: 22px; }
.project-dialog p,
.dialog-field { color: var(--muted); font-size: 12px; }
.project-dialog input { min-height: 42px; border-color: var(--line-strong); background: #101410; }

@media (max-width: 1279px) {
  :root { --topbar-height: 62px; }
  .calm-topbar.topbar { padding: 0 18px; }
  .calm-topbar .project-switcher select { width: min(205px, 27vw); min-width: 150px; }
  .workbench.workspace { grid-template-columns: minmax(246px, 294px) minmax(0, 1fr); }
  .workbench .library-panel { grid-column: 1; }
  .workbench .image-panel { grid-column: 2; }
  .calm-topbar .direction-toggle { display: inline-flex; }
  .workbench .direction-panel {
    position: fixed;
    z-index: 25;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    width: min(462px, calc(100vw - 24px));
    border-left: 1px solid var(--line-strong);
    border-right: 0;
    box-shadow: -20px 0 56px rgba(0, 0, 0, .42);
    opacity: 0;
    pointer-events: none;
    transform: translateX(104%);
    transition: transform .2s ease, opacity .16s ease;
  }
  .workbench .direction-panel.is-open { opacity: 1; pointer-events: auto; transform: translateX(0); }
  .direction-close { display: inline-flex; }
  .direction-backdrop {
    position: fixed;
    z-index: 24;
    inset: var(--topbar-height) 0 0;
    background: rgba(0, 0, 0, .48);
    opacity: 0;
    transition: opacity .16s ease;
  }
  .direction-backdrop.is-visible { display: block; opacity: 1; }
  .candidate-grid { gap: 13px; }
}

@media (max-width: 760px) {
  :root { --topbar-height: 58px; }
  body { overflow: hidden; }
  .calm-topbar.topbar {
    display: flex;
    gap: 7px;
    height: var(--topbar-height);
    padding: 0 10px;
  }
  .calm-topbar .brand { gap: 0; }
  .calm-topbar .brand-mark { width: 27px; height: 27px; }
  .calm-topbar .brand-name,
  .topbar-service-status,
  .topbar-guide-link,
  .calm-topbar .topbar-help { display: none; }
  .calm-topbar .project-switcher { flex: 1; }
  .calm-topbar .project-switcher select { width: 100%; min-width: 0; min-height: 34px; font-size: 11px; }
  .calm-topbar .topbar-project-action {
    width: 33px;
    min-height: 33px;
    padding: 0;
    font-size: 0;
    justify-content: center;
  }
  .calm-topbar .topbar-project-action > span:first-child { font-size: 20px; }
  .calm-topbar .topbar-project-action > span:last-child { display: none; }
  .calm-topbar .direction-toggle { min-height: 33px; padding: 5px 7px; font-size: 10px; }
  .calm-topbar .topbar-more { width: 31px; }
  .more-menu { width: min(250px, calc(100vw - 20px)); }

  .workbench.workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 112px minmax(0, 1fr);
    height: calc(100dvh - var(--topbar-height));
  }
  .workbench .library-panel {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 35px minmax(0, 1fr);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .library-tabs { grid-column: 1; padding: 3px 10px 0; }
  .library-tab { min-height: 31px; font-size: 11px; }
  .library-pane {
    grid-column: 1;
    padding: 7px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .library-pane::-webkit-scrollbar { display: none; }
  .library-pane-heading,
  .library-search { display: none; }
  .library-pane .shot-list,
  .library-pane .reference-list {
    display: flex;
    gap: 7px;
    min-height: 58px;
    overflow: visible;
  }
  .library-pane .shot-item {
    flex: 0 0 152px;
    grid-template-columns: 32px minmax(0, 1fr) 7px;
    min-height: 57px;
  }
  .library-pane .shot-index { width: 30px; height: 45px; }
  .library-pane .shot-copy strong { font-size: 11px; }
  .library-pane .shot-copy span { display: none; }
  .library-pane .reference-card { flex: 0 0 62px; display: block; }
  .library-pane .reference-thumb { width: 58px; height: 54px; }
  .library-pane .reference-copy { display: none; }
  .library-footer,
  .library-footer-actions { display: none; }
  .library-rail-scroll {
    display: flex;
    gap: 11px;
    padding: 7px 10px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .library-rail-scroll .library-section { flex: 0 0 auto; }
  .library-rail-scroll .library-section-head { display: none; }

  .workbench .image-panel { grid-column: 1; grid-row: 2; }
  .workbench .direction-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(87dvh, 780px);
    border-top: 1px solid var(--line-strong);
    border-left: 0;
    border-radius: 16px 16px 0 0;
    transform: translateY(105%);
    box-shadow: 0 -18px 52px rgba(0, 0, 0, .46);
  }
  .workbench .direction-panel.is-open { transform: translateY(0); }
  .direction-backdrop { inset: 0; }
  .direction-panel-head { min-height: 65px; padding: 18px 16px 13px; }
  .direction-panel-head h2 { font-size: 17px; }
  .direction-panel .context-bar { min-height: 42px; padding: 10px 16px; }
  .direction-content { padding: 18px 16px 12px; }
  .direction-workspace,
  .direction-work-object { gap: 17px; }
  .direction-intent-readable { font-size: 13px; }
  .direction-intent-editor { min-height: 172px; font-size: 13px; }
  .direction-panel .composer { padding: 15px 16px 18px; }
  .composer textarea { min-height: 116px; max-height: 190px; }
  .composer-footer > span { display: none; }
  .composer-footer { justify-content: flex-end; }
  .generation-dock-details,
  .generation-controls { gap: 8px; padding: 10px; }

  .image-panel-head { min-height: 53px; padding: 12px 12px 10px; }
  .image-panel-head h2 { font-size: 16px; }
  .image-panel .scene { padding: 12px 10px 22px; }
  .candidate-grid { grid-template-columns: 1fr; gap: 12px; }
  .candidate-image { aspect-ratio: 16 / 10; }
  .candidate-footer { min-height: 46px; padding-top: 8px; padding-bottom: 8px; }
  .execution-card { padding: 9px 12px; }
  .execution-meta { display: none; }
  .execution-copy span { white-space: normal; }
  .inspector-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(80dvh, 680px);
    border-top: 1px solid var(--line-strong);
    border-left: 0;
    border-radius: 16px 16px 0 0;
    transform: translateY(105%);
  }
  .inspector-panel.is-open { transform: translateY(0); }
  .inspector-backdrop { inset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition-duration: .01ms !important;
  }
}

/* Structure hooks introduced with the atelier markup. */
.topbar-project-context {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.topbar-service-status::before { display: none; }
.service-status-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #70dfa0;
  box-shadow: 0 0 12px rgba(112, 223, 160, .42);
}
.topbar-service-status:has(.connection-state.bad) .service-status-dot {
  background: var(--red);
  box-shadow: none;
}
.topbar-utility {
  display: flex;
  align-items: center;
  justify-content: center;
}

.workbench .direction-panel.direction-workspace {
  width: auto;
  gap: 0;
}
.direction-panel-head .direction-heading-copy {
  display: block;
}
.direction-panel .direction-context-region {
  min-height: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .012);
}
.direction-panel .direction-context-region .context-bar {
  min-height: 47px;
  padding: 11px 27px;
  border: 0;
  background: transparent;
}
.direction-status[data-tone="fable"] {
  border-color: rgba(190, 162, 255, .43);
  background: rgba(114, 79, 190, .16);
  color: #e1d6ff;
}
.direction-status[data-tone="flora"] {
  border-color: rgba(112, 223, 209, .4);
  background: rgba(30, 123, 115, .15);
  color: #bdf3ed;
}
.direction-status[data-tone="ready"],
.direction-status[data-tone="validated"] {
  border-color: rgba(112, 223, 160, .38);
  background: rgba(55, 124, 80, .12);
  color: #b7eec6;
}
.direction-status[data-tone="decision"] {
  border-color: rgba(240, 203, 130, .42);
  background: rgba(120, 87, 21, .16);
  color: #ffe0a1;
}
.direction-status[data-tone="alert"] {
  border-color: rgba(243, 152, 140, .43);
  background: rgba(122, 49, 43, .16);
  color: #ffd1ca;
}
.direction-status[data-tone="direct"] {
  border-color: rgba(169, 200, 255, .43);
  background: rgba(54, 89, 137, .15);
  color: #d7e7ff;
}
.direction-pending {
  padding: 18px;
  border: 1px solid rgba(190, 162, 255, .21);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(112, 78, 187, .13), rgba(255, 255, 255, .018));
}
.direction-pending .eyebrow { color: #c9b9f2; font-size: 10px; }
.direction-pending h3 { margin: 7px 0 6px; color: var(--text); font-size: 15px; }
.direction-pending p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.stage-settings {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0 !important;
  border-color: transparent !important;
  color: var(--muted) !important;
}
.stage-settings:hover,
.stage-settings:focus-visible {
  border-color: var(--line-strong) !important;
  background: rgba(255, 255, 255, .045) !important;
  color: var(--text) !important;
}
.stage-settings svg { width: 21px; height: 21px; }

@media (min-width: 1280px) {
  .reference-rail .library-rail-scroll {
    grid-template-rows: minmax(250px, 1fr) auto;
    align-content: stretch;
  }
  .reference-rail .library-plans-section {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .reference-rail .library-references-section {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .reference-rail .library-section-head > .library-pane-heading {
    display: block;
    margin: 0;
  }
  .reference-rail .library-tabs { display: none; }
  .reference-rail .library-pane,
  .reference-rail .library-pane.is-wide-visible:not([hidden]) {
    display: block;
    min-height: 0;
    padding: 0;
    overflow: auto;
  }
  .reference-rail .library-plans-pane { padding-top: 14px; }
  .reference-rail .library-references-pane { padding-top: 14px; }
  .reference-rail .library-search { margin-bottom: 12px; }
  .reference-rail .reference-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
  }
  .reference-rail .reference-card {
    min-width: 0;
  }
  .reference-rail .reference-thumb {
    aspect-ratio: 1 / .9;
  }
}

@media (max-width: 760px) {
  .topbar-project-context { flex: 1; gap: 7px; min-width: 0; }
  .topbar-project-context .project-switcher { min-width: 0; }
  .topbar-utility { width: 31px; }
  .direction-panel .direction-context-region .context-bar { padding: 10px 16px; }
  .stage-settings { width: 31px; min-height: 31px; }
}

/* Last-mile fit: prevent legacy inline brand rules and an expanded profile
   from ever consuming the reading surface. */
.calm-topbar .brand-name b {
  color: transparent;
  font-size: 0;
}
.calm-topbar .brand-name::after { word-spacing: 2px; }
.workbench .direction-panel {
  grid-template-rows: auto auto minmax(0, 1fr) minmax(0, auto);
}
.direction-panel .direction-context-region:has(.context-bar[hidden]) {
  display: block;
  min-height: 0;
  height: 0;
  border: 0;
}
.direction-work-status-row {
  display: flex;
  justify-content: flex-end;
  min-height: 23px;
  margin: -3px 0 -5px;
}
.direction-panel .composer {
  min-height: 0;
  max-height: min(52dvh, 510px);
  overflow: auto;
  overscroll-behavior: contain;
}
.generation-profile-toggle-copy,
.generation-profile-chevron { display: none; }
.generation-controls-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.generation-controls-head strong {
  display: block;
  color: var(--text);
  font-size: 12px;
}
.generation-controls-head p {
  margin: 3px 0 0;
  color: var(--subtle);
  font-size: 10px;
  line-height: 1.4;
}
.generation-controls-head .quiet-button {
  flex: none;
  min-height: 30px;
  padding: 5px 7px;
  border-color: var(--line-strong);
  color: var(--muted);
  font-size: 10px;
}
.generation-model-browser {
  grid-column: 1 / -1;
  padding: 0;
  border: 0;
}
.generation-model-browser summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}
.generation-model-browser[open] {
  display: grid;
  gap: 6px;
}
.generation-model-browser label,
.model-filter-note { color: var(--subtle); font-size: 10px; }
.generation-model-browser input {
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #111612;
  color: var(--text);
}
.candidate-grid:has(> .candidate-card:only-child) {
  grid-template-columns: minmax(0, 460px);
  justify-content: start;
}
.candidate-grid > .candidate-card:only-child { max-width: 460px; }

/* This selector deliberately matches the older image-panel rule as well.
   On a real series, two variants are always compared side by side; the
   single-variant exception above remains intentionally compact. */
.image-panel .candidate-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 760px) {
  .direction-panel .composer { max-height: min(54dvh, 520px); }
  .image-panel .candidate-grid,
  .candidate-grid:has(> .candidate-card:only-child) { grid-template-columns: 1fr; }
  .candidate-grid > .candidate-card:only-child { max-width: none; }
}

/* Mobile keeps the rail useful: tabs occupy one row and the active content
   occupies the next. The previous flex fallback positioned both panes below
   a 35px clipping area, which made Plans and Références look empty. */
@media (max-width: 760px) {
  .workbench .library-panel {
    position: relative;
    grid-template-rows: minmax(0, 1fr);
  }
  .library-rail-scroll {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 35px minmax(0, 1fr);
    gap: 0;
    height: 100%;
    padding: 0 10px;
    overflow: hidden;
  }
  .library-rail-scroll .library-section { display: contents; }
  .library-rail-scroll .library-section-head { display: none; }
  .library-tabs {
    grid-column: 1;
    grid-row: 1;
    width: min(184px, calc(100% - 78px));
    padding: 3px 0 0;
  }
  .library-pane {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    min-height: 0;
    padding: 7px 0;
    overflow-x: auto;
    overflow-y: hidden;
  }
  /* The import controls now live beside the active tab, so the legacy
     two-row reference pane must not reserve an empty import row here. */
  .library-references-pane,
  .library-references-pane.is-active:not([hidden]) {
    display: block;
    grid-template-rows: none;
    gap: 0;
  }
  .library-pane .shot-list,
  .library-pane .reference-list {
    min-height: 58px;
    padding: 0;
  }
  .library-pane .shot-item {
    flex-basis: 152px;
    border-color: rgba(235, 241, 233, .13);
    background: rgba(255, 255, 255, .055);
  }
  .library-pane .reference-card {
    flex-basis: 64px;
    border-color: rgba(235, 241, 233, .12);
    background: rgba(255, 255, 255, .025);
  }
  .library-pane .reference-thumb { width: 58px; height: 54px; }

  /* Keep creation available from the active tab without reopening a second
     toolbar. The controls remain labelled for assistive technology. */
  .library-panel[data-active-tab="plans"] .library-plans-section .library-section-head,
  .library-panel[data-active-tab="references"] .library-references-section .library-section-head {
    position: absolute;
    z-index: 3;
    top: 3px;
    right: 10px;
    display: flex;
    min-height: 31px;
    margin: 0;
  }
  .library-panel[data-active-tab="plans"] .library-plans-section .library-section-title,
  .library-panel[data-active-tab="references"] .library-references-section .library-section-title { display: none; }
  .library-panel[data-active-tab="plans"] .library-section-action {
    width: 31px;
    height: 31px;
  }
  .library-panel[data-active-tab="references"] .reference-quick-actions {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  .reference-import-settings { position: relative; }
  .reference-import-settings summary {
    display: inline-grid;
    min-width: 39px;
    min-height: 31px;
    padding: 5px 6px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    color: var(--muted);
    font-size: 10px;
    list-style: none;
  }
  .reference-import-settings summary::-webkit-details-marker { display: none; }
  .reference-import-settings[open] .reference-role-field {
    position: absolute;
    z-index: 5;
    top: 36px;
    right: 0;
    display: block;
    width: 138px;
    padding: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #171c18;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .34);
  }
  .reference-import-settings[open] .reference-role-field select { width: 100%; }
}
