/* ==========================================================================
   turnstone server UI — page-specific styles
   Design tokens, reset, shared components live in /shared/base.css
   ========================================================================== */

/* ==========================================================================
   Header — server-specific elements
   ========================================================================== */
#model-name {
  font-size: 11px;
  color: var(--fg-dim);
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}
#mcp-status {
  color: var(--magenta);
  font-size: 11px;
  font-family: var(--font-mono);
  opacity: 0;
  transition: opacity 0.3s;
  cursor: default;
}
#health-indicator {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  margin-left: 8px;
  font-family: var(--font-mono);
  transition: opacity 0.3s ease, background 0.3s ease;
}
#health-indicator.health-ok {
  opacity: 0;
  pointer-events: none;
}
#health-indicator.health-degraded {
  background: var(--accent);
  color: var(--bg);
  opacity: 1;
}
.skip-permissions-warning {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--yellow);
  padding: 2px 8px;
  border: 1px solid var(--yellow);
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Hamburger menu
   ========================================================================== */
#hamburger-wrap { position: relative; }
#hamburger-btn {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--fg);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
#hamburger-btn:hover { background: var(--bg-highlight); border-color: var(--accent-dim); }
#hamburger-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#hamburger-btn span { display: block; width: 14px; height: 2px; background: var(--fg); border-radius: 1px; }
#hamburger-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 40;
  overflow: hidden;
}
[data-theme="light"] #hamburger-menu { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
#hamburger-menu.open { display: block; }
.hmenu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--fg);
  font: inherit;
  font-family: var(--font-display);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.1s;
}
.hmenu-item:hover { background: var(--bg-highlight); }
.hmenu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hmenu-item .hmenu-icon { width: 16px; text-align: center; font-size: 14px; opacity: 0.8; }
.hmenu-sep { height: 1px; background: var(--border-strong); margin: 4px 0; }
@media (max-width: 600px) {
  #hamburger-btn { width: 40px; height: 40px; }
  .hmenu-item { padding: 12px 14px; }
  .ws-tab .tab-close { opacity: 1; padding: 4px 6px; font-size: 16px; }
  #split-btn { display: none; }
}

/* ==========================================================================
   Tab bar
   ========================================================================== */
#tab-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}
#tab-list {
  display: flex;
  align-items: center;
  gap: 2px;
}
#tab-bar::-webkit-scrollbar { height: 3px; }
#tab-bar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.ws-tab {
  padding: 6px 10px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  color: var(--fg-dim);
  white-space: nowrap;
  user-select: none;
  position: relative;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ws-tab:hover { background: var(--bg-highlight); color: var(--fg-bright); }
.ws-tab.active {
  background: var(--bg-highlight);
  color: var(--fg-bright);
  border-bottom: 2px solid var(--accent);
}

