*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0d1117;
  --surface:      #161b27;
  --surface2:     #1e2536;
  --border:       #2a3347;
  --accent:       #6366f1;
  --accent-dim:   #3730a3;
  --text:         #e2e8f0;
  --text-dim:     #8892a4;
  --text-muted:   #4a5568;
  --user-bg:      #2d3748;
  --agent-bg:       #1a2238;
  --trace-call:   #1e3a5f;
  --trace-result: #1a3020;
  --green:        #34d399;
  --yellow:       #fbbf24;
  --red:          #f87171;
  --amber:        #f59e0b;
  --font-mono:    'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

/* ── Layout ─────────────────────────────────────────────────────── */
.layout { display: flex; flex-direction: column; height: 100vh; }

header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo { font-size: 18px; font-weight: 700; letter-spacing: -0.5px; color: var(--accent); }
.tagline { font-size: 12px; color: var(--text-dim); }
.spacer { flex: 1; }
.status-bar { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--text-dim); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.status-dot.off { background: var(--red); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }
.pulse { animation: pulse 1.8s ease-in-out infinite; }
#pipeline-count { color: var(--yellow); }

/* ── Steward presence pills ──────────────────────────────────────── */
#steward-presence { display: flex; align-items: center; gap: 5px; margin-left: 8px; }
.s-pill {
  font-size: 10px; font-family: var(--font-mono);
  padding: 2px 9px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); user-select: none; transition: border-color 0.2s, color 0.2s;
}
.s-pill.typing {
  border-color: var(--accent); color: var(--accent);
  animation: pill-flash 0.5s ease-in-out infinite alternate;
}
@keyframes pill-flash { from { opacity: 1; } to { opacity: 0.35; } }

.key-wrap { display: flex; align-items: center; gap: 6px; }
.key-wrap label { font-size: 11px; color: var(--text-muted); }
.key-wrap input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; padding: 4px 8px;
  border-radius: 4px; width: 160px;
}

.btn {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 12px; padding: 5px 12px;
  border-radius: 4px; cursor: pointer; transition: border-color .15s;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { opacity: .85; }
.btn:disabled { opacity: .4; cursor: default; }

.panels { display: flex; flex: 1; overflow: hidden; }

/* ── Chat panel ──────────────────────────────────────────────────── */
.chat-panel {
  width: 42%; display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
}
.messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg { max-width: 90%; line-height: 1.55; font-size: 14px; }
.msg.user { align-self: flex-end; background: var(--user-bg); padding: 10px 14px; border-radius: 12px 12px 3px 12px; }
.msg.agent  { align-self: flex-start; background: var(--agent-bg); padding: 10px 14px; border-radius: 12px 12px 12px 3px; }
.msg.system { align-self: center; font-size: 12px; color: var(--text-muted); font-style: italic; }
.msg strong { color: var(--accent); }

/* ── Markdown rendering inside agent messages ────────────────── */
.msg.agent p              { margin-bottom: 8px; }
.msg.agent p:last-child   { margin-bottom: 0; }
.msg.agent h1, .msg.agent h2, .msg.agent h3,
.msg.agent h4, .msg.agent h5, .msg.agent h6 {
  color: var(--text); font-weight: 600; margin: 12px 0 6px;
  line-height: 1.3;
}
.msg.agent h1 { font-size: 16px; }
.msg.agent h2 { font-size: 15px; }
.msg.agent h3, .msg.agent h4, .msg.agent h5, .msg.agent h6 { font-size: 14px; }
.msg.agent ul, .msg.agent ol { padding-left: 18px; margin-bottom: 8px; }
.msg.agent li  { margin-bottom: 3px; }
.msg.agent code {
  background: rgba(255,255,255,.08); border-radius: 3px;
  padding: 1px 5px; font-family: var(--font-mono); font-size: 12px;
}
.msg.agent pre {
  background: rgba(0,0,0,.3); border-radius: 5px;
  padding: 10px 12px; overflow-x: auto; margin: 8px 0;
}
.msg.agent pre code { background: none; padding: 0; font-size: 12px; }
.msg.agent blockquote {
  border-left: 3px solid var(--accent-dim); margin: 8px 0;
  padding: 4px 12px; color: var(--text-dim);
}
.msg.agent a          { color: var(--accent); text-decoration: underline; }
.msg.agent hr         { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.msg.agent table      { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13px; }
.msg.agent th, .msg.agent td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; }
.msg.agent th         { background: var(--surface2); color: var(--text); }

/* ── Markdown in file viewer ─────────────────────────────────── */
.file-content.md-rendered { white-space: normal; font-family: inherit; }
.file-content.md-rendered h1, .file-content.md-rendered h2,
.file-content.md-rendered h3 { font-size: 15px; font-weight: 600; margin: 12px 0 6px; }
.file-content.md-rendered p  { margin-bottom: 8px; line-height: 1.6; }
.file-content.md-rendered ul, .file-content.md-rendered ol { padding-left: 18px; margin-bottom: 8px; }
.file-content.md-rendered code {
  background: rgba(255,255,255,.08); border-radius: 3px;
  padding: 1px 5px; font-family: var(--font-mono); font-size: 11px;
}
.file-content.md-rendered pre {
  background: rgba(0,0,0,.3); border-radius: 5px;
  padding: 10px; overflow-x: auto; margin: 8px 0;
  font-family: var(--font-mono); font-size: 11px;
}
.file-content.md-rendered pre code { background: none; padding: 0; }

.thinking { display: flex; gap: 4px; padding: 10px 14px; }
.thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: bounce .9s infinite; }
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

