:root {
  color-scheme: dark;
  --bg: #0b141a;
  --panel: #111b21;
  --panel-2: #202c33;
  --line: #2a3942;
  --text: #e9edef;
  --muted: #8696a0;
  --out: #005c4b;
  --accent: #00a884;
  --danger: #f15c6d;
  --warn: #3b3320;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
h1, h2, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; }
.top-meta { color: var(--muted); font-size: 13px; text-align: right; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px 1fr 340px;
}
.sidebar, .thread {
  min-height: 0;
}
.sidebar {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.sidebar-head, .thread-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.thread-head p, .conversation small { color: var(--muted); }
.conversation-list, .messages {
  overflow: auto;
  flex: 1;
}
.conversation {
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  cursor: pointer;
}
.conversation.active, .conversation:hover { background: #1a272f; }
.conversation strong, .conversation span { display: block; }
.conversation span {
  margin-top: 4px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread { display: flex; flex-direction: column; background: #0e161b; }
.messages {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bubble {
  max-width: min(560px, 80%);
  padding: 8px 10px 6px;
  border-radius: 8px;
  background: var(--panel-2);
  align-self: flex-start;
}
.bubble.out { background: var(--out); align-self: flex-end; }
.bubble.failed { outline: 1px solid var(--danger); }
.bubble p { white-space: pre-wrap; line-height: 1.4; }
.meta {
  margin-top: 4px;
  color: #c7d2d6;
  font-size: 11px;
  text-align: right;
}
.empty {
  color: var(--muted);
  padding: 24px;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: var(--panel);
}
.quick, .compose-row { display: flex; gap: 8px; }
.quick { margin-bottom: 8px; flex-wrap: wrap; }
input, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
}
input {
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
}
#toInput { width: 220px; }
#textInput { flex: 1; }
button {
  background: var(--accent);
  color: #04241c;
  border: 0;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 650;
}
.quick button, .ghost {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 550;
}
.error { color: var(--danger); min-height: 1.2em; margin-top: 8px; font-size: 13px; }

.logs {
  border-left: 1px solid var(--line);
  background: #0e161b;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.log-note {
  margin: 0;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.log-list { overflow: auto; flex: 1; }
.log-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.log-item header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
}
.badge.sample { color: #f2c14b; }
.badge.error { color: var(--danger); }
.badge.ok { color: var(--accent); }
.log-item p { margin-top: 6px; font-size: 13px; }
.log-item pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c7d2d6;
  font-size: 11px;
  max-height: 180px;
  overflow: auto;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar, .logs { max-height: 320px; }
}
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .sidebar { max-height: 280px; }
  #toInput { width: 100%; }
  .compose-row { flex-wrap: wrap; }
}
