:root {
  --ink: #11212d;
  --muted: #697983;
  --paper: #f4f0e7;
  --panel: #fffdf8;
  --line: #ded7ca;
  --accent: #e96b3a;
  --gold: #d8a62e;
  --green: #19765a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .45;
  background-image: radial-gradient(#bdb4a5 0.6px, transparent 0.6px);
  background-size: 12px 12px;
}
.topbar, main { position: relative; max-width: 1180px; margin: auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 42px 24px 24px; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, "Songti SC", serif; font-size: 27px; }
.eyebrow { margin-bottom: 7px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .17em; }
.local-badge { display: flex; gap: 9px; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 9px 14px; background: rgba(255,255,255,.5); font-size: 13px; }
.local-badge span { width: 8px; height: 8px; border-radius: 50%; background: #2bac73; box-shadow: 0 0 0 4px #d7eee5; }
main { padding: 0 24px 70px; }
.panel { border: 1px solid var(--line); border-radius: 18px; background: rgba(255,253,248,.93); box-shadow: 0 16px 42px rgba(47,42,33,.06); }
.hero { padding: 34px; overflow: hidden; background: var(--ink); color: white; }
.hero h2 { max-width: 680px; margin-bottom: 12px; font-family: Georgia, "Songti SC", serif; font-size: clamp(29px, 4vw, 45px); font-weight: 500; line-height: 1.2; }
.hero p { max-width: 650px; color: #bdc8cd; line-height: 1.7; }
.step { display: inline-block; margin-bottom: 18px; color: #ffd981; font-size: 12px; letter-spacing: .12em; }
.workflow { display: flex; align-items: center; margin-top: 28px; }
.workflow div { padding: 7px 12px; border: 1px solid #51616c; border-radius: 99px; color: #aab7bf; font-size: 12px; }
.workflow div.active { color: #1c2a33; border-color: #ffd981; background: #ffd981; }
.workflow i { flex: 1; height: 1px; min-width: 10px; background: #465863; }
.material-card { margin-top: 18px; padding: 27px; }
.material-intro { max-width: 780px; color: var(--muted); line-height: 1.6; }
.material-input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.material-source-box { padding: 16px; border: 1px solid #e2dbce; border-radius: 12px; background: #fbf8f2; }
.material-source-box label { margin-top: 0; }
.material-source-box input[type=file] { width: 100%; padding: 10px 0; color: var(--muted); font-size: 12px; }
.material-source-box textarea { min-height: 78px; }
.material-source-box button { margin-top: 12px; }
.material-list { display: grid; gap: 9px; margin-top: 15px; }
.material-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; font-size: 12px; }
.material-tools .select-all-label { display: flex; align-items: center; gap: 7px; margin: 0; }
.material-tools input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.material-tools button { width: auto; margin: 0; padding: 9px 12px; font-size: 12px; }
.material-purge { background: #b94a2c; color: white; }
.material-item { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 13px; border: 1px solid #e2dbce; border-radius: 10px; background: #fffdf8; font-size: 13px; }
.material-select { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.material-main { min-width: 0; }
.material-item small { margin: 4px 0 0; text-align: left; }
.material-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.material-actions .task-action { margin: 0; }
.material-error { color: #a34c3a; }
.grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; margin-top: 18px; }
.create-card, .status-card, .tasks-card { padding: 27px; }
.section-title { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 23px; }
.section-title h3 { margin-bottom: 0; font-size: 21px; }
.number { color: #cfc7ba; font-family: Georgia, serif; font-size: 28px; }
label { display: block; margin: 18px 0 8px; font-size: 13px; font-weight: 700; }
textarea { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fbf8f1; color: var(--ink); font: inherit; line-height: 1.6; outline: none; }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #fbe1d7; }
.duration-row { display: flex; gap: 18px; align-items: center; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
output { min-width: 68px; color: var(--accent); font-weight: 800; }
button { width: 100%; margin-top: 15px; border: 0; border-radius: 11px; padding: 13px 18px; color: white; background: var(--accent); font: inherit; font-weight: 800; cursor: pointer; }
button:hover { filter: brightness(.95); transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: .55; transform: none; }
small { display: block; margin-top: 11px; color: var(--muted); text-align: center; line-height: 1.5; }
.message { min-height: 18px; margin: 10px 0 0; color: var(--accent); font-size: 13px; }
.checks { display: grid; gap: 10px; }
.check { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid #ebe5da; font-size: 14px; }
.check:last-child { border: 0; }
.check b { color: var(--green); font-size: 12px; }
.check b.missing { color: #a34c3a; }
.tasks-card { margin-top: 18px; }
.count { border-radius: 99px; padding: 7px 11px; background: #ede8dd; color: var(--muted); font-size: 12px; }
.empty-state { padding: 45px 20px; text-align: center; color: var(--muted); }
.empty-state h4 { margin-bottom: 8px; color: var(--ink); }
.empty-icon { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 15px; border: 1px dashed #b9afa0; border-radius: 50%; font-size: 23px; }
.task-list { display: grid; gap: 11px; }
.task { display: grid; grid-template-columns: 20px minmax(0, 1fr) 108px 108px 126px; gap: 14px; align-items: center; padding: 15px; border: 1px solid #e5ded2; border-radius: 12px; background: #fbf8f2; }
.task.is-selected { border-color: var(--accent); background: #fff4ec; }
.task-main { min-width: 0; overflow-wrap: anywhere; }
.task-select, #select-all-tasks { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.task-select { align-self: start; margin-top: 3px; }
.task-select:disabled { cursor: not-allowed; }
.queue-tools { margin-bottom: 18px; }
.queue-tools > label { margin-top: 0; }
.queue-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; font-size: 12px; }
.queue-actions .select-all-label { display: flex; align-items: center; gap: 7px; margin: 0; }
.queue-actions button { width: auto; margin: 0; padding: 9px 12px; font-size: 12px; }
.queue-actions button:disabled { cursor: not-allowed; }
.danger-button { color: #a13d2b; background: #f7e2db; }
.text-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.task-controls { font-size: 12px; }
.task-id { margin-top: 5px; color: var(--muted); font-family: ui-monospace, monospace; font-size: 12px; }
.task-topic { font-weight: 750; }
.task-reference { margin-top: 5px; color: var(--accent); font-size: 12px; font-weight: 700; }
.task-meta { margin-top: 5px; color: var(--muted); font-size: 12px; }
.status { width: max-content; border-radius: 99px; padding: 6px 9px; color: #80520d; background: #f9e9bd; font-size: 12px; }
.approval { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.task-action { width: auto; margin: 0; padding: 9px 11px; font-size: 12px; }
.task-action.review { color: var(--ink); background: #e9e2d5; }
.task-error { grid-column: 2 / -1; margin: 0; color: #a34c3a; font-size: 12px; }
.text-input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; background: #fbf8f1; color: var(--ink); font: inherit; outline: none; }
.check b small { margin: 3px 0 0; color: var(--muted); font-size: 10px; font-weight: 500; text-align: right; }
dialog { width: min(980px, calc(100vw - 30px)); max-height: calc(100vh - 30px); border: 0; border-radius: 18px; padding: 0; background: var(--panel); color: var(--ink); box-shadow: 0 28px 100px rgba(17,33,45,.28); }
dialog::backdrop { background: rgba(17,33,45,.66); backdrop-filter: blur(3px); }
.dialog-shell { display: flex; flex-direction: column; max-height: calc(100vh - 30px); }
.dialog-header, .dialog-footer { display: flex; justify-content: space-between; align-items: center; padding: 20px 25px; border-bottom: 1px solid var(--line); }
.dialog-header h3 { margin-bottom: 0; }
.dialog-footer { border-top: 1px solid var(--line); border-bottom: 0; background: #f8f4ec; }
.dialog-footer > div { display: flex; gap: 10px; }
.dialog-footer button { width: auto; margin: 0; }
.dialog-body { overflow-y: auto; padding: 8px 25px 28px; }
.icon-button { width: 38px; height: 38px; margin: 0; padding: 0; border-radius: 50%; color: var(--ink); background: #ece6da; font-size: 24px; font-weight: 400; }
.secondary-button { color: var(--ink); background: #ded7ca; }
.compact-button { margin-top: 14px; padding: 10px 13px; font-size: 13px; }
.settings-dialog { width: min(620px, calc(100vw - 30px)); }
.task-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 22px; }
.task-detail-grid > div { padding: 11px 12px; border: 1px solid #e2dbce; border-radius: 10px; background: #fbf8f2; }
.task-detail-grid span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.task-detail-grid b { display: block; overflow-wrap: anywhere; font-size: 13px; }
.task-detail-error { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: 13px; border-radius: 10px; background: #f8e9e2; color: #943f2e; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.settings-note { margin: 8px 0 20px; padding: 12px 14px; border-left: 3px solid var(--gold); background: #f7edcf; color: #675329; font-size: 13px; line-height: 1.6; }
.scene-heading { display: flex; justify-content: space-between; align-items: center; margin-top: 27px; }
.scene-heading h4 { margin: 0; }
.scene-heading span { color: var(--muted); font-size: 12px; }
.scene-editors { display: grid; gap: 13px; margin-top: 13px; }
.scene-editor { padding: 17px; border: 1px solid #e2dbce; border-radius: 12px; background: #fbf8f2; }
.scene-editor header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.scene-editor header b { color: var(--accent); }
.scene-editor header span { color: var(--muted); font-size: 12px; }
.scene-editor label { margin-top: 12px; }
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .material-input-grid { grid-template-columns: 1fr; }
  .workflow { overflow-x: auto; }
  .workflow i { min-width: 18px; }
.images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.images-grid .image-cell { border: 1px solid #e2dbce; border-radius: 12px; overflow: hidden; background: #fbf8f2; }
.images-grid .image-cell img { display: block; width: 100%; aspect-ratio: 9 / 16; object-fit: cover; cursor: zoom-in; background: #2a2a3a; }
.images-grid .image-cell .image-cap { padding: 7px 10px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.images-grid .image-cell .image-cap b { color: var(--accent); font-weight: 600; }
.images-grid .image-failed { padding: 16px; min-height: 180px; display: flex; flex-direction: column; justify-content: center; gap: 8px; border: 1px dashed #d98b72; }
.image-failed-title { color: #b94a2c; font-weight: 700; }
.image-failed-reason { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
.images-note, .settings-note { color: var(--muted); font-size: 13px; margin-top: 0; }
.settings-divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0 4px; }
.image-lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(20,18,15,.82); cursor: zoom-out; }
.image-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 6px; box-shadow: 0 24px 80px rgba(0,0,0,.5); }
.audio-list { display: flex; flex-direction: column; gap: 12px; }
.audio-list .audio-cell { border: 1px solid #e2dbce; border-radius: 12px; background: #fbf8f2; padding: 10px 12px; }
.audio-list .audio-cell .audio-cap { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.audio-list .audio-cell .audio-cap b { color: var(--accent); font-weight: 600; }
.audio-list .audio-cell audio { width: 100%; }
.video-player { width: 100%; max-height: 60vh; border-radius: 12px; background: #000; display: block; margin: 8px 0; }
.download-link { color: var(--accent); font-size: 13px; text-decoration: none; font-weight: 600; }
.download-link:hover { text-decoration: underline; }

  .task { grid-template-columns: 20px minmax(0, 1fr); }
  .task .status, .task .approval, .task .task-action, .task .task-controls { grid-column: 2; }
  .dialog-footer { align-items: stretch; flex-direction: column; }
  .dialog-footer > div { display: grid; grid-template-columns: 1fr 1fr; }
}

.voice-selector { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }
.voice-selector label { margin: 0; font-size: 13px; white-space: nowrap; }
.voice-selector select { flex: 1; max-width: 320px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fbf8f1; color: var(--ink); font: inherit; }
.voice-selector .compact-button { width: auto; margin: 0; white-space: nowrap; }
.voice-preview-player { width: min(520px, 100%); height: 34px; margin: 2px 0 5px; }
.voice-hint { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.image-check, .audio-check { display: flex; align-items: center; gap: 7px; margin: 0 0 8px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.image-check input, .audio-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
