/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --bg:          #ffffff;
  --surface:     #f5f5f7;
  --border:      #e0e0e3;
  --text:        #1a1a1a;
  --muted:       #6b7280;
  --primary:     #0b5cff;
  --primary-dk:  #0042cc;
  --success:     #16a34a;
  --success-bg:  #dcfce7;
  --success-bd:  #86efac;
  --warning:     #b45309;
  --warning-bg:  #fef3c7;
  --warning-bd:  #fcd34d;
  --danger:      #dc2626;
  --danger-bg:   #fee2e2;
  --danger-bd:   #fca5a5;
  --radius:      8px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #1c1c1e;
    --surface: #2c2c2e;
    --border:  #3a3a3c;
    --text:    #f0f0f0;
    --muted:   #9ca3af;
  }
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background:  var(--bg);
  color:       var(--text);
  font-size:   13px;
  line-height: 1.5;
  min-height:  100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Views ───────────────────────────────────────────────────────────────── */
.view         { display: none; }
.view.active  { display: block; }

/* ── Loading / No-access / Auth centred cards ──────────────────────────── */
.center-card {
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  min-height:      100vh;
  padding:         32px 24px;
  text-align:      center;
  gap:             12px;
}
.center-card h2   { font-size: 18px; font-weight: 600; }
.center-card p    { max-width: 240px; }

.brand-icon-svg {
  width: 52px; height: 52px;
  color: var(--primary);
  stroke: var(--primary);
}
.muted-text   { color: var(--muted); font-size: 13px; }

