:root {
  --bg: #f7f8fa; --surface: #ffffff; --border: #e6e8ec;
  --text: #1c2330; --muted: #6b7280; --primary: #2563eb; --primary-50: #eff4ff;
  --success: #16a34a; --warn: #d97706; --danger: #dc2626; --new: #7c3aed;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); color: var(--text); background: var(--bg); height: 100vh; display: flex; flex-direction: column; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.topbar { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-size: 15px; } .brand .muted { font-weight: 400; margin-left: 6px; }
.workdir { font-family: var(--mono); font-size: 12px; }

.layout { flex: 1; display: grid; grid-template-columns: 240px 1fr 280px; min-height: 0; }
.sidebar, .rail { background: var(--surface); overflow-y: auto; padding: 12px; }
.sidebar { border-right: 1px solid var(--border); }
.rail { border-left: 1px solid var(--border); }
.chat { display: flex; flex-direction: column; min-height: 0; }

.btn-new { width: 100%; padding: 8px; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius); cursor: pointer; font-size: 14px; margin-bottom: 12px; }
.btn-new:hover { background: var(--primary-50); border-color: var(--primary); }

.session-row, .activity-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: 8px; text-decoration: none; color: var(--text); }
.session-row:hover, .activity-row:hover { background: var(--bg); }
.session-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; font-size: 13px; cursor: pointer; }

.session-actions { display: none; gap: 2px; margin-left: auto; }
.session-row:hover .session-actions { display: flex; }
.session-actions button { background: none; border: 0; cursor: pointer; font-size: 12px;
  line-height: 1; padding: 3px 5px; border-radius: 6px; color: var(--muted); }
.session-actions button:hover { background: var(--border); color: var(--text); }
.session-actions button.danger:hover { background: var(--danger); color: #fff; }
.session-group-h { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 14px 0 4px; padding-left: 4px; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--muted); }
.dot-live { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.dot-queued { background: var(--warn); }
.dot-done { background: var(--success); }
.dot-fail { background: var(--danger); }
.dot-idle { background: var(--border); }

.rail-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  margin: 6px 0; }

.chat-inner { display: flex; flex-direction: column; height: 100%; }
.chat-head { padding: 12px 24px; border-bottom: 1px solid var(--border); }
.chat-title { font-weight: 600; }
.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; }

/* Full-width rows; the inner element is an inline-block bubble that hugs its
   content (reliable across browsers + htmx swaps, unlike fit-content on a
   flex item). text-align positions the bubble left/right. */
.msg { align-self: stretch; max-width: 100%; }
.msg-user { text-align: right; }
.msg-assistant { text-align: left; }
.msg-user .plain { display: inline-block; text-align: left; max-width: 75%;
  background: var(--primary); color: #fff; padding: 10px 14px;
  border-radius: 14px 14px 2px 14px; white-space: pre-wrap; word-break: break-word; }
.msg-assistant .md { display: inline-block; text-align: left; max-width: 75%; }
.md { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px 16px; box-shadow: var(--shadow); }
.md pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow-x: auto; }
.md code { font-family: var(--mono); font-size: 13px; }

.composer { border-top: 1px solid var(--border); padding: 12px 24px; background: var(--surface); }
.composer textarea { width: 100%; resize: vertical; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; font-family: var(--sans); font-size: 14px; }
.composer-row { display: flex; justify-content: space-between; margin-top: 8px; }
.composer select { border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.btn-send { background: var(--primary); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 16px; cursor: pointer; font-size: 14px; }
.btn-send:hover { filter: brightness(1.05); }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 12px; color: var(--muted); }
.empty .btn-new { width: auto; }

/* Claude Code-style in-progress indicator: braille spinner + shimmering text. */
.run-status, .pending { align-self: flex-start; display: flex; align-items: center; gap: 8px;
  padding: 6px 2px; font-size: 14px; }
.cc-spinner::before { content: "⠋"; color: var(--primary); font-family: var(--mono);
  font-size: 15px; animation: cc-frames .8s steps(1, end) infinite; }
@keyframes cc-frames {
  0%   { content: "⠋"; } 12.5% { content: "⠙"; } 25%  { content: "⠹"; }
  37.5%{ content: "⠸"; } 50%   { content: "⠼"; } 62.5%{ content: "⠴"; }
  75%  { content: "⠦"; } 87.5% { content: "⠧"; } 100% { content: "⠇"; }
}
.cc-shimmer { background: linear-gradient(90deg, var(--muted) 30%, var(--text) 50%, var(--muted) 70%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text;
  color: transparent; animation: cc-shimmer 1.6s linear infinite; }
@keyframes cc-shimmer { to { background-position: -200% 0; } }

/* First-run Claude auth banner. */
.authbar { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.authbar.warn { background: #fffbeb; }
.authbar.ok { background: var(--primary-50); color: var(--success); }
.auth-msg { margin-bottom: 8px; color: var(--text); }
.auth-msg code { font-family: var(--mono); background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.auth-error { color: var(--danger); margin-top: 4px; }
.auth-steps { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.auth-getbtn { display: inline-block; background: var(--primary); color: #fff; text-decoration: none;
  padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.auth-getbtn:hover { filter: brightness(1.08); }
.auth-arrow { color: var(--muted); }
.auth-step2 { color: var(--text); font-size: 13px; }
.auth-choices { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.auth-ind { display: inline-flex; align-items: center; gap: 6px; }
.auth-alt { margin-top: 8px; }
.auth-alt summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.auth-ol { margin: 8px 0; padding-left: 20px; }
.auth-ol li { margin-bottom: 10px; }
.auth-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.auth-tail { background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px; max-height: 160px; overflow: auto; font-family: var(--mono); font-size: 11px;
  white-space: pre-wrap; word-break: break-all; }
.auth-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.auth-row select, .auth-row input { border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; font-size: 13px; }
.auth-row input { flex: 1; min-width: 220px; font-family: var(--mono); }
.auth-row button { background: var(--primary); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; }

/* Read-only capabilities landing page (chat hidden). */
.caps-page { flex: 1; overflow-y: auto; max-width: 880px; width: 100%; margin: 0 auto; padding: 28px 24px 48px; }
.caps-head { margin-bottom: 22px; }
.caps-title { font-size: 22px; margin: 0 0 6px; }
.caps-live { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; font-size: 12px; }
.caps-live .dot { display: inline-block; }
.caps-section { margin-bottom: 26px; }
.caps-h { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.caps-count { background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 9px; font-size: 12px; color: var(--text); }
.caps-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.caps-item { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; box-shadow: var(--shadow); }
.caps-methods { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.caps-method { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .03em;
  padding: 1px 6px; border-radius: 5px; background: var(--bg); color: var(--muted); text-transform: uppercase; }
.m-get { background: var(--primary-50); color: var(--primary); }
.m-post { background: #ecfdf3; color: var(--success); }
.m-delete { background: #fef2f2; color: var(--danger); }
.m-put, .m-patch { background: #fffbeb; color: var(--warn); }
.m-mcp { background: #f5f0ff; color: var(--new); }
.caps-name { font-weight: 600; font-size: 13px; }
.caps-path { font-family: var(--mono); font-size: 13px; color: var(--text); }
.caps-url { font-family: var(--mono); font-size: 12px; }
.caps-desc { font-size: 13px; }
.caps-tag { font-size: 11px; color: var(--new); border: 1px solid var(--new); border-radius: 999px;
  padding: 0 7px; margin-left: auto; }
.caps-foot { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 12px; }
.caps-foot code { font-family: var(--mono); }
