
* { box-sizing: border-box; }

body {
  font-family: var(--sans);
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-block: 2rem;
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding-inline: 1.25rem;
}

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

header.top h1 {
  font-size: 1.35rem;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.01em;
}

header.top .tagline {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Project picker --- */
#projects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.project-pill {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.project-pill:hover { border-color: var(--accent); color: var(--text); }
.project-pill.archived { opacity: 0.55; font-style: italic; }
.project-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}
#projects:empty::before {
  content: "No projects yet — create one below.";
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* --- New project form --- */
#new-project-form .field { margin-bottom: 0.9rem; }
#new-project-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}
#new-project-form input[type="text"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  color: var(--text);
  font-size: 0.9rem;
}
#new-project-form input[type="text"]:focus,
#new-project-form input[type="file"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
#new-project-form input[type="file"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  color: var(--text-dim);
  font-size: 0.82rem;
}
.hint { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.3rem; }

button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
button:hover { background: var(--accent-hover); }
button.ghost:hover { background: var(--control); }
button:active { transform: translateY(1px); }
button.ghost {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}
button:disabled { opacity: 0.5; cursor: default; filter: none; }

#new-project-status {
  display: inline-block;
  margin-left: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}
#new-project-status.error { color: var(--error); }
#new-project-status.ok { color: var(--done); }

/* --- Pipeline / stages --- */
.pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.stage {
  flex: 1 1 190px;
  background: var(--pending-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.stage .stage-name {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.stage .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
  flex: none;
}
.stage.done { background: var(--done-bg); border-color: rgba(52, 201, 138, 0.35); }
.stage.done .dot { background: var(--done); }
.stage.running .dot { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.stage.notwired { opacity: 0.45; }
.stage.wide { flex-basis: 100%; }

.llm-controls { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.2rem 0; }
.llm-controls select {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 0.35rem 0.5rem; font-size: 0.78rem; width: fit-content;
}
.llm-controls textarea {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 0.45rem 0.6rem; font-size: 0.8rem; resize: vertical; font-family: inherit;
}
#song-player { width: 100%; margin-bottom: 0.8rem; }
.lyrics {
  white-space: pre-wrap; margin: 0; max-height: 14rem; overflow-y: auto;
  background: var(--panel-2); border-radius: var(--radius); padding: 0.8rem;
  font-family: inherit; font-size: 0.82rem; line-height: 1.5; color: var(--text);
}
.banner {
  background: rgba(239, 180, 60, 0.12); border: 1px solid rgba(239, 180, 60, 0.35);
  color: #f0c060; border-radius: var(--radius); padding: 0.5rem 0.7rem; font-size: 0.78rem; margin: 0 0 0.7rem;
}
.flag {
  display: inline-block; background: rgba(239, 91, 107, 0.15); color: var(--error);
  border-radius: 4px; padding: 0.05rem 0.35rem; font-size: 0.7rem; margin-left: 0.3rem;
}
.stage .stage-status { font-size: 0.75rem; color: var(--text-dim); }
.stage-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.stage-actions button { padding: 0.35rem 0.8rem; font-size: 0.78rem; margin-left: 0; }
.stage-detail:empty { display: none; }
.stage-detail {
  margin-top: 0.4rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text);
}
.stage-detail p { margin: 0 0 0.55rem; line-height: 1.4; }
.stage-detail p strong { color: var(--text-dim); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.02em; }
.stage-detail pre {
  white-space: pre-wrap; word-break: break-word; font-size: 0.75rem;
  background: var(--panel-2); padding: 0.6rem; border-radius: var(--radius); margin: 0;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 0.4rem;
}
.detail-table th, .detail-table td {
  text-align: left;
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.detail-table th { color: var(--text-dim); font-weight: 600; }

/* --- Player --- */
#player:empty { display: none; }
#player video {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
}

footer.note {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-align: center;
  margin-top: 2rem;
}

.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.7rem; margin: 0.5rem 0; }
.cast { margin: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cast img { width: 100%; display: block; aspect-ratio: 4 / 5; object-fit: cover; }
.cast.environment img { aspect-ratio: 16 / 9; }
.cast-empty { padding: 2rem 0.5rem; text-align: center; color: var(--text-dim); font-size: 0.78rem; }
.cast figcaption { padding: 0.4rem 0.6rem; font-size: 0.78rem; }
code { background: var(--panel-2); border-radius: 4px; padding: 0.05rem 0.3rem; font-size: 0.75rem; }

/* --- Casting editor --- */
.cast-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 0.6rem; }
.cast-item { display: grid; grid-template-columns: minmax(180px, 320px) 1fr; gap: 1rem; padding: 0.8rem;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); }
.cast-item.environment { grid-template-columns: minmax(240px, 420px) 1fr; }
.cast-item figure { margin: 0; }
.cast-item img { width: 100%; height: auto; display: block; border-radius: var(--radius); }
.cast-edit textarea { width: 100%; box-sizing: border-box; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem; font: inherit; font-size: 0.8rem; line-height: 1.4; resize: vertical; }
.cast-edit details { margin: 0.4rem 0; }
.cast-edit summary { cursor: pointer; font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.3rem; }
.cast-title { margin-bottom: 0.4rem; }
.cast-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.cast-row input[type=number] { width: 9.5rem; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.3rem 0.4rem; }
.lbl { display: block; font-size: 0.72rem; color: var(--text-dim); margin: 0.3rem 0 0.2rem; }
.lbl.inline { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; }
.badge.queued { font-size: 0.7rem; padding: 0.1rem 0.5rem; border-radius: var(--radius); background: rgba(255, 190, 70, 0.15); color: #ffbe46; }
.cast-msg.error { color: var(--error); }
@media (max-width: 720px) { .cast-item, .cast-item.environment { grid-template-columns: 1fr; } }

/* --- Animatic shot review --- */
.shot-bar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem;
  padding: 0.5rem 0.6rem; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.5rem; }
