:root {
  --bg:      #0a0a0f;
  --surface: #111118;
  --surface2:#16161f;
  --border:  #1e1e2e;
  --accent:  #00ff88;
  --accent2: #ff3c6e;
  --accent3: #7b61ff;
  --text:    #e0e0f0;
  --muted:   #555570;
  --warn:    #ffb020;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow Condensed', sans-serif;
  min-height: 100vh;
}

body::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,.04) 2px, rgba(0,0,0,.04) 4px);
  pointer-events: none; z-index: 999;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(0,255,136,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,255,136,.025) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

header {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 36px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
header::after {
  content: '';
  position: absolute; bottom: -1px; left: 36px; right: 36px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent 60%);
}
.logo {
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px; color: var(--accent); letter-spacing: 3px;
}
.logo span { color: var(--muted); }
.logo-sub {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; color: var(--accent3); letter-spacing: 2px;
  padding: 3px 8px; border: 1px solid var(--accent3);
}
.header-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.header-link {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; letter-spacing: 1px; padding: 6px 12px;
  border: 1px solid var(--border); color: var(--muted);
  text-decoration: none; transition: all .2s;
}
.header-link:hover { border-color: var(--accent3); color: var(--accent3); }

.btn {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; letter-spacing: 1px; padding: 8px 16px;
  border: 1px solid; cursor: pointer; background: transparent; transition: all .2s;
}
.btn-primary { border-color: var(--accent);  color: var(--accent);  }
.btn-primary:hover { background: rgba(0,255,136,.08); }
.btn-danger  { border-color: var(--accent2); color: var(--accent2); }
.btn-danger:hover  { background: rgba(255,60,110,.08); }
.btn-purple  { border-color: var(--accent3); color: var(--accent3); }
.btn-purple:hover  { background: rgba(123,97,255,.08); }
.btn-muted   { border-color: var(--border);  color: var(--muted);   }
.btn-muted:hover   { border-color: var(--muted); }
.btn-sm { padding: 5px 10px; font-size: 9px; }

