:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --bg-2: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f5f7fa;
  --hover: #eaeef4;
  --border: #e2e7ee;
  --border-strong: #cfd6e0;
  --text: #17202e;
  --muted: #667387;
  --faint: #98a3b3;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-soft: rgba(2, 132, 199, .08);
  --accent-line: rgba(2, 132, 199, .30);
  --on-accent: #ffffff;
  --ok: #059669;
  --warn: #b45309;
  --danger: #dc2626;
  --error-text: #991b1b;
  --track: #cfd6e0;
  --bar-bg: #e6ebf1;
  --topbar-bg: rgba(255, 255, 255, .92);
  --json-text: #334155;
  --toast-bg: #17202e;
  --toast-text: #ffffff;
  --shadow: rgba(16, 24, 40, .10);
  --radius: 12px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}
h1, h2 { margin: 0; font-weight: 650; }
h2 { font-size: 14px; letter-spacing: .01em; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }

/* ── 상단바 ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 60px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--topbar-bg); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(2,132,199,.06), rgba(2,132,199,.16));
  color: var(--accent); border: 1px solid var(--accent-line);
}
.brand-mark.big { width: 52px; height: 52px; margin: 0 auto 12px; }
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); font-size: 12px; white-space: nowrap;
}
.pill.subtle { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(138,155,176,.15); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(52,211,153,.18); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(248,113,113,.18); }

/* ── 레이아웃 ───────────────────────────────────────────────────────── */
.layout {
  flex: 1; display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 16px;
  padding: 16px 20px; width: 100%; max-width: 1600px; margin: 0 auto;
}
.sidebar { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.content { min-width: 0; display: flex; flex-direction: column; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 1px 2px var(--shadow);
}
.card.grow { flex: 1; min-height: 240px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head .hint { font-size: 11.5px; color: var(--muted); }
.head-actions { display: flex; gap: 6px; }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); font-size: 11px; text-align: center; color: var(--muted);
}

/* ── 버튼 ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--panel-2); cursor: pointer; font-weight: 600; font-size: 13px;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }

/* ── 업로드 ─────────────────────────────────────────────────────────── */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 26px 14px; text-align: center;
  color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--text); border-style: solid; }
.dz-icon { color: var(--accent); margin-bottom: 6px; }
.dz-title { font-weight: 600; color: var(--text); }
.dz-title u { text-decoration-color: var(--accent); text-underline-offset: 3px; }
.dz-sub { font-size: 12px; margin-top: 2px; }
.pending-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow: auto; }
.pending-list li {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--border); font-size: 12.5px;
}
.pending-list .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-list .psize { color: var(--muted); font-variant-numeric: tabular-nums; }
.pending-list .pdur { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 6px; line-height: 1; }
.icon-btn:hover { color: var(--danger); background: rgba(248,113,113,.12); }

.options { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
select {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 8px 10px; outline: none;
}
select:focus { border-color: var(--accent); }
.switch-field { align-items: flex-start; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; margin-top: 4px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0; background: var(--track); border-radius: 999px; transition: background .15s; cursor: pointer;
}
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(20px); }
.option-note { margin: -2px 0 0; font-size: 11.5px; color: var(--muted); }
.option-note b { color: var(--text); font-weight: 600; }
.upload-progress { display: flex; flex-direction: column; gap: 6px; }
.upload-progress-text { font-size: 12px; color: var(--muted); }
.bar { height: 6px; border-radius: 999px; background: var(--bar-bg); overflow: hidden; }
.bar .fill { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.error-box {
  padding: 9px 11px; border-radius: 8px; background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.35);
  color: var(--error-text); font-size: 12.5px; white-space: pre-wrap;
}

