:root {
  color-scheme: light;
  --bg: #f4f4f6; --panel: #ffffff; --block: #f8f8f9; --line: #e2e2e6; --line-strong: #d0d0d6;
  --text: #1d1d22; --muted: #6b6b75; --accent: #6d5dfc; --accent-strong: #5b45e0; --accent-soft: #eeebff; --accent-line: #8b7ffb;
  --ok: #18794e; --ok-soft: #e6f4ec; --warn: #9a5b00; --warn-soft: #fff4dd; --bad: #c42b2b; --bad-soft: #fdeceb; --info-soft: #ecf1ff; --info: #3451b2;
  --radius: 14px; --shadow: 0 1px 2px rgb(20 20 40 / 6%), 0 8px 24px rgb(20 20 40 / 5%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121216; --panel: #1b1b21; --block: #222229; --line: #30303a; --line-strong: #3d3d48;
    --text: #ececf1; --muted: #9a9aa6; --accent: #8b7ffb; --accent-strong: #a69dff; --accent-soft: #2a2550; --accent-line: #8b7ffb;
    --ok: #4cc38a; --ok-soft: #173426; --warn: #f0b44c; --warn-soft: #3a2c12; --bad: #ff7b72; --bad-soft: #3d1a1a; --info-soft: #1d2747; --info: #9db1ff;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 18px; } h3 { font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--block); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

.primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--accent-strong); }
.secondary { background: var(--panel); color: var(--accent-strong); border: 1px solid var(--accent-line); border-radius: 10px; padding: 8px 14px; font-weight: 600; }
.secondary:hover:not(:disabled) { background: var(--accent-soft); }
.link { background: none; border: 0; padding: 0; color: var(--accent-strong); font-size: 13px; }
.link:hover { text-decoration: underline; }
.ghost { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; color: var(--muted); }
.ghost:hover { background: var(--block); color: var(--text); }
.danger-text { color: var(--bad); }
.wide { width: 100%; padding: 12px 18px; font-size: 16px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 20px; } .brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.small-brand { gap: 10px; font-size: 16px; }
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: 28px; display: grid; gap: 16px; }
.field { display: grid; gap: 6px; font-size: 14px; }
.field > span { color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line-strong); background: var(--panel); border-radius: 10px; padding: 10px 12px; }
.field textarea { resize: vertical; line-height: 1.6; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { margin: 0; color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 8px 12px; font-size: 14px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px; background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.who { color: var(--muted); font-size: 14px; margin-right: 6px; }
.banner { margin: 16px 24px 0; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }

.layout { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: 20px; padding: 20px 24px 40px; max-width: 1280px; margin: 0 auto; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; }
.create { display: grid; gap: 14px; }
.block { background: var(--block); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

.drop { display: grid; place-items: center; min-height: 120px; border: 1.5px dashed var(--line-strong); border-radius: 12px; background: var(--panel); cursor: pointer; overflow: hidden; text-align: center; transition: border-color .15s, background .15s; }
.drop:hover, .drop.dragging { border-color: var(--accent-line); background: var(--accent-soft); }
.drop:focus-within { border-color: var(--accent-line); }
.drop-empty { display: grid; gap: 4px; padding: 16px; }
.drop img { display: block; max-height: 260px; max-width: 100%; object-fit: contain; }
.drop-audio { min-height: 84px; }
.audio-info { display: grid; gap: 2px; padding: 12px 16px; word-break: break-all; }
audio { width: 100%; height: 36px; }

.choices { display: grid; gap: 10px; }
.choices.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choices.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice { background: var(--panel); border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 12px 8px; text-align: center; font-weight: 500; transition: border-color .15s, background .15s; }
.choice:hover:not(:disabled) { border-color: var(--accent-line); }
.choice[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-strong); font-weight: 700; }
.choice small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.5em; }
.custom-size { display: flex; align-items: flex-end; gap: 10px; }
.custom-size .field { flex: 1; }
.times { padding-bottom: 10px; color: var(--muted); }

.tasks { min-height: 320px; }
.tasks-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.segmented { display: inline-flex; background: var(--block); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented button { border: 0; background: transparent; border-radius: 7px; padding: 5px 14px; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.task { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--panel); }
.thumb { width: 64px; height: 86px; border-radius: 10px; object-fit: cover; background: var(--block); }
.task-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; }
.task-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.task-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.task-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.pill { flex: none; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px; background: var(--info-soft); color: var(--info); white-space: nowrap; }
.pill.completed { background: var(--ok-soft); color: var(--ok); }
.pill.failed, .pill.attention { background: var(--bad-soft); color: var(--bad); }
.pill.waiting, .pill.cancelled { background: var(--block); color: var(--muted); }
.progress { height: 6px; background: var(--block); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s; }
.task-note { font-size: 13px; margin: 0; color: var(--muted); }
.task-note.error { color: var(--bad); }
.task-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.task-actions button, .task-actions a { font-size: 13px; border: 1px solid var(--line-strong); background: var(--panel); border-radius: 8px; padding: 5px 12px; text-decoration: none; color: var(--text); }
.task-actions button:hover, .task-actions a:hover { border-color: var(--accent-line); }
.task video { width: 100%; max-height: 480px; border-radius: 10px; background: #000; }
.empty { color: var(--muted); text-align: center; padding: 48px 16px; }

.dialog { border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: min(420px, calc(100vw - 32px)); background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgb(10 10 20 / 45%); }
.dialog form, .dialog > div { display: grid; gap: 14px; }
.wide-dialog { width: min(560px, calc(100vw - 32px)); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.admin-section { display: grid; gap: 8px; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.checks .ok::before { content: "✓ "; color: var(--ok); font-weight: 700; } .checks .bad::before { content: "✗ "; color: var(--bad); font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin: 0; }
.stats div { background: var(--block); border-radius: 10px; padding: 8px; text-align: center; }
.stats dt { font-size: 12px; color: var(--muted); } .stats dd { margin: 0; font-size: 18px; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--panel); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100vw - 32px); z-index: 20; }

/* ---- navigation ---- */
.views { display: flex; gap: 4px; background: var(--block); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.views a { text-decoration: none; color: var(--muted); padding: 5px 14px; border-radius: 7px; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.views a[aria-current] { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 6px; line-height: 18px; min-width: 18px; text-align: center; }

/* ---- multi-select ---- */
.drop:has(+ .photo-grid:not(:empty)), .drop:has(+ .audio-list:not(:empty)) { min-height: 64px; }
.photo-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.photo-grid:empty, .audio-list:empty { display: none; }
.photo { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: grid; }
.photo img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--block); }
.photo-grid.single { grid-template-columns: minmax(0, 220px); justify-content: center; }
.photo-grid.single .photo img { aspect-ratio: auto; max-height: 300px; object-fit: contain; }
.photo-name { font-size: 12px; padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.remove { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 999px; border: 0; background: rgb(0 0 0 / 55%); color: #fff; font-size: 16px; line-height: 1; }
.audio-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.audio-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.audio-row .remove { position: static; background: var(--block); color: var(--muted); }
.audio-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.audio-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.play { width: 28px; height: 28px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--block); font-size: 11px; color: var(--accent-strong); }
.summary { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); font-size: 14px; font-weight: 600; }
.summary.danger-text { background: var(--bad-soft); }

/* ---- batches in the task list ---- */
.batch { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; background: var(--block); }
.batch-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.batch-title { display: grid; gap: 2px; min-width: 0; }
.task-list.nested { gap: 8px; }
.task.compact { grid-template-columns: 44px minmax(0, 1fr); padding: 8px; gap: 10px; }
.task.compact .thumb { width: 44px; height: 58px; }

/* ---- board ---- */
.board { padding: 20px 24px 40px; max-width: 1280px; margin: 0 auto; display: grid; gap: 16px; }
.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.board-note { margin: 0; }
.stat-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 4px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 15px; }
.stat.ok strong { color: var(--ok); } .stat.bad strong { color: var(--bad); } .stat.warn strong { color: var(--warn); }
.board-section { display: grid; gap: 12px; }
.running-list { display: grid; gap: 10px; }
.running { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; }
.running.mine, .queue-table tr.mine { background: var(--accent-soft); }
.table-wrap { overflow-x: auto; }
.queue-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.queue-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.queue-table td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.queue-table td.audio-cell { white-space: normal; min-width: 160px; }
.queue-table td.empty { text-align: center; padding: 24px; }

/* ---- script and voice settings ---- */
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; }
.mode-switch button { padding: 8px 14px; font-size: 15px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 10px; }
.field.compact { gap: 4px; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline select { width: auto; min-width: 160px; padding: 6px 10px; }
.advanced { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 10px; }
.advanced summary { cursor: pointer; font-size: 14px; font-weight: 600; }
.advanced[open] summary { margin-bottom: 8px; }
.sliders { display: grid; gap: 8px; }
.slider { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) 3.5em; align-items: center; gap: 10px; font-size: 13px; }
.slider span { color: var(--muted); }
.slider output { text-align: right; font-variant-numeric: tabular-nums; }
.slider input { width: 100%; accent-color: var(--accent); }
.row-actions { display: flex; gap: 16px; flex-wrap: wrap; }
.script-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.script-list:empty { display: none; }
.script-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 14px; }
.script-row .audio-name { font-size: 14px; }
.preview-row { display: flex; align-items: center; gap: 10px; }
.preview-row audio { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---- voice library ---- */
.voices-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.voice-forms { display: grid; gap: 16px; }
.voice-forms h3 { font-size: 16px; }
.voice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.voice-list:empty { display: none; }
.voice { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; }
.voice.archived { opacity: .65; }
.pill.ready { background: var(--ok-soft); color: var(--ok); }
.pill.speaking { background: var(--info-soft); color: var(--info); }
.members { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0; }
.members legend { font-size: 14px; color: var(--muted); padding: 0 4px; }
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 12px; max-height: 260px; overflow: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: var(--block); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-size: 12px; }

@media (max-width: 860px) {
  .voices-grid { grid-template-columns: minmax(0, 1fr); }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .topbar { padding: 10px 16px; }
  .banner { margin: 12px 16px 0; }
  .who { display: none; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar { flex-wrap: wrap; }
  .views { order: 3; width: 100%; justify-content: center; }
  .board { padding: 16px; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .choices.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .slider { grid-template-columns: 6em minmax(0, 1fr) 3em; }
  .panel { padding: 14px; }
}
