/* Pixie UI - warm, paper-like Claude Code aesthetic. Coral is the only accent. */
:root {
  --font: "SF Mono", "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, Menlo, Consolas, monospace;
  --radius: 8px;
  --sp: 8px;
}
html[data-theme="light"] {
  --bg: #faf9f5; --bg-elev: #f2f0e9; --bg-sunk: #ecebe3; --border: #e3e1d6;
  --text: #2b2a27; --muted: #8c8a82; --dim: #b0aea5;
  --accent: #d97757; --accent-deep: #cc785c; --link: #4a7bb0;
  --success: #4e8a3d; --error: #c0392b; --warning: #b8860b;
  --diff-add-bg: #e6f2e6; --diff-add-fg: #2f6b27; --diff-del-bg: #fbe9e7; --diff-del-fg: #a23a2c;
}
html[data-theme="dark"] {
  --bg: #1a1915; --bg-elev: #24221c; --bg-sunk: #15140f; --border: #34322a;
  --text: #edeae0; --muted: #a8a69b; --dim: #75736b;
  --accent: #d97757; --accent-deep: #e08a6a; --link: #8bb4e0;
  --success: #7db36a; --error: #e06c5e; --warning: #d9a557;
  --diff-add-bg: #16301b; --diff-add-fg: #8fce7e; --diff-del-bg: #3a1715; --diff-del-fg: #e89084;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  overflow: hidden;
}
.spacer { flex: 1; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.brand { display: flex; align-items: baseline; gap: 6px; }
.brand-glyph { color: var(--accent); font-size: 16px; }
.brand-name { font-weight: 600; letter-spacing: 0.3px; }
.brand-tag { color: var(--dim); font-size: 11px; }
.crumbs { color: var(--dim); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.chip {
  font-size: 11.5px; color: var(--muted); padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 20px; background: var(--bg);
  white-space: nowrap;
}
.chip.model { color: var(--accent-deep); }
.icon-btn {
  background: none; border: 1px solid transparent; color: var(--muted);
  font-size: 15px; width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg); color: var(--text); border-color: var(--border); }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: 1fr 320px; min-height: 0; }
.chat { display: grid; grid-template-rows: 1fr auto; min-height: 0; min-width: 0; border-right: 1px solid var(--border); }
.chat > * { min-width: 0; }

/* ---- transcript ---- */
.transcript { overflow-y: auto; padding: 18px 20px 28px; }
.transcript > * { max-width: 880px; margin: 0 auto; }

.welcome {
  display: flex; gap: 14px; align-items: flex-start;
  border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 14px 16px; margin: 6px auto 18px; background: color-mix(in srgb, var(--accent) 7%, var(--bg));
}
.welcome-glyph { color: var(--accent); font-size: 22px; line-height: 1; }
.welcome-title { font-weight: 600; }
.welcome-sub { color: var(--muted); font-size: 12px; }
.welcome-sub code { color: var(--accent-deep); }

.msg { display: flex; gap: 8px; margin: 12px auto; align-items: flex-start; }
.msg .prompt { color: var(--accent); font-weight: 600; }
.msg .marker { color: var(--accent); }
.msg.user .bubble { color: var(--muted); white-space: pre-wrap; }
.msg.assistant .md { flex: 1; min-width: 0; }
.msg.error { color: var(--error); }
.msg.error .marker { color: var(--error); }
.msg.notice { color: var(--dim); font-size: 12px; font-style: italic; }

/* markdown */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md-p { margin: 8px 0; }
.md-h { margin: 14px 0 6px; font-size: 14px; }
.md-list { margin: 6px 0; padding-left: 22px; }
.md-list li { margin: 2px 0; }
.md-quote { border-left: 3px solid var(--border); margin: 8px 0; padding: 2px 12px; color: var(--muted); }
.md-hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.md a { color: var(--link); }
.md code, .md-pre code { font-family: var(--font); }
.md :not(pre) > code { background: var(--bg-sunk); padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }
.md-pre {
  background: var(--bg-sunk); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; overflow-x: auto; margin: 10px 0; font-size: 12.5px; line-height: 1.5;
}

