@import url('https://cdn.jsdelivr.net/npm/inter-ui@4/default/inter.min.css');

:root {
  --bg: #0c0c10;
  --bg-2: #111116;
  --surface: #16161c;
  --surface-2: #1c1c24;
  --surface-3: #23232e;
  --border: #2a2a38;
  --border-light: #35354a;
  --text: #e8e8ef;
  --text-2: #c8c8d8;
  --muted: #7a7a92;
  --accent: #9146ff;
  --accent-2: #7c3aed;
  --accent-glow: rgba(145,70,255,0.15);
  --success: #00f593;
  --success-glow: rgba(0,245,147,0.12);
  --danger: #ff4f4f;
  --warning: #f5a623;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

.logo-img {
  width: 64px; height: 64px;
  display: inline-block;
  flex-shrink: 0;
  object-fit: contain;
}
.logo-img-lg {
  width: 104px; height: 104px;
  margin-bottom: 20px;
}

.channel-page {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 50;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-link { text-decoration: none; line-height: 0; display: inline-flex; }
.sidebar-brand .logo-img { width: 36px; height: 36px; }
.sidebar-channel-info {
  min-width: 0;
  text-align: left;
  flex: 1;
}
.sidebar-channel-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-channel-text {
  min-width: 0;
}
.sidebar-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}
.sidebar-channel-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-channel-name + .badge { margin-top: 2px; display: inline-block; width: fit-content; }

.sidebar-subcount {
  margin: 8px 10px 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sc-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.sc-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.sc-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
}
.sc-value-sm {
  font-size: 17px;
  color: var(--text);
  text-shadow: none;
}
.sc-updated {
  font-size: 10px;
  font-style: italic;
  opacity: 0.75;
}

.sidebar-nav {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.sidebar-nav-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar-nav-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-section {
  flex: 1;
  padding: 8px 10px 0;
  overflow-y: auto;
}
.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sidebar-refresh-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.sidebar-refresh-btn:hover { background: var(--surface-2); color: var(--text); }
.sidebar-stream-list { display: flex; flex-direction: column; gap: 2px; }
.sidebar-stream-item {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  border-left: 3px solid transparent;
}
.sidebar-stream-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar-stream-item.active { background: var(--accent-glow); color: var(--accent); font-weight: 600; border-left-color: var(--accent); }
.sidebar-stream-item.live {
  background: rgba(0,245,147,0.04);
  border-left-color: var(--success);
}
.sidebar-stream-item.live:hover { background: rgba(0,245,147,0.08); }
.sidebar-stream-item.live .ss-title { color: var(--text); }
.sidebar-stream-item .ss-title {
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}
.sidebar-stream-item.live .ss-live-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: var(--success);
  background: rgba(0,245,147,0.1);
  border: 1px solid rgba(0,245,147,0.25);
  padding: 1px 6px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 4px;
  vertical-align: middle;
}
.sidebar-stream-item .ss-meta {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
}
.sidebar-stream-item.active .ss-meta { color: var(--accent); opacity: 0.85; }

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 24px 32px 48px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.dashboard-header {
  margin-bottom: 20px;
}
.dh-back {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 6px;
}
.dh-back:hover { color: var(--accent-2); }
.dh-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.dh-sub {
  font-size: 14px;
  color: var(--muted);
}
.dh-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}
.dh-actions { margin-top: 10px; }

.clips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.clip-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  transition: background 0.12s, border-color 0.12s;
}
.clip-card:hover {
  background: var(--surface-3);
  border-color: var(--border-light);
}
.clip-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.clip-card-creator {
  font-size: 11px;
  color: var(--muted);
}
.clip-card-link {
  display: block;
  color: var(--accent);
  text-decoration: none;
}
.clip-card-link:hover { color: var(--accent-2); text-decoration: underline; }

.not-found-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.not-found-card {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
}
.not-found-card h2 { margin: 16px 0 8px; }
.not-found-card .btn { margin-top: 20px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-live {
  background: var(--success-glow);
  color: var(--success);
  border: 1px solid rgba(0,245,147,0.25);
}
.badge-offline {
  background: rgba(148,163,184,0.08);
  color: var(--muted);
  border: 1px solid rgba(148,163,184,0.18);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  transition: border-color 0.15s;
}
.stat-card:hover { border-color: var(--border-light); }
.stat-card .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.stat-card .value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  overflow-wrap: break-word;
  word-break: break-word;
}
.stat-live {
  border-color: rgba(0,245,147,0.25);
  background: linear-gradient(135deg, rgba(0,245,147,0.04), var(--surface));
}
.stat-live .value { color: var(--success); }

.stat-sub {
  border-color: rgba(245,166,35,0.2);
  background: linear-gradient(135deg, rgba(245,166,35,0.04), var(--surface));
}
.stat-sub .value { color: var(--warning); }