/* Tab state indicators — LED glow */
.ws-tab .tab-indicator { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ws-tab .tab-indicator[data-state="idle"] { background: var(--fg-dim); opacity: 0.3; }
.ws-tab .tab-indicator[data-state="thinking"] { background: var(--cyan); box-shadow: 0 0 6px var(--cyan-glow); animation: pulse 1.5s ease-in-out infinite; will-change: opacity; }
.ws-tab .tab-indicator[data-state="running"] { background: var(--green); border-radius: 2px; box-shadow: 0 0 6px var(--green-glow); animation: pulse 1s ease-in-out infinite; will-change: opacity; }
.ws-tab .tab-indicator[data-state="attention"] { background: var(--yellow); border-radius: 1px; transform: rotate(45deg); box-shadow: 0 0 6px var(--yellow-glow); animation: pulse 1s ease-in-out infinite; will-change: opacity; }
.ws-tab .tab-indicator[data-state="error"] { background: var(--red); box-shadow: 0 0 4px var(--red-glow); }

.ws-tab .tab-close {
  background: none;
  border: none;
  color: var(--fg-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.1s;
}
.ws-tab:hover .tab-close, .ws-tab:focus-within .tab-close, .ws-tab .tab-close:focus-visible { opacity: 1; }
.ws-tab .tab-close:hover { color: var(--red); }

#new-tab-btn {
  background: none;
  border: 1px dashed var(--border-strong);
  color: var(--fg-dim);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#new-tab-btn:hover { background: var(--bg-highlight); color: var(--accent); border-color: var(--accent); }

#split-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--fg-dim);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 6px 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  margin-left: 2px;
}
#split-btn:hover { background: var(--bg-highlight); color: var(--accent); border-color: var(--accent); }
#split-btn.hidden { display: none; }

/* ==========================================================================
   Split panes
   ========================================================================== */
#split-root {
  display: flex;
  flex: 1;
  min-height: 0;
}
.split-container {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}
.split-horizontal { flex-direction: row; }
.split-vertical { flex-direction: column; }
.split-child {
  display: flex;
  min-width: 0;
  min-height: 0;
}
.split-handle {
  flex: 0 0 4px;
  background: var(--border);
  cursor: col-resize;
  transition: background 0.15s;
  z-index: 1;
  position: relative;
  touch-action: none;
}
.split-handle:hover,
.split-handle:active,
.split-handle.dragging { background: var(--accent); }
.split-vertical > .split-handle { cursor: row-resize; }
/* Expand hit area to 12px via pseudoelement */
.split-handle::before {
  content: '';
  position: absolute;
  z-index: 1;
}
.split-horizontal > .split-handle::before {
  top: 0; bottom: 0; left: -4px; right: -4px;
}
.split-vertical > .split-handle::before {
  left: 0; right: 0; top: -4px; bottom: -4px;
}

/* Pane */
.pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 200px;
  min-height: 150px;
  overflow: hidden;
}
.pane.focused { outline: 1px solid var(--accent-dim); outline-offset: -1px; }
.multi-pane .pane.focused .pane-header {
  border-bottom-color: var(--accent);
  background: var(--bg-highlight);
}

/* Pane header — only visible in multi-pane mode */
.pane-header { display: none; }
.multi-pane .pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 24px;
}
.pane-ws-name {
  font-size: 11px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pane.focused .pane-ws-name { color: var(--accent); }
.pane-actions { display: flex; gap: 2px; flex-shrink: 0; }
.pane-action-btn {
  background: none;
  border: none;
  color: var(--fg-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
  opacity: 0.3;
  transition: opacity 0.15s, color 0.1s, background 0.1s;
}
.pane.focused .pane-action-btn { opacity: 0.5; }
.pane-header:hover .pane-action-btn,
.pane-action-btn:focus-visible { opacity: 1; }
.pane-action-btn:hover { color: var(--fg-bright); background: var(--bg-highlight); }
.pane-close-btn:hover { color: var(--red); }

/* Pane context menu */
.pane-ctx-menu {
  position: fixed;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 300;
  overflow: hidden;
  padding: 4px 0;
}
[data-theme="light"] .pane-ctx-menu { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
.pane-ctx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 7px 14px;
  background: none;
  border: none;
  color: var(--fg);
  font: inherit;
  font-family: var(--font-display);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.1s;
}
.pane-ctx-item:hover:not(:disabled) { background: var(--bg-highlight); }
.pane-ctx-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pane-ctx-item:disabled { color: var(--fg-dim); opacity: 0.4; cursor: default; }
.pane-ctx-label { flex: 1; }
.pane-ctx-key {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-dim);
  flex-shrink: 0;
}
.pane-ctx-sep { height: 1px; background: var(--border-strong); margin: 4px 0; }

/* ==========================================================================
   Messages
   ========================================================================== */
.pane-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  max-width: 95%;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.msg-user {
  background: var(--bg-highlight);
  border: 1px solid var(--border-strong);
  align-self: flex-end;
  color: var(--fg-bright);
}
.msg-assistant { align-self: flex-start; }
.msg-info { color: var(--cyan); font-size: 12px; padding: 4px 14px; white-space: pre-wrap; font-family: inherit; }
.msg-error { color: var(--red); font-size: 12px; padding: 4px 14px; }
.msg-tool {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--yellow);
  font-size: 12px;
  padding: 8px 12px;
  align-self: flex-start;
  max-width: 95%;
}
.msg-tool .tool-header { color: var(--yellow); font-weight: 600; margin-bottom: 4px; font-size: 11px; }
.msg-tool .tool-preview { color: var(--fg-dim); white-space: pre-wrap; font-size: 12px; max-height: 300px; overflow-y: auto; }

