:root {
  --bg: #0d0d0d;
  --panel-bg: #111111;
  --line: #1e1e1e;
  --ink: #e8e8e8;
  --muted: #666666;
  --accent: #e8ff47;
  --accent-dim: rgba(232, 255, 71, 0.15);
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --font-mono: 'IBM Plex Mono', 'Consolas', 'Cascadia Mono', monospace;
  --font-ui: 'Syne', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  height: 100vh;
}

.workspace {
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--panel-bg);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.panel-sources {
  width: 30%;
  min-width: 260px;
}

.panel-stream {
  width: 35%;
  min-width: 300px;
}

.panel-agent {
  width: 35%;
  min-width: 300px;
  border-right: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-bg);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.panel-head h2 {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-bg);
  flex-shrink: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.logo {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.panel-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.panel-label em {
  font-style: normal;
  color: var(--ink);
}

.divider {
  color: var(--line);
  font-size: 14px;
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted);
}

.live-status.live .live-dot {
  background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}

.live-status.idle .live-dot {
  background: var(--yellow);
}

.live-status.error .live-dot {
  background: var(--red);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#liveLabel {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

button {
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 6px 12px;
  cursor: pointer;
  transition: all 150ms;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#refreshBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

#refreshBtn:hover {
  background: #d4e030;
  border-color: #d4e030;
}

.badge {
  font-size: 10px;
  padding: 3px 7px;
  background: var(--accent-dim);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sources-list {
  display: flex;
  flex-direction: column;
}

.source-card {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: all 150ms;
  border-left: 3px solid transparent;
}

.source-card:hover {
  background: rgba(255, 255, 255, 0.03);
}

.source-card.selected {
  border-left-color: var(--accent);
  background: var(--accent-dim);
}

.source-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.source-name {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.source-id {
  font-family: var(--font-mono);
}

.source-stats {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
}

.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 28px;
}

.spark-bar {
  width: 6px;
  background: var(--accent);
  opacity: 0.6;
  border-radius: 1px;
}

.spark-bar:hover {
  opacity: 1;
}

#allSourcesBtn {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: all 150ms;
  border-left: 3px solid transparent;
}

#allSourcesBtn:hover {
  background: rgba(255, 255, 255, 0.03);
}

#allSourcesBtn.selected {
  border-left-color: var(--accent);
  background: var(--accent-dim);
}

.source-label {
  font-size: 12px;
  font-weight: 600;
}

.source-count {
  font-size: 11px;
  color: var(--muted);
  margin-left: 8px;
}

#totalGroups,
#totalMessagesToday {
  font-size: 11px;
  color: var(--muted);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#searchInput {
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 5px 10px;
  width: 120px;
}

#searchInput::placeholder {
  color: var(--muted);
}

#searchInput:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-chips {
  display: flex;
  gap: 4px;
}

.chip {
  font-size: 10px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 150ms;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

#confidenceFilter {
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 4px 8px;
  cursor: pointer;
}

.stream-list {
  display: flex;
  flex-direction: column;
}

.stream-card {
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--green);
  cursor: pointer;
  transition: all 150ms;
  animation: slideIn 200ms ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stream-card:hover {
  background: rgba(255, 255, 255, 0.03);
}

.stream-card.collapsed {
  opacity: 0.5;
}

.stream-card.collapsed .stream-raw {
  display: block;
}

.irrelevant-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stream-raw {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stream-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stream-meta {
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 8px;
}

.empty-state p {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.blink-cursor {
  color: var(--accent);
  animation: blink 1s step-end infinite;
}

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

.hidden {
  display: none;
}

#modelSelector {
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--line);
  background: var(--panel-bg);
  color: var(--ink);
  padding: 4px 8px;
  cursor: pointer;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #000;
  margin-left: auto;
}

.chat-bubble.agent {
  align-self: flex-start;
  background: #1a1a1a;
  color: #999999;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--muted);
  animation: typingBounce 1s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.suggested-prompts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.prompt-btn {
  text-align: left;
  font-size: 11px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 150ms;
}

.prompt-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-form {
  display: flex;
  gap: 8px;
}

#chatInput {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  resize: none;
  min-height: 40px;
  max-height: 100px;
}

#chatInput:focus {
  outline: none;
  border-color: var(--accent);
}

.send-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
  padding: 8px 16px;
  align-self: flex-end;
}

.send-btn:hover {
  background: #d4e030;
  border-color: #d4e030;
}

.context-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#settingsBtn {
  padding: 6px 10px;
}

@media (max-width: 900px) {
  .workspace {
    flex-direction: column;
    height: auto;
    overflow-y: auto;
  }

  .panel {
    width: 100% !important;
    min-width: 0;
    height: auto;
    max-height: 400px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .panel-agent {
    border-bottom: none;
  }
}