* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; background:#0e0e10; color:#efeff1; }
.container { max-width:1600px; margin:0 auto; padding:24px; }
h1 { font-size:26px; margin-bottom:24px; color:#bf94ff; font-weight: 800; letter-spacing: -0.5px; }
.card { background:#1f1f23; border-radius:16px; padding:24px; margin-bottom:24px; border:1px solid #2d2d30; box-shadow: 0 4px 12px rgba(0,0,0,0.2); transition: transform 0.2s ease, box-shadow 0.2s ease; }
label { display:block; font-size:14px; font-weight:600; margin-bottom:8px; color:#adadb8; }
select, input, textarea { width:100%; padding:10px 14px; border-radius:10px; border:2px solid #3a3a3d; background:#18181b; color:#efeff1; font-size:14px; transition: border-color 0.2s ease, background 0.2s ease; }
select:focus, input:focus, textarea:focus { outline:none; border-color:#772ce8; background: #202024; }
button { padding:10px 20px; border:none; border-radius:10px; cursor:pointer; font-size:14px; font-weight:700; transition: all 0.2s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background:#772ce8; color:#fff; }
.btn-primary:hover { background:#9147ff; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(119, 44, 232, 0.3); }
.btn-primary:active { transform: translateY(0); }
.btn-danger { background:#e91916; color:#fff; }
.btn-danger:hover { background:#ff4f4d; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(233, 25, 22, 0.3); }
.btn-secondary { background:#3a3a3d; color:#efeff1; }
.btn-secondary:hover { background:#4e4e52; transform: translateY(-1px); }
.btn-secondary.btn-active { background:#772ce8; }
.btn-sm { padding:6px 12px; font-size:12px; border-radius:8px; }
.toggle-switch { position:relative; display:inline-block; width:48px; height:26px; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-slider { position:absolute; cursor:pointer; inset:0; background:#3a3a3d; border-radius:26px; transition:.3s; }
.toggle-slider:before { position:absolute; content:""; height:20px; width:20px; left:3px; bottom:3px; background:#fff; border-radius:50%; transition:.3s; }
.toggle-switch input:checked + .toggle-slider { background:#772ce8; }
.toggle-switch input:checked + .toggle-slider:before { transform:translateX(22px); }
.toggle-label { display:flex; flex-direction:column; gap:2px; }
.toggle-label span:first-child { font-size:14px; font-weight:600; }

details.alert-vars-dropdown { background:transparent; border:none; padding:8px 10px; }
details.alert-vars-dropdown > summary { list-style:none; cursor:pointer; font-size:14px; font-weight:600; user-select:none; outline:none; color:#adadb8; }
details.alert-vars-dropdown > summary::-webkit-details-marker { display:none; }
details.alert-vars-dropdown > summary::before { content:"▸"; display:inline-block; margin-right:6px; color:#adadb8; transition:transform .2s; }
details.alert-vars-dropdown[open] > summary::before { transform:rotate(90deg); }
details.alert-vars-dropdown > summary::after { content:""; }
#default-alert-font-card > summary > span:first-child { display:inline-block; transition:transform .2s; }
#default-alert-font-card[open] > summary > span:first-child { transform:rotate(90deg); }
.toggle-desc { font-size:11px; color:#adadb8; }
.disabled-row { opacity:0.5; }
.disabled-row td:first-child::before { content:"✗ "; color:#e91916; }
.table-toggle { position:relative; display:inline-block; width:40px; height:22px; margin-right:6px; }
.table-toggle input { opacity:0; width:0; height:0; }
.table-toggle .toggle-slider { position:absolute; cursor:pointer; inset:0; background:#3a3a3d; border-radius:22px; transition:.3s; }
.table-toggle .toggle-slider:before { position:absolute; content:""; height:16px; width:16px; left:3px; bottom:3px; background:#fff; border-radius:50%; transition:.3s; }
.table-toggle input:checked + .toggle-slider { background:#772ce8; }
.table-toggle input:checked + .toggle-slider:before { transform:translateX(18px); }
table { width:100%; border-collapse:separate; border-spacing: 0; }
th, td { text-align:left; padding:14px 16px; border-bottom:1px solid #2d2d30; }
th { font-size:11px; text-transform:uppercase; color:#adadb8; font-weight:700; letter-spacing: 0.5px; }
th.sortable { cursor:pointer; user-select:none; }
th.sortable:hover { color:#efeff1; }
th.sortable .sort-ind { display:inline-block; margin-left:6px; font-size:10px; color:#772ce8; }
th.sort-active { color:#efeff1; }
tr:last-child td { border-bottom: none; }
tr:hover td { background:rgba(255,255,255,0.02); }

.alert-history-table { table-layout:fixed; }
.alert-history-table td { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; vertical-align:middle; }
.alert-history-table td span { max-width:100%; overflow:hidden; text-overflow:ellipsis; }
tr:first-child td:first-child { border-top-left-radius: 12px; }
tr:first-child td:last-child { border-top-right-radius: 12px; }
tr:last-child td:first-child { border-bottom-left-radius: 12px; }
tr:last-child td:last-child { border-bottom-right-radius: 12px; }
.actions { display:flex; gap:8px; }
.toolbar { display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; }
.empty { text-align:center; padding:60px 20px; color:#5a5a5f; font-size: 15px; }
.loading { text-align:center; padding:60px 20px; color:#772ce8; font-weight: 600; }
.tabs-wrap { display: flex; align-items: center; gap: 8px; max-width: 100%; }
.tabs { display:flex; gap:4px; margin-bottom:0; background: #18181b; padding: 6px; border-radius: 14px; border: 1px solid #2d2d30; width: fit-content; max-width: 100%; flex-wrap: nowrap; align-items: stretch; overflow-x: auto; min-width: 0; }
.tabs::-webkit-scrollbar { height: 6px; }
.tabs::-webkit-scrollbar-thumb { background: #2d2d30; border-radius: 4px; }
.more-wrap { position: relative; flex: 0 0 auto; }
.tab { padding:8px 18px; cursor:pointer; color:#adadb8; font-weight:600; font-size:14px; border-radius:10px; transition: all 0.2s ease; white-space: nowrap; flex: 0 0 auto; }
.tab:hover { color:#efeff1; background: rgba(255,255,255,0.05); }
.tab.active { color:#fff; background:#772ce8; box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
.tab.tab-more { padding:8px 14px 8px 18px; background: rgba(255,255,255,0.03); border: 1px solid #2d2d30; }
.tab.tab-more[aria-expanded="true"] { color:#fff; background:#772ce8; }
.more-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px; background: #1d1d20; border: 1px solid #2d2d30; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); padding: 6px; z-index: 200; }
.more-menu-item { padding: 8px 14px; cursor: pointer; color: #adadb8; font-weight: 600; font-size: 13px; border-radius: 6px; }
.more-menu-item:hover { color:#efeff1; background: rgba(255,255,255,0.05); }
.more-menu-item.active { color:#fff; background:#772ce8; }
.tab-content { display:none; }
.tab-content.active { display:block; }
.modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.8); justify-content:center; align-items:center; z-index:100; backdrop-filter: blur(4px); }
.modal-overlay.active { display:flex; }
.modal { background:#1f1f23; border-radius:20px; padding:32px; width:90%; max-width:560px; max-height:90vh; overflow-y:auto; border:1px solid #3a3a3d; box-shadow: 0 20px 40px rgba(0,0,0,0.4); }
.modal h2 { margin-bottom:24px; color:#bf94ff; font-weight: 800; }
.form-group { margin-bottom:18px; }
.form-row { display:flex; gap:16px; }
.form-row .form-group { flex:1; }
.modal-actions { display:flex; gap:12px; justify-content:flex-end; margin-top:28px; }
.badge { display:inline-block; padding:4px 10px; border-radius:20px; font-size:11px; font-weight:700; text-transform: uppercase; }
.badge-all { background:#2d2d30; color:#adadb8; border:1px solid #3a3a3d; }
.badge-owner { background:rgba(191, 148, 255, 0.1); color:#bf94ff; border:1px solid #772ce8; }
.badge-broadcaster { background:rgba(0, 239, 139, 0.1); color:#00ef8b; border:1px solid #00ef8b; }
.badge-moderator { background:rgba(0, 184, 239, 0.1); color:#00b8ef; border:1px solid #00b8ef; }
.badge-vip { background:rgba(239, 184, 0, 0.1); color:#efb800; border:1px solid #efb800; }
.badge-elevated { background:rgba(191, 148, 255, 0.15); color:#bf94ff; border:1px solid #bf94ff; }
.error { color:#ff4f4d; padding:16px; background:rgba(233, 25, 22, 0.1); border-radius:12px; margin-bottom:16px; border: 1px solid rgba(233, 25, 22, 0.2); font-weight: 500; }
.fade-in { animation:fadeIn .3s ease-out; }
@keyframes fadeIn { from{opacity:0;transform:translateY(-12px)} to{opacity:1;transform:translateY(0)} }
.vars-help { margin-top:8px; background:#18181b; border-radius:10px; padding:12px; border:1px solid #3a3a3d; }
.vars-table { width:100%; font-size:12px; border-collapse:collapse; }
.vars-table td { padding:6px 8px; border:none; }
.vars-table td:first-child { white-space:nowrap; font-family:monospace; color:#bf94ff; font-weight: 600; }
.vars-table td:last-child { color:#adadb8; }
.response-preview { max-width:300px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color: #efeff1; }
.aliases-cell { font-size:12px; color:#adadb8; font-style: italic; }
.count-val { font-weight:800; font-size:18px; color:#bf94ff; }
.timer-remaining { font-size:12px; color:#adadb8; }
.success { color:#00ef8b; padding:16px; background:rgba(0, 239, 139, 0.1); border-radius:12px; margin-bottom:16px; border: 1px solid rgba(0, 239, 139, 0.2); font-weight: 500; }
.btn-pill { border-radius: 50px; padding: 12px 32px; }
.login-card { text-align: center; max-width: 450px; width: 100%; padding: 48px 32px; }
.login-card h1 { font-size: 32px; margin-bottom: 12px; color: #bf94ff; font-weight: 800; }
.login-card p { color: #adadb8; margin-bottom: 32px; font-size: 16px; line-height: 1.5; }
.login-card .icon-box { margin-bottom: 24px; color: #9147ff; }
.login-card .icon-box svg { width: 64px; height: 64px; }
.alert-event-row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid #2d2d30; }
.alert-event-row:last-of-type { border-bottom: none; }
.alert-event-info { flex: 1; }
.media-preview-thumb { width: 60px; height: 45px; object-fit: cover; border-radius: 8px; background: #18181b; }
.media-type-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.media-type-image { background: rgba(0, 239, 139, 0.1); color: #00ef8b; }
.media-type-video { background: rgba(119, 44, 232, 0.1); color: #bf94ff; }
.media-type-audio { background: rgba(239, 184, 0, 0.1); color: #efb800; }

.media-group-header td { background: #1a1a1d; padding: 8px 12px; border-top: 1px solid #2a2a2e; }
.media-group-header:first-child td { border-top: none; }

.media-player-modal-content {
  max-width: 800px;
  padding: 0;
  overflow: hidden;
}

.media-player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #2d2d30;
}

.media-player-header h3 {
  margin: 0;
  color: #bf94ff;
  font-weight: 800;
  font-size: 18px;
}

.media-player-body {
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  max-height: 70vh;
  overflow: auto;
}

.media-player-body video,
.media-player-body audio {
  outline: none;
}

/* Editor Canvas Elements */
.canvas-widget {
  position: absolute;
  border: 2px solid #772ce8;
  background: rgba(119, 44, 232, 0.15);
  color: white;
  cursor: move;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.canvas-widget:hover {
  background: rgba(119, 44, 232, 0.25);
  border-color: #9147ff;
}
.canvas-widget.selected {
  border-color: #00ef8b;
  background: rgba(0, 239, 139, 0.15);
  box-shadow: 0 0 15px rgba(0, 239, 139, 0.4);
}
.canvas-widget-type {
  font-size: 11px;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 6px;
  letter-spacing: 0.5px;
}
.canvas-widget-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 15px;
  height: 15px;
  cursor: se-resize;
  background: #772ce8;
  border-top-left-radius: 4px;
  border-bottom-right-radius: 4px;
}
.canvas-widget.selected .canvas-widget-resize {
  background: #00ef8b;
}
.overlay-card {
  background: #18181b;
  border-radius: 12px;
  border: 1px solid #2d2d30;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.overlay-card h3 {
  color: #bf94ff;
  font-size: 16px;
}

/* Alert Rule Event Type Badges */
.badge-follow { background: rgba(0, 239, 139, 0.1); color: #00ef8b; border: 1px solid #00ef8b; }
.badge-sub { background: rgba(145, 71, 255, 0.1); color: #9147ff; border: 1px solid #9147ff; }
.badge-subgift { background: rgba(239, 184, 0, 0.1); color: #efb800; border: 1px solid #efb800; }
.badge-subgift_bomb { background: rgba(191, 148, 255, 0.1); color: #bf94ff; border: 1px solid #bf94ff; }
.badge-raid { background: rgba(255, 107, 107, 0.1); color: #ff6b6b; border: 1px solid #ff6b6b; }
.badge-gift { background: rgba(0, 184, 239, 0.1); color: #00b8ef; border: 1px solid #00b8ef; }
.badge-custom { background: rgba(191, 148, 255, 0.1); color: #bf94ff; border: 1px solid #bf94ff; }
.badge-redeem { background: rgba(255, 159, 67, 0.1); color: #ff9f43; border: 1px solid #ff9f43; }
.badge-alertbox { background: rgba(119, 44, 232, 0.1); color: #772ce8; border: 1px solid #772ce8; }

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #18181b;
  border: 2px solid #3a3a3d;
  border-top: none;
  border-radius: 0 0 10px 10px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.search-results.active {
  display: block;
}
.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #2d2d30;
  transition: background 0.2s ease;
}
.search-result-item:last-child {
  border-bottom: none;
}
.search-result-item:hover {
  background: rgba(119, 44, 232, 0.2);
}
.search-result-item img {
  width: 28px;
  height: 38px;
  border-radius: 4px;
  object-fit: cover;
}
.search-result-item .category-name {
  font-size: 14px;
  color: #efeff1;
}

/* =========================================================
   RESPONSIVE — Mobile & Tablet
   Desktop-Styles darüber bleiben UNVERÄNDERT
   ========================================================= */

/* Mobile-Hilfsklassen: auf Desktop no-op */
.mobile-tabs-toggle { display: none; }
.mobile-tabs-toggle::after { content: ""; }

/* ===== Tablets & kleine Laptops (≤ 1024px) ===== */
@media (max-width: 1024px) {
  .container { padding: 16px; max-width: 100%; }
  .card { padding: 18px; border-radius: 14px; }
  .modal { width: 95%; padding: 24px; max-width: 560px; }
  .form-row { gap: 12px; }
}

/* ===== Tablet Portrait & große Phones (≤ 768px) ===== */
@media (max-width: 768px) {
  /* Layout-Grundgerüst */
  .container { padding: 10px; }
  h1 { font-size: 22px; margin-bottom: 14px; }
  .card { padding: 14px; margin-bottom: 14px; border-radius: 12px; }
  .form-group { margin-bottom: 14px; }
  .form-row { flex-direction: column; gap: 0; }
  .form-row .form-group { width: 100%; }

  /* Header oben: vertikal stapeln */
  body > .container > div:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }
  #user-info.header-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }
  #user-info.header-right > a { width: 100%; text-align: center; }

  /* Touch-Targets (Apple HIG: mind. 44×44 px) */
  button { padding: 12px 18px; font-size: 15px; min-height: 44px; }
  .btn-sm { padding: 10px 14px; font-size: 14px; min-height: 40px; }
  .btn-pill { padding: 12px 24px; }
  select, input, textarea {
    padding: 12px 14px;
    font-size: 15px;
    min-height: 44px;
  }
  label { font-size: 13px; margin-bottom: 6px; }
  .toggle-switch { width: 52px; height: 28px; }
  .toggle-switch input:checked + .toggle-slider:before { transform: translateX(24px); }
  .toggle-slider:before { height: 22px; width: 22px; }
  .table-toggle { width: 44px; height: 24px; }
  .table-toggle .toggle-slider:before { height: 18px; width: 18px; }
  .table-toggle input:checked + .toggle-slider:before { transform: translateX(20px); }

  /* Toolbar stapelt sauber (Grid = vorhersehbar) */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }
  .toolbar h2 { font-size: 17px; }
  .toolbar .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .toolbar .actions input[type="text"] {
    grid-column: 1 / -1;
    width: 100% !important;
  }
  .toolbar .actions button { width: 100%; }

  /* HAMBURGER-MENÜ statt Tabs */
  .mobile-tabs-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    background: #18181b;
    border: 1px solid #2d2d30;
    border-radius: 12px;
    color: #efeff1;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    min-height: 48px;
  }
  .mobile-tabs-toggle::after {
    content: "▾";
    font-size: 18px;
    color: #bf94ff;
    transition: transform 0.25s ease;
  }
  .mobile-tabs-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }

  .tabs {
    display: none;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    margin-top: 8px;
    background: #18181b;
    border: 1px solid #2d2d30;
    border-radius: 12px;
    padding: 6px;
    height: auto;
    overflow: visible;
  }
  .tabs.mobile-open { display: flex; }
  .tab {
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    font-size: 14px;
    border-radius: 8px;
  }
  .tab.active {
    background: #772ce8;
    color: #fff;
    box-shadow: none;
  }
  .tab:hover { background: rgba(119, 44, 232, 0.2); }

  /* Tabellen: nativer horizontaler Scroll (robust ohne JS-Hack) */
  .card > table,
  .card > div > table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  th, td { padding: 12px 14px; font-size: 14px; white-space: nowrap; }
  th { font-size: 11px; }

  /* Modals: Bottom-Sheet */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    height: 92vh;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    padding: 20px 16px;
  }
  .modal h2 { font-size: 20px; margin-bottom: 18px; }
  .modal-actions { flex-direction: column-reverse; gap: 10px; }
  .modal-actions button { width: 100%; min-height: 48px; }

  /* Login */
  .login-card { padding: 32px 22px; }
  .login-card h1 { font-size: 26px; }
  .login-card p { font-size: 14px; }

  /* Empty / Loading */
  .empty, .loading { padding: 40px 14px; font-size: 14px; }

  /* Suche / Dropdown */
  .search-results { max-height: 50vh; }

  /* Alert-Event-Reihen stapeln */
  .alert-event-row { flex-wrap: wrap; gap: 10px; padding: 14px 0; }
  .alert-event-row > button { flex: 1 1 auto; min-width: 80px; }
  .media-preview-thumb { width: 50px; height: 38px; }

  /* Overlay-Card sauber stapeln */
  .overlay-card { padding: 14px; gap: 10px; }
}

/* ===== Kleine Phones (≤ 480px) ===== */
@media (max-width: 480px) {
  .container { padding: 8px; }
  h1 { font-size: 19px; }
  .card { padding: 12px; border-radius: 10px; }
  .toolbar .actions { grid-template-columns: 1fr; }
  .badge { font-size: 10px; padding: 3px 8px; }
  .count-val { font-size: 16px; }
  .modal { padding: 16px 12px; }
  .login-card h1 { font-size: 22px; }
  .tab { font-size: 13px; padding: 10px 12px; }
}

/* ===== Querformat auf Phone ===== */
@media (max-width: 900px) and (orientation: landscape) {
  .modal { height: auto; max-height: 95vh; border-radius: 16px; }
}

/* =========================================================
   ANALYTICS — responsive Overrides
   Greift nur innerhalb der bestehenden Media Queries,
   lässt Desktop-Layout (4-spaltige Top-Karten) unberührt.
   ========================================================= */

@media (max-width: 1024px) {
  /* Top-Listen-Karten statt 4 Spalten -> 2 Spalten auf Tablet */
  #tab-analytics div[style*="repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Stats-Karten: mindestens 2 pro Zeile */
  #analytics-stats {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
    gap: 10px !important;
  }
  /* Chart-Höhe leicht reduzieren */
  #analytics-chart-events,
  #analytics-chart-viewers,
  #analytics-chart-chatters { height: 200px !important; }
}

@media (max-width: 768px) {
  /* Analytics-Session-Select in der Toolbar: volle Breite statt min-width 240px */
  #analytics-session {
    min-width: 0 !important;
    width: 100% !important;
    height: 44px !important;
    font-size: 15px !important;
    padding: 10px 14px !important;
  }
  #tab-analytics .toolbar .actions label {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
  }
  /* Beschreibungstext kleiner und enger */
  #tab-analytics > .card > p { font-size: 13px !important; line-height: 1.5; }

  /* Top-Karten: 1 Spalte auf Phone */
  #tab-analytics div[style*="repeat(4, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  /* Outer Analytics-Grid (320px-min) -> 1 Spalte */
  #tab-analytics div[style*="minmax(320px, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Charts: kompakter & volle Höhe nutzen */
  #analytics-chart-events,
  #analytics-chart-viewers,
  #analytics-chart-chatters { height: 220px !important; }

  /* Chart-Überschriften kompakter */
  #tab-analytics h3 { font-size: 14px !important; margin-bottom: 10px !important; }

  /* Stat-Cards kompakter */
  #analytics-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
  }
  #analytics-stats > div { padding: 10px !important; }
  #analytics-stats .count-val { font-size: 18px !important; }

  /* Listen in Top-Karten: Zeilenhöhe angenehmer für Touch */
  #tab-analytics .alert-event-row,
  #tab-analytics .vars-table td { padding: 10px 0 !important; }
}

@media (max-width: 480px) {
  #analytics-chart-events,
  #analytics-chart-viewers,
  #analytics-chart-chatters { height: 180px !important; }
  #analytics-stats { grid-template-columns: 1fr 1fr !important; }
}

/* =========================================================
   CHAT LOG — Twitch-style scrollable chat history
   ========================================================= */

.chat-log-scroller {
  background: #18181b;
  border: 1px solid #2d2d30;
  border-radius: 8px;
  height: 480px;
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: #5a5a5f #18181b;
}

.chat-log-scroller::-webkit-scrollbar { width: 10px; }
.chat-log-scroller::-webkit-scrollbar-track { background: #18181b; border-radius: 8px; }
.chat-log-scroller::-webkit-scrollbar-thumb {
  background: #5a5a5f;
  border-radius: 8px;
  border: 2px solid #18181b;
}
.chat-log-scroller::-webkit-scrollbar-thumb:hover { background: #7a7a7f; }

.chat-log-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 14px;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #efeff1;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.chat-log-msg + .chat-log-msg { padding-top: 2px; padding-bottom: 2px; }

.chat-log-msg:hover { background: rgba(255, 255, 255, 0.03); }

.chat-log-ts {
  flex: 0 0 auto;
  font-size: 11px;
  color: #6a6a6f;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
  opacity: 0.55;
  transition: opacity 80ms linear;
}

.chat-log-msg:hover .chat-log-ts { opacity: 1; }

.chat-log-badges {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  padding-top: 2px;
}

.chat-log-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  width: 18px;
  background: transparent;
  flex: 0 0 18px;
}

.chat-log-badge img {
  height: 18px;
  width: auto;
  max-width: 36px;
  vertical-align: middle;
  image-rendering: -webkit-optimize-contrast;
}

.chat-log-badge-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  background: #4a4a4f;
  letter-spacing: 0.3px;
  line-height: 1;
}

.chat-log-badge-fallback.broadcaster { background: #e91916; }
.chat-log-badge-fallback.moderator   { background: #00ad03; }
.chat-log-badge-fallback.vip         { background: #d7a11f; color: #18181b; }
.chat-log-badge-fallback.subscriber  { background: #6441a5; }
.chat-log-badge-fallback.partner     { background: #6441a5; }
.chat-log-badge-fallback.staff       { background: #1990ad; }
.chat-log-badge-fallback.admin       { background: #faaf19; color: #18181b; }
.chat-log-badge-fallback.global_mod  { background: #0a8c4d; }
.chat-log-badge-fallback.founder     { background: #6441a5; }
.chat-log-badge-fallback.bits        { background: #ffca28; color: #18181b; }
.chat-log-badge-fallback.premium     { background: #009cdc; }

.chat-log-name {
  flex: 0 0 auto;
  font-weight: 700;
  letter-spacing: 0.1px;
  white-space: nowrap;
  cursor: default;
}

.chat-log-name.system { color: #adadb8; font-style: italic; font-weight: 600; }

.chat-log-colon {
  flex: 0 0 auto;
  color: #adadb8;
  padding-right: 4px;
}

.chat-log-text {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-log-emote {
  display: inline-block;
  height: 1.4em;
  width: auto;
  vertical-align: -3px;
  margin: 0 1px;
}

/* Loading/empty placeholders inside the chat-log scroller need to inherit
   the dark window's background, not the global .loading/.empty style which
   uses a light page background. */
.chat-log-scroller .chat-log-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 24px 16px;
  color: #6a6a6f;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

/* Multi-select chatter chips on the Chat Search tab. */
.chat-search-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  background: rgba(145, 71, 255, 0.18);
  border: 1px solid rgba(145, 71, 255, 0.55);
  color: #efeff1;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
}

.chat-search-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.chat-search-chip-x:hover {
  background: rgba(255, 75, 75, 0.35);
}

.chat-log-msg.chat-log-deleted .chat-log-emote {
  opacity: 0.4;
  filter: grayscale(0.6);
}

.chat-log-msg.chat-log-deleted .chat-log-name,
.chat-log-msg.chat-log-deleted .chat-log-action-name {
  color: #5a5a5f !important;
  text-decoration: line-through;
}

.chat-log-msg.chat-log-deleted .chat-log-text {
  color: #5a5a5f;
  font-style: italic;
  text-decoration: line-through;
  text-decoration-color: rgba(90, 90, 95, 0.5);
}

.chat-log-msg.chat-log-deleted .chat-log-badges {
  opacity: 0.4;
  filter: grayscale(0.6);
}

.chat-log-msg.chat-log-deleted .chat-log-ts {
  opacity: 0.3;
}

.chat-log-deleted-tag {
  display: inline-block;
  background: rgba(255, 75, 75, 0.12);
  border: 1px solid rgba(255, 75, 75, 0.45);
  color: #ff8585;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.4px;
  margin-left: 6px;
  vertical-align: middle;
}

.chat-log-mention {
  color: #9147ff;
  font-weight: 700;
  background: rgba(145, 71, 255, 0.08);
  padding: 0 2px;
  border-radius: 3px;
}

.chat-log-link {
  color: #00b3ff;
  text-decoration: underline;
  text-decoration-color: rgba(0, 179, 255, 0.4);
  text-underline-offset: 2px;
  word-break: break-word;
}

.chat-log-link:hover {
  color: #4cc9ff;
  text-decoration-color: #4cc9ff;
}

.chat-log-action {
  font-style: italic;
}

.chat-log-action .chat-log-action-name {
  font-weight: 700;
  font-style: italic;
}

.chat-log-action-text {
  color: inherit;
}

.chat-log-day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 14px 6px;
  font-size: 11px;
  color: #adadb8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-log-day-divider::before,
.chat-log-day-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #2d2d30;
}

@media (max-width: 768px) {
  .chat-log-scroller { height: 360px; max-height: 55vh; }
  .chat-log-msg { padding: 4px 10px; font-size: 12.5px; }
}