/* Streaming content */
.reasoning { color: var(--fg-dim); font-style: italic; }
.thinking-indicator { color: var(--fg-dim); font-size: 12px; padding: 6px 14px; }
.thinking-indicator::after { content: '...'; animation: dots 1.5s steps(3, end) infinite; }
@keyframes dots { 0% { content: '.'; } 33% { content: '..'; } 66% { content: '...'; } }

/* ==========================================================================
   Markdown styling
   ========================================================================== */
/* Override KaTeX body rule — our layout requires body as a static flex container */
body { position: static; }
.msg-assistant h1, .msg-assistant h2, .msg-assistant h3, .msg-assistant h4, .msg-assistant h5, .msg-assistant h6 { color: var(--accent); margin: 8px 0 4px; font-family: var(--font-display); }
.msg-assistant h1 { font-size: 18px; }
.msg-assistant h2 { font-size: 16px; }
.msg-assistant h3 { font-size: 14px; }
.msg-assistant h4 { font-size: 13px; font-weight: 600; }
.msg-assistant h5 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.msg-assistant h6 { font-size: 12px; font-weight: 500; color: var(--fg-dim); }
.msg-assistant strong { color: var(--fg-bright); }
.msg-assistant em { color: var(--magenta); }
.msg-assistant del { color: var(--fg-dim); text-decoration: line-through; }
.msg-assistant code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  border: 1px solid var(--border);
}
.msg-assistant pre {
  background: var(--code-bg);
  padding: 12px 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--border);
}
.msg-assistant pre code { background: none; padding: 0; border: none; }
.msg-assistant ul, .msg-assistant ol { margin: 4px 0 4px 20px; }
.msg-assistant li { margin: 2px 0; }
.msg-assistant a { color: var(--accent); text-decoration: underline; }
.msg-assistant blockquote { border-left: 3px solid var(--accent-dim); padding-left: 12px; color: var(--fg-dim); margin: 6px 0; }
.msg-assistant hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.msg-assistant p { margin: 4px 0; }
.msg-assistant .table-wrap { overflow-x: auto; margin: 8px 0; -webkit-overflow-scrolling: touch; }
.msg-assistant .table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.msg-assistant table { border-collapse: collapse; width: auto; min-width: 50%; font-size: 13px; }
.msg-assistant thead { border-bottom: 2px solid var(--border-strong); }
.msg-assistant th { background: var(--code-bg); font-weight: 600; color: var(--fg-bright); }
.msg-assistant th, .msg-assistant td { padding: 6px 12px; border: 1px solid var(--border-strong); }
.msg-assistant tbody tr { transition: background 0.12s ease; }
.msg-assistant tbody tr:nth-child(even) { background: var(--row-alt); }
.msg-assistant tbody tr:hover { background: var(--bg-highlight); }
.msg-assistant .align-left { text-align: left; }
.msg-assistant .align-center { text-align: center; }
.msg-assistant .align-right { text-align: right; }
.msg-assistant img { display: block; max-width: 100%; height: auto; border-radius: var(--radius); margin: 4px 0; }
.msg-assistant .img-placeholder {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; margin: 4px 0;
  background: var(--code-bg); border: 1px solid var(--border-strong);
  border-radius: var(--radius); cursor: pointer;
  transition: border-color 0.12s ease;
}
.msg-assistant .img-placeholder:hover { border-color: var(--accent); }
.msg-assistant .img-placeholder:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.msg-assistant .img-placeholder-icon { font-size: 16px; }
.msg-assistant .img-placeholder-label { color: var(--fg-bright); font-size: 13px; }
.msg-assistant .img-placeholder-domain { color: var(--fg-dim); font-size: 11px; }
.msg-assistant li > input[type="checkbox"] { margin-right: 6px; vertical-align: middle; accent-color: var(--accent); }
.msg-assistant blockquote blockquote { margin: 4px 0; border-left-color: var(--border-strong); }
.msg-assistant blockquote blockquote blockquote { border-left-color: var(--border); }
.msg-assistant .katex-display { margin: 8px 0; padding: 8px 0; overflow-x: auto; overflow-y: hidden; }
.msg-assistant .katex-error { color: var(--red) !important; font-size: 12px; }

