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

:root {
  --bg:        #0e0e13;
  --surface:   #18181f;
  --surface2:  #22222c;
  --border:    #2e2e3a;
  --accent:    #9b8cff;
  --accent2:   #c3b8ff;
  --text:      #e8e6f0;
  --text-muted:#8e8aa8;
  --success:   #5cb97e;
  --warning:   #e8a045;
  --danger:    #e05c6e;
  --twitch:    #9146ff;
  --radius:    10px;
  --radius-sm: 6px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
code {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  background: var(--surface2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--accent2);
}

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: 360px;
  padding: 11px 15px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 32px #0008;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.4;
}
.toast-error { border-left-color: var(--danger); }

.login-error {
  max-width: 480px;
  margin: 14px auto;
  padding: 12px 18px;
  background: #3a1b1e;
  border: 1px solid #5a2a30;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.9rem;
  text-align: center;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { filter: brightness(0.9); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

.btn-primary  { background: var(--accent);  color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-twitch   { background: var(--twitch);  color: #fff; font-size: 1rem; padding: 12px 28px; }
.btn-ghost    {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }

/* ── Mode toggle ─────────────────────────────────────────────────────────── */
.mode-toggle { display: flex; gap: 6px; }
.btn-mode {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-mode:hover { color: var(--text); border-color: var(--accent); }
.btn-mode.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-connecting { background: #333; color: var(--text-muted); }
.badge-connected  { background: #1b3a2a; color: var(--success); }
.badge-reconnecting { background: #3a2f1b; color: var(--warning); }
.badge-error      { background: #3a1b1e; color: var(--danger); }
.badge-open       { background: #1b3a2a; color: var(--success); }
.badge-closed     { background: #3a2a1b; color: var(--warning); }

/* ── Login Screen ───────────────────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.login-logo { font-size: 3rem; margin-bottom: 16px; }
.login-card h1 { font-size: 1.6rem; margin-bottom: 10px; }
.login-card p  { color: var(--text-muted); margin-bottom: 32px; line-height: 1.6; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.logo { font-size: 1.4rem; }
.site-title { font-weight: 700; font-size: 1.05rem; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 4px;
}
.header-nav-link {
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.header-nav-link:hover { color: var(--text); }
.header-nav-link.active {
  background: var(--surface2);
  color: var(--text);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

#user-name { font-size: 0.9rem; color: var(--text-muted); }

/* ── Main Layout ────────────────────────────────────────────────────────────── */
#dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 20px 72px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.dash-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dash-left,
.dash-right {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.dash-left .controls {
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}

.dash-center {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Controls ───────────────────────────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.queue-count {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.controls .youtube-connection {
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

/* ── Settings stack ─────────────────────────────────────────────────────────── */
.settings-stack {
  display: flex;
  flex-direction: column;
}

.pane-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
}
.pane-heading .section-title { margin-bottom: 0; }
.pane-heading-hint {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.pane-footer-link {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.pane-footer-link:hover { color: var(--accent2); }

.settings-block {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.settings-stack .settings-block:first-child { border-top: none; }

/* Brief confirmation that an instant-save setting reached the server. */
.settings-block.just-saved {
  animation: savedPulse 1.1s ease-out;
}
@keyframes savedPulse {
  from { background: color-mix(in srgb, var(--success) 20%, transparent); }
  to   { background: transparent; }
}

.settings-block .setting-label {
  color: var(--text);
  font-size: 0.92rem;
}

.chat-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.chat-group-head strong {
  font-size: 0.78rem;
  font-weight: 700;
}

.setting-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.setting-row-end { margin-left: auto; display: flex; gap: 6px; }

.setting-label {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.setting-unit {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.cap-input {
  width: 64px;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: center;
}
.cap-input:focus { outline: none; border-color: var(--accent); }

.setting-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.setting-hint-block {
  display: block;
  margin-top: 6px;
  line-height: 1.4;
}

.youtube-connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent);
}
.status-online {
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 16%, transparent);
}
.status-waiting {
  background: var(--warning);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 16%, transparent);
}
.status-offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent);
}

/* ── Chat messages page ─────────────────────────────────────────────────────── */
.settings-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 96px;
  width: 100%;
}

.settings-intro { margin-bottom: 20px; }
.settings-intro h1 { font-size: 1.5rem; margin-bottom: 6px; }
.settings-intro p {
  max-width: 62ch;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.settings-groups {
  display: grid;
  gap: 14px;
}

.settings-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.settings-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.settings-group-head h2 {
  font-size: 0.95rem;
  font-weight: 700;
}
.settings-group-head p {
  max-width: 60ch;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* A disabled group keeps its wording but stops competing for attention. */
.settings-group.is-off .settings-fields { opacity: 0.45; }

.settings-fields {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.settings-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.settings-field-label {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
}

.settings-field textarea {
  width: 100%;
  resize: vertical;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
}
.settings-field textarea:focus { outline: none; border-color: var(--accent); }

.settings-field-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 20px;
}

.char-count {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.settings-field-number { grid-template-columns: max-content; }
.settings-number-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.placeholder-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
}
.placeholder-chip {
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface2);
  color: var(--accent2);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}
.placeholder-chip:hover { border-color: var(--accent); color: var(--text); }

.chat-save-bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 10px 32px #0008;
  color: var(--text);
  font-size: 0.88rem;
}
.chat-save-bar.is-saved { border-color: var(--success); }
.chat-save-bar.is-saved .btn { display: none; }

/* ── Section titles ─────────────────────────────────────────────────────────── */
.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header .section-title { margin-bottom: 0; }

/* ── Current Card ───────────────────────────────────────────────────────────── */
.current-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.2s;
}

.current-card:not(.empty) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent)22, 0 4px 24px #9b8cff18;
}

.current-empty {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 16px 0;
}

.current-trigger {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent2);
  line-height: 1.3;
}

.current-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.current-meta strong {
  color: var(--text);
  margin-left: 4px;
}

.current-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Queue List ─────────────────────────────────────────────────────────────── */
.queue-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.queue-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 28px 0;
}

.queue-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  transition: border-color 0.15s;
  animation: slideIn 0.2s ease;
}

.queue-item:hover { border-color: var(--accent); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.queue-pos {
  min-width: 26px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.queue-trigger {
  flex: 1;
  font-weight: 600;
  color: var(--text);
}

.queue-user {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.queue-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.queue-remove:hover { color: var(--danger); background: #3a1b1e44; }

/* ── Commands Table ─────────────────────────────────────────────────────────── */
.commands-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.commands-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.commands-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--border)88;
  vertical-align: middle;
}
.commands-table tr:last-child td { border-bottom: none; }

/* ── Collapsible reference ──────────────────────────────────────────────────── */
.reference-block {
  border-top: 1px solid var(--border);
}
.reference-block:last-child { border-bottom: 1px solid var(--border); }

.reference-block > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 2px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.reference-block > summary::-webkit-details-marker { display: none; }
.reference-block > summary::before {
  content: '›';
  display: inline-block;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.15s ease;
}
.reference-block[open] > summary::before { transform: rotate(90deg); }
.reference-block > summary:hover { color: var(--text); }
.reference-block[open] > summary { color: var(--text); }

.reference-body {
  padding: 0 2px 10px;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}
.reference-block .commands-table { margin-bottom: 10px; }

/* ── Manual Add ─────────────────────────────────────────────────────────────── */
.manual-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.manual-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.manual-input {
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.manual-input:focus { outline: none; border-color: var(--accent); }

.manual-trigger {
  flex: 1;
  min-width: 180px;
}

.manual-select {
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.manual-select:focus { outline: none; border-color: var(--accent); }

.queue-edit-input {
  flex: 1;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}
.queue-edit-input:focus { outline: none; }

/* ── Tier badges (priority labels in queue) ─────────────────────────────────── */
/* ── Timer ──────────────────────────────────────────────────────────────────── */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface2);
  border-radius: 24px;
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .switch-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(16px);
  background: #fff;
}

.timer-display {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}
.timer-display.paused {
  color: var(--warning);
}

.btn-timer {
  background: var(--success);
  color: #fff;
}
.btn-timer:hover { filter: brightness(1.15); }

.btn-timer-stop {
  background: var(--warning);
  color: #fff;
}
.btn-timer-stop:hover { filter: brightness(1.15); }

.btn-timer-pause {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-timer-pause:hover { border-color: var(--accent); color: var(--accent2); }

.tier-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
  background: var(--surface2);
  color: var(--accent2);
  border: 1px solid var(--border);
}

/* ── Analytics ──────────────────────────────────────────────────────────────── */
.analytics-main { max-width: 1500px; }

.analytics-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.analytics-intro h1 { font-size: 1.7rem; line-height: 1.2; margin-bottom: 5px; }
.analytics-intro p,
.analytics-range,
.analytics-muted { color: var(--text-muted); }
.analytics-range { font-size: 0.86rem; white-space: nowrap; }

.notice {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  text-align: center;
}
.notice-error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}
/* Shown before the page shell exists, so it needs its own centering. */
#settings-loading {
  max-width: 900px;
  margin: 40px auto;
}

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.analytics-metric {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.analytics-metric span,
.analytics-metric small { color: var(--text-muted); font-size: 0.76rem; }
.analytics-metric strong { font-size: 1.45rem; line-height: 1.2; }

.analytics-workspace {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.analytics-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.analytics-panel-heading h2,
.session-detail-header h2 { font-size: 1.05rem; }
.analytics-panel-heading p,
.session-detail-header p { color: var(--text-muted); font-size: 0.8rem; }

.session-timeline {
  position: relative;
  display: grid;
  gap: 4px;
  max-height: calc(100vh - 250px);
  margin-top: 14px;
  overflow-y: auto;
}
.session-timeline::before {
  content: '';
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 9px;
  width: 1px;
  background: var(--border);
}
.session-timeline-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 10px 8px 10px 2px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.session-timeline-item:hover,
.session-timeline-item.active { background: var(--surface2); border-color: var(--border); }
.timeline-marker {
  z-index: 1;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  margin-top: 1px;
  border: 5px solid var(--surface);
  border-radius: 50%;
  background: var(--text-muted);
}
.session-timeline-item.active .timeline-marker { background: var(--accent); }
.timeline-copy { display: grid; flex: 1; min-width: 0; }
.timeline-copy strong { font-size: 0.87rem; }
.timeline-copy span,
.timeline-copy small { color: var(--text-muted); font-size: 0.75rem; }
.session-open-label {
  color: var(--success);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.session-detail { display: grid; gap: 20px; }
.session-detail-badges { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.analytics-mode { color: var(--accent2); font-size: 0.76rem; font-weight: 700; }
.session-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--border);
}
.session-stat-grid > div { display: grid; gap: 2px; padding: 12px; background: var(--surface2); }
.session-stat-grid strong { font-size: 1.1rem; }
.session-stat-grid span { color: var(--text-muted); font-size: 0.72rem; }

.analytics-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}
.analytics-breakdown,
.session-subsection { display: grid; gap: 10px; }
.analytics-breakdown h3,
.session-subsection h3 { font-size: 0.82rem; }
.breakdown-row { display: grid; gap: 5px; }
.breakdown-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: capitalize;
}
.breakdown-track {
  height: 5px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--surface2);
}
.breakdown-track span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

.analytics-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.analytics-chip {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.76rem;
}
.analytics-chip strong { margin-left: 4px; color: var(--text); }
.top-trigger-list { display: grid; gap: 7px; list-style: none; }
.top-trigger-list li { display: flex; justify-content: space-between; gap: 16px; font-size: 0.8rem; }
.top-trigger-list li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.analytics-table-wrap { overflow-x: auto; }
.analytics-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.analytics-table th {
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.7rem;
  text-align: left;
}
.analytics-table td {
  padding: 9px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  vertical-align: top;
}
.analytics-table td:nth-child(2) { white-space: nowrap; }
.analytics-table td small { display: block; color: var(--text-muted); font-size: 0.68rem; }
.request-status { font-size: 0.7rem; font-weight: 700; }
.request-status-completed { color: var(--success); }
.request-status-skipped,
.request-status-removed { color: var(--warning); }
.request-status-pending { color: var(--text-muted); }
.request-status-in_progress { color: var(--accent2); }
.analytics-empty { padding: 28px 10px; color: var(--text-muted); font-size: 0.86rem; text-align: center; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: 12px 16px; }
  main { padding: 16px 12px 48px; }
  .controls { flex-direction: column; align-items: flex-start; }
  .login-card { padding: 32px 20px; }
  .current-trigger { font-size: 1.2rem; }
  .settings-main { padding: 20px 12px 96px; }
  .settings-group { padding: 16px 14px; }
  .analytics-intro { align-items: flex-start; flex-direction: column; }
  .analytics-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-workspace { grid-template-columns: 1fr; }
  .session-timeline { max-height: 360px; }
  .session-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-breakdown-grid { grid-template-columns: 1fr; }
  #analytics-user-name { display: none; }
  #user-name { display: none; }
}

@media (min-width: 601px) and (max-width: 1000px) {
  .analytics-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .analytics-workspace { grid-template-columns: 1fr; }
  .session-timeline { max-height: 380px; }
}

/* Three panes as soon as there is room for them. This deliberately does not
   gate on aspect ratio — a tall 1400px window still has room for the grid. */
@media (min-width: 1180px) {
  /* The dashboard owns the viewport, so its header does not need to stick.
     Scrolling pages (settings, analytics) keep the sticky header. */
  #dashboard header { position: static; padding: 10px 16px; }
  #dashboard { height: 100vh; overflow: hidden; }
  main.dash-layout {
    max-width: none;
    margin: 0;
    padding: 0;
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(260px, 20vw) minmax(0, 1fr) minmax(240px, 18vw);
    gap: 0;
  }
  .dash-pane {
    min-height: 0;
    overflow: auto;
    background: var(--surface);
  }
  .dash-left,
  .dash-right {
    overflow: hidden;
    border: none;
    border-radius: 0;
  }
  .dash-left { border-right: 1px solid var(--border); }
  .dash-right {
    border-left: 1px solid var(--border);
    overflow: auto;
  }
  .dash-center {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px 20px;
    background: var(--bg);
    overflow: hidden;
  }
  .dash-center .queue-section {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }
  /* Stack the control groups: the rail is too narrow to sit them side by side. */
  .dash-left .controls {
    display: grid;
    gap: 9px;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
  }
  .dash-left .controls-left,
  .dash-left .controls-right { gap: 8px; }
  .dash-left .controls .youtube-connection {
    padding-left: 0;
    border-left: none;
  }
  .dash-left .settings-stack {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }
  .dash-right .commands-section {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 14px 16px;
  }
  .dash-center .current-section,
  .dash-center .manual-section { flex: 0 0 auto; }
}
