/* Sortformer 실시간 화자 분리 웹 데모 */

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: #0f0f1a; color: #e0e0e0;
  height: 100vh; display: flex; flex-direction: column;
}

/* Header */
header {
  background: #16182a; padding: 14px 24px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid #2a2d45; flex-shrink: 0;
}
header h1 { font-size: 17px; font-weight: 600; color: #c8cce0; }
.badges { display: flex; gap: 10px; }
.badge { font-size: 11px; padding: 3px 10px; border-radius: 10px; font-weight: 500; }
.badge.off { background: #2a1a1a; color: #a05050; }
.badge.on  { background: #1a2a1a; color: #50a060; }

/* Speaker panel */
.speaker-panel {
  display: flex; gap: 6px; padding: 10px 24px;
  border-bottom: 1px solid #2a2d45; flex-shrink: 0;
}
.spk-meter {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 6px; background: #161830;
}
.spk-meter .lbl { font-size: 11px; font-weight: 700; min-width: 42px; }
.spk-meter .prob { font-size: 10px; color: #888; min-width: 32px; text-align: right; font-variant-numeric: tabular-nums; }
.spk-meter .track { flex: 1; height: 6px; background: #1e2040; border-radius: 3px; overflow: hidden; }
.spk-meter .fill { height: 100%; border-radius: 3px; width: 0%; transition: width 0.12s ease-out; }
.s0 .lbl { color: #5b9bd5; } .s0 .fill { background: #5b9bd5; }
.s1 .lbl { color: #5cc88a; } .s1 .fill { background: #5cc88a; }
.s2 .lbl { color: #f0a050; } .s2 .fill { background: #f0a050; }
.s3 .lbl { color: #e06060; } .s3 .fill { background: #e06060; }

/* Main content */
.main-content {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

/* Section header (shared) */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 24px; background: #16182a; border-bottom: 1px solid #2a2d45;
  flex-shrink: 0;
}
.section-title {
  font-size: 12px; font-weight: 700; color: #888;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.clear-btn {
  padding: 2px 10px; font-size: 11px; background: #1e2040; color: #666;
  border: 1px solid #2a2d45; border-radius: 4px; cursor: pointer;
}
.clear-btn:hover { background: #2a2d45; color: #999; }

/* Diarization log */
.diar-log-container {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.diar-log {
  flex: 1; overflow-y: auto;
}
.diar-log::-webkit-scrollbar { width: 5px; }
.diar-log::-webkit-scrollbar-track { background: transparent; }
.diar-log::-webkit-scrollbar-thumb { background: #2a2d45; border-radius: 3px; }

/* Diarization table */
#diar-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  font-variant-numeric: tabular-nums;
}
#diar-table thead {
  position: sticky; top: 0; background: #0f0f1a; z-index: 1;
}
#diar-table th {
  padding: 6px 12px; text-align: left; color: #666; font-weight: 600;
  border-bottom: 1px solid #2a2d45; font-size: 11px;
}
#diar-table td {
  padding: 3px 12px; border-bottom: 1px solid #1a1c30;
}
.col-time { width: 70px; color: #888; font-size: 11px; }
.col-dom { width: 80px; text-align: center; }

/* Mini probability bars in table */
.mini-bar {
  display: inline-block; width: 60px; height: 4px;
  background: #1e2040; border-radius: 2px; overflow: hidden;
  vertical-align: middle; margin-right: 6px;
}
.mini-fill { height: 100%; border-radius: 2px; }
.mini-bar.s0 .mini-fill { background: #5b9bd5; }
.mini-bar.s1 .mini-fill { background: #5cc88a; }
.mini-bar.s2 .mini-fill { background: #f0a050; }
.mini-bar.s3 .mini-fill { background: #e06060; }
.mini-val { font-size: 10px; color: #666; }

/* Dominant speaker badge */
.dom-badge {
  font-size: 10px; font-weight: 700; padding: 1px 6px;
  border-radius: 3px; background: rgba(255,255,255,0.05);
}

/* Row highlight for dominant speaker */
tr.dom-s0 { background: rgba(91,155,213,0.06); }
tr.dom-s1 { background: rgba(92,200,138,0.06); }
tr.dom-s2 { background: rgba(240,160,80,0.06); }
tr.dom-s3 { background: rgba(224,96,96,0.06); }

/* Intro overlay */
.intro {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; color: #444; min-height: 200px;
  flex: 1;
}
.intro svg { opacity: 0.3; }
.intro p { font-size: 14px; }
.status-msg { text-align: center; color: #555; padding: 10px; font-size: 14px; }

/* ASR panel (collapsible) */
.asr-panel {
  border-top: 1px solid #2a2d45; flex-shrink: 0;
  display: flex; flex-direction: column;
  max-height: 40vh; transition: max-height 0.2s ease;
}
.asr-panel.collapsed { max-height: 32px; overflow: hidden; }
.asr-panel .section-header { cursor: pointer; }
.asr-panel .section-header:hover { background: #1a1d35; }
.toggle-icon { color: #666; font-size: 10px; }
.asr-content {
  flex: 1; overflow-y: auto; padding: 12px 24px;
}
.asr-content::-webkit-scrollbar { width: 5px; }
.asr-content::-webkit-scrollbar-track { background: transparent; }
.asr-content::-webkit-scrollbar-thumb { background: #2a2d45; border-radius: 3px; }

/* Transcript content (inside ASR panel) */
#transcript-content { font-size: 15px; line-height: 1.9; color: #ffffff; }
.spk-token { font-weight: 800; font-size: 13px; }
.c0 { color: #5b9bd5; } .c1 { color: #5cc88a; }
.c2 { color: #f0a050; } .c3 { color: #e06060; }
.c-mixed { color: #bb86fc; }   /* 혼합 화자: 보라색 */
#partial { color: #777; font-style: italic; }

.word-ts {
  display: none;
  font-size: 0.7em;
  color: #7a7d90;
  margin-left: 2px;
  margin-right: 4px;
}
.show-word-timestamps .word-ts { display: inline-block; }

/* Controls */
.controls {
  display: flex; gap: 12px; padding: 14px 24px; background: #16182a;
  border-top: 1px solid #2a2d45; justify-content: center; align-items: center; flex-shrink: 0;
}
button {
  padding: 9px 30px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
button:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-start { background: #2a6b45; color: #c0f0d0; }
.btn-start:hover:not(:disabled) { background: #35845a; }
.btn-stop { background: #6b2a2a; color: #f0c0c0; }
.btn-stop:hover:not(:disabled) { background: #843535; }
.timer { font-size: 13px; color: #555; font-variant-numeric: tabular-nums; min-width: 48px; text-align: center; }
.opt { font-size: 12px; color: #666; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 4px; }
.opt input { cursor: pointer; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.recording .badge.mic-on { animation: pulse 1.5s ease-in-out infinite; }

/* Advanced options panel */
.btn-adv-toggle {
  padding: 4px 14px; font-size: 12px; background: #1e2040; color: #888;
  border: 1px solid #2a2d45; border-radius: 6px; cursor: pointer; font-weight: 500;
}
.btn-adv-toggle:hover { background: #2a2d45; color: #bbb; }

.advanced-panel {
  background: #12142a; border-top: 1px solid #2a2d45;
  padding: 10px 24px; display: flex; flex-direction: column; gap: 8px;
  overflow: hidden; max-height: 200px; transition: max-height 0.25s ease, padding 0.25s ease;
  flex-shrink: 0;
}
.advanced-panel.collapsed { max-height: 0; padding: 0 24px; border-top: none; }

.adv-row {
  display: flex; align-items: center; gap: 16px;
}
.adv-slider-group {
  display: flex; align-items: center; gap: 8px;
}
.adv-slider-group input[type="range"] {
  width: 120px; accent-color: #5b9bd5; cursor: pointer;
}
.adv-val {
  font-size: 12px; color: #aaa; font-variant-numeric: tabular-nums; min-width: 36px;
}