/* Syntax highlighting — highlight.js theme (instrument panel) */
.msg-assistant pre code.hljs { background: var(--code-bg); color: var(--fg); padding: 0; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-type { color: var(--magenta); }
.hljs-string, .hljs-attr, .hljs-template-tag, .hljs-template-variable { color: var(--green); }
.hljs-number, .hljs-literal, .hljs-variable, .hljs-symbol, .hljs-bullet { color: var(--cyan); }
.hljs-title, .hljs-title.class_, .hljs-title.function_ { color: var(--accent); }
.hljs-comment, .hljs-quote { color: var(--fg-dim); font-style: italic; }
.hljs-meta { color: var(--fg-dim); }
.hljs-doctag { color: var(--cyan); font-weight: 500; }
.hljs-char.escape_ { color: var(--cyan); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: bold; color: var(--fg-bright); }
.hljs-attribute { color: var(--yellow); }
.hljs-regexp, .hljs-link { color: var(--cyan); }
.hljs-selector-id, .hljs-selector-class { color: var(--yellow); }
.hljs-section { color: var(--accent); font-weight: bold; }
.hljs-tag { color: var(--fg-dim); }
.hljs-name { color: var(--magenta); }
.hljs-params { color: var(--fg); }
.hljs-addition { color: var(--green); background: rgba(52, 211, 153, 0.08); display: inline-block; width: 100%; }
.hljs-deletion { color: var(--red); background: rgba(248, 113, 113, 0.08); display: inline-block; width: 100%; }
.msg-assistant pre.code-terminal { border-left: 2px solid var(--green); }
[data-theme="light"] .hljs-addition { background: rgba(4, 120, 87, 0.06); }
[data-theme="light"] .hljs-deletion { background: rgba(220, 38, 38, 0.06); }

/* Mermaid diagrams */
.msg-assistant .mermaid-container {
  margin: 8px 0;
  text-align: center;
  border-radius: var(--radius);
  overflow-x: auto;
  min-height: 40px;
}
.msg-assistant .mermaid-container svg { max-width: 100%; height: auto; }
.msg-assistant .mermaid-loading {
  padding: 16px;
  color: var(--fg-dim);
  font-size: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}
.msg-assistant .mermaid-error { text-align: left; }
.msg-assistant .mermaid-error-msg {
  padding: 8px 12px;
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
@media (prefers-reduced-motion: reduce) {
  .msg-assistant .mermaid-container svg * { animation: none !important; }
}

/* Safe HTML elements */
.msg-assistant details {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  overflow: hidden;
}
.msg-assistant details summary {
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--fg-bright);
  user-select: none;
}
.msg-assistant details summary:hover { color: var(--accent); }
.msg-assistant details[open] > summary { border-bottom: 1px solid var(--border); }
.msg-assistant details > :not(summary) { padding: 0 12px; }
.msg-assistant kbd {
  background: var(--bg-highlight);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-size: 11px;
  font-family: var(--font-mono);
  box-shadow: 0 1px 0 var(--border-strong);
}
.msg-assistant mark { background: var(--yellow-glow); color: var(--fg-bright); border-radius: 2px; padding: 0 2px; }

/* GFM Callouts / Alerts */
.msg-assistant .callout {
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-surface);
  margin: 8px 0;
  overflow: hidden;
}
.msg-assistant .callout-title {
  padding: 8px 12px 4px;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.msg-assistant .callout-icon { font-size: 14px; }
.msg-assistant .callout-body { padding: 0 12px 8px; color: var(--fg); }
.msg-assistant .callout-body p:first-child { margin-top: 0; }
.msg-assistant .callout-body p:last-child { margin-bottom: 0; }
.msg-assistant .callout-note { border-left-color: var(--cyan); }
.msg-assistant .callout-note .callout-title { color: var(--cyan); }
.msg-assistant .callout-tip { border-left-color: var(--green); }
.msg-assistant .callout-tip .callout-title { color: var(--green); }
.msg-assistant .callout-important { border-left-color: var(--magenta); }
.msg-assistant .callout-important .callout-title { color: var(--magenta); }
.msg-assistant .callout-warning { border-left-color: var(--yellow); }
.msg-assistant .callout-warning .callout-title { color: var(--yellow); }
.msg-assistant .callout-caution { border-left-color: var(--red); }
.msg-assistant .callout-caution .callout-title { color: var(--red); }

/* Definition lists */
.msg-assistant dl { margin: 8px 0; }
.msg-assistant dt {
  font-weight: 600;
  color: var(--fg-bright);
  margin-top: 8px;
}
.msg-assistant dt:first-child { margin-top: 0; }
.msg-assistant dd {
  margin: 2px 0 0 20px;
  padding-left: 12px;
  border-left: 2px solid var(--border-strong);
}

/* Footnotes */
.msg-assistant .footnotes { margin-top: 16px; font-size: 12px; color: var(--fg-dim); }
.msg-assistant .footnotes-sep { border: none; border-top: 1px solid var(--border); margin-bottom: 8px; }
.msg-assistant .footnotes-list { margin: 0 0 0 20px; padding: 0; }
.msg-assistant .footnote-item { margin: 4px 0; line-height: 1.5; }
.msg-assistant .fn-ref a {
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
}
.msg-assistant .fn-ref a:hover { text-decoration: underline; }
.msg-assistant .fn-backref {
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
  margin-left: 4px;
}
.msg-assistant .fn-backref:hover { text-decoration: underline; }
.msg-assistant .fn-ref a:focus-visible,
.msg-assistant .fn-backref:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 2px;
}

