:root {
  --bg: #0a0b0d; --bg2: #111318; --bg3: #181c24; --bg4: #1e2330;
  --border: #252c3a; --border2: #2e3847;
  --amber: #f59e0b; --amber2: #fbbf24;
  --amber-dim: rgba(245,158,11,0.12); --amber-dim2: rgba(245,158,11,0.06);
  --red: #ef4444; --red-dim: rgba(239,68,68,0.12);
  --green: #10b981; --green-dim: rgba(16,185,129,0.12);
  --blue: #3b82f6;
  --text: #e2e8f0; --text2: #94a3b8; --text3: #4a5568;
  --radius: 6px;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  /* Readable UI / headings (avoid condensed display fonts that collide at small sizes) */
  --font-display: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-mono); font-size: 13px; overflow: hidden; }
.scanline { display: none; }
.noise { position: fixed; inset: 0; pointer-events: none; z-index: 999; opacity: 0.012; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
body { display: flex; }
.sidebar { width: 244px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 22px 0 20px; position: relative; z-index: 10; }
.sidebar::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 1px; background: linear-gradient(to bottom, transparent, var(--border2) 35%, var(--border2) 65%, transparent); opacity: 0.9; }
.brand { display: flex; align-items: flex-start; gap: 12px; padding: 0 18px 20px; border-bottom: 1px solid var(--border); }
.brand-text { min-width: 0; flex: 1; user-select: none; padding-top: 2px; }
.brand-icon { width: 36px; height: 36px; margin-top: 1px; background: var(--amber-dim); border: 1px solid rgba(245,158,11,0.35); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-icon svg { width: 18px; height: 18px; stroke: var(--amber); }
.brand-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
  line-height: 1.35;
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
}
.brand-sub { font-family: var(--font-display); font-size: 12px; color: var(--text2); letter-spacing: 0.02em; font-weight: 500; margin-top: 8px; line-height: 1.4; }
.nav { padding: 12px 0; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: var(--text2); text-decoration: none; font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; border-left: 2px solid transparent; border-radius: 0 6px 6px 0; margin-right: 10px; transition: background 0.12s, color 0.12s, border-color 0.12s; cursor: pointer; }
.nav-item .nav-label { flex: 1; min-width: 0; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { color: var(--text); background: var(--bg3); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active { color: var(--amber); border-left-color: var(--amber); background: var(--amber-dim2); }
.nav-item.active svg { opacity: 1; stroke: var(--amber); }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.transcribe-status { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text3); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text3); flex-shrink: 0; transition: background 0.3s; }
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red); }
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; font-size: 14px; }
.page { display: none; padding: 28px 32px; min-height: 100%; }
.page.active { display: flex; flex-direction: column; gap: 24px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
  line-height: 1.25;
  -webkit-font-smoothing: antialiased;
}
.page-sub { font-family: var(--font-display); color: var(--text2); font-size: 12px; margin-top: 8px; letter-spacing: 0.01em; line-height: 1.45; max-width: 52rem; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius); font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; border: 1px solid; cursor: pointer; transition: all 0.15s; }
.btn svg { width: 13px; height: 13px; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #0a0b0d; }
.btn-primary:hover { background: var(--amber2); border-color: var(--amber2); }
.btn-ghost { background: transparent; border-color: var(--border2); color: var(--text2); }
.btn-ghost:hover { border-color: var(--text3); color: var(--text); background: var(--bg3); }
.btn-danger { background: var(--red-dim); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-sm { padding: 5px 10px; font-size: 10px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-select, .filter-input { background: var(--bg3); border: 1px solid var(--border2); color: var(--text); padding: 7px 10px; border-radius: var(--radius); font-family: var(--font-mono); font-size: 11px; outline: none; }
.filter-select:focus, .filter-input:focus { border-color: var(--amber); }
.clips-container { display: flex; flex-direction: column; gap: 2px; }
.loading-state { display: flex; align-items: center; gap: 12px; padding: 48px; color: var(--text3); justify-content: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border2); border-top-color: var(--amber); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.date-group-header { display: flex; align-items: center; gap: 12px; padding: 16px 0 8px; color: var(--amber); font-family: var(--font-display); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.date-group-header::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.batch-toolbar { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); }
.batch-toolbar[hidden] { display: none !important; }
.batch-combine-label { display: flex; align-items: flex-start; gap: 10px; font-size: 11px; color: var(--text2); line-height: 1.45; cursor: pointer; }
.batch-combine-label input { margin-top: 2px; accent-color: var(--amber); flex-shrink: 0; }
.batch-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.clip-row { display: grid; grid-template-columns: 28px 128px 1fr auto auto auto; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all 0.12s; animation: fadeIn 0.2s ease; }
.clip-cb-cell { display: flex; align-items: center; justify-content: center; }
.clip-cb { width: 14px; height: 14px; accent-color: var(--amber); cursor: pointer; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.clip-row:hover { background: var(--bg3); border-color: var(--border2); }
.clip-row.review-no_speech { border-color: rgba(245,158,11,0.35); }
.clip-review-tag { display: inline-flex; margin-right: 6px; padding: 2px 6px; border-radius: 3px; font-size: 9px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,158,11,0.25); vertical-align: middle; }
.clip-row:hover .clip-time { color: var(--amber); }
.clip-time { font-size: 13px; font-weight: 600; color: var(--text2); font-variant-numeric: tabular-nums; transition: color 0.12s; }
.worker-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; background: var(--bg4); border: 1px solid var(--border2); border-radius: 3px; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; color: var(--text2); }
.worker-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); }
.clip-duration, .clip-size { color: var(--text3); font-size: 11px; }
.clip-status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 3px; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; }
.clip-status.none { background: var(--bg4); color: var(--text3); border: 1px solid var(--border); }
.clip-status.completed { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,185,129,0.2); }
.clip-status.processing { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,158,11,0.2); animation: pulse 1s ease infinite; }
.clip-status.failed { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding-top: 8px; }
.page-info { color: var(--text3); font-size: 11px; }
.empty-state { text-align: center; padding: 64px 24px; color: var(--text3); }
.empty-state svg { width: 48px; height: 48px; opacity: 0.3; margin-bottom: 12px; }
.workers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.worker-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.worker-card.online { border-left: 3px solid var(--green); }
.worker-card.offline { border-left: 3px solid var(--border2); }
.worker-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.worker-hostname { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: 0.01em; line-height: 1.3; }
.worker-status-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 8px; border-radius: 3px; }
.worker-status-badge.online { background: var(--green-dim); color: var(--green); }
.worker-status-badge.offline { background: var(--bg4); color: var(--text3); }
.worker-meta { display: flex; flex-direction: column; gap: 6px; }
.worker-meta-row { display: flex; justify-content: space-between; font-size: 11px; }
.worker-meta-row .label { color: var(--text3); }
.worker-meta-row .value { color: var(--text2); font-weight: 600; }
.worker-token { margin-top: 14px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); font-size: 11px; color: var(--amber); letter-spacing: 0.05em; word-break: break-all; }
.register-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-top: 8px; }
.register-box h3 { font-family: var(--font-display); font-size: 14px; font-weight: 600; margin-bottom: 8px; letter-spacing: 0.01em; }
.register-box p { color: var(--text2); font-size: 11px; line-height: 1.7; }
.token-example { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); font-size: 11px; }
.token-label { color: var(--text3); }
.token-example code { color: var(--amber); font-family: var(--font-mono); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.settings-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.settings-card-header { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--text); padding-bottom: 16px; border-bottom: 1px solid var(--border); letter-spacing: 0.01em; }
.settings-card-header svg { width: 18px; height: 18px; stroke: var(--amber); }
.setting-row { display: flex; flex-direction: column; gap: 6px; }
.setting-row label { font-size: 11px; font-weight: 700; color: var(--text2); letter-spacing: 0.05em; text-transform: uppercase; }
.setting-checkbox-label { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--text); text-transform: none; letter-spacing: normal; }
.setting-checkbox-label input { margin-top: 2px; flex-shrink: 0; }
.setting-hint { font-size: 10px; color: var(--text3); line-height: 1.6; }
.setting-input { background: var(--bg); border: 1px solid var(--border2); color: var(--text); padding: 9px 12px; border-radius: var(--radius); font-family: var(--font-mono); font-size: 12px; outline: none; width: 100%; transition: border-color 0.15s; }
.setting-input:focus { border-color: var(--amber); }
.input-with-browse { display: flex; gap: 8px; }
.input-with-browse .setting-input { flex: 1; }
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider { flex: 1; appearance: none; height: 4px; background: var(--bg4); border-radius: 2px; outline: none; }
.slider::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; background: var(--amber); border-radius: 50%; cursor: pointer; }
.slider-label { font-size: 11px; color: var(--amber); white-space: nowrap; min-width: 120px; }
.transcribe-health-row { display: flex; align-items: center; gap: 12px; }
.health-result { font-size: 11px; }
.health-result.ok { color: var(--green); }
.health-result.err { color: var(--red); }
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg2); border: 1px solid var(--border2); border-radius: 8px; width: 600px; max-width: 95vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,0.6); animation: modalIn 0.2s ease; }
.modal-sm { width: 380px; }
.modal-browse { width: min(92vw, 720px); max-width: 720px; }
.browse-path { display: block; white-space: pre-wrap; word-break: break-all; font-size: 11px; color: var(--text); line-height: 1.35; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.97) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; letter-spacing: 0.01em; line-height: 1.35; }
.modal-meta { color: var(--text3); font-size: 11px; margin-top: 4px; }
.modal-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: var(--radius); }
.modal-close:hover { color: var(--text); background: var(--bg3); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.audio-player { width: 100%; filter: invert(0.9) sepia(0.3) hue-rotate(30deg); border-radius: var(--radius); }
.transcription-box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-height: 100px; max-height: 320px; overflow-y: auto; font-size: 12px; line-height: 1.65; color: var(--text2); }
.transcription-placeholder { color: var(--text3); font-style: italic; margin: 0; }
.transcription-pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); font-size: 12px; line-height: 1.65; color: var(--text2); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.browse-list { display: flex; flex-direction: column; gap: 4px; }
.browse-item { max-width: 100%; padding: 10px 12px; border-radius: var(--radius); cursor: pointer; font-size: 12px; color: var(--text2); border: 1px solid transparent; transition: all 0.1s; overflow-wrap: anywhere; }
.browse-item:hover { background: var(--bg3); color: var(--text); }
.browse-item.selected { background: var(--amber-dim); border-color: var(--amber); color: var(--amber); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--bg3); border: 1px solid var(--border2); border-left: 3px solid var(--amber); padding: 12px 16px; border-radius: var(--radius); font-size: 12px; color: var(--text); z-index: 200; animation: toastIn 0.2s ease; max-width: 320px; }
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
