/* Voice Transcriber Dashboard */
:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c222b;
  --border: #2d333b;
  --fg: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent-2: #7ee787;
  --warn: #f0883e;
  --err: #ff7b72;
  --queued: #d29922;
  --running: #58a6ff;
  --done: #7ee787;
  --failed: #ff7b72;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft Yahei", "Noto Sans CJK SC", Arial, sans-serif;
  background: var(--bg); color: var(--fg);
  font-size: 14px; line-height: 1.5;
}
small { font-size: 11px; color: var(--muted); }

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(180deg, #181d27, #11151c);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 600; }
.brand h1 small { font-weight: 400; margin-left: 6px; }
.brand .logo { font-size: 22px; }

.stats { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stat {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 10px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.stat .stat-num { font-weight: 700; color: var(--fg); font-size: 14px; }
.stat.queued .stat-num { color: var(--queued); }
.stat.running .stat-num { color: var(--running); }
.stat.done .stat-num { color: var(--done); }
.stat.failed .stat-num { color: var(--failed); }
.stat.ws { padding: 4px 8px; }
.docs-link {
  color: #6fc3ff; text-decoration: none; font-size: 13.5px;
  border: 1px solid #2a4a66; border-radius: 6px; padding: 4px 12px;
  display: inline-flex; align-items: center; transition: background .15s;
}
.docs-link:hover { background: #142030; }
#hwStat { cursor: pointer; }
#hwStat:hover { background: #14201a; border-radius: 4px; }
#hwIcon { font-size: 13px; }
#hwText { color: #7ee2a8; font-weight: 600; }
.hw-modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.hw-modal[hidden] { display: none; }
.hw-panel { background: #0f1a13; border: 1px solid #1e3a2a; border-radius: 10px; padding: 20px 24px; min-width: 380px; max-width: 560px; }
.hw-panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.hw-panel h2 { margin: 0; font-size: 16px; color: #7ee2a8; }
.hw-body table { width: 100%; }
.hw-body th { background: transparent; color: var(--muted); font-weight: 400; width: 40%; }
.hw-body .badge { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 12px; }
.hw-body .badge.cuda { background: #1e3a2a; color: #7ee2a8; border: 1px solid #2a4a36; }
.hw-body .badge.cpu { background: #3a2a1e; color: #ffd166; border: 1px solid #5e4a30; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #14201a; color: #cde3d3; border: 1px solid #1e3a2a;
  border-radius: 8px; padding: 10px 18px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.info { border-color: #2a4a66; }
.stat.ws #wsState { font-size: 12px; }
.stat.ws.ok #wsState { color: var(--done); }
.stat.ws.bad #wsState { color: var(--err); }

/* layout */
.layout {
  display: grid; grid-template-columns: minmax(380px, 460px) 1fr;
  gap: 16px; padding: 16px 24px 48px;
  max-width: 1400px; margin: 0 auto;
}
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.card h2 {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 12px; font-size: 14px; font-weight: 600;
}
.card h2 small { font-weight: 400; }
.card.placeholder { text-align: center; padding: 48px 24px; }

/* form */
form label { display: block; margin-bottom: 12px; }
form label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
form input, form select {
  width: 100%; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--fg); font: inherit;
}
form input:focus, form select:focus { border-color: var(--accent); outline: 0; }
form .row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
form button {
  width: 100%; padding: 10px; font-weight: 600; font-size: 14px;
  background: var(--accent); color: #0d1117;
  border: 0; border-radius: 6px; cursor: pointer;
}
form button:hover { background: #79b8ff; }
form button:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }

/* buttons */
button.mini {
  padding: 3px 10px; font-size: 12px;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; cursor: pointer;
}
button.mini:hover { color: var(--fg); }
button.danger { color: var(--err); }
button.danger:hover { color: #ff9a93; }

/* job list */
.jobs { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; max-height: 56vh; overflow-y: auto; }
.job {
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent; background: var(--panel-2);
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  align-items: start;
}
.job:hover { border-color: var(--border); }
.job.active { border-color: var(--accent); background: #16243a; }
.job-title { font-size: 13px; font-weight: 500; max-width: 280px;
  display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.job-url { font-size: 11px; color: var(--muted); margin-top: 2px; max-width: 280px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .progress {
  grid-column: 1/-1; height: 4px; background: var(--bg);
  border-radius: 2px; overflow: hidden; margin-top: 6px;
}
.job .progress-fill { height: 100%; background: var(--running); width: 0%; transition: width 0.2s; }
.job.status-done .progress-fill { background: var(--done); }
.job.status-failed .progress-fill { background: var(--err); }
.job.status-canceled .progress-fill { background: var(--warn); }
.job.status-done .progress-fill { width: 100% !important; }
.job .status-pill {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--bg); color: var(--muted); white-space: nowrap;
}
.job.status-queued .status-pill { color: var(--queued); }
.job.status-downloading .status-pill, .job.status-transcribing .status-pill, .job.status-translating .status-pill { color: var(--running); }
.job.status-done .status-pill { color: var(--done); }
.job.status-failed .status-pill { color: var(--err); }
.job.status-canceled .status-pill { color: var(--warn); }

/* detail */
.detail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 8px;
}
.detail-head .title { font-size: 16px; font-weight: 600; word-break: break-word; }
.detail-head .meta { font-size: 12px; color: var(--muted); }
.detail-head .actions { display: flex; gap: 8px; }
.detail-section { margin-top: 16px; }
.detail-section h3 {
  margin: 0 0 8px; font-size: 12px; text-transform: uppercase;
  color: var(--muted); letter-spacing: 0.06em;
}
.logs {
  background: #07090d; border-radius: 6px; padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px; height: 320px; overflow-y: auto;
  border: 1px solid var(--border);
}
.log-line { white-space: pre-wrap; word-break: break-all; color: var(--fg); }
.log-line.error { color: var(--err); }
.log-line.sys { color: var(--accent); }
.log-empty { color: var(--muted); text-align: center; padding: 32px; }
.transcript {
  white-space: pre-wrap; word-break: break-word;
  background: var(--panel-2); border-radius: 6px; padding: 16px;
  max-height: 480px; overflow-y: auto;
  border: 1px solid var(--border); font-size: 14px; line-height: 1.7;
}
.transcript.empty { color: var(--muted); text-align: center; }
.summary {
  white-space: pre-wrap; word-break: break-word;
  background: linear-gradient(180deg, #14201a, #101a15);
  border: 1px solid #1e3a2a; border-radius: 6px; padding: 14px 16px;
  font-size: 14.5px; line-height: 1.8;
}
.muted { color: var(--muted); }

a.dl {
  display: inline-block; padding: 6px 12px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--accent); text-decoration: none; font-size: 13px;
  margin-right: 8px;
}
a.dl:hover { background: #20262f; }
audio.dl { display: block; width: 100%; margin-top: 8px; }

.empty-list { color: var(--muted); text-align: center; padding: 24px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .topbar { flex-direction: column; gap: 8px; padding: 12px; }
  form .row { grid-template-columns: 1fr 1fr; }
}
