:root {
  --bg: #0c0c0d;
  --panel: #141415;
  --panel-2: #1a1a1b;
  --border: #2a2a2c;
  --text: #ececee;
  --muted: #8b8b90;
  --accent: #f2f2f2;
  --accent-fg: #111;
  --blue: #6ea8fe;
  --amber: #e6b84d;
  --green: #5ecf8e;
  --user: #1c1c1e;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 280px;
  height: 100vh;
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; height: auto; min-height: 100vh; }
  .sidebar, .rail { max-height: 240px; overflow: auto; }
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 10px;
}
.sidebar-head .logo { font-weight: 650; font-size: 0.95rem; }
.sidebar-head .logo-sub { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }

.btn-new, .btn-primary, .btn-ghost {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}
.btn-new {
  width: 100%;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.mode-row {
  display: grid;
  gap: 4px;
}
.mode-row label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mode-row select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 8px;
  font: inherit;
}

.agent-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.agent-item {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
}
.agent-item:hover { background: var(--panel-2); }
.agent-item.active {
  background: var(--panel-2);
  border-color: var(--border);
}
.agent-item .t {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-item .s {
  margin-top: 3px;
  font-size: 0.7rem;
  color: var(--muted);
}

.sidebar-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
}
.pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
}
.muted { color: var(--muted); }

.main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  background: var(--bg);
}
.main-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.main-title { font-weight: 600; }
.main-meta { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.main-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.transcript {
  overflow: auto;
  padding: 20px 22px 28px;
}
.empty {
  max-width: 560px;
  margin: 12vh auto 0;
  color: var(--muted);
}
.empty h1 {
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0 0 10px;
}
.empty ul { padding-left: 18px; line-height: 1.7; }

.msg {
  max-width: 760px;
  margin: 0 auto 16px;
  display: grid;
  gap: 6px;
}
.msg .role {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.msg .bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 0.92rem;
}
.msg.user .bubble { background: var(--user); }
.msg.system .bubble {
  border-style: dashed;
  color: var(--amber);
}
.tool-chip {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--blue);
  border: 1px solid #2a3a55;
  border-radius: 6px;
  padding: 2px 8px;
}

.composer {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
  background: linear-gradient(180deg, transparent, #0c0c0d 30%);
}
.composer textarea {
  width: 100%;
  resize: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  line-height: 1.45;
}
.composer textarea:focus {
  outline: 1px solid #3a3a3d;
}
.composer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.hint { color: var(--muted); font-size: 0.75rem; }

.rail {
  border-left: 1px solid var(--border);
  background: var(--panel);
  padding: 14px 12px;
  overflow: auto;
}
.rail h3 {
  margin: 14px 0 8px;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.rail h3:first-child { margin-top: 0; }
.rail-block {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
  white-space: pre-wrap;
}
.status-idle { color: var(--muted); }
.status-running { color: var(--blue); }
.status-needs_approval { color: var(--amber); }
.status-completed { color: var(--green); }
.status-failed { color: #ff7b7b; }
