:root {
  color-scheme: dark;
  --bg: #09111f;
  --bg-2: #101a2f;
  --surface: rgba(14, 21, 39, 0.88);
  --surface-2: rgba(21, 30, 52, 0.92);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eefc;
  --muted: #94a3c7;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --radius: 20px;
  --twitch: #9146ff;
  --youtube: #ff4d4d;
  --green: #21c58a;
  --amber: #f5b84b;
  --red: #f87171;
  --chip: rgba(255, 255, 255, 0.08);
  --chip-active: rgba(145, 70, 255, 0.18);
  --chip-active-border: rgba(145, 70, 255, 0.4);
  --priority-accent: linear-gradient(135deg, rgba(145, 70, 255, 0.22), rgba(33, 197, 138, 0.18));
  --superchat-accent: linear-gradient(135deg, rgba(245, 184, 75, 0.22), rgba(255, 77, 77, 0.1));
  --chat-accent: linear-gradient(135deg, rgba(36, 96, 209, 0.22), rgba(14, 21, 39, 0.16));
  --font: "Avenir Next", "Avenir", "Helvetica Neue", "Segoe UI", "Trebuchet MS", sans-serif;
  --font-ui: "Avenir Next", "Avenir", "Helvetica Neue", "Segoe UI", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  font-family: var(--font);
  font-kerning: normal;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(145, 70, 255, 0.16), transparent 34%),
    radial-gradient(circle at top right, rgba(255, 77, 77, 0.14), transparent 28%),
    radial-gradient(circle at 20% 80%, rgba(33, 197, 138, 0.12), transparent 32%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  overflow-x: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none; 
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black 40%, transparent 100%);
  opacity: 0.25;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 28px;
}

.panel,
.toolbar,
.stats-board {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.eyebrow,
.panel-kicker,
.stat-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
}

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

.session-row input {
  flex: 1;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
  font: inherit;
}

.session-row--inline {
  min-width: min(560px, 100%);
  justify-content: flex-end;
}

.session-row--inline input {
  min-width: 180px;
  max-width: 280px;
  padding: 8px 10px;
  font-size: 0.86rem;
}

.session-row input:focus {
  border-color: rgba(145, 70, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(145, 70, 255, 0.12);
}

.session-row button,
.keep-awake-button,
.event-actions button,
.filter-button {
  border: 0;
  border-radius: 14px;
  padding: 9px 11px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.session-row button,
.keep-awake-button {
  min-width: 96px;
  color: white;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  font-size: 0.84rem;
}

.session-row button:hover,
.keep-awake-button:hover,
.event-actions button:hover,
.filter-button:hover {
  transform: translateY(-1px);
}

.connection-status {
  margin: 6px 2px 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.toolbar-meta--inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 2px 10px;
  color: var(--muted);
  font-size: 0.76rem;
}

.stats-board {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  border-radius: var(--radius);
  padding: 10px 12px 9px;
  margin-bottom: 10px;
}

.stats-board-head {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.keep-awake-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.keep-awake-button:disabled {
  opacity: 0.72;
  cursor: progress;
  transform: none;
}

.mock-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(245, 184, 75, 0.35);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(245, 184, 75, 0.14);
  color: #ffd98a;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.filter-group--inline {
  margin-left: 0;
}

.stats-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  position: relative;
  overflow: hidden;
}

.stat-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--muted);
  opacity: 0.75;
}

.stat-row strong {
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text);
  text-shadow: none;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.panel-count,
.event-time,
.event-meta,
.priority-months,
.connection-status,
.keep-awake-status {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.stat-twitch::before {
  background: var(--twitch);
}

.stat-youtube::before {
  background: var(--youtube);
}

.stat-total::before {
  background: var(--green);
}

.stat-superchat::before {
  background: var(--amber);
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-button {
  color: var(--text);
  background: var(--chip);
  border: 1px solid transparent;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-family: var(--font-ui);
}

.filter-button.is-active {
  background: var(--chip-active);
  border-color: var(--chip-active-border);
}

.summary-button {
  flex: 0 0 auto;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-family: var(--font-ui);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  font-size: 0.84rem;
  white-space: nowrap;
}

.keep-awake-button {
  flex: 0 1 auto;
  min-width: 260px;
  white-space: normal;
}

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

.summary-popup {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
}

.summary-popup[hidden] {
  display: none;
}

.summary-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 18, 0.58);
  backdrop-filter: blur(4px);
}

.summary-panel {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100vw - 24px));
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(10, 16, 29, 0.96);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  padding: 14px;
}

.summary-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.summary-panel-head h2 {
  margin: 4px 0 0;
  font-size: 1.05rem;
}

.summary-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary-action,
.summary-close {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-family: var(--font-ui);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.84rem;
  transition: transform 0.15s ease, background 0.15s ease;
}