/* ==========================================================================
   Input area
   ========================================================================== */
.pane-input-area {
  padding: 12px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-strong);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.pane-input {
  flex: 1;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 200px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pane-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.pane-input-area button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-family: var(--font-display);
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: filter 0.15s;
}
.pane-input-area button:hover { filter: brightness(1.1); }
.pane-input-area button:disabled { opacity: 0.35; cursor: not-allowed; filter: none; }
.pane-stop { background: var(--red, #c94040); }
.pane-stop:focus-visible { outline: 2px solid var(--fg-bright, #e8ecf4); outline-offset: 2px; }
[data-theme="light"] .pane-stop { color: #fff; }

/* ==========================================================================
   Inline approval blocks
   ========================================================================== */
.approval-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--yellow);
  border-radius: var(--radius);
  padding: 0;
  align-self: flex-start;
  max-width: 95%;
  font-size: 12px;
}
.approval-block.approved { border-left-color: var(--green); }
.approval-block.denied { border-left-color: var(--red); }
.approval-block.denied .approval-tool { opacity: 0.55; }
.approval-block.denied .approval-tool .tool-name { color: var(--muted); }
.approval-tool { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.approval-tool:last-of-type { border-bottom: none; }
.approval-tool .tool-name { color: var(--yellow); font-weight: 600; font-size: 11px; margin-bottom: 3px; }
.approval-tool .tool-cmd { color: var(--fg-bright); white-space: pre-wrap; word-break: break-all; }
.approval-tool .tool-cmd .dollar { color: var(--green); }
.approval-tool .tool-diff { white-space: pre-wrap; font-size: 12px; margin-top: 4px; }
.approval-tool .tool-diff .diff-del { color: var(--red); }
.approval-tool .tool-diff .diff-add { color: var(--green); }
.approval-tool .tool-diff .diff-warn { color: var(--yellow); }
.approval-prompt { padding: 8px 12px; font-size: 12px; border-top: 1px solid var(--border); background: var(--bg-highlight); }
.approval-actions { display: flex; gap: 6px; margin-bottom: 6px; }
.approval-btn {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--fg-bright);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.approval-btn:hover { background: var(--bg-highlight); }
.approval-btn .key {
  display: inline-block;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 4px;
  font-size: 10px;
  color: var(--accent);
  font-weight: 600;
  min-width: 18px;
  text-align: center;
}
.btn-approve:hover { border-color: var(--green); color: var(--green); }
.btn-deny:hover { border-color: var(--red); color: var(--red); }
.btn-always { border-style: dashed; }
.btn-always:hover { border-color: var(--accent); color: var(--accent); }
.approval-feedback-input {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.approval-feedback-input:focus { border-color: var(--accent); }
.approval-feedback-input::placeholder { color: var(--fg-dim); }
.approval-badge { padding: 6px 12px; font-size: 12px; font-weight: 600; border-top: 1px solid var(--border); overflow-wrap: break-word; word-break: break-word; }
.approval-badge.badge-approved { color: var(--green); }
.approval-badge.badge-denied { color: var(--red); }
.tool-output {
  padding: 8px 12px;
  background: var(--code-bg);
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  font-size: 12px;
  color: var(--fg-dim);
  max-height: 300px;
  overflow-y: auto;
}
.tool-output-stream {
  border-left: 2px solid var(--accent);
  max-height: 400px;
  animation: stream-pulse 2s ease-in-out infinite;
}
@keyframes stream-pulse {
  0%, 100% { border-left-color: var(--accent); }
  50% { border-left-color: var(--accent-dim); }
}
.tool-output.collapsed { max-height: 150px; position: relative; }
.tool-output.collapsed::after {
  content: 'click to expand';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 6px;
  background: linear-gradient(transparent, var(--code-bg) 60%);
  color: var(--fg-dim);
  font-size: 10px;
  font-family: var(--font-display);
  cursor: pointer;
  letter-spacing: 0.03em;
}

/* ==========================================================================
   Plan review dialog
   ========================================================================== */
#plan-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: center;
}
#plan-overlay.active { display: flex; }
#plan-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5);
  position: relative;
}
#plan-dialog::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 1px;
}
#plan-dialog h3 {
  font-family: var(--font-display);
  color: var(--accent);
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
#plan-content {
  white-space: pre-wrap;
  font-size: 12px;
  color: var(--fg-bright);
  margin-bottom: 16px;
  max-height: 50vh;
  overflow-y: auto;
  background: var(--code-bg);
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
#plan-feedback {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color 0.15s;
}
#plan-feedback:focus { border-color: var(--accent); }
#plan-buttons { display: flex; gap: 8px; justify-content: flex-end; }
#plan-buttons button {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: filter 0.15s, background 0.2s;
}
#plan-buttons button:hover { filter: brightness(1.1); }
#plan-buttons button:focus-visible { outline: 2px solid var(--fg-bright); outline-offset: 2px; }
#plan-buttons button .key {
  display: inline-block;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
}
#btn-plan-approve { background: var(--green); color: var(--on-color); }
#btn-plan-reject { background: var(--red); color: var(--on-color); }

