:root {
  --ui-color-scheme: dark;
  --bg-1: #1a1916;
  --bg-2: #23211d;
  --surface: rgba(26, 25, 22, 0.9);
  --surface-soft: rgba(232, 229, 222, 0.06);
  --surface-accent: rgba(232, 229, 222, 0.08);
  --surface-danger: rgba(217, 137, 158, 0.12);
  --input-bg: #22201b;
  --border: #2e2c28;
  --border-strong: rgba(232, 229, 222, 0.32);
  --text: #e8e5de;
  --muted: #9a9a98;
  --accent: #e8e5de;
  --accent-2: #d6d2ca;
  --danger: #d9899e;
  --success: #9fd8bc;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  --page-glow-a: rgba(232, 229, 222, 0.06);
  --page-glow-b: rgba(232, 229, 222, 0.03);
  --topbar-bg: rgba(26, 25, 22, 0.88);
  --status-strip-bg: rgba(26, 25, 22, 0.9);
  --tabs-bg: rgba(26, 25, 22, 0.88);
  --urgent-surface: rgba(34, 32, 27, 0.94);
  --toast-bg: rgba(26, 25, 22, 0.96);
  --toast-error-bg: rgba(130, 48, 48, 0.34);
  --toast-info-bg: rgba(232, 229, 222, 0.1);
  --button-primary-bg: #e8e5de;
  --button-primary-fg: #1a1916;
  --shadow-inset-btn:
    rgba(255, 255, 255, 0.2) 0 0.5px 0 0 inset,
    rgba(0, 0, 0, 0.28) 0 0 0 0.5px inset,
    rgba(0, 0, 0, 0.16) 0 1px 2px 0;
  --preview-bar-bg:
    linear-gradient(135deg, rgba(255, 145, 88, 0.14), rgba(87, 223, 218, 0.08)),
    rgba(6, 14, 28, 0.97);
  --preview-bar-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 145, 88, 0.12);
  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-main: "DM Sans", "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "DM Sans", "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  color-scheme: var(--ui-color-scheme);
}

