:root {
  color-scheme: dark;
  --bg: #121410;
  --panel: #1b1e18;
  --panel-2: #242820;
  --line: #34382e;
  --text: #f3f1e7;
  --muted: #a3a898;
  --accent: #dff25a;
  --accent-ink: #1a1c12;
  --danger: #ff8d7a;
  --ok: #9ddeaf;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.55; }

.app { display: grid; grid-template-columns: 300px 1fr; height: 100%; }
.sidebar, .topbar, .composer-actions, .row, .brand, .mcp-head { display: flex; gap: 8px; }
.sidebar { flex-direction: column; padding: 16px; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
.brand { align-items: center; }
.brand strong { flex: 1; letter-spacing: 0.04em; }
.sessions { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 4px; min-height: 80px; }
.session, .dir, .tool, .card { border: 1px solid var(--line); background: var(--panel-2); }
.session { text-align: left; border-radius: 8px; padding: 8px; display: flex; gap: 8px; align-items: center; }
.session.active { border-color: var(--accent); }
.session span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost { background: transparent; border: 0; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.row input, textarea, select, .grow { width: 100%; }
input, textarea, select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
textarea { resize: vertical; min-height: 72px; }
button.wide, .primary, #send, #browse, #reload-mcp, #new-chat {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--panel-2);
}
button.wide, #send, .primary { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.mcp-head { align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
.mcp-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow: auto; }
.card { border-radius: 8px; padding: 8px; font-size: 13px; }
.card .dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; margin-right: 6px; background: var(--muted); }
.dot.connected { background: var(--ok); }
.dot.error { background: var(--danger); }
.card small { display: block; color: var(--muted); margin-top: 4px; }

main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.topbar select { max-width: 520px; }
.log { flex: 1; overflow: auto; padding: 24px 16px 12px; }
.message { max-width: 780px; margin: 0 auto 18px; }
.message .who { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.bubble { line-height: 1.5; }
.bubble pre, .tool pre {
  overflow: auto;
  background: #0d0e0b;
  border-radius: 8px;
  padding: 10px;
  border: 1px solid var(--line);
}
.bubble code { font-family: ui-monospace, monospace; font-size: 0.92em; }
.tool { border-radius: 8px; margin-top: 8px; }
.tool summary { cursor: pointer; padding: 8px 10px; }
.tool pre { margin: 0 10px 10px; max-height: 220px; white-space: pre-wrap; }
.tool.bad { border-color: var(--danger); }
.error { color: var(--danger); }
.empty { max-width: 780px; margin: 12vh auto 0; color: var(--muted); }
#composer { padding: 12px 16px 16px; }
.composer-actions { max-width: 780px; margin: 8px auto 0; align-items: center; }
#composer textarea { display: block; max-width: 780px; margin: 0 auto; }
.hint { flex: 1; margin: 0; color: var(--muted); font-size: 12px; }
.icon { border: 0; background: transparent; color: var(--text); font-size: 18px; }
.mobile-only, .scrim { display: none; }

dialog { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 12px; width: min(720px, calc(100% - 24px)); padding: 16px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.provider, .mcp-edit { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.dir { width: 100%; text-align: left; border-radius: 8px; padding: 8px; background: var(--bg); }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .mobile-only { display: inline-flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    z-index: 3;
    transform: translateX(-105%);
    transition: transform 0.16s ease;
  }
  .app.show-side .sidebar { transform: none; }
  .app.show-side .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 2; }
}
