:root {
  --bg: #0e0f12;
  --fg: #d8dadf;
  --muted: #8a8f99;
  --card: #1a1c21;
  --card-hover: #22252b;
  --line: #2a2d34;
  --accent: #5fa9ff;
  --ok: #6ed184;
  --bad: #ff7a85;
  --warn: #ffc760;
  --queued: #6cc7ff;
  --preparing: #ffc760;
  --transcribing: #b08bff;
  --done: #6ed184;
  --error: #ff7a85;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  line-height: 1.45;
}

.mono, code { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace; }

.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.grow  { flex: 1 1 auto; }
.ok    { color: var(--ok); }
.bad   { color: var(--bad); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}

header h1 { margin: 0; font-size: 1.4rem; font-weight: 600; }

footer {
  border-top: 1px solid var(--line);
  margin-top: 2rem;
  padding-top: 0.75rem;
  text-align: center;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 720px) {
  .row { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.card-header h2 { margin: 0; font-size: 1rem; font-weight: 600; }

.kvs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  display: inline-block;
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--card-hover);
  color: var(--muted);
  font-weight: 500;
}

.badge.queued      { background: rgba(108,199,255,0.15); color: var(--queued); }
.badge.preparing   { background: rgba(255,199,96,0.15);  color: var(--preparing); }
.badge.transcribing{ background: rgba(176,139,255,0.15); color: var(--transcribing); }
.badge.done        { background: rgba(110,209,132,0.15); color: var(--done); }
.badge.error       { background: rgba(255,122,133,0.15); color: var(--error); }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }

table.compact td, table.compact th { padding: 0.3rem 0.5rem; }

tr.row-error-detail td { border-bottom: none; padding-top: 0; padding-bottom: 0.5rem; }

.workers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.worker {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.worker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mem-bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.2rem;
}

.mem-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ok), var(--warn) 70%, var(--bad) 90%);
  transition: width 0.4s ease;
}

/* Phase 5: job detail + compare */

.badge.variant { background: rgba(176,139,255,0.15); color: var(--transcribing); }

pre.dialog {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  max-height: 60vh;
  overflow-y: auto;
}

pre.json {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-grid input,
.form-grid select,
.advanced textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.9rem;
}

.advanced { margin-bottom: 0.75rem; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; padding: 0.25rem 0; }
.advanced textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 0.82rem; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.form-actions button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.form-actions button:hover { opacity: 0.9; }

/* Click-to-copy button next to truncated job IDs in the recent-jobs
   table. The displayed ID is only the first 12 chars for readability;
   the API matches the full 64-char hash, so users need a way to grab
   the full string. */
.copy-id {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0 0.35rem;
  border-radius: 3px;
  cursor: pointer;
  margin-left: 0.25rem;
  vertical-align: middle;
}
.copy-id:hover { color: inherit; border-color: var(--accent); }

/* Export card — radios + checkboxes for downloading the transcript in
   different formats (json/text/bitrix/srt). */
.export-controls { padding: 0.75rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.export-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.export-label {
  width: 5.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: right;
}
.export-row label { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.9rem; }
.export-row input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--line);
  color: inherit;
  padding: 0.3rem 0.5rem;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.9rem;
  min-width: 14rem;
}
.export-row .button {
  display: inline-block;
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
  padding: 0.4rem 1rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.9rem;
}
.export-row .button:hover { opacity: 0.9; }

tr.self td { background: rgba(95,169,255,0.06); }

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1rem;
}

.drop-zone {
  border: 2px dashed var(--line);
  border-radius: 6px;
  padding: 1.25rem;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(95, 169, 255, 0.08);
}

.drop-zone p { margin: 0.25rem 0; }

.drop-zone button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.35rem 0.8rem;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

#upload-status { margin-top: 0.6rem; min-height: 1em; }
#upload-status.bad { color: var(--bad); }

.dialog-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

.dialog-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border-left: 3px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.015);
}

.dialog-line.sp-1 { border-left-color: var(--accent); }
.dialog-line.sp-2 { border-left-color: var(--warn); }
.dialog-line.sp-3 { border-left-color: var(--ok); }
.dialog-line.sp-4 { border-left-color: var(--transcribing); }

.dialog-meta {
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}
.dialog-line.sp-1 .dialog-meta { color: var(--accent); }
.dialog-line.sp-2 .dialog-meta { color: var(--warn); }
.dialog-line.sp-3 .dialog-meta { color: var(--ok); }
.dialog-line.sp-4 .dialog-meta { color: var(--transcribing); }

.dialog-text { flex: 1 1 240px; min-width: 0; word-wrap: break-word; }
