:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #697184;
  --line: #e2e5eb;
  --accent: #2f5bea;
  --ok: #1d7f47;
  --warn: #a8690f;
  --error: #c0392b;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: .25rem 0 .75rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: 14px; flex: 1; }
.top nav a { color: var(--muted); }
.top nav a[aria-current] { color: var(--text); font-weight: 600; }
.top form { margin: 0; }

main { max-width: 1040px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 440px; margin: 32px auto; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions form { margin: 0; }
.scroll { overflow-x: auto; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 91, 234, .25); border-color: var(--accent); }
input[readonly], textarea[readonly] { background: #fafbfc; }
fieldset { display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 0; }
legend { font-weight: 600; padding: 0 4px; }

button, .button { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 600; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.button:hover { text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary, .button.secondary { background: #fff; color: var(--accent); }
button.link { background: none; border: 0; color: var(--muted); padding: 4px; font-weight: 400; }
button.small { padding: 5px 10px; font-size: .88rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--error); }
.flash { padding: 10px 12px; border-radius: 8px; margin: 0 0 16px; background: #e9f6ee; color: var(--ok); }
.flash-warn { background: #fdf5e6; color: var(--warn); }
.flash-error { background: #fcebea; color: var(--error); }

table.list { width: 100%; border-collapse: collapse; }
.list th, .list td { text-align: left; vertical-align: top; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.list th { font-size: .8rem; font-weight: 600; color: var(--muted); }
.list td form { margin: 0; }
.num { text-align: right !important; white-space: nowrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: #eceff4; color: var(--muted); }
.badge-done { background: #e6f4ec; color: var(--ok); }
.badge-running, .badge-queued, .badge-in_progress { background: #e8eefc; color: var(--accent); }
.badge-failed { background: #fcebea; color: var(--error); }
.badge-stopped { background: #fdf5e6; color: var(--warn); }

.stages { list-style: none; margin: 0 0 12px; padding: 0; }
.stage { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.stage .error { grid-column: 2 / 4; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #cdd2dc; }
.stage-done .dot, .stage-skipped .dot { background: var(--ok); }
.stage-running .dot { background: var(--accent); animation: pulse 1.2s infinite; }
.stage-failed .dot { background: var(--error); }
@keyframes pulse { 50% { opacity: .3; } }

.jobs { list-style: none; margin: 0; padding: 0; }
.jobs li { padding: 4px 0; }

.player { width: 100%; max-height: 70vh; border-radius: 8px; background: #000; }
.copyable { margin-top: 12px; }
.copyable label { margin-bottom: 4px; }
.field-row { display: flex; gap: 8px; align-items: flex-start; }
.shorts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.short video { display: block; width: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: 8px; }

.qr svg { display: block; width: 220px; height: auto; margin: 12px 0; }
.secret { word-break: break-all; }
.steps { padding-left: 1.2rem; }

@media (max-width: 600px) {
  main { padding: 12px; }
  .card { padding: 12px; }
  .field-row { flex-direction: column; align-items: stretch; }
}
