:root {
  --bg: #15121f; --card: #201b2e; --line: #322b45; --text: #ece8f5; --muted: #a39cb8;
  --accent: #9b7bff; --accent2: #6f4cff; --err: #ff7a8a; --ok: #6fe3a5;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(21,18,31,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
main { max-width: 720px; margin: 0 auto; padding: 14px 14px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 0 0 14px; }
h2 { margin: 0 0 12px; font-size: 17px; }
input, select, textarea { width: 100%; background: #171324; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font: inherit; }
textarea { resize: vertical; font-size: 15px; line-height: 1.5; margin-top: 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.small { flex-direction: row; align-items: center; gap: 6px; }
label.small select { width: auto; padding: 6px 8px; }
.row { display: flex; gap: 10px; align-items: flex-end; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
button, .btn { border: 0; border-radius: 10px; padding: 12px 16px; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--text); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.ghost { background: #2a2340; }
.small { padding: 7px 11px; font-size: 14px; }
.danger { color: var(--err); }
.hidden { display: none !important; }
.error { color: var(--err); margin: 8px 0 0; min-height: 0; }
.error:empty { display: none; }
.muted { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
audio { width: 100%; margin-top: 4px; }

.job { padding: 10px 0; border-top: 1px solid var(--line); }
.job:first-child { border-top: 0; padding-top: 0; }
.job .t { font-weight: 600; }
.bar { height: 8px; background: #171324; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--ok)); transition: width .4s; }

.item { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .info { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .m { color: var(--muted); font-size: 13px; }
.item.playing .t { color: var(--accent); }
.play { width: 42px; height: 42px; border-radius: 50%; padding: 0; flex: none; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.row.tight { margin-top: 0; gap: 6px; align-items: stretch; }
.row.tight select { flex: 1; }
#castPanel { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 6px; }
.castrow { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.castrow:first-child { border-top: 0; }
.castrow .info { flex: 1; min-width: 0; }
.castrow .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.castrow .m { color: var(--muted); font-size: 12px; }
.castrow select { width: auto; padding: 7px 8px; }
.muted.inline { margin: 0; font-size: 13px; }
label.switch { flex-direction: row; align-items: flex-start; gap: 12px; margin-top: 14px; font-size: 15px; color: var(--text); cursor: pointer; }
label.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
label.switch .slider { flex: none; position: relative; width: 46px; height: 26px; border-radius: 99px; background: #3a3252; transition: background .2s; margin-top: 2px; }
label.switch .slider::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
label.switch input:checked + .slider { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
label.switch input:checked + .slider::after { transform: translateX(20px); }
label.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.guess { color: #ffc46b; font-weight: 600; }
details.batch { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
details.batch summary { cursor: pointer; font-weight: 600; color: var(--accent); }
label.spaced { margin-top: 10px; }
#modelNote { margin-top: 4px; font-size: 13px; }
label.switch input:disabled + .slider { opacity: .4; }