.input-row {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}
#msg-input {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; padding: 8px 12px;
  border-radius: 6px; resize: none; outline: none; line-height: 1.4;
  font-family: inherit;
}
#msg-input:focus { border-color: var(--accent); }
#send-btn {
  background: var(--accent); border: none; color: #fff;
  font-size: 13px; padding: 8px 16px; border-radius: 6px;
  cursor: pointer; font-weight: 600; transition: opacity .15s;
}
#send-btn:disabled { opacity: .4; cursor: default; }

/* ── Right panel + tabs ──────────────────────────────────────────── */
.right-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.panel-tabs {
  display: flex; align-items: center; gap: 0;
  padding: 0 12px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.panel-tab {
  padding: 9px 14px; font-size: 12px; cursor: pointer;
  color: var(--text-dim); border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s; user-select: none;
}
.panel-tab.active { color: var(--accent); border-color: var(--accent); }
.panel-tab:hover:not(.active) { color: var(--text); }
.panel-tab-spacer { flex: 1; }

/* ── Activity pane ───────────────────────────────────────────────── */
#pane-activity {
  flex: 1; overflow-y: auto; padding: 10px;
  font-family: var(--font-mono); font-size: 12px;
}
.event {
  padding: 6px 10px; border-radius: 5px; margin-bottom: 5px;
  line-height: 1.45;
}
.event.call   { background: var(--trace-call); border-left: 3px solid var(--accent); }
.event.result { background: var(--trace-result); border-left: 3px solid var(--green); }
.event-header { display: flex; gap: 8px; color: var(--text-dim); margin-bottom: 3px; }
.event-from   { color: var(--accent); font-weight: 600; }
.event-arrow  { color: var(--text-muted); }
.event-to     { color: var(--green); font-weight: 600; }
.event-ts     { margin-left: auto; color: var(--text-muted); }
.event-body   {
  color: var(--text); word-break: break-word; white-space: pre-wrap; opacity: .85;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
#pane-activity.full .event-body {
  display: block; -webkit-line-clamp: unset; overflow: visible;
}

/* Session divider */
.session-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; color: var(--text-muted); font-size: 11px;
}
.session-divider::before, .session-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.session-divider span { white-space: nowrap; }

/* ── Steward pane ────────────────────────────────────────────────── */
#pane-steward { flex: 1; display: none; flex-direction: column; overflow: hidden; min-height: 0; }
#pane-steward.active { display: flex; }

.steward-sub-tabs {
  display: flex; align-items: center; gap: 0;
  padding: 0 12px; border-bottom: 1px solid var(--border);
  background: var(--surface2); flex-shrink: 0;
}
.steward-sub-tab {
  padding: 7px 12px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s; user-select: none;
}
.steward-sub-tab.active { color: var(--green); border-color: var(--green); }
.steward-sub-tab:hover:not(.active) { color: var(--text-dim); }

.steward-pane { flex: 1; display: none; flex-direction: column; overflow: hidden; min-height: 0; }
.steward-pane.active { display: flex; }