.shot-bar #shot-now { flex: 1 1 14rem; }
.shot-bar select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.2rem; }
.shot-scroll { max-height: 70vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.shots { width: 100%; border-collapse: collapse; }
table.shots th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
table.shots td { vertical-align: top; padding: 0.4rem 0.5rem; border-top: 1px solid var(--border); font-size: 0.82rem; }
table.shots td.play { white-space: nowrap; }
table.shots td.tm { white-space: nowrap; }
table.shots td.song { min-width: 9rem; max-width: 14rem; }
table.shots tr.now { background: rgba(245, 158, 11, 0.14); outline: 1px solid var(--accent); }
.lyric { font-style: italic; color: var(--dim); }
.chip { display: inline-block; font-size: 0.68rem; padding: 0.05rem 0.45rem; margin: 0.2rem 0.25rem 0 0;
  border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim); }
.chip.loc { color: #ffcf8a; }
.meta { margin-top: 0.15rem; }
.energy { display: block; width: 3rem; height: 4px; margin-top: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.energy i { display: block; height: 100%; background: var(--accent); }
button.tiny { padding: 0.15rem 0.45rem; font-size: 0.8rem; }

/* --- Editorial review --- */
.editor-card { margin: 0.5rem 0 0.8rem; padding: 0.6rem 0.8rem; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); }
.editor-card summary { cursor: pointer; font-weight: 600; margin-bottom: 0.4rem; }
.editor-card ul { margin: 0.2rem 0 0.4rem 1.1rem; padding: 0; font-size: 0.8rem; color: var(--text-dim); }
.chip.cam { color: #9fd3ff; }
.chip.edited { color: #ffbe46; border-color: rgba(255, 190, 70, 0.4); }
.cast-item.keyframe { grid-template-columns: minmax(260px, 460px) 1fr; }
.cast-item.keyframe .lyric { margin: 0.2rem 0; }
@media (max-width: 720px) { .cast-item.keyframe { grid-template-columns: 1fr; } }
.takes { margin-top: 0.5rem; }
.take-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.take { width: 31%; min-width: 120px; }
.take img { width: 100%; display: block; border-radius: var(--radius); border: 1px solid var(--border); }
.take button { width: 100%; margin-top: 0.25rem; }

/* --- Reviewer notes --- */
.notes { margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px dashed var(--border); }
.note-input { width: 100%; box-sizing: border-box; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.4rem 0.5rem; font: inherit; font-size: 0.8rem; resize: vertical; margin-bottom: 0.3rem; }
.note { display: flex; justify-content: space-between; gap: 0.6rem; align-items: flex-start; padding: 0.35rem 0.5rem; margin-bottom: 0.3rem;
  background: rgba(255, 190, 70, 0.08); border-left: 3px solid #ffbe46; border-radius: 4px; font-size: 0.8rem; }
.note.resolved { opacity: 0.5; border-left-color: var(--done); background: transparent; }
.note.resolved .note-text { text-decoration: line-through; }
.note-text { white-space: pre-wrap; flex: 1; }
.note-actions { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; font-size: 0.72rem; color: var(--text-dim); }
.notes-header { margin: 0.4rem 0 0.8rem; padding: 0.6rem 0.8rem; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); }

/* --- Image critic --- */
.critic-fail { color: #ff9b8a; }
.critic-pass { color: var(--done); }


/* --- Home: next action, stepper, dashboard --- */
.container { max-width: 1080px; }
header.top { align-items: center; justify-content: flex-start; margin-bottom: 1.25rem; }
header.top h1 { font-size: 1.1rem; margin-right: auto; }
#projects { margin: 0; }
.project-pill { border-radius: var(--radius); }
details.card > summary, details.field > summary { cursor: pointer; font-size: .85rem; color: var(--dim); }
details.card[open] > summary { margin-bottom: .8rem; }

.next { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.1rem; margin-bottom: 1rem;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); }
.next.wait { border-left-color: var(--changed); }
.next.blocked { border-left-color: var(--flag); }
.next.done { border-left-color: var(--ok); }
.next .label { font: 500 14.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--faint); flex-basis: 100%; }
.next .text { flex: 1 1 20rem; font-size: 1.05rem; font-weight: 500; }
.next a.cta, .next button.cta { display: inline-block; text-decoration: none; background: var(--accent); color: var(--bg); font-weight: 600;
  padding: .6rem 1.1rem; border-radius: var(--radius); border: 0; font-size: .9rem; }
.next a.cta:hover { background: var(--accent-hover); }
.cmd { flex-basis: 100%; display: flex; gap: .5rem; align-items: stretch; }
.cmd code { flex: 1; padding: .55rem .7rem; background: var(--bg); border: 1px solid var(--line); font: 15.5px var(--mono); color: var(--dim); white-space: pre-wrap; word-break: break-all; }
.cmd button { padding: .4rem .8rem; font-size: .78rem; }

.stepper { display: flex; gap: 0; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--panel); }
.step { flex: 1 1 0; min-width: 118px; text-align: left; background: transparent; color: var(--text); border: 0; border-right: 1px solid var(--line);
  border-radius: 0; padding: .65rem .8rem; font-weight: 500; display: flex; flex-direction: column; gap: .4rem; }
.step:last-child { border-right: 0; }
.step:hover { background: var(--panel-2); }
.step.focus { background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.step .n { font: 500 14.5px var(--mono); color: var(--faint); }
.step.unavailable { opacity: .55; }
.step .sub { font: 400 14.5px var(--mono); color: var(--faint); }

.dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .85rem; }
.metric .k { font: 500 14.5px var(--mono); color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.metric .v { font: 500 1.35rem var(--mono); margin: .2rem 0 .4rem; }
.metric .v small { font-size: .8rem; color: var(--faint); }
.seg { display: flex; height: 6px; background: var(--control); border-radius: 1px; overflow: hidden; }
.seg i { display: block; height: 100%; }
.seg .ok { background: var(--ok); } .seg .flag { background: var(--flag); } .seg .run { background: var(--changed); }

.pipeline .stage { flex-basis: 100%; }
.stage-head { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.stage-head h2 { margin: 0; font-size: 1.05rem; }
.stage-why { color: var(--dim); font-size: .85rem; }
.stage-actions { margin: .3rem 0; }
.stage-actions a.ghost { text-decoration: none; }
.stage-actions .primary { background: var(--accent); color: var(--bg); }

/* --- Options block (fix: it was a flex column applied to <details>) --- */
details.llm-controls { display: block; margin: .4rem 0 .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
details.llm-controls > summary { cursor: pointer; padding: .45rem .7rem; font-size: .8rem; color: var(--dim); margin: 0; }
details.llm-controls[open] > summary { border-bottom: 1px solid var(--line); }
details.llm-controls .opts { display: grid; gap: .5rem; padding: .7rem; }
details.llm-controls select, details.llm-controls textarea { width: 100%; max-width: 32rem; }
details.llm-controls textarea { min-height: 4.5rem; }

a.navlink { text-decoration: none; padding: .5rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); color: var(--text); font-size: .85rem; }
a.navlink:hover { background: var(--control); }

html { font-size: 26.5px; }
.stage-why, .hint, .detail-table { font-size: max(.85em, 15px); }

.pill { white-space: nowrap; }
.step { min-width: 138px; }
.step .sub { font-size: 14px; }

/* fit the larger type: wider page, stepper wraps instead of scrolling */
html { font-size: 20.5px; }
.container { max-width: 1280px; }
.stepper { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); overflow: visible; }
.step { min-width: 0; border-bottom: 1px solid var(--line); }
.step .pill { font-size: 13px; padding: .25rem .4rem; }

#new-project-form textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .7rem; color: var(--text); font: inherit; margin-top: .5rem; resize: vertical; }
#new-project-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button:not(.ghost):not(.tiny):not(.step):not(.cta) { min-height: 2.4rem; }

#settings-card h3 { font-size: 1rem; margin: 1.4rem 0 .4rem; }
#settings-card input[type=text], #settings-card textarea { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .7rem; color: var(--text); font: inherit; }
#settings-card textarea { width: 100%; margin-top: .5rem; resize: vertical; }
#settings-card .field { margin-bottom: .8rem; }
#settings-card label { display: block; font-size: .8rem; color: var(--dim); margin-bottom: .3rem; }
.row-form { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
button.danger { color: var(--flag); border-color: rgba(249,115,22,.5); }

.stale-warn { color: var(--flag); }