:root[data-theme="light"] {
  --ui-color-scheme: light;
  --bg-1: #f7f4ed;
  --bg-2: #f3efe7;
  --surface: rgba(247, 244, 237, 0.92);
  --surface-soft: rgba(28, 28, 28, 0.04);
  --surface-accent: rgba(28, 28, 28, 0.04);
  --surface-danger: rgba(180, 63, 96, 0.1);
  --input-bg: #f7f4ed;
  --border: #eceae4;
  --border-strong: rgba(28, 28, 28, 0.24);
  --text: #1c1c1c;
  --muted: #5f5f5d;
  --accent: #1c1c1c;
  --accent-2: rgba(28, 28, 28, 0.83);
  --danger: #b43f60;
  --success: #2f7e57;
  --shadow: 0 12px 28px rgba(28, 28, 28, 0.09);
  --page-glow-a: rgba(28, 28, 28, 0.04);
  --page-glow-b: rgba(28, 28, 28, 0.03);
  --topbar-bg: rgba(247, 244, 237, 0.88);
  --status-strip-bg: rgba(247, 244, 237, 0.88);
  --tabs-bg: rgba(247, 244, 237, 0.88);
  --urgent-surface: rgba(247, 244, 237, 0.92);
  --toast-bg: rgba(247, 244, 237, 0.97);
  --toast-error-bg: rgba(180, 63, 96, 0.16);
  --toast-info-bg: rgba(28, 28, 28, 0.08);
  --button-primary-bg: #1c1c1c;
  --button-primary-fg: #fcfbf8;
  --shadow-inset-btn:
    rgba(255, 255, 255, 0.4) 0 0.5px 0 0 inset,
    rgba(28, 28, 28, 0.2) 0 0 0 0.5px inset,
    rgba(28, 28, 28, 0.08) 0 1px 2px 0;
  --preview-bar-bg:
    linear-gradient(135deg, rgba(214, 102, 47, 0.12), rgba(13, 143, 137, 0.08)),
    rgba(255, 248, 238, 0.97);
  --preview-bar-shadow: 0 8px 26px rgba(71, 47, 20, 0.2), 0 0 0 1px rgba(214, 102, 47, 0.18);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --ui-color-scheme: light;
    --bg-1: #f7f4ed;
    --bg-2: #f3efe7;
    --surface: rgba(247, 244, 237, 0.92);
    --surface-soft: rgba(28, 28, 28, 0.04);
    --surface-accent: rgba(28, 28, 28, 0.04);
    --surface-danger: rgba(180, 63, 96, 0.1);
    --input-bg: #f7f4ed;
    --border: #eceae4;
    --border-strong: rgba(28, 28, 28, 0.24);
    --text: #1c1c1c;
    --muted: #5f5f5d;
    --accent: #1c1c1c;
    --accent-2: rgba(28, 28, 28, 0.83);
    --danger: #b43f60;
    --success: #2f7e57;
    --shadow: 0 12px 28px rgba(28, 28, 28, 0.09);
    --page-glow-a: rgba(28, 28, 28, 0.04);
    --page-glow-b: rgba(28, 28, 28, 0.03);
    --topbar-bg: rgba(247, 244, 237, 0.88);
    --status-strip-bg: rgba(247, 244, 237, 0.88);
    --tabs-bg: rgba(247, 244, 237, 0.88);
    --urgent-surface: rgba(247, 244, 237, 0.92);
    --toast-bg: rgba(247, 244, 237, 0.97);
    --toast-error-bg: rgba(180, 63, 96, 0.16);
    --toast-info-bg: rgba(28, 28, 28, 0.08);
    --button-primary-bg: #1c1c1c;
    --button-primary-fg: #fcfbf8;
    --shadow-inset-btn:
      rgba(255, 255, 255, 0.4) 0 0.5px 0 0 inset,
      rgba(36, 24, 13, 0.2) 0 0 0 0.5px inset,
      rgba(36, 24, 13, 0.08) 0 1px 2px 0;
    --preview-bar-bg:
      linear-gradient(135deg, rgba(214, 102, 47, 0.12), rgba(13, 143, 137, 0.08)),
      rgba(255, 248, 238, 0.97);
    --preview-bar-shadow: 0 8px 26px rgba(71, 47, 20, 0.2), 0 0 0 1px rgba(214, 102, 47, 0.18);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: var(--font-main);
  background:
    radial-gradient(circle at top left, var(--page-glow-a), transparent 24%),
    radial-gradient(circle at top right, var(--page-glow-b), transparent 22%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

body {
  padding: 8px 8px 24px;
  overflow-x: hidden;
  scroll-padding-top: 120px;
}

/* ── Global form element reset ──────────────────────────────── */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* ── Dark select — prevents OS white background ─────────────── */
select {
  -webkit-appearance: none;
  appearance: none;
  background-color: var(--input-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 4.5L11 1' stroke='%2390a6c9' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px !important;
  color: var(--text);
  cursor: pointer;
}

:root[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 4.5L11 1' stroke='%236d5740' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 4.5L11 1' stroke='%236d5740' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

.shell {
  width: min(100%, 820px);
  margin: 0 auto;
}

.topbar,
.status-strip,
.section-tabs,
.panel,
.summary-card,
.toast {
  backdrop-filter: blur(16px);
}

.topbar {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--topbar-bg);
  box-shadow: var(--shadow);
}

.topbar-row,
.topbar-grid,
.section-tabs,
.status-row,
.panel-head,
.queue-actions,
.transport-buttons,
.slider-meta,
.viewer-badge,
.chip-row,
.library-actions,
.form-actions,
.inline-action {
  display: flex;
}

.topbar-row {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-row > .button-compact,
.topbar-row > .theme-toggle-button,
.topbar-row > .topbar-back {
  flex-shrink: 0;
}

.topbar-row-sub {
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-mark {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255, 145, 88, 0.18), rgba(87, 223, 218, 0.12));
}

.venue-field {
  flex: 1 1 auto;
  min-width: 0;
}

.venue-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 36px 8px 12px;
  background-color: var(--input-bg);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}

.icon-button-round {
  min-height: 42px;
  min-width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  margin-left: auto;
}

.status-cluster .pill {
  padding: 4px 9px;
  font-size: 11px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
}

h1 {
  font-size: 30px;
  line-height: 0.96;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 25px;
  line-height: 1.02;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 20px;
}

.button,
.icon-button {
  appearance: none;
  border: none;
  border-radius: 999px;
  min-height: 46px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 150ms ease, transform 150ms ease, background 150ms ease;
}

.button:disabled,
.icon-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.icon-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
}

.icon-button-ghost {
  background: rgba(255, 255, 255, 0.03);
}

.button-primary {
  color: var(--button-primary-fg);
  background: var(--button-primary-bg);
  box-shadow: var(--shadow-inset-btn);
}

.button-secondary {
  color: var(--text);
  background: rgba(87, 223, 218, 0.11);
  border: 1px solid rgba(87, 223, 218, 0.22);
}

.button-danger {
  color: var(--danger);
  background: rgba(255, 154, 176, 0.12);
  border: 1px solid rgba(255, 154, 176, 0.22);
}

.button-compact {
  min-height: 42px;
}

.theme-toggle-button {
  min-height: 42px;
  min-width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  flex-shrink: 0;
}

.button-ghost {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.button-ghost:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.switch input:disabled + span {
  opacity: 0.6;
  text-decoration: line-through;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.inline-edit-grid input,
.inline-action input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background-color: var(--input-bg);
  color: var(--text);
}

.field input:focus,
.field select:focus,
.inline-edit-grid input:focus,
.inline-action input:focus {
  outline: none;
  border-color: rgba(87, 223, 218, 0.44);
  box-shadow: 0 0 0 4px rgba(87, 223, 218, 0.08);
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* ── Permission hint shown when field is locked ───────────── */
.permission-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.permission-hint.hidden {
  display: none !important;
}

.audio-device-manual {
  margin-top: 6px;
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
}

.audio-device-manual.hidden {
  display: none !important;
}

/* ── Per-device settings disclosure (Devices panel) ──────── */
.device-settings {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 12px;
}

.device-settings > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  list-style: none;
  user-select: none;
}

.device-settings[open] > summary {
  margin-bottom: 10px;
}

.device-settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.device-settings-grid .field-wide {
  grid-column: 1 / -1;
}

.device-settings-grid select,
.device-settings-grid input[type="text"],
.device-settings-grid input[type="number"] {
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
}

/* ── WebSocket connection status dot ─────────────────────── */
.ws-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 300ms ease, box-shadow 300ms ease;
}

.ws-status-connected {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(134, 235, 178, 0.22);
}

.ws-status-reconnecting {
  background: #ffca67;
  animation: wsPulse 1.1s ease-in-out infinite;
}

.ws-status-disconnected {
  background: var(--danger);
  opacity: 0.8;
}

@keyframes wsPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Form dirty indicator ─────────────────────────────────── */
.settings-save-btn.is-dirty {
  box-shadow: 0 0 0 3px rgba(255, 145, 88, 0.35);
  animation: dirtyPulse 2s ease-in-out infinite;
}

@keyframes dirtyPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 145, 88, 0.35); }
  50%       { box-shadow: 0 0 0 6px rgba(255, 145, 88, 0.15); }
}