/* ── 작업 목록 ───────────────────────────────────────────────────────── */
.job-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow: auto; max-height: 60vh; }
.job {
  position: relative; display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: start;
  padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.job:hover { border-color: var(--border-strong); }
.job.selected { border-color: var(--accent); background: var(--accent-soft); }
.job .jdot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--muted); }
.job .jdot.queued { background: var(--muted); }
.job .jdot.processing { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.job .jdot.completed { background: var(--ok); }
.job .jdot.no_speech { background: var(--warn); }
.job .jdot.failed { background: var(--danger); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(2,132,199,.40);} 50% { box-shadow: 0 0 0 6px rgba(2,132,199,0);} }
.job .jmain { min-width: 0; }
.job .jname { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .jmeta { font-size: 11.5px; color: var(--muted); margin-top: 1px; display: flex; gap: 6px; flex-wrap: wrap; }
.job .jbar { margin-top: 7px; }
.job .jbar .bar { height: 4px; }
.job .jstage { font-size: 11px; color: var(--muted); margin-top: 4px; }
.job .jright { text-align: right; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.job .jright b { display: block; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.job .jremove { position: absolute; top: 6px; right: 6px; opacity: 0; }
.job:hover .jremove { opacity: 1; }

/* ── 결과 ───────────────────────────────────────────────────────────── */
.empty { color: var(--muted); text-align: center; padding: 24px 12px; }
.empty.tall { background: var(--panel); flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 420px; border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); }
.result { display: flex; flex-direction: column; gap: 14px; }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.result-title h1 { font-size: 19px; word-break: break-all; }
.result-meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 12.5px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--border-strong); background: var(--panel-2); }
.badge.processing { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.badge.completed { color: var(--ok); border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.12); }
.badge.no_speech { color: var(--warn); border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.12); }
.badge.failed { color: var(--danger); border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.12); }
.result-actions { flex-shrink: 0; }
.menu { position: relative; }
.menu-items {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 240px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 12px 30px var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.menu-items button {
  display: grid; grid-template-columns: 52px 1fr; gap: 8px; align-items: center; text-align: left;
  padding: 8px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer;
}
.menu-items button:hover { background: var(--panel-2); }
.menu-items button span { font-size: 12px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; box-shadow: 0 1px 2px var(--shadow); }
.stat-label { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .03em; }
.stat-value { font-size: 18px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-sub { font-size: 10.5px; color: var(--muted); }

.progress-panel {
  display: flex; align-items: center; gap: 22px; padding: 28px 24px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.ring { position: relative; width: 84px; height: 84px; flex-shrink: 0; }
.ring svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--bar-bg); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 213.6; stroke-dashoffset: 213.6; transition: stroke-dashoffset .4s; }
.ring-text { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.progress-stage { font-size: 16px; font-weight: 650; }
.progress-msg, .progress-elapsed { font-size: 12.5px; margin-top: 2px; }
.error-panel { padding: 18px 20px; border-radius: var(--radius); background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.35); }
.error-title { font-weight: 650; color: var(--danger); margin-bottom: 6px; }

.player { background: #000; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.player video { display: block; width: 100%; max-height: 300px; background: #000; }
.player.audio-only { background: var(--panel-2); }
.player.audio-only video { height: 44px; max-height: 44px; background: var(--panel-2); }

.tabs { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab-list { display: flex; gap: 2px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; color: var(--muted); font-weight: 600; cursor: pointer; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-tools { display: flex; align-items: center; gap: 10px; padding-bottom: 6px; }
.speakers { display: flex; gap: 6px; flex-wrap: wrap; }
.spk { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid; }
.search { display: flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.search input { background: none; border: 0; outline: none; color: var(--text); font: inherit; width: 160px; }

.seg-list { display: flex; flex-direction: column; }
.seg {
  display: grid; grid-template-columns: 128px 1fr; gap: 12px; padding: 9px 12px; border-radius: 8px;
  border-left: 3px solid transparent; cursor: pointer; transition: background .12s;
}
.seg:hover { background: var(--panel-2); }
.seg.active { background: var(--accent-soft); border-left-color: var(--accent); }
.seg.hidden { display: none; }
.seg .stime { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.seg .stime small { display: block; color: var(--faint); }
.seg .stext { font-size: 14.5px; line-height: 1.55; }
.seg .stext mark { background: rgba(251,191,36,.35); color: inherit; border-radius: 3px; padding: 0 1px; }
.seg .sspk { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 700; border: 1px solid; vertical-align: 2px; }
.fulltext { padding: 16px 18px; font-size: 15px; line-height: 1.85; white-space: pre-wrap; word-break: keep-all; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.fulltext .turn { display: block; margin-top: 10px; }
.fulltext .turn:first-child { margin-top: 0; }
.json-view { margin: 0; padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; font-family: var(--mono); font-size: 12px; line-height: 1.5; overflow: auto; max-height: 60vh; color: var(--json-text); }

/* ── 푸터·게이트·토스트 ─────────────────────────────────────────────── */
.foot { padding: 14px 20px 20px; font-size: 11.5px; color: var(--muted); text-align: center; }
.foot .sep { margin: 0 8px; }
.gate { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.40); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; }
.gate-card { width: 100%; max-width: 360px; padding: 30px 26px; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 16px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.gate-card h1 { font-size: 20px; }
.gate-card p { margin: 0 0 6px; }
.gate-card input { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 9px; padding: 11px 12px; outline: none; text-align: center; letter-spacing: .1em; }
.gate-card input:focus { border-color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 90; padding: 10px 16px; border-radius: 10px; background: var(--toast-bg); color: var(--toast-text); border: 0; box-shadow: 0 10px 30px var(--shadow); font-size: 13px; white-space: pre-line; }

/* ── 반응형 ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px; }
  .job-list { max-height: 40vh; }
  .empty.tall { min-height: 240px; }
  .topbar { padding: 0 16px; }
  .brand-sub { display: none; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .seg { grid-template-columns: 1fr; gap: 2px; }
  .result-head { flex-direction: column; }
  .queue-pill, #queue-pill { display: none; }
  .search input { width: 110px; }
}