.controls {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 36px 0; flex-wrap: wrap;
}
.ctrl-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; color: var(--muted); letter-spacing: 2px;
}
select {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: 'Share Tech Mono', monospace; font-size: 13px;
  padding: 7px 30px 7px 12px; cursor: pointer; outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23555570'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  min-width: 160px; transition: border-color .2s;
}
select:hover, select:focus { border-color: var(--accent); }
select option { background: #111118; }

.live-badge {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; letter-spacing: 2px; padding: 5px 10px;
  border: 1px solid currentColor;
}
.live-badge.live    { color: var(--accent); text-shadow: 0 0 8px var(--accent); }
.live-badge.offline { color: var(--muted); }

.tab-bar { display: flex; }
.tab {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; letter-spacing: 1px; padding: 7px 14px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer; transition: all .2s;
}
.tab:not(:last-child) { border-right: none; }
.tab.active { background: var(--accent); color: #000; border-color: var(--accent); }
.tab.active-purple { background: var(--accent3); color: #000; border-color: var(--accent3); }

.stats-bar {
  display: flex; gap: 28px; padding: 16px 36px;
  border-bottom: 1px solid var(--border); margin-top: 14px; flex-wrap: wrap;
}
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-label { font-family: 'Share Tech Mono', monospace; font-size: 9px; color: var(--muted); letter-spacing: 2px; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1; color: var(--accent); }
.stat-value.v2 { color: var(--accent3); }
.stat-value.v3 { color: var(--accent2); }

.admin-toolbar {
  display: none; padding: 10px 36px;
  background: rgba(123,97,255,.06);
  border-bottom: 1px solid rgba(123,97,255,.2);
  align-items: center; gap: 10px; flex-wrap: wrap;
}
.admin-toolbar.visible { display: flex; }
.toolbar-label { font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--accent3); letter-spacing: 2px; }

main { padding: 24px 36px 80px; }
.panel { display: none; }
.panel.active { display: block; }

.tbl-header {
  display: grid;
  grid-template-columns: 44px 40px 1fr 140px 180px 52px 80px;
  gap: 0 10px; padding: 0 0 10px;
  border-bottom: 1px solid var(--border);
  font-family: 'Share Tech Mono', monospace; font-size: 9px; color: var(--muted); letter-spacing: 2px;
}
.tbl-header .h-admin { opacity: 0; transition: opacity .3s; }
body.admin-mode .tbl-header .h-admin { opacity: 1; }

.emote-list { list-style: none; }
.emote-row {
  display: grid;
  grid-template-columns: 44px 40px 1fr 140px 180px 52px 80px;
  gap: 0 10px; align-items: center; padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
  animation: rowIn .3s ease both; transition: background .15s;
}
.emote-row:hover { background: rgba(0,255,136,.025); }
@keyframes rowIn { from { opacity:0; transform:translateX(-6px); } to { opacity:1; transform:none; } }

.rank { font-family: 'Share Tech Mono', monospace; font-size: 11px; color: var(--muted); text-align: right; }
.rank.r1 { color: #ffd700; font-size: 14px; } .rank.r2 { color: #c0c0c0; } .rank.r3 { color: #cd7f32; }
.eimg { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.ethumb { max-width: 34px; max-height: 34px; image-rendering: pixelated; filter: drop-shadow(0 0 4px rgba(0,255,136,.2)); transition: transform .2s; }
.emote-row:hover .ethumb { transform: scale(1.3); }
.eph { width: 26px; height: 26px; background: var(--border); opacity: .3; }
.ename { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ecount { font-family: 'Share Tech Mono', monospace; font-size: 18px; font-weight: 600; color: var(--accent); text-align: right; }
.bar-wrap { height: 5px; background: var(--border); overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent3), var(--accent)); transform-origin: left; animation: barGrow .6s cubic-bezier(.16,1,.3,1) both; }
@keyframes barGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.row-acts { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
.emote-row:hover .row-acts { opacity: 1; }
body:not(.admin-mode) .row-acts { display: none; }
.ra {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: transparent; cursor: pointer; font-size: 11px; color: var(--muted); transition: all .15s;
}
.ra.edit:hover { border-color: var(--warn); color: var(--warn); }
.ra.del:hover  { border-color: var(--accent2); color: var(--accent2); }

.emote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 10px; list-style: none; }
.grid-card {
  background: var(--surface); border: 1px solid var(--border);
  padding: 14px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: border-color .2s, transform .2s; animation: cardIn .3s ease both; position: relative;
}
.grid-card:hover { border-color: var(--accent); transform: translateY(-3px); }
@keyframes cardIn { from { opacity:0; transform:scale(.92); } to { opacity:1; transform:scale(1); } }
.grid-rank { position: absolute; top: 5px; left: 7px; font-family: 'Share Tech Mono', monospace; font-size: 9px; color: var(--muted); }
.grid-del {
  position: absolute; top: 4px; right: 4px; width: 18px; height: 18px;
  display: none; align-items: center; justify-content: center;
  background: rgba(255,60,110,.15); border: 1px solid var(--accent2); color: var(--accent2); cursor: pointer; font-size: 9px;
}
body.admin-mode .grid-del { display: flex; }
.gimg { max-width: 50px; max-height: 50px; image-rendering: pixelated; transition: transform .2s; }
.grid-card:hover .gimg { transform: scale(1.1); }
.gph { width: 36px; height: 36px; background: var(--border); opacity: .25; }
.gname { font-size: 12px; font-weight: 600; text-align: center; word-break: break-all; line-height: 1.2; }
.gcount { font-family: 'Share Tech Mono', monospace; font-size: 15px; color: var(--accent); font-weight: 700; }

.stream-list-wrap { display: flex; flex-direction: column; gap: 6px; }
.stream-card {
  background: var(--surface); border: 1px solid var(--border);
  padding: 14px 18px; display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: border-color .2s;
}
.stream-card:hover { border-color: var(--accent); }
.stream-card.live-now { border-color: var(--accent); box-shadow: 0 0 12px rgba(0,255,136,.1); }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.sdot.live { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.sinfo { flex: 1; min-width: 0; }
.stitle { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.smeta  { font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--muted); margin-top: 3px; }
.stotals { font-family: 'Share Tech Mono', monospace; font-size: 12px; color: var(--accent3); flex-shrink: 0; text-align: right; }
.stream-del {
  font-family: 'Share Tech Mono', monospace; font-size: 9px; padding: 4px 8px;
  border: 1px solid var(--accent2); color: var(--accent2); background: transparent;
  cursor: pointer; display: none; flex-shrink: 0; transition: background .2s;
}
body.admin-mode .stream-del { display: block; }
.stream-del:hover { background: rgba(255,60,110,.1); }

.stream-drawer {
  display: none; background: var(--surface2);
  border: 1px solid rgba(0,255,136,.15); border-top: none; padding: 16px 18px;
}
.stream-drawer.open { display: block; }
.drawer-title { font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--muted); letter-spacing: 2px; margin-bottom: 12px; }
.drawer-row {
  display: grid; grid-template-columns: 36px 36px 1fr 100px 52px;
  gap: 0 10px; align-items: center; padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.dr { font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--muted); text-align: right; }
.dc { font-family: 'Share Tech Mono', monospace; font-size: 14px; color: var(--accent); text-align: right; }
body:not(.admin-mode) .drawer-acts { display: none; }

.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75); backdrop-filter: blur(4px);
  z-index: 200; display: none; align-items: center; justify-content: center;
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface2); border: 1px solid var(--border);
  width: 100%; max-width: 420px; padding: 32px; position: relative;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(.96) translateY(8px); } to { opacity:1; transform:none; } }