/* Spinners */
.loader-ring {
  width:  38px; height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.spinner-small {
  width:  20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-top: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Panel header ────────────────────────────────────────────────────────── */
.panel-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         11px 14px;
  background:      var(--bg);
  border-bottom:   1px solid var(--border);
  position:        sticky;
  top: 0;
  z-index: 10;
}
.panel-title { font-weight: 600; font-size: 14px; }
.panel-title-row { display: flex; align-items: center; gap: 6px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display:     inline-flex;
  align-items: center;
  padding:     2px 9px;
  border-radius: 12px;
  font-size:   11px;
  font-weight: 500;
}
.badge-inactive { background: var(--surface); color: var(--muted); }
.badge-active   { background: var(--success-bg); color: var(--success); }
.badge-muted    { background: var(--warning-bg); color: var(--warning); }

/* ── Warning bar ─────────────────────────────────────────────────────────── */
.warning-bar {
  background:   var(--warning-bg);
  color:        var(--warning);
  padding:      8px 14px;
  font-size:    12px;
  border-bottom: 1px solid var(--warning-bd);
}
.warning-bar code {
  background:   var(--warning-bd);
  padding:      1px 4px;
  border-radius: 3px;
  font-size:    11px;
}

/* ── Sections ────────────────────────────────────────────────────────────── */
.section {
  padding:       12px 14px;
  border-bottom: 1px solid var(--border);
}
.section-label {
  font-size:    10.5px;
  font-weight:  600;
  color:        var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

/* ── Mode toggle ─────────────────────────────────────────────────────────── */
.mode-toggle { display: flex; gap: 8px; }

.mode-btn {
  flex:           1;
  display:        flex;
  flex-direction: column;
  align-items:    center;
  gap:            4px;
  padding:        9px 6px;
  border:         1.5px solid var(--border);
  border-radius:  var(--radius);
  background:     var(--surface);
  color:          var(--muted);
  font-size:      12px;
  font-family:    var(--font);
  cursor:         pointer;
  transition:     border-color 0.12s, background 0.12s, color 0.12s;
}
.mode-btn .mode-icon { width: 22px; height: 22px; }
.mode-btn.active {
  border-color: var(--primary);
  background:   #eff4ff;
  color:        var(--primary);
}
@media (prefers-color-scheme: dark) {
  .mode-btn.active { background: #1a2c5c; }
}
.mode-btn:hover:not(.active) { border-color: #aaa; }

/* ── Status row (dot + text) ─────────────────────────────────────────────── */
.status-row {
  display:     flex;
  align-items: center;
  gap:         8px;
  margin-bottom: 10px;
  font-size:   12px;
}

.dot {
  width:  8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-inactive   { background: #9ca3af; }
.dot-active     { background: var(--success); }
.dot-connecting { background: #f59e0b; animation: pulse 1s ease infinite; }
.dot-error      { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Mute button ─────────────────────────────────────────────────────────── */
.btn-mute {
  display:         flex;
  align-items:     center;
  justify-content: center;
  gap:             7px;
  width:           100%;
  padding:         9px;
  border:          1.5px solid var(--border);
  border-radius:   var(--radius);
  background:      var(--surface);
  color:           var(--text);
  font-size:       13px;
  font-family:     var(--font);
  cursor:          pointer;
  transition:      all 0.12s;
}
.btn-mute.muted {
  border-color: var(--warning-bd);
  background:   var(--warning-bg);
  color:        var(--warning);
}
.btn-mute:disabled { opacity: 0.38; cursor: not-allowed; }

/* ── Source toggle ───────────────────────────────────────────────────────── */
.src-toggle { display: flex; gap: 6px; margin-bottom: 8px; }

.src-btn {
  flex:         1;
  padding:      6px;
  border:       1.5px solid var(--border);
  border-radius: 6px;
  background:   var(--surface);
  color:        var(--muted);
  font-size:    12px;
  font-family:  var(--font);
  cursor:       pointer;
  transition:   all 0.12s;
}
.src-btn.active {
  border-color: var(--primary);
  background:   #eff4ff;
  color:        var(--primary);
}
@media (prefers-color-scheme: dark) { .src-btn.active { background: #1a2c5c; } }

/* ── URL row ─────────────────────────────────────────────────────────────── */
.url-row { display: flex; gap: 6px; }

/* ── Participant list ────────────────────────────────────────────────────── */
.participant-search-row {
  display:     flex;
  align-items: center;
  gap:         6px;
  margin-bottom: 8px;
  position:    relative;
}
.participant-search-row .search-icon {
  position:  absolute;
  left:      10px;
  top:       50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.participant-search-row .input { padding-left: 30px; }

.participant-list {
  max-height:  220px;
  overflow-y:  auto;
  display:     flex;
  flex-direction: column;
  gap:         3px;
}

.participant-item {
  display:     flex;
  align-items: center;
  gap:         10px;
  padding:     7px 10px;
  border-radius: 7px;
  cursor:      pointer;
  transition:  background 0.1s;
  user-select: none;
}
.participant-item:hover { background: var(--surface); }

.participant-item input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.participant-avatar {
  width:  28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.participant-name {
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.participant-role {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}

.empty-hint {
  color:     var(--muted);
  font-size: 12px;
  padding:   10px 0;
  text-align: center;
}

/* ── Caption status bar ──────────────────────────────────────────────────── */
.cap-status-bar {
  display:     flex;
  align-items: center;
  gap:         8px;
  padding:     7px 14px;
  font-size:   12px;
  color:       var(--muted);
  border-bottom: 1px solid var(--border);
}

/* ── Caption area ────────────────────────────────────────────────────────── */
.caption-area {
  padding:    16px 14px;
  min-height: 220px;
  font-size:  18px;
  line-height: 1.65;
  overflow-y: auto;
  max-height: calc(100vh - 130px);
}
.cap-placeholder { color: var(--muted); font-size: 14px; }
.cap-para        { margin: 0 0 8px 0; line-height: 1.6; }
.final-text      { display: inline; }
.partial-text    { display: inline; font-style: italic; color: var(--muted); }

/* ── Caption area scrollbar ──────────────────────────────────────────────── */
.caption-area::-webkit-scrollbar        { width: 6px; }
.caption-area::-webkit-scrollbar-track  { background: transparent; }
.caption-area::-webkit-scrollbar-thumb  {
  background:    #9ca3af;
  border-radius: 3px;
}
.caption-area::-webkit-scrollbar-thumb:hover { background: #6b7280; }

/* ── Caption footer ──────────────────────────────────────────────────────── */
.cap-footer {
  display:        flex;
  flex-wrap:      wrap;
  gap:            6px;
  padding:        8px 14px;
  border-top:     1px solid var(--border);
  justify-content: flex-end;
}

/* ── Auto-load label ─────────────────────────────────────────────────────── */
.auto-label {
  display:     flex;
  align-items: center;
  gap:         5px;
  font-size:   12px;
  color:       var(--muted);
  cursor:      pointer;
  user-select: none;
}
.auto-label input { cursor: pointer; }

/* ── Generic inputs ──────────────────────────────────────────────────────── */
.input {
  flex:         1;
  padding:      6px 10px;
  border:       1.5px solid var(--border);
  border-radius: 6px;
  background:   var(--bg);
  color:        var(--text);
  font-size:    13px;
  font-family:  var(--font);
  outline:      none;
  min-width:    0;
}
.input:focus { border-color: var(--primary); }

/* ── Generic buttons ─────────────────────────────────────────────────────── */
.btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             5px;
  padding:         6px 14px;
  border:          1.5px solid var(--border);
  border-radius:   6px;
  background:      var(--surface);
  color:           var(--text);
  font-size:       12px;
  font-family:     var(--font);
  cursor:          pointer;
  transition:      all 0.12s;
  white-space:     nowrap;
}
.btn:hover:not(:disabled) { border-color: #aaa; }
.btn:disabled             { opacity: 0.38; cursor: not-allowed; }

.btn-primary {
  background:   var(--primary);
  border-color: var(--primary);
  color:        #fff;
}
.btn-primary:hover:not(:disabled) {
  background:   var(--primary-dk);
  border-color: var(--primary-dk);
}

.btn-green {
  background:   var(--success-bg);
  border-color: var(--success-bd);
  color:        var(--success);
}
.btn-sm   { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 4px 10px; font-size: 12px; min-width: 36px; }
.btn-full { width: 100%; padding: 10px; font-size: 14px; }

/* ── Font size picker (matches viewer) ───────────────────────────────────── */
.font-picker-wrapper { position: relative; }

.font-picker-toggle  { font-weight: 700; letter-spacing: -0.5px; min-width: 36px; }
.font-picker-toggle.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.font-picker-panel {
  display:       none;
  position:      absolute;
  top:           calc(100% + 8px);
  left:          50%;
  transform:     translateX(-50%);
  z-index:       1000;
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: 12px;
  padding:       12px 10px 10px;
  box-shadow:    0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1);
  min-width:     260px;
}
.font-picker-panel.open { display: block; }

.font-picker-title {
  font-size:      10px;
  font-weight:    600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color:          var(--muted);
  margin-bottom:  8px;
  padding-left:   2px;
}

.font-picker-grid {
  display:               grid;
  grid-template-columns: repeat(3, 1fr);
  gap:                   6px;
}

.font-size-option {
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: flex-end;
  gap:             4px;
  padding:         8px 4px 6px;
  border:          1px solid var(--border);
  border-radius:   8px;
  background:      var(--bg);
  cursor:          pointer;
  color:           var(--text);
  transition:      background 0.12s, border-color 0.12s, transform 0.1s;
  min-height:      60px;
  font-family:     var(--font);
  user-select:     none;
}
.font-size-option:hover   { background: var(--surface); border-color: var(--muted); transform: translateY(-1px); }
.font-size-option:active  { transform: translateY(0); }
.font-size-option.selected {
  background:   var(--surface);
  border-color: var(--text);
  box-shadow:   inset 0 0 0 1px var(--text);
}
.font-size-option .preview-letter { font-weight: 700; line-height: 1; display: block; }
.font-size-option .size-label     { font-size: 10px; color: var(--muted); font-weight: 500; line-height: 1; white-space: nowrap; }
.font-size-option.selected .size-label { color: var(--text); font-weight: 700; }