/* Inline plan block (rendered in chat after plan review) */
.plan-inline {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.plan-inline-header {
  padding: 6px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.plan-inline-label.plan-approved { color: var(--green); }
.plan-inline-label.plan-rejected { color: var(--red); }
.plan-inline-label.plan-amending { color: var(--accent); }
.plan-inline-body {
  padding: 10px 14px;
  background: var(--code-bg);
  font-size: 12px;
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
}
.plan-inline-body.collapsed { max-height: 150px; position: relative; }
.plan-inline-body.collapsed::after {
  content: 'click to expand';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  text-align: center;
  padding: 8px 0 4px;
  background: linear-gradient(transparent, var(--code-bg));
  color: var(--fg-dim);
  font-size: 11px;
  cursor: pointer;
}
.plan-inline-body h2, .plan-inline-body h3 { font-size: 13px; margin: 10px 0 4px; color: var(--accent); }
.plan-inline-body p { margin: 4px 0; }
.plan-inline-body ol, .plan-inline-body ul { margin: 4px 0; padding-left: 20px; }
.plan-inline-feedback {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--accent);
  font-style: italic;
}

/* ==========================================================================
   Focus indicators — server-specific overrides
   ========================================================================== */
.pane-input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.approval-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty-state {
  color: var(--fg-dim);
  text-align: center;
  padding: 48px 16px;
  font-family: var(--font-display);
  font-size: 13px;
  font-style: italic;
  opacity: 0.7;
}

/* ==========================================================================
   Dashboard overlay
   ========================================================================== */
.dashboard-overlay { display: none; position: fixed; inset: 0; background: var(--bg); z-index: 50; overflow-y: auto; }
.dashboard-overlay.active { display: flex; justify-content: center; align-items: flex-start; }
.dashboard-content { width: 100%; max-width: 960px; padding: 32px 20px 24px; }
.dashboard-input-row { display: flex; gap: 8px; margin-bottom: 24px; }
.dashboard-input {
  flex: 1;
  background: var(--bg-surface);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dashboard-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.dashboard-input::placeholder { color: var(--fg-dim); }
.dashboard-new-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 12px 20px;
  font: inherit;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: filter 0.15s;
}
.dashboard-new-btn:hover { filter: brightness(1.1); }
.dashboard-new-btn:disabled { opacity: 0.35; cursor: not-allowed; filter: none; }
.dashboard-section { margin-bottom: 24px; }
.dashboard-section-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 12px;
}
.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.dashboard-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dashboard-card:hover { border-color: var(--accent); background: var(--bg-highlight); }
.dashboard-card:active { background: var(--bg-highlight); border-color: var(--accent); }
.dashboard-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dashboard-card .card-title { font-size: 13px; color: var(--fg-bright); font-weight: 500; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-card .card-meta { font-size: 11px; color: var(--fg-dim); }

/* Server dashboard row — clickable */
.dash-row { cursor: pointer; }

/* Dashboard footer */
.dash-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--code-bg);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 11px;
  margin-bottom: 24px;
}
.dash-footer-nodes { color: var(--fg-dim); display: flex; align-items: center; gap: 6px; }
.dash-footer-node-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; flex-shrink: 0; box-shadow: 0 0 4px var(--green-glow); }
.dash-footer-stats { color: var(--fg-dim); font-variant-numeric: tabular-nums; }

