:root {
  --bg: #faf9f7;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e5e5e5;
  --accent: #2563eb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --fg: #f5f5f5;
    --muted: #a1a1a1;
    --border: #333;
    --accent: #60a5fa;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Newsreader', Georgia, serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  padding: 2rem;
  max-width: 640px;
  margin: 0 auto;
}
h1 { font-size: 2rem; font-weight: 500; margin-bottom: 0.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; font-weight: 500; margin: 1.5rem 0 0.75rem; color: var(--muted); }
p { margin: 0.5rem 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.watch-link { font-family: 'IBM Plex Mono', monospace; font-size: 0.9rem; word-break: break-all; }
code, .endpoint {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  background: var(--border);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  display: block;
  word-break: break-all;
  margin: 0.5rem 0;
}
ol, ul { margin: 0.5rem 0 0.5rem 1.5rem; }
li { margin: 0.25rem 0; }
.subtle { color: var(--muted); font-size: 0.9rem; }
.js-hint { display: none; }
.footer { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.footer a { margin-right: 1.5rem; }

/* Copy block */
.copy-block {
  position: relative;
  margin: 0.5rem 0;
}
.copy-block pre {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  background: var(--border);
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  border-radius: 6px;
  word-break: break-all;
  white-space: pre-wrap;
  margin: 0;
}
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.copy-btn:hover {
  color: var(--fg);
  background: rgba(0,0,0,0.05);
}
.copy-btn.copied {
  color: #22c55e;
}
@media (prefers-color-scheme: dark) {
  .copy-btn:hover { background: rgba(255,255,255,0.1); }
}

/* Watch page styles */
.watch-page h1 { margin-bottom: 0.25rem; }
.messages {
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.message {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--border);
}
.message.from-a {
  border-left: 3px solid var(--accent);
}
.message.from-b {
  border-left: 3px solid #22c55e;
}
.message .sender {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  display: block;
  margin-bottom: 0.25rem;
}
.message .content {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
}
.message .time {
  font-size: 0.75rem;
  color: var(--muted);
  display: block;
  margin-top: 0.25rem;
}
.refresh-hint {
  margin-top: 1.5rem;
}
.refresh-hint code {
  display: inline;
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
}

/* Three-column watch page */
.watch-page.three-column {
  max-width: 1200px;
}
.watch-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.watch-header h1 {
  font-size: 1.25rem;
  font-family: 'IBM Plex Mono', monospace;
}
.columns {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 1.5rem;
  min-height: 400px;
}
@media (max-width: 900px) {
  .columns {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}
.agent-column {
  background: var(--border);
  border-radius: 8px;
  padding: 1rem;
}
.agent-column h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}
.agent-a-column { border-top: 3px solid var(--accent); }
.agent-b-column { border-top: 3px solid #22c55e; }
.chat-column {
  display: flex;
  flex-direction: column;
}
.chat-column h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}
.messages-container {
  flex: 1;
  max-height: 350px;
  overflow-y: auto;
  background: var(--border);
  border-radius: 8px;
  padding: 1rem;
}
.no-messages {
  text-align: center;
  padding: 2rem 0;
}
.refresh-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* Buttons and controls */
.connect-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: opacity 0.15s;
}
.connect-btn:hover { opacity: 0.9; }
.connected-badge {
  padding: 0.5rem 1rem;
  background: #22c55e20;
  color: #22c55e;
  border-radius: 6px;
  text-align: center;
  font-weight: 500;
  font-size: 0.9rem;
}
.agent-controls {
  margin-top: 1rem;
}
.control-group {
  margin-bottom: 1rem;
}
.action-btn {
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--muted);
  border-radius: 4px;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  transition: background 0.15s;
}
.action-btn:hover { background: var(--border); }
.action-btn.small { padding: 0.35rem 0.6rem; }
.result-box {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  max-height: 100px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.result-box:empty { display: none; }
.agent-controls textarea {
  width: 100%;
  padding: 0.5rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--muted);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
  margin-bottom: 0.5rem;
}
.agent-instructions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(128,128,128,0.2);
}
.agent-instructions .subtle {
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}
.copy-block.small pre {
  font-size: 0.7rem;
  padding: 0.5rem 2rem 0.5rem 0.5rem;
}