/* ── Files browser ───────────────────────────────────────────────── */
.file-browser { flex: 1; display: flex; overflow: hidden; }
.file-sidebar {
  width: 200px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.file-dir-bar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 8px;
  border-bottom: 1px solid var(--border); flex-shrink: 0; align-items: center;
}
.upload-btn {
  font-size: 11px; padding: 3px 8px; border-radius: 3px;
  background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.3);
  color: var(--green); cursor: pointer; transition: all .15s; white-space: nowrap;
}
.upload-btn:hover { background: rgba(52,211,153,.2); }
#upload-input { display: none; }
.dir-btn {
  font-size: 11px; padding: 3px 8px; border-radius: 3px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; transition: all .15s;
}
.dir-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--text); }
.dir-btn:hover:not(.active) { border-color: var(--accent); color: var(--text-dim); }
.file-list { flex: 1; overflow-y: auto; padding: 6px; }
.file-item {
  padding: 5px 8px; border-radius: 4px; font-size: 12px; font-family: var(--font-mono);
  cursor: pointer; color: var(--text-dim); transition: background .1s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-item:hover { background: var(--surface2); color: var(--text); }
.file-item.active { background: var(--surface2); color: var(--accent); }
.file-item .file-size { float: right; font-size: 10px; color: var(--text-muted); }
.file-content-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.file-content-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim); flex-shrink: 0;
}
.file-content {
  flex: 1; overflow: auto; padding: 12px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; color: var(--text);
}
.file-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-muted); font-style: italic;
}

/* ── Feedback ────────────────────────────────────────────────────── */
.feedback-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  font-size: 12px; color: var(--text-dim);
}
.feedback-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.feedback-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; overflow: hidden; flex-shrink: 0;
}
.feedback-item.status-open   { border-left: 3px solid var(--yellow); }
.feedback-item.status-resolved { border-left: 3px solid var(--green); }
.feedback-item.status-closed,
.feedback-item.status-fix-failed { border-left: 3px solid var(--text-muted); }
.feedback-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px 8px; border-bottom: 1px solid var(--border);
}
.feedback-tool { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--accent); }
.feedback-body { padding: 12px 14px; }
.feedback-description {
  font-size: 13px; line-height: 1.65; color: var(--text);
  white-space: pre-wrap; word-break: break-word; margin-bottom: 10px;
}
.feedback-meta {
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  font-size: 11px; color: var(--text-muted); margin-bottom: 10px;
}
.feedback-meta span { display: flex; gap: 4px; }
.feedback-meta .label { color: var(--text-muted); }
.feedback-meta .value { color: var(--text-dim); font-family: var(--font-mono); }
.feedback-comment {
  background: rgba(52,211,153,.06); border: 1px solid rgba(52,211,153,.2);
  border-radius: 4px; padding: 8px 10px; font-size: 12px;
  color: var(--text-dim); line-height: 1.55; margin-bottom: 8px;
}
.feedback-comment .comment-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--green); margin-bottom: 3px; }
.resolve-row { display: flex; gap: 6px; align-items: center; padding-top: 4px; }
.resolve-input {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; padding: 6px 9px; border-radius: 4px;
  outline: none;
}
.resolve-input:focus { border-color: var(--green); }

/* ── Status badges ───────────────────────────────────────────────── */
.badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: .04em; flex-shrink: 0;
}
.badge.open     { background: rgba(251,191,36,.15); color: var(--yellow); border: 1px solid rgba(251,191,36,.3); }
.badge.resolved { background: rgba(52,211,153,.15); color: var(--green); border: 1px solid rgba(52,211,153,.3); }
.badge.closed   { background: rgba(74,85,104,.3); color: var(--text-muted); border: 1px solid var(--border); }
.badge.fix-failed { background: rgba(248,113,113,.15); color: var(--red); border: 1px solid rgba(248,113,113,.3); }
.badge.high { background: rgba(248,113,113,.15); color: var(--red); border: 1px solid rgba(248,113,113,.3); }
.badge.medium { background: rgba(251,191,36,.15); color: var(--yellow); border: 1px solid rgba(251,191,36,.3); }
.badge.low { background: rgba(74,85,104,.3); color: var(--text-muted); border: 1px solid var(--border); }

/* Capability toggles */
.cap-toggle { transition: all 0.15s; }
.cap-toggle.cap-on  { background: rgba(99,102,241,.2); color: var(--accent); border: 1px solid rgba(99,102,241,.4); }
.cap-toggle.cap-off { background: rgba(74,85,104,.15); color: var(--text-muted); border: 1px solid var(--border); }
.cap-toggle:hover   { filter: brightness(1.3); }

/* User cards */
.user-card { border: 1px solid var(--border); border-radius: 6px; padding: 12px; margin-bottom: 8px; }