/* Dashboard responsive */
@media (max-width: 700px) {
  :root { --dash-grid: 68px 110px 1fr 56px 44px; }
  .dash-col-model, .dash-cell-model, .dash-col-node, .dash-cell-node { display: none; }
  .dash-row-sub { padding-left: 76px; }
}
@media (max-width: 600px) {
  .dashboard-input-row { flex-direction: column; }
  .dashboard-new-btn { width: 100%; }
}
@media (max-width: 480px) {
  .dashboard-content { padding: 24px 12px 16px; }
  .dashboard-cards { grid-template-columns: 1fr; }
  :root { --dash-grid: 50px 1fr 50px; }
  .dash-col-model, .dash-cell-model, .dash-col-node, .dash-cell-node, .dash-col-task, .dash-cell-task, .dash-col-ctx, .dash-cell-ctx { display: none; }
  .dash-row-sub { padding-left: 66px; }
  .tool-output, .tool-output-stream { max-height: 200px; }
}

/* ==========================================================================
   Verdict badges (intent judge)
   ========================================================================== */
.verdict-badge {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}
.verdict-low      { color: var(--green);  border-left: 3px solid var(--green);  }
.verdict-medium   { color: var(--yellow); border-left: 3px solid var(--yellow); }
.verdict-high     { color: var(--red);    border-left: 3px solid var(--red);    }
.verdict-critical { color: var(--red);    border-left: 3px solid var(--red);
                    background: rgba(255, 80, 80, 0.05); }

.verdict-detail {
  padding: 6px 12px;
  font-size: 11px;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}
.verdict-detail .verdict-summary   { margin-bottom: 4px; font-weight: 600; }
.verdict-detail .verdict-reasoning { color: var(--fg-dim); margin-bottom: 4px; }
.verdict-detail .verdict-evidence  { color: var(--fg-dim); font-style: italic; margin-bottom: 4px; }
.verdict-detail .verdict-tier      { color: var(--fg-dim); font-size: 10px; }

