:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e2229;
  --border: #2a2f3a;
  --text: #e6e8eb;
  --muted: #8b93a1;
  --accent: #6d8dff;
  --accent-2: #4f6bd6;
  --error: #ff6b6b;
  --success: #4ade80;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Hiragino Sans, "Yu Gothic", sans-serif;
  line-height: 1.5;
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 32px 20px 60px; }

header h1 { margin: 0 0 4px; font-size: 26px; font-weight: 700; }
header h1 .sub { color: var(--muted); font-weight: 400; }
header .tagline { color: var(--muted); margin: 0 0 28px; font-size: 14px; }

.grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.mode-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.mode-tab {
  flex: 1; min-width: 110px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 10px 8px; cursor: pointer; text-align: center;
  font-size: 14px; font-weight: 600; transition: all .15s;
}
.mode-tab span { display: block; font-weight: 400; font-size: 11px; color: var(--muted); margin-top: 2px; }
.mode-tab:hover { border-color: var(--accent); }
.mode-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.mode-tab.active span { color: rgba(255,255,255,.85); }

.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.val { font-weight: 400; color: var(--accent); }

textarea, select, input[type="file"], input[type="text"] {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; font-family: inherit; resize: vertical;
}
textarea:focus, select:focus, input:focus { outline: none; border-color: var(--accent); }

input[type="range"] { width: 100%; accent-color: var(--accent); margin-top: 8px; }

.checkbox-field { display: flex; flex-direction: column; justify-content: flex-end; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; margin-bottom: 4px; }
.checkbox-label input { width: auto; accent-color: var(--accent); }

.hint { font-size: 12px; color: var(--muted); margin: 4px 0 12px; }

.mode-fields { border-top: 1px dashed var(--border); padding-top: 14px; margin-bottom: 14px; }

.primary-btn {
  width: 100%; padding: 13px; background: var(--accent); color: #fff; border: none;
  border-radius: 8px; font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 6px;
  transition: background .15s;
}
.primary-btn:hover { background: var(--accent-2); }
.primary-btn:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }

.status-panel h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.status-panel .history-title { margin-top: 24px; }

.status-box { background: var(--panel-2); border-radius: 8px; padding: 16px; font-size: 14px; color: var(--muted); }
.status-box.error { color: var(--error); background: rgba(255,107,107,.08); border: 1px solid rgba(255,107,107,.3); }

#status-active { display: flex; align-items: center; gap: 14px; }
.status-text #status-state { color: var(--text); font-weight: 600; margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 12px; }

.spinner {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#result { margin-top: 16px; }
#result video { width: 100%; border-radius: 8px; background: #000; }
.download-link {
  display: block; text-align: center; margin-top: 10px; padding: 10px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; font-size: 13px;
}
.download-link:hover { border-color: var(--accent); }

.history-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.history-list li {
  padding: 10px 12px; border-radius: 8px; background: var(--panel-2); margin-bottom: 8px;
  cursor: pointer; font-size: 13px; border: 1px solid transparent;
}
.history-list li:hover { border-color: var(--accent); }
.history-list li .h-mode { font-weight: 700; color: var(--accent); margin-right: 6px; }
.history-list li .h-prompt { color: var(--muted); display: block; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-list li .h-status { float: right; font-size: 11px; }
.history-list li .h-status.completed { color: var(--success); }
.history-list li .h-status.error { color: var(--error); }
.history-list li .h-status.running, .history-list li .h-status.queued { color: var(--muted); }