/* ---- tool cards ---- */
.tool { border: 1px solid var(--border); border-radius: 6px; margin: 8px auto; background: var(--bg-elev); overflow: hidden; }
.tool-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; user-select: none; }
.tool-head:hover { background: var(--bg-sunk); }
.bullet { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--dim); }
.tool.running .bullet { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.tool.ok .bullet { background: var(--success); }
.tool.err .bullet { background: var(--error); }
.tool-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tool-summary { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tool-body { display: none; border-top: 1px solid var(--border); padding: 8px 10px; }
.tool.open .tool-body { display: block; }
.tool-out { background: var(--bg-sunk); border-radius: 4px; padding: 8px 10px; overflow-x: auto; margin: 6px 0 0; font-size: 12px; line-height: 1.45; max-height: 320px; }
.tool-out code, .diff code { white-space: pre; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.spin {
  display: inline-block; width: 11px; height: 11px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* diffs */
.diff { background: var(--bg-sunk); border-radius: 4px; padding: 8px 10px; overflow-x: auto; margin: 6px 0 0; font-size: 12px; line-height: 1.5; }
.diff-del { display: block; background: var(--diff-del-bg); color: var(--diff-del-fg); }
.diff-add { display: block; background: var(--diff-add-bg); color: var(--diff-add-fg); }

/* ---- approval ---- */
.approval { border: 1px solid var(--accent); border-radius: 6px; padding: 12px; margin: 10px auto; background: color-mix(in srgb, var(--accent) 8%, var(--bg-elev)); }
.approval-head { font-weight: 600; color: var(--accent-deep); margin-bottom: 4px; }
.approval-title { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; word-break: break-all; }
.approval-cmd { background: var(--bg-sunk); border-radius: 4px; padding: 8px 10px; overflow-x: auto; font-size: 12.5px; margin: 0 0 8px; }
.approval-file { font-size: 12px; color: var(--accent-deep); margin-bottom: 4px; }
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.approval-status { margin-top: 6px; font-size: 12px; color: var(--muted); }
.approval.resolved { opacity: 0.7; }
.approval.allowed { border-color: var(--success); }
.approval.denied { border-color: var(--error); }

/* ---- buttons ---- */
.btn {
  font-family: var(--font); font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  padding: 6px 12px; border-radius: 6px;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary, .btn.send, .btn.allow { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover, .btn.send:hover, .btn.allow:hover { background: var(--accent-deep); }
.btn.deny { color: var(--error); border-color: color-mix(in srgb, var(--error) 50%, var(--border)); }
.btn.ghost { background: none; }
.btn.stop { color: var(--error); border-color: color-mix(in srgb, var(--error) 50%, var(--border)); }

/* ---- composer ---- */
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-elev); }
#input {
  flex: 1; resize: none; font-family: var(--font); font-size: 13.5px; line-height: 1.5;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; max-height: 200px; outline: none;
}
#input:focus { border-color: var(--accent); }
#input.working { opacity: 0.85; }
.send { padding: 9px 16px; }

/* ---- status footer ---- */
.status { display: flex; align-items: center; gap: 8px; padding: 5px 14px; border-top: 1px solid var(--border); background: var(--bg-elev); color: var(--dim); font-size: 11.5px; overflow: hidden; white-space: nowrap; }
.status .sep { color: var(--border); }

/* ---- settings modal ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.overlay.show { display: flex; }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; width: 480px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); }
.field input, .field select {
  font-family: var(--font); font-size: 13px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field small { color: var(--dim); font-size: 11px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }
.hint { color: var(--dim); font-size: 11px; margin: 0; }

/* ---- responsive ---- */
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .chat { border-right: none; grid-row: 2; min-height: 0; }
  .stage { grid-row: 1; }
  .crumbs, .brand-tag { display: none; }
  .topbar { gap: 6px; padding: 8px 10px; }
  .chip { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .transcript { padding: 14px 12px 22px; }
  .composer { padding: 10px 12px; }
  #input:placeholder-shown { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 520px) {
  #provider-chip, #status-provider, #status-provider + .sep { display: none; }
  .icon-btn { width: 28px; }
}