.modal::before {
  content: ''; position: absolute; top: -1px; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent3), var(--accent2));
}
.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.modal-sub   { font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--muted); margin-bottom: 24px; }
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.field-label { font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--muted); letter-spacing: 2px; display: block; margin-bottom: 6px; }
.field-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: 'Share Tech Mono', monospace; font-size: 14px;
  padding: 10px 12px; outline: none; margin-bottom: 18px; transition: border-color .2s;
}
.field-input:focus { border-color: var(--accent); }
.field-input[type=password]:focus { border-color: var(--accent3); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.err { font-family: 'Share Tech Mono', monospace; font-size: 11px; color: var(--accent2); min-height: 16px; margin-bottom: 12px; letter-spacing: .5px; }

.admin-section {
  background: var(--surface); border: 1px solid var(--border);
  padding: 24px; margin-bottom: 16px;
}
.admin-section-title {
  font-family: 'Share Tech Mono', monospace; font-size: 11px; color: var(--accent3);
  letter-spacing: 3px; margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.04); gap: 16px;
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 15px; font-weight: 600; }
.setting-desc  { font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--muted); margin-top: 3px; }
.badge {
  font-family: 'Share Tech Mono', monospace; font-size: 9px; letter-spacing: 1px;
  padding: 3px 8px; border: 1px solid currentColor;
}
.badge-live    { color: var(--accent); }
.badge-offline { color: var(--muted); }
.badge-legacy  { color: var(--warn); }

.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 70px 0; gap: 8px;
  font-family: 'Share Tech Mono', monospace; font-size: 11px; color: var(--accent); letter-spacing: 3px;
}
.dot { width: 5px; height: 5px; background: var(--accent); border-radius: 50%; animation: pulse 1.2s ease-in-out infinite; }
.dot:nth-child(2) { animation-delay: .2s; } .dot:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%,80%,100% { transform:scale(.6); opacity:.3; } 40% { transform:scale(1); opacity:1; } }
.empty { display: flex; flex-direction: column; align-items: center; padding: 70px 0; gap: 10px; color: var(--muted); }
.empty-icon { font-size: 44px; opacity: .25; }
.empty-text { font-family: 'Share Tech Mono', monospace; font-size: 12px; letter-spacing: 2px; }

footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 14px 36px;
  border-top: 1px solid var(--border);
  background: rgba(10,10,15,.97); backdrop-filter: blur(8px);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px;
  font-family: 'Share Tech Mono', monospace; font-size: 12px; color: var(--muted); letter-spacing: .5px; z-index: 100;
}

@media (max-width: 700px) {
  header, .controls, .stats-bar, main { padding-left: 14px; padding-right: 14px; }
  .tbl-header, .emote-row { grid-template-columns: 34px 36px 1fr 80px; }
  .bar-wrap, .row-acts, .h-bar, .h-act, .h-pct { display: none; }
}

.settings-tab {
  font-family: 'Share Tech Mono', monospace; font-size: 10px; letter-spacing: 1px;
  padding: 8px 16px; border: none; border-bottom: 2px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; transition: all .2s;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent3); border-bottom-color: var(--accent3); }

.settings-panel { animation: rowIn .2s ease; }

.channel-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--border);
  transition: border-color .2s;
}
.channel-item:hover { border-color: var(--accent3); }
.channel-name {
  font-family: 'Share Tech Mono', monospace; font-size: 13px; color: var(--text);
}
.channel-badges { display: flex; align-items: center; gap: 8px; }

.stream-card.untracked-stream { opacity: 0.65; border-style: dashed; }
.stream-card.untracked-stream:hover { opacity: 1; border-color: var(--warn); border-style: solid; }
.badge-untracked { color: var(--warn); border-color: var(--warn); }

/* ── Global Notification Banner ─────────────────────────────────────────── */
#global-notifications {
  position: sticky;
  top: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.notif-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.5px;
  line-height: 1.5;
  border-bottom: 1px solid transparent;
  animation: notifSlide .3s ease;
  justify-content: center;
  text-align: center;
}
@keyframes notifSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.notif-bar.notif-info {
  background: rgba(0, 255, 136, 0.08);
  border-color: rgba(0, 255, 136, 0.25);
  color: var(--accent);
}
.notif-bar.notif-warn {
  background: rgba(255, 176, 32, 0.08);
  border-color: rgba(255, 176, 32, 0.25);
  color: var(--warn);
}
.notif-bar.notif-alert {
  background: rgba(255, 60, 110, 0.08);
  border-color: rgba(255, 60, 110, 0.25);
  color: var(--accent2);
}

.notif-icon { font-size: 14px; flex-shrink: 0; }
.notif-msg  { }
.notif-dismiss {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
  transition: opacity .2s;
  flex-shrink: 0;
}
.notif-dismiss:hover { opacity: 1; }

.notif-list-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 6px;
  transition: border-color .2s;
}
.notif-list-item:hover { border-color: var(--accent3); }
.notif-list-item.inactive { opacity: 0.45; }

.notif-type-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
}
.notif-type-dot.info  { background: var(--accent); }
.notif-type-dot.warn  { background: var(--warn); }
.notif-type-dot.alert { background: var(--accent2); }