.summary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.summary-action--danger {
  border-color: rgba(248, 113, 113, 0.32);
  background: rgba(248, 113, 113, 0.12);
  color: #ffd6d6;
}

.summary-action:hover,
.summary-close:hover {
  transform: translateY(-1px);
}

.summary-action--danger:hover {
  background: rgba(248, 113, 113, 0.18);
}

.summary-stats {
  margin-top: 12px;
}

.detail-popup {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 16px;
}

.detail-popup[hidden] {
  display: none;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 18, 0.68);
  backdrop-filter: blur(6px);
}

.detail-panel {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100vw - 24px));
  border: 1px solid rgba(255, 205, 94, 0.24);
  border-radius: 24px;
  background: rgba(10, 16, 29, 0.98);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
  padding: 18px;
}

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

.detail-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.detail-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.detail-title-wrap h2 {
  margin: 4px 0 0;
  font-size: 1.18rem;
  line-height: 1.1;
}

.detail-platform-badge {
  width: 34px;
  height: 34px;
}

.detail-meta-row {
  margin-top: 0;
  margin-bottom: 14px;
}

.detail-message {
  margin: 0;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #f5f8ff;
  font-size: 1.08rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: min(52vh, 520px);
  overflow: auto;
  font-family: var(--font);
  font-variant-emoji: emoji;
}

.detail-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

.detail-actions button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.detail-actions button[data-detail-action="favorite"] {
  background: rgba(245, 184, 75, 0.12);
  color: #ffe2a8;
}

.detail-actions button[data-detail-action="read"] {
  background: rgba(33, 197, 138, 0.12);
  color: #c7fae4;
}

.detail-actions button.is-active {
  border-color: rgba(255, 205, 94, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 205, 94, 0.18);
}

.detail-actions button:hover {
  transform: translateY(-1px);
}

.detail-popup[data-kind="superchat"] .detail-meta-row [data-detail-extra] {
  font-size: 1.08rem;
  font-weight: 900;
  color: #ffe2a8;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.panel {
  border-radius: var(--radius);
  padding: 16px;
  overflow: hidden;
}

.panel-priority {
  background: var(--priority-accent), var(--surface);
}

.panel-superchat {
  background: var(--superchat-accent), var(--surface);
  grid-column: 1 / 2;
}

.panel-chat {
  grid-column: 2 / -1;
  background: var(--chat-accent), var(--surface);
}

.panel-priority {
  grid-column: 1 / -1;
  background: var(--priority-accent), var(--surface);
}

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

.panel-header h2 {
  margin: 6px 0 0;
  font-size: 1.08rem;
}

.panel-count {
  min-width: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  text-align: center;
  font-weight: 700;
}

.event-list {
  display: grid;
  gap: 10px;
  max-height: min(66vh, 680px);
  overflow: auto;
  padding-right: 2px;
}

.priority-strip {
  display: flex;
  gap: 10px;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
}

.priority-strip > * {
  scroll-snap-align: start;
}

.panel-superchat .event-list,
.panel-chat .event-list {
  max-height: min(52vh, 520px);
}

.priority-card {
  flex: 0 0 min(320px, 82vw);
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  padding: 10px 12px;
  min-height: 52px;
  position: relative;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.priority-card .event-user {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.priority-months {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffe2a8;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.priority-card.is-selected {
  border-color: rgba(255, 215, 120, 0.88);
  box-shadow: 0 0 0 1px rgba(255, 205, 94, 0.45), 0 16px 30px rgba(0, 0, 0, 0.22);
  background: linear-gradient(135deg, rgba(255, 199, 72, 0.16), rgba(255, 255, 255, 0.03));
}

.event-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  padding: 12px;
  position: relative;
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  cursor: pointer;
}

.event-head,
.event-body {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
}

.event-head {
  flex-wrap: nowrap;
  align-items: center;
}

.event-body {
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.event-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  min-width: 0;
  flex: 1 1 auto;
}

.event-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.platform-badge,
.event-meta,
.priority-months,
.event-actions button {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.platform-badge {
  width: 26px;
  height: 26px;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
}

.platform-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.event-user {
  min-width: 0;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.15;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

.event-message {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: #eef3ff;
  font-size: 0.96rem;
  line-height: 1.35;
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
  width: 100%;
  font-family: var(--font-content, var(--font));
  font-variant-numeric: normal;
  font-feature-settings: normal;
  font-variant-ligatures: none;
  font-variant-emoji: emoji;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

.event-meta {
  padding: 5px 8px;
  color: #ffe2a8;
  background: rgba(245, 184, 75, 0.12);
  flex: 0 0 auto;
}

.event-time {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
}

.event-card.is-superchat .event-meta {
  font-size: 0.88rem;
  padding: 6px 10px;
}

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

.event-actions button {
  color: white;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 0.68rem;
  border-radius: 999px;
  min-width: 0;
}

.event-actions button[data-action="favorite"] {
  color: #ffe2a8;
  background: rgba(245, 184, 75, 0.12);
}

.event-actions button[data-action="read"].is-active,
.event-actions button[data-action="favorite"].is-active {
  background: rgba(255, 205, 94, 0.18);
  color: #fff1c9;
  border-color: rgba(255, 205, 94, 0.45);
}

.event-card.is-pushed {
  transform: scale(0.99);
  border-color: rgba(255, 215, 120, 0.88);
  box-shadow: 0 0 0 1px rgba(255, 205, 94, 0.5), 0 16px 30px rgba(0, 0, 0, 0.24);
  background: linear-gradient(135deg, rgba(255, 201, 94, 0.16), rgba(255, 255, 255, 0.03));
}

.event-card.is-selected {
  border-color: rgba(255, 215, 120, 0.88);
  box-shadow: 0 0 0 1px rgba(255, 205, 94, 0.45), 0 16px 30px rgba(0, 0, 0, 0.22);
  background: linear-gradient(135deg, rgba(255, 199, 72, 0.16), rgba(255, 255, 255, 0.03));
}

.event-card.is-read .status-badge {
  background: rgba(33, 197, 138, 0.12);
  color: #b8f7d9;
}

.event-card.is-favorite {
  border-color: rgba(245, 184, 75, 0.3);
  box-shadow: 0 0 0 1px rgba(245, 184, 75, 0.22), 0 16px 30px rgba(0, 0, 0, 0.22);
  background: linear-gradient(135deg, rgba(245, 184, 75, 0.16), rgba(255, 255, 255, 0.03));
}

.event-card.is-favorite .status-badge {
  background: rgba(245, 184, 75, 0.14);
  color: #ffe2a8;
}

.event-card.is-superchat {
  border-color: rgba(245, 184, 75, 0.24);
}

.event-card.is-priority {
  border-color: rgba(145, 70, 255, 0.26);
}

.event-card.is-superchat .event-head {
  align-items: center;
}

.event-card.is-superchat .event-body {
  gap: 6px;
}

.event-card.is-superchat .event-head .event-user {
  display: none;
}

.event-card.is-superchat .event-body .event-meta-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.event-card.is-superchat .event-body .event-user {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.event-card.is-superchat .event-message {
  font-size: 1rem;
  line-height: 1.45;
}

.event-card.is-live-message .event-actions {
  display: none;
}

.event-card .event-user {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-card,
.event-head,
.event-body,
.event-main,
.event-meta-row {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

.event-card:not(.has-actions) .event-actions {
  display: none;
}

.empty-state {
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

@media (max-width: 1100px) {
  .stats-table {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 18px, 1600px);
    padding-top: 12px;
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .panel-superchat,
  .panel-chat {
    grid-column: auto;
  }

  .panel-priority {
    grid-column: auto;
  }

  .dashboard .panel-priority {
    order: -1;
  }

  .stats-table {
    grid-template-columns: 1fr 1fr;
  }

  .session-row--inline {
    min-width: 100%;
  }

  .session-row--inline input {
    max-width: none;
  }

  .summary-button {
    margin-left: 0;
    width: auto;
  }

  .stats-board-head {
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .stats-board-head::-webkit-scrollbar {
    height: 6px;
  }

  .stats-board-head::-webkit-scrollbar-thumb {
    border-radius: 999px;
  }
}

@media (max-width: 560px) {
  .panel,
  .stats-board,
  .summary-panel {
    border-radius: 16px;
  }

  .session-row {
    flex-direction: column;
    width: 100%;
  }

  .session-row button {
    width: 100%;
  }

  .session-row--inline {
    flex-direction: row;
    width: 100%;
  }

  .session-row--inline input,
  .session-row--inline button {
    width: auto;
    flex: 1;
  }

  .summary-panel {
    width: min(100vw - 20px, 760px);
    padding: 14px;
  }

  .stats-table {
    grid-template-columns: 1fr;
  }

  .site-brand {
    flex: 0 0 auto;
  }

  .site-brand h1 {
    font-size: 1rem;
  }

  .filter-group {
    gap: 6px;
    flex-wrap: nowrap;
    flex: 0 0 auto;
  }

  .filter-group--inline {
    margin-left: 0;
  }

  .filter-group--inline .filter-button {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 7px 9px;
    font-size: 0.74rem;
  }

  .mock-badge {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 0.7rem;
  }

  .summary-button {
    flex: 0 0 auto;
    padding: 7px 10px;
    font-size: 0.8rem;
  }
}