.stat-bits {
  border-color: rgba(145,70,255,0.2);
  background: linear-gradient(135deg, rgba(145,70,255,0.04), var(--surface));
}
.stat-bits .value { color: #c9a8ff; }

.stat-follow {
  border-color: rgba(255,107,107,0.2);
  background: linear-gradient(135deg, rgba(255,107,107,0.04), var(--surface));
}
.stat-follow .value { color: #ff6b6b; }

.stat-raid {
  border-color: rgba(0,245,147,0.2);
  background: linear-gradient(135deg, rgba(0,245,147,0.04), var(--surface));
}
.stat-raid .value { color: #00f593; }

.stat-card .time-window {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-sub .stat-sub, .stat-bits .stat-sub, .stat-follow .stat-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.section-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.01em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filters.filters-right { justify-content: flex-end; }
.filters input, .filters select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.filters input:focus-visible, .filters select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.filters input:focus, .filters select:focus { border-color: var(--accent); }
.filters select.export-select {
  background: var(--surface-3);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--accent-2); }
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--border); }

.chart-container { position: relative; min-height: 220px; height: 260px; }
.chart-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; font-style: italic;
}

.stream-list { display: flex; flex-direction: column; gap: 6px; }
.stream-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.stream-item:hover { background: var(--surface-3); border-color: var(--border-light); }
.stream-item.stream-live { border-color: rgba(0,245,147,0.2); }
.stream-item-title { font-weight: 600; font-size: 13px; }
.stream-item-meta { display: flex; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.stream-item-stats { font-size: 12px; color: var(--muted); flex-shrink: 0; }

.event-feed {
  max-height: 1040px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.event-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.12s, border-color 0.12s;
}
.event-item:hover {
  background: var(--surface-3);
  border-color: var(--border-light);
}
.event-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.event-body { flex: 1; min-width: 0; }
.event-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.event-type { font-weight: 600; font-size: 12px; }
.event-time { color: var(--muted); font-size: 11px; }
.event-detail { font-size: 14px; line-height: 1.55; }
.event-user { font-weight: 700; color: var(--accent); }
.event-highlight { color: var(--warning); font-weight: 600; }
.event-msg { color: var(--muted); font-style: italic; font-size: 13px; }
.event-meta { color: var(--muted); font-size: 12px; }
.event-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.5;
}

.ubadge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-left: 3px;
  vertical-align: middle;
  line-height: 1.6;
}
.ubadge-mod { background: rgba(0,245,147,0.1); color: var(--success); border: 1px solid rgba(0,245,147,0.2); }
.ubadge-vip { background: rgba(232,121,249,0.1); color: #e879f9; border: 1px solid rgba(232,121,249,0.18); }
.ubadge-sub { background: rgba(145,70,255,0.1); color: #c9a8ff; border: 1px solid rgba(145,70,255,0.2); }
.ubadge-gift { background: rgba(255,105,180,0.1); color: #ff69b4; border: 1px solid rgba(255,105,180,0.18); }
.ubadge-anon { background: rgba(148,163,184,0.1); color: #94a3b8; border: 1px solid rgba(148,163,184,0.18); }
.ubadge-multi { background: rgba(250,204,21,0.1); color: #facc15; border: 1px solid rgba(250,204,21,0.18); }
.ubadge-gold { background: rgba(250,204,21,0.12); color: #ffd700; border: 1px solid rgba(250,204,21,0.25); }

.pagination {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
  margin-top: 10px;
  align-items: center;
}
.pagination button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  transition: background 0.12s;
}
.pagination button:disabled { opacity: 0.35; cursor: not-allowed; }
.pagination button:hover:not(:disabled) { background: var(--surface-3); }

.muted { color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .sidebar { width: 220px; }
  .main-content { padding: 16px 20px; }
  .two-col { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filters { gap: 4px; }
  .filters input, .filters select { font-size: 13px; padding: 6px 8px; }
  .filters.filters-right { justify-content: flex-start; margin-top: 6px; }
  .clips-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 640px) {
  .channel-page { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    gap: 8px;
  }
  .sidebar-brand { flex: 1; padding: 0; border-bottom: none; }
  .sidebar-nav { flex: 1; padding: 0; flex-direction: row; gap: 4px; }
  .sidebar-nav-item { font-size: 12px; padding: 5px 8px; white-space: nowrap; }
  .sidebar-section { display: none; }
  .sidebar-footer { display: none; }
  .main-content { padding: 12px 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .dh-title { font-size: 20px; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text-2); }
.btn-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.btn-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px; }
.modal-stream-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.modal-stream-meta { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.modal-stream-meta span { margin-right: 14px; }
.modal-section { margin-bottom: 16px; }
.modal-section-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.modal-vod-link, .modal-clip-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 6px;
  transition: background 0.12s;
}
.modal-vod-link:hover, .modal-clip-link:hover { background: var(--surface-3); }
.modal-clips-list { list-style: none; }
.modal-clips-list li { margin-bottom: 4px; }
.modal-no-data { color: var(--muted); font-size: 13px; font-style: italic; }

.stream-log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
}
.stream-log-item:last-child { margin-bottom: 0; }
.stream-log-game { font-weight: 600; color: var(--text); }
.stream-log-time { color: var(--text-2); font-size: 12px; }
.stream-log-viewers { color: var(--text-2); font-size: 12px; }

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f5;
    --bg-2: #e8e8ee;
    --surface: #ffffff;
    --surface-2: #f0f0f4;
    --surface-3: #e4e4ec;
    --border: #d0d0da;
    --border-light: #e0e0e8;
    --text: #1a1a2e;
    --text-2: #3a3a4e;
    --muted: #8888a0;
    --accent: #7c3aed;
    --accent-2: #5b21b6;
    --accent-glow: rgba(124,58,237,0.12);
  }
  .section, .not-found-card, .stream-item {
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }
}