.verdict-expand {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 10px;
  text-decoration: underline;
  padding: 0;
}
.verdict-expand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.verdict-judge-spinner {
  font-size: 10px;
  color: var(--fg-dim);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 400;
}
.judge-spinner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: judge-pulse 1.2s ease-in-out infinite;
}
@keyframes judge-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Verdict glow on approval action buttons */
.approval-prompt.verdict-glow-approve .btn-approve {
  box-shadow: 0 0 8px var(--green-glow);
  border-color: var(--green);
}
.approval-prompt.verdict-glow-deny .btn-deny {
  box-shadow: 0 0 8px var(--red-glow);
  border-color: var(--red);
}
.approval-prompt.verdict-glow-review .btn-approve,
.approval-prompt.verdict-glow-review .btn-deny {
  box-shadow: 0 0 6px var(--yellow-glow);
  border-color: var(--yellow);
}

/* Output guard warning */
.output-warning { padding: 4px 8px; font-size: 11px; border-left: 3px solid; margin: 2px 0 2px 16px; }
.output-warning-low { border-color: var(--cyan); color: var(--cyan); }
.output-warning-medium { border-color: var(--yellow); color: var(--yellow); }
.output-warning-high { border-color: var(--red); color: var(--red); }
.output-warning-label { font-weight: 600; }
.output-warning-redacted { color: var(--fg-dim); font-style: italic; }

/* ==========================================================================
   New workstream modal
   ========================================================================== */
#new-ws-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
}
#new-ws-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 32px 24px;
  width: 380px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5),
              0 0 80px -20px var(--accent-dim);
  position: relative;
}
#new-ws-box::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 1px;
}
#new-ws-box h3 {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 0 0 16px;
}
#new-ws-box label {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 14px;
  margin-bottom: 5px;
}
#new-ws-box label:first-of-type { margin-top: 0; }
.nws-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.6;
}
#new-ws-box input[type="text"],
#new-ws-box select {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#new-ws-box input[type="text"]:focus,
#new-ws-box select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
#new-ws-box input[type="text"]::placeholder { color: var(--fg-dim); }
#new-ws-box select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a93ad' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
#new-ws-error {
  color: var(--red);
  font-size: 12px;
  margin-bottom: 8px;
  display: none;
}
#new-ws-buttons {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}
#new-ws-cancel {
  padding: 9px 20px;
  background: var(--bg-highlight);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
#new-ws-cancel:hover { background: var(--bg-elevated); }
#new-ws-cancel:focus-visible { outline: 2px solid var(--fg-bright); outline-offset: 2px; }
#new-ws-submit {
  padding: 9px 20px;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
#new-ws-submit:hover { filter: brightness(1.1); }
#new-ws-submit:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
#new-ws-submit:focus-visible { outline: 2px solid var(--fg-bright); outline-offset: 2px; }

/* ==========================================================================
   Reduced motion — page-specific
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .ws-tab .tab-indicator[data-state="thinking"],
  .ws-tab .tab-indicator[data-state="running"],
  .ws-tab .tab-indicator[data-state="attention"] { animation: none; opacity: 1; }
  .tool-output-stream { animation: none; border-left-color: var(--accent); }
  .judge-spinner-dot { animation: none; opacity: 1; }
  .thinking-indicator::after { animation: none; content: '...'; }
  .ws-tab, .ws-tab .tab-close, #new-tab-btn, #split-btn,
  .hmenu-item, .dashboard-card,
  .approval-btn, .approval-feedback-input,
  #plan-buttons button, .pane-input-area button,
  .dashboard-new-btn, .dashboard-input,
  #health-indicator, #hamburger-btn,
  #mcp-status, .msg-assistant tbody tr,
  .msg-assistant .img-placeholder,
  #new-ws-cancel, #new-ws-submit,
  #new-ws-box input, #new-ws-box select,
  .split-handle, .pane-action-btn,
  .pane-ctx-item { transition: none; }
}