/* ── Logs ────────────────────────────────────────────────────────── */
.log-browser { flex: 1; display: flex; overflow: hidden; }
.log-list-pane { width: 220px; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.log-list-header { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.log-list { flex: 1; overflow-y: auto; padding: 6px; }
.log-item {
  padding: 5px 8px; border-radius: 4px; font-size: 11px; font-family: var(--font-mono);
  cursor: pointer; color: var(--text-dim); transition: background .1s;
  line-height: 1.4;
}
.log-item:hover { background: var(--surface2); color: var(--text); }
.log-item.active { background: var(--surface2); color: var(--accent); }
.log-item .log-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-item .log-meta { font-size: 10px; color: var(--text-muted); }
.log-content-pane { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.log-content-header {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text-dim); flex-shrink: 0;
}
.log-view-tabs { display: flex; gap: 4px; margin-left: auto; }
.log-view-tab {
  font-size: 11px; padding: 2px 8px; border-radius: 3px; cursor: pointer;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted);
}
.log-view-tab.active { border-color: var(--green); color: var(--green); }
.log-content {
  flex: 1; overflow: auto; padding: 12px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; color: var(--text);
}

/* ── Pipeline ────────────────────────────────────────────────────── */
.pipeline-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.pipeline-schedule-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.pipeline-schedule-form select,
.pipeline-schedule-form input[type="text"],
.pipeline-schedule-form input[type="datetime-local"] {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 5px; padding: 4px 8px;
  font-size: 12px; font-family: inherit;
}
.pipeline-schedule-form select { min-width: 130px; }
.pipeline-schedule-form input[type="text"] { flex: 1; min-width: 160px; }
.pipeline-schedule-form input[type="datetime-local"] { min-width: 180px; }
.pipeline-schedule-form label { font-size: 12px; color: var(--text-dim); }
.pipeline-list { flex: 1; overflow-y: auto; padding: 8px; }
.pipeline-empty { padding: 24px; font-size: 13px; color: var(--text-muted); font-style: italic; }
.pipeline-entry {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; margin-bottom: 6px; font-size: 12px;
}
.pipeline-type { font-family: var(--font-mono); color: var(--accent); font-weight: 600; }
.pipeline-label { flex: 1; color: var(--text-dim); }
.pipeline-due { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

/* ── Auth overlay ────────────────────────────────────────────────── */
#auth-overlay {
  position: fixed; inset: 0; background: rgba(13,17,23,.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.auth-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 32px 28px; min-width: 320px; text-align: center;
}
.auth-box h2 { margin-bottom: 8px; font-size: 18px; }
.auth-box p  { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.auth-box input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; padding: 9px 12px;
  border-radius: 6px; margin-bottom: 12px;
}
.auth-box button {
  width: 100%; background: var(--accent); border: none; color: #fff;
  font-size: 14px; padding: 9px; border-radius: 6px; cursor: pointer; font-weight: 600;
}
.auth-error { color: var(--red); font-size: 12px; margin-top: 8px; }

/* ── Misc ────────────────────────────────────────────────────────── */
.loading-msg { padding: 12px; font-size: 12px; color: var(--text-muted); font-style: italic; }
.error-msg   { padding: 12px; font-size: 12px; color: var(--red); }

/* ── Left panel toggle ───────────────────────────────────────────── */
.left-toggle-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.left-toggle-btn {
  font-size: 11px; padding: 2px 10px; border-radius: 3px; cursor: pointer;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted);
  transition: all .15s;
}
.left-toggle-btn.active { border-color: var(--accent); color: var(--accent); }
.left-toggle-btn:hover:not(.active) { border-color: var(--text-dim); color: var(--text-dim); }

/* ── Heartbeat stream events ─────────────────────────────────────── */
.event.hb-start { background: rgba(99,102,241,.12); border-left: 3px solid var(--accent); }
.event.hb-end   { background: rgba(52,211,153,.10); border-left: 3px solid var(--green); }
.event.hb-error { background: rgba(248,113,113,.10); border-left: 3px solid var(--red); }
.event.hb-text  { background: rgba(255,255,255,.025); border-left: 2px solid var(--text-muted); padding: 4px 10px; }

/* ── Dialog panel ────────────────────────────────────────────────── */
#dialog-panel { flex: 1; display: none; flex-direction: column; overflow: hidden; }
#dialog-panel.active { display: flex; }
.dialog-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.dialog-msg { max-width: 90%; line-height: 1.55; font-size: 14px; }
.dialog-msg.agent   { align-self: flex-start; background: var(--agent-bg); padding: 10px 14px; border-radius: 12px 12px 12px 3px; }
.dialog-msg.steward { align-self: flex-end;   background: var(--user-bg); padding: 10px 14px; border-radius: 12px 12px 3px 12px; }
.dialog-msg .msg-meta    { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.dialog-msg .msg-subject { font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 3px; }
.dialog-reply-row {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-shrink: 0;
}
#dialog-reply-input {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; padding: 8px 12px;
  border-radius: 6px; resize: none; outline: none; line-height: 1.4;
  font-family: inherit;
}
#dialog-reply-input:focus { border-color: var(--accent); }

/* ── Stack tab ───────────────────────────────────────────────────── */
.stack-surface-bar {
  display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stack-surface-btn {
  padding: 3px 10px; border-radius: 4px; font-size: 11px; cursor: pointer;
  color: var(--text-dim); background: var(--surface2); font-family: var(--font-mono);
}
.stack-surface-btn.active { background: var(--accent); color: #000; font-weight: 600; }
.stack-type-bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.stack-type-label { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }
.stack-type-sel {
  font-size: 11px; font-family: var(--font-mono); background: var(--surface2);
  color: var(--text); border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 6px; cursor: pointer;
}
.stack-type-hint { font-size: 11px; color: var(--text-dim); }
.stack-profile-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.stack-profile-name { font-weight: 600; font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.stack-profile-version { font-size: 11px; color: var(--accent); font-family: var(--font-mono); }
.stack-profile-desc { font-size: 11px; color: var(--text-dim); flex: 1; }
.stack-total-chars { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }
.stack-history-btn { margin-left: auto; padding: 2px 8px; font-size: 11px; }
.stack-layers { padding: 4px 0; }
.stack-layer {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px;
  border-bottom: 1px solid var(--border); transition: background 0.1s;
}
.stack-layer:hover { background: var(--surface2); }
.stack-layer.expanded { background: var(--surface2); }
.stack-layer.unresolved { opacity: 0.5; }
.stack-layer.disabled { opacity: 0.35; }
.stack-layer-reorder { display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; width: 18px; }
.stack-reorder-btn {
  background: none; border: none; color: var(--text-dim); font-size: 10px;
  cursor: pointer; padding: 0; line-height: 1; width: 14px; text-align: center;
}
.stack-reorder-btn:hover { color: var(--accent); }
.stack-reorder-placeholder { display: inline-block; width: 14px; height: 14px; }
.stack-layer-num  { width: 18px; text-align: right; font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); flex-shrink: 0; cursor: pointer; }
.stack-layer-name { width: 140px; font-size: 12px; font-family: var(--font-mono); color: var(--text); flex-shrink: 0; cursor: pointer; }
.stack-layer-source { flex: 1; font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.stack-layer-empty { color: var(--text-muted) !important; font-style: italic; cursor: pointer; }
.stack-layer-size { width: 52px; text-align: right; font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); flex-shrink: 0; cursor: pointer; }
.stack-layer-arrow { width: 14px; text-align: center; font-size: 10px; color: var(--text-dim); flex-shrink: 0; cursor: pointer; }
.stack-layer-content {
  padding: 12px 16px 12px 52px; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.stack-layer-pre {
  margin: 0; font-family: var(--font-mono); font-size: 11px; color: var(--text);
  white-space: pre-wrap; word-break: break-word; line-height: 1.55; max-height: 400px;
  overflow-y: auto;
}
.stack-ls {
  font-size: 11px; vertical-align: middle;
  user-select: none; cursor: help; font-weight: 700;
}
.stack-ls-line { color: #4ade80; }   /* U+2028 line separator — chartered green */
.stack-ls-para { color: #60a5fa; }   /* U+2029 section separator — venue blue */
.stack-footer {
  padding: 8px 12px; font-size: 11px; color: var(--text-dim);
  font-family: var(--font-mono); border-top: 1px solid var(--border);
}
/* History panel */
.stack-history-header {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.stack-history-title { font-size: 12px; color: var(--text); font-family: var(--font-mono); }
.stack-history-list { overflow-y: auto; padding: 4px 0; }
.stack-history-entry {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.stack-history-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; }
.stack-history-ver  { font-family: var(--font-mono); color: var(--accent); font-weight: 600; min-width: 28px; }
.stack-history-op   { font-family: var(--font-mono); color: var(--text); flex: 1; }
.stack-history-ts   { color: var(--text-dim); white-space: nowrap; }