/* ── Toast animation ─────────────────────────────────────── */
.toast:not(.hidden) {
  animation: adminToastIn 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes adminToastIn {
  from { transform: translateX(-50%) translateY(12px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}

/* ── Focus-visible ───────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Copy-token button ───────────────────────────────────── */
.copy-token-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: rgba(87, 223, 218, 0.08);
  color: var(--accent-2);
  cursor: pointer;
  transition: background 150ms ease;
}

.copy-token-btn:hover {
  background: rgba(87, 223, 218, 0.16);
}

.copy-token-btn.copied {
  color: var(--success);
  border-color: rgba(134, 235, 178, 0.3);
}

.viewer-badge {
  flex: 1 1 auto;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: 0;
}

.viewer-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.viewer-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-meta {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-level-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-shrink: 0;
}

.viewer-level-label {
  display: none;
}

.viewer-level-picker select {
  min-height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 6px 34px 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

/* ── Level downgrade banner ───────────────────────────────── */
.level-downgrade-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 0;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(220, 160, 30, 0.12);
  border: 1px solid rgba(220, 160, 30, 0.3);
  color: #e8c060;
  font-size: 12px;
  font-weight: 500;
}

.level-downgrade-banner.hidden {
  display: none !important;
}

.level-downgrade-reset {
  flex-shrink: 0;
  background: rgba(220, 160, 30, 0.15);
  border: 1px solid rgba(220, 160, 30, 0.35);
  color: #e8c060;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.level-downgrade-reset:hover {
  background: rgba(220, 160, 30, 0.25);
}

.playback-confirm-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 145, 88, 0.12);
  border: 1px solid rgba(255, 145, 88, 0.34);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

.playback-confirm-banner.hidden {
  display: none !important;
}

.playback-confirm-button {
  flex-shrink: 0;
  background: var(--accent);
  border: none;
  color: #1a0f08;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}

.playback-confirm-button:hover {
  filter: brightness(1.08);
}

.playback-confirm-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.status-row {
  flex-wrap: wrap;
  gap: 8px;
}

.summary-grid {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.summary-grid::-webkit-scrollbar {
  display: none;
}

.summary-card {
  flex: 1 1 0;
  min-width: 124px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)),
    var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.summary-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.summary-card.tone-0 {
  background:
    linear-gradient(135deg, rgba(255, 145, 88, 0.1), rgba(255, 255, 255, 0.02)),
    var(--surface);
}

.summary-card.tone-1 {
  background:
    linear-gradient(135deg, rgba(87, 223, 218, 0.1), rgba(255, 255, 255, 0.02)),
    var(--surface);
}

.summary-card.tone-2 {
  background:
    linear-gradient(135deg, rgba(255, 213, 122, 0.08), rgba(255, 255, 255, 0.02)),
    var(--surface);
}

.summary-card.tone-3 {
  background:
    linear-gradient(135deg, rgba(255, 154, 176, 0.09), rgba(255, 255, 255, 0.02)),
    var(--surface);
}

.summary-label {
  font-size: 11px;
  color: var(--muted);
}

.summary-value {
  margin-top: 0;
  font-weight: 800;
  font-size: 16px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-tabs {
  position: sticky;
  top: 6px;
  z-index: 30;
  margin-top: 12px;
  padding: 6px;
  gap: 6px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--tabs-bg);
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.section-tabs::-webkit-scrollbar {
  display: none;
}

.section-tab {
  appearance: none;
  border: none;
  background: transparent;
  border-radius: 14px;
  min-height: 52px;
  padding: 7px 6px;
  flex: 1;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  min-width: 0;
  flex: 1 1 0;
}

.section-tab > span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-tab > span:not(.tab-icon):not(.tab-count) {
  max-width: 100%;
}

.section-tab .tab-icon {
  font-size: 16px;
  line-height: 1;
}

/* Transport button icon-only style */
.transport-btn {
  min-width: 44px;
  font-size: 15px;
}

/* Admin summary card icon layout */
.summary-icon {
  font-size: 18px;
  line-height: 1;
  margin-bottom: 0;
  flex-shrink: 0;
}

.section-tab.is-active {
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(255, 145, 88, 0.18), rgba(87, 223, 218, 0.14)),
    rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 11px;
}

.tab-count-static {
  color: var(--accent-2);
}

.views {
  margin-top: 12px;
}

/* Specificity (0,2,0) beats .view-stack (0,1,0) which has display:grid */
.admin-view:not(.is-active) {
  display: none;
}
/* Active views inherit display:grid from .view-stack — correct panel layout */

.view-stack,
.settings-stack,
.stack-grid,
.search-stack,
.queue-list,
.source-list,
.library-list {
  display: grid;
  gap: 12px;
}

.panel {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  /* constrain children */
  min-width: 0;
  overflow: hidden;
}

.admin-view[data-admin-view="settings"] .panel,
.admin-view[data-admin-view="settings"] .settings-block {
  overflow: visible;
}

.panel-player {
  background:
    linear-gradient(135deg, rgba(87, 223, 218, 0.1), rgba(255, 145, 88, 0.06)),
    var(--surface);
}

.panel-urgent {
  background:
    linear-gradient(135deg, rgba(255, 154, 176, 0.12), rgba(255, 145, 88, 0.05)),
    var(--urgent-surface);
}

.panel-settings {
  background:
    linear-gradient(135deg, rgba(87, 223, 218, 0.06), rgba(255, 255, 255, 0.02)),
    var(--surface);
}

.panel-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.panel-head-tight {
  margin-bottom: 12px;
}

.track-card,
.queue-item,
.source-item,
.library-item,
.settings-block {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  /* prevent inner content from expanding past the panel */
  min-width: 0;
  overflow: hidden;
}

.queue-main {
  display: grid;
  gap: 6px;
}

.queue-title {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-meta,
.source-meta,
.library-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.queue-actions,
.transport-buttons,
.chip-row,
.library-actions,
.mobile-actions {
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-actions > * {
  flex: 1 1 calc(50% - 4px);
}

.queue-actions > * {
  flex: 1 1 calc(50% - 4px);
}

.pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.pill.info,
.chip {
  color: var(--accent-2);
}

/* ── Chip editor (autoplay themes) ── */
.chip-removable {
  position: relative;
  padding-right: 1.6rem;
}
.chip-remove-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: inherit;
  opacity: 0.6;
  padding: 0 2px;
}
.chip-remove-btn:hover {
  opacity: 1;
}
.chip-empty {
  opacity: 0.45;
  font-style: italic;
}
.chip-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ── Visibility table ── */
.visibility-table-wrap {
  overflow-x: auto;
}
.visibility-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.visibility-table th,
.visibility-table td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.visibility-table th {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
}
.visibility-table td:first-child {
  text-align: left;
  font-weight: 500;
}
.visibility-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.visibility-table input[type="checkbox"]:disabled {
  opacity: 0.4;
  cursor: default;
}
.visibility-table .vis-section-header td {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.4;
  padding-top: 12px;
  padding-bottom: 4px;
  text-align: left;
  font-weight: 700;
}

.pill.success {
  color: var(--success);
}

.pill.danger {
  color: var(--danger);
}

.library-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  /* prevent row from stretching beyond panel */
  min-width: 0;
  overflow: hidden;
}

.library-artwork-wrap,
.artwork {
  width: 72px;
  flex-shrink: 0;
}

.library-artwork-wrap {
  overflow: hidden;
  border-radius: 14px;
}

.artwork {
  width: 72px;
  height: 72px;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0e1829;
  /* never stretch beyond its box */
}

.artwork-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(87, 223, 218, 0.06);
  font-size: 26px;
  overflow: hidden;
  opacity: 0.55;
  user-select: none;
}

.inline-edit-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.track-progress {
  margin-top: 12px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.progress-bar {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* Interactive scrubber: the progress bar itself becomes the seek control. */
.progress-bar.seekable {
  height: 10px;
  overflow: visible;
  cursor: pointer;
  touch-action: none;
}

/* Larger invisible hit area so the thin bar is easy to grab. */
.progress-bar.seekable::before {
  content: "";
  position: absolute;
  inset: -8px 0;
}

.progress-knob {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.progress-bar.seekable:hover .progress-knob,
.progress-bar.seekable.dragging .progress-knob {
  opacity: 1;
}

.transport-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.transport-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.slider-stack,
.slider-field {
  display: grid;
  gap: 8px;
}

.slider-meta {
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.range-input {
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 145, 88, 0.35), rgba(87, 223, 218, 0.35));
  outline: none;
}

.range-input::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(7, 17, 31, 0.9);
  background: #fff;
}

.range-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(7, 17, 31, 0.9);
  background: #fff;
}

.settings-block {
  display: grid;
  gap: 12px;
}

.settings-block-head {
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.settings-grid,
.switch-grid {
  display: grid;
  gap: 10px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.form-actions {
  justify-content: flex-start;
}

.inline-action {
  flex-direction: column;
  gap: 8px;
}

.source-item {
  background:
    linear-gradient(135deg, rgba(87, 223, 218, 0.05), rgba(255, 145, 88, 0.04)),
    rgba(255, 255, 255, 0.04);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: min(92vw, 420px);
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--toast-bg);
  box-shadow: var(--shadow);
  z-index: 100;
}

.settings-save-dock {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(calc(100vw - 24px), 820px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--toast-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  z-index: 210;
}

.settings-save-summary {
  min-width: 0;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-save-button {
  min-height: 42px;
  flex-shrink: 0;
}

body:has(.settings-save-dock:not(.hidden)) {
  padding-bottom: 118px;
}

.hidden {
  display: none !important;
}

.empty-state {
  color: var(--muted);
}

.admin-item .queue-actions {
  margin-top: 10px;
}

.admins-disclosure {
  margin-top: 10px;
}

.admins-disclosure > summary {
  cursor: pointer;
  user-select: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  color: var(--text);
  list-style: none;
}

.admins-disclosure > summary::-webkit-details-marker {
  display: none;
}

.admins-disclosure > summary::before {
  content: "▸";
  display: inline-block;
  width: 14px;
  color: var(--accent-2);
}

.admins-disclosure[open] > summary::before {
  content: "▾";
}

.admins-disclosure > .queue-list {
  margin-top: 10px;
}

/* Per-admin "venue access" matrix inside each admin row. */
.venue-access-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.venue-access-disclosure {
  margin-top: 10px;
}

.venue-access-disclosure > summary {
  cursor: pointer;
  user-select: none;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  list-style: none;
}

.venue-access-disclosure > summary::-webkit-details-marker {
  display: none;
}

.venue-access-disclosure > summary::before {
  content: "▸";
  display: inline-block;
  width: 14px;
  color: var(--accent-2);
}

.venue-access-disclosure[open] > summary::before {
  content: "▾";
}

.venue-access-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.venue-access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.venue-access-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.venue-access-row .venue-access-select {
  flex: 0 0 auto;
  max-width: 50%;
}

.library-disclosure > summary {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 2px;
  list-style: none;
}

.library-disclosure > summary::-webkit-details-marker {
  display: none;
}

.library-disclosure > summary::after {
  content: "▸";
  color: var(--accent-2);
  font-size: 18px;
  line-height: 1;
}

.library-disclosure[open] > summary::after {
  content: "▾";
}

.library-disclosure > .library-list {
  margin-top: 14px;
}

.queue-item.queue-item-background {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.02);
}

.queue-item-background .queue-title,
.queue-item-background .queue-meta {
  color: var(--muted);
}

@media (min-width: 700px) {
  body {
    padding: 12px 12px 30px;
  }

  .summary-grid {
    overflow-x: visible;
  }

  .section-tab {
    display: inline-flex;
    flex-direction: row;
    justify-content: center;
  }

  .view-stack {
    gap: 14px;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .switch-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-edit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .library-card {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .library-artwork-wrap,
  .artwork {
    width: 96px;
    max-width: 96px;
  }

  .artwork {
    width: 96px;
    height: 96px;
    max-width: 96px;
  }

  .inline-action {
    flex-direction: row;
    align-items: stretch;
  }

  .inline-action > input {
    flex: 1;
  }

  .inline-action > button {
    min-width: 160px;
  }
}

/* ── Level-view system ─────────────────────────────────────── */
.level-view {
  display: none;
  grid-template-columns: 1fr;
  gap: 12px;
}

.level-view.is-active {
  display: grid;
}

/* ── Tab hidden for level gating ───────────────────────────── */
.tab-hidden {
  display: none !important;
}

/* ── Settings section locked by level ──────────────────────── */
.level-locked {
  display: none !important;
}

/* ── Level stats row (quick metrics at top of each hub) ─────── */
.level-stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.level-stat-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.level-stat-card.tone-0 {
  background:
    linear-gradient(135deg, rgba(255, 145, 88, 0.12), rgba(255, 255, 255, 0.02)),
    var(--surface);
  border-color: rgba(255, 145, 88, 0.18);
}

.level-stat-card.tone-1 {
  background:
    linear-gradient(135deg, rgba(87, 223, 218, 0.12), rgba(255, 255, 255, 0.02)),
    var(--surface);
  border-color: rgba(87, 223, 218, 0.18);
}

.level-stat-card.tone-2 {
  background:
    linear-gradient(135deg, rgba(255, 213, 122, 0.1), rgba(255, 255, 255, 0.02)),
    var(--surface);
  border-color: rgba(255, 213, 122, 0.18);
}

.level-stat-card.tone-3 {
  background:
    linear-gradient(135deg, rgba(255, 154, 176, 0.12), rgba(255, 255, 255, 0.02)),
    var(--surface);
  border-color: rgba(255, 154, 176, 0.18);
}

.level-stat-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.level-stat-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.level-stat-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.level-stat-value {
  display: block;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Moderation panel accent ───────────────────────────────── */
.panel-moderation {
  background:
    linear-gradient(135deg, rgba(255, 199, 95, 0.1), rgba(255, 145, 88, 0.06)),
    var(--surface);
  border-color: rgba(255, 199, 95, 0.25);
}

/* ── Moderation queue item — amber left accent ─────────────── */
.moderation-item {
  border-left: 3px solid rgba(255, 199, 95, 0.75) !important;
}

/* ── Venue card in L3 sysadmin view ────────────────────────── */
.venue-stat-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* ── Moderation preview player (fixed floating bar) ────────── */
.preview-player-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  /* fixed at bottom so it never pushes other blocks out */
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100vw - 24px), 820px);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--preview-bar-bg);
  backdrop-filter: blur(24px);
  box-shadow: var(--preview-bar-shadow);
  z-index: 200;
  /* prevent its own children from bleeding */
  overflow: hidden;
}

.preview-player-bar.hidden {
  display: none !important;
}

/* push page content up when player is visible */
body:has(.preview-player-bar:not(.hidden)) {
  padding-bottom: 100px;
}

.preview-artwork {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
}

.preview-art-img {
  width: 44px;
  height: 44px;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.preview-art-placeholder {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: rgba(87, 223, 218, 0.1);
  border: 1px solid rgba(87, 223, 218, 0.2);
  border-radius: 10px;
  color: var(--accent-2);
  font-size: 20px;
}

.preview-info {
  flex: 1;
  min-width: 0;
}

.preview-title {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.preview-artist {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.preview-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.preview-progress-bar {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  overflow: hidden;
}

.preview-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
}

.preview-time {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.preview-btn {
  appearance: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: background 150ms ease, transform 100ms ease;
  padding: 0;
}

.preview-btn:hover {
  transform: scale(1.08);
}

.preview-play-btn {
  background: linear-gradient(135deg, var(--accent), #ffb97f);
  color: #fff;
}

.preview-play-btn:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  cursor: default;
  opacity: 0.7;
}

/* loading state — pulse animation while yt-dlp extracts the stream */
.preview-play-btn:disabled[title*="аудиопоток"],
.preview-play-btn:disabled[title*="Получаем"] {
  animation: previewPulse 1.2s ease-in-out infinite;
}

@keyframes previewPulse {
  0%, 100% { opacity: 0.55; }
  50%       { opacity: 0.85; }
}


.preview-close-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* "Listen" button on moderation items */
.moderation-listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 145, 88, 0.3);
  background: rgba(255, 145, 88, 0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease;
}

.moderation-listen-btn:hover {
  background: rgba(255, 145, 88, 0.2);
}

.moderation-listen-btn.is-playing {
  background: rgba(87, 223, 218, 0.12);
  border-color: rgba(87, 223, 218, 0.3);
  color: var(--accent-2);
}

@media (max-width: 560px) {
  .is-telegram .topbar-back {
    display: none;
  }

  .topbar-row {
    align-items: center;
    gap: 8px;
  }

  h1 {
    font-size: 26px;
  }

  .viewer-badge {
    flex-wrap: wrap;
    align-items: center;
  }

  .viewer-level-picker {
    min-width: 0;
  }

  .section-tabs {
    overflow-x: visible;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .section-tabs::-webkit-scrollbar {
    display: none;
  }

  .section-tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: 50px;
    font-size: 12px;
    padding: 8px 4px;
    gap: 2px;
  }

  .section-tab > span:not(.tab-icon):not(.tab-count) {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    line-height: 1.05;
  }

  .section-tab .tab-count {
    min-width: 20px;
    padding: 2px 5px;
    font-size: 10px;
  }

  .level-stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-value {
    font-size: 16px;
  }

  .queue-actions > *,
  .mobile-actions > * {
    flex-basis: 100%;
  }
}

@media (max-width: 420px) {
  .transport-buttons {
    grid-template-columns: 1fr;
  }
}

/* Deep-link target: flash the queue item an admin jumped to from a
   moderation/cash notification so it's easy to spot after the scroll. */
.queue-item.deep-link-highlight {
  animation: deepLinkFlash 4.2s ease-out;
}

@keyframes deepLinkFlash {
  0% {
    box-shadow: 0 0 0 2px var(--success), 0 0 0 6px rgba(159, 216, 188, 0.35);
    background: var(--surface-accent);
  }
  12% {
    box-shadow: 0 0 0 2px var(--success), 0 0 0 10px rgba(159, 216, 188, 0.18);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(159, 216, 188, 0);
    background: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .queue-item.deep-link-highlight {
    animation: none;
    box-shadow: 0 0 0 2px var(--success);
  }
}

/* ── Analytics view ─────────────────────────────────────────── */
.analytics-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.analytics-range {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.range-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.range-btn.is-active {
  background: var(--button-primary-bg);
  color: var(--button-primary-fg);
  font-weight: 600;
}
.analytics-range-label {
  color: var(--muted);
  font-size: 13px;
}
.analytics-refresh {
  margin-left: auto;
}
.analytics-section {
  margin-bottom: 22px;
}
.analytics-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
}
.analytics-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 720px) {
  .analytics-two-col { grid-template-columns: 1fr; }
}

/* Funnel */
.funnel-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex-wrap: wrap;
}
.funnel-step {
  flex: 1 1 0;
  min-width: 78px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}
.funnel-value { font-size: 20px; font-weight: 700; color: var(--text); }
.funnel-label { font-size: 12px; color: var(--muted); }
.funnel-arrow {
  align-self: center;
  color: var(--success);
  font-size: 12px;
  white-space: nowrap;
  padding: 0 2px;
}

/* KPI cards */
.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.kpi-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-value { font-size: 18px; font-weight: 700; color: var(--text); }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

/* Hour chart */
.hour-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 140px;
  padding: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.hour-col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}
.hour-bar {
  width: 70%;
  min-height: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 3px 3px 0 0;
  transition: height 0.2s ease;
}
.hour-tick { font-size: 9px; color: var(--muted); margin-top: 3px; }

/* Tables */
.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.analytics-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.analytics-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.analytics-table td.rank { color: var(--muted); width: 24px; }
.analytics-table .muted, .analytics-table td .muted { color: var(--muted); }
.analytics-note { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }
