:root {
  --bg: #0A0A0C;
  --bg-base: #0F0D10;
  --bg-surface: #161218;
  --bg-elevated: #1C1719;
  --bg-card: #221B1E;
  --bg-input: #2A2225;
  --bg-hover: #332528;

  --accent: #FF0033;
  --accent-dark: #8B0020;
  --accent-deep: #5C0015;
  --accent-light: #FF1A5E;
  --accent-muted: #FF4D6D;
  --accent-bright: #FF1744;
  --accent-soft: #FF5252;
  --accent-dim: #6B2033;
  --accent-bg: #4A1525;

  --text-primary: #EAE0E2;
  --text-secondary: #D4C4C8;
  --text-tertiary: #8A7A7E;
  --text-disabled: #5A4F52;

  --success: #00E676;
  --warning: #FFD740;
  --error: #FF1744;
  --info: #448AFF;

  --border: #2A1F22;
  --border-accent: #FF003344;
  --border-accent-full: #FF0033;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', 'Menlo', monospace;

  --header-h: 52px;
  --sidebar-w: 280px;
}

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

html, body, #root { height: 100%; width: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dark); }

a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { color: var(--accent-light); }

button {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent-dark); color: var(--text-primary); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: var(--accent-bright); border-color: var(--accent-bright); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-tertiary); }
button.ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
button.sm { font-size: 12px; padding: 4px 10px; }

input, textarea {
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--border-accent); }
input::placeholder { color: var(--text-disabled); }

.app-layout { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}

.header-brand { display: flex; align-items: center; gap: 8px; }
.header-logo { font-family: var(--font-mono); font-weight: 900; font-size: 18px; color: var(--accent); letter-spacing: 3px; user-select: none; }
.header-version { font-size: 11px; color: var(--accent-dim); font-family: var(--font-mono); }

.header-nav { display: flex; gap: 4px; margin-left: 32px; }

.nav-tab {
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.nav-tab:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-tab.active { color: #fff; background: var(--accent); }
.tab-icon { display: flex; align-items: center; }

.header-spacer { flex: 1; }

.header-indicators { display: flex; align-items: center; gap: 12px; }
.indicator { width: 8px; height: 8px; border-radius: 50%; transition: background 0.3s; }
.indicator.ok { background: var(--success); }
.indicator.warn { background: var(--warning); }
.indicator.error { background: var(--error); }
.indicator.off { background: var(--text-disabled); }

.header-clock { font-family: var(--font-mono); font-size: 12px; color: var(--accent); font-weight: 600; }

.content { flex: 1; overflow: hidden; position: relative; }
.content > div { position: absolute; inset: 0; overflow: hidden; }
.tab-hidden { display: none; }

.statusbar {
  height: 28px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-disabled);
}
.statusbar-left, .statusbar-right { display: flex; align-items: center; gap: 12px; }
.statusbar-sudo {
  font-size: 10px; font-weight: 700; font-family: var(--font-mono);
  padding: 1px 6px; border-radius: 3px;
  background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.statusbar-shortcut { display: inline-flex; align-items: center; gap: 4px; }
.statusbar-shortcut kbd {
  display: inline-block; padding: 1px 5px; border-radius: 3px;
  background: var(--bg-card); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--accent-dim); }
.card-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge.ok { background: rgba(0,230,118,0.15); color: var(--success); }
.badge.error { background: rgba(255,23,68,0.15); color: var(--error); }
.badge.warn { background: rgba(255,215,64,0.15); color: var(--warning); }
.badge.info { background: rgba(68,138,255,0.15); color: var(--info); }
.badge.neutral { background: var(--bg-hover); color: var(--text-tertiary); }
.badge.accent { background: var(--accent-bg); color: var(--accent); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.chip:hover { border-color: var(--accent-dark); background: var(--bg-hover); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.progress { height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-light)); border-radius: 3px; transition: width 0.4s ease; }

.tool-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.tool-row:last-child { border-bottom: none; }
.tool-name { flex: 1; color: var(--text-primary); font-weight: 500; }
.tool-version { color: var(--text-tertiary); font-size: 12px; font-family: var(--font-mono); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; height: 100%; padding: 20px; overflow: auto; }
.split-horizontal { display: flex; height: 100%; }
.split-right { width: var(--sidebar-w); border-left: 1px solid var(--border); background: var(--bg-surface); overflow: auto; padding: 16px; }

.chat-layout { display: flex; flex-direction: column; height: 100%; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.message.user { align-self: flex-end; background: var(--accent-bg); color: var(--text-primary); border-bottom-right-radius: 4px; }
.message.ai { align-self: flex-start; background: var(--bg-card); color: var(--text-primary); border-bottom-left-radius: 4px; border-left: 3px solid var(--accent); }
.chat-input-bar { display: flex; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border); background: var(--bg-surface); }
.chat-input-bar input { flex: 1; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 20px; }
.sidebar-tab {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius);
  font-size: 13px; color: var(--text-tertiary); cursor: pointer; transition: all 0.15s;
}
.sidebar-tab:hover { background: var(--bg-card); color: var(--text-primary); }
.sidebar-tab.active { background: var(--accent); color: #fff; font-weight: 600; }

.shell-layout { display: flex; height: 100%; overflow: hidden; }
.shell-terminal-col { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.shell-tabs-bar {
  display: flex; align-items: center; background: var(--bg-surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  height: 36px; padding: 0 8px; gap: 4px;
}
.shell-tabs {
  display: flex; align-items: center; gap: 2px; flex: 1; overflow-x: auto;
  scrollbar-width: none;
}
.shell-tabs::-webkit-scrollbar { display: none; }

.shell-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius) var(--radius) 0 0;
  font-size: 12px; font-weight: 500; color: var(--text-tertiary);
  cursor: pointer; transition: all 0.15s; user-select: none;
  border: 1px solid transparent; border-bottom: none;
  white-space: nowrap; max-width: 180px; position: relative;
  background: transparent;
}
.shell-tab:hover { color: var(--text-primary); background: var(--bg-card); }
.shell-tab.active {
  color: var(--text-primary); background: var(--bg);
  border-color: var(--border); border-bottom-color: var(--bg);
  margin-bottom: -1px;
}
.shell-tab-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 120px; font-size: 12px;
}
.shell-tab-index {
  font-size: 9px; color: var(--text-disabled); font-family: var(--font-mono);
  padding: 0 3px; background: var(--bg-input); border-radius: 3px; line-height: 1.4;
}
.shell-tab-close {
  display: flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 3px; border: none;
  background: transparent; color: var(--text-disabled); cursor: pointer;
  padding: 0; transition: all 0.1s; flex-shrink: 0;
}
.shell-tab-close:hover { background: var(--accent-bg); color: var(--accent); }

.shell-tab-rename {
  width: 80px; font-size: 12px; padding: 1px 4px; border-radius: 3px;
  background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--accent);
  outline: none; font-family: var(--font-sans);
}

.shell-tab-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.shell-zoom-badge {
  font-size: 10px; font-family: var(--font-mono); font-weight: 600;
  color: var(--accent); background: var(--accent-bg);
  padding: 2px 6px; border-radius: 3px;
  border: 1px solid var(--accent-dim);
  white-space: nowrap;
}

.shell-new-tab-wrapper { position: relative; }
.shell-new-tab-btn {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 8px; border-radius: var(--radius);
  background: transparent; border: 1px solid var(--border);
  color: var(--text-tertiary); cursor: pointer; transition: all 0.15s;
  font-size: 12px;
}
.shell-new-tab-btn:hover { color: var(--text-primary); background: var(--bg-card); border-color: var(--accent-dark); }

.shell-menu-overlay {
  position: fixed; inset: 0; z-index: 998;
}
.shell-new-tab-menu {
  position: absolute; top: 100%; right: 0; z-index: 999;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 6px;
  min-width: 260px; max-height: 400px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.shell-menu-label {
  font-size: 10px; font-weight: 700; color: var(--text-disabled);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 6px 10px 4px;
}
.shell-menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 10px; border-radius: var(--radius);
  background: transparent; border: none; color: var(--text-secondary);
  cursor: pointer; transition: all 0.1s; font-size: 12px;
  text-align: left; font-family: var(--font-sans);
}
.shell-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.shell-menu-item.accent { color: var(--accent); }
.shell-menu-item.accent:hover { background: var(--accent-bg); }
.shell-menu-item-sub {
  font-size: 10px; color: var(--text-disabled); font-family: var(--font-mono);
  margin-left: auto;
}
.shell-menu-item-row { display: flex; align-items: center; }
.shell-menu-item-icon {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary);
  cursor: pointer; transition: all 0.1s; flex-shrink: 0;
}
.shell-menu-item-icon:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-dim); }
.shell-menu-empty {
  font-size: 12px; color: var(--text-disabled); padding: 8px 10px;
  font-style: italic;
}
.shell-menu-divider { height: 1px; background: var(--border); margin: 4px 6px; }

.shell-xterm-wrapper { flex: 1; min-height: 0; background: var(--bg); overflow: hidden; position: relative; }

.shell-search-bar {
  position: absolute; top: 8px; right: 12px; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.shell-search-icon { color: var(--text-tertiary); flex-shrink: 0; }
.shell-search-input {
  width: 200px; font-size: 12px; padding: 3px 6px; border-radius: 4px;
  background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border);
  font-family: var(--font-mono); outline: none;
}
.shell-search-input:focus { border-color: var(--accent); }
.shell-search-nav {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 4px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-tertiary); cursor: pointer; font-size: 12px;
  padding: 0; transition: all 0.1s;
}
.shell-search-nav:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent-dark); }
.shell-search-close {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 4px;
  background: transparent; border: none;
  color: var(--text-disabled); cursor: pointer; padding: 0;
}
.shell-search-close:hover { color: var(--accent); }
.shell-xterm-instance {
  position: absolute;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}
.shell-xterm-instance.active {
  visibility: visible;
  pointer-events: auto;
}
.shell-xterm-instance .xterm { height: 100%; }

.connection-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.connection-dot.on { background: var(--success); box-shadow: 0 0 6px var(--success); }
.connection-dot.off { background: var(--error); }

.shell-tab.ai-tab .shell-tab-name { color: var(--accent); }
.shell-tab.ai-tab { border-bottom-color: var(--accent); }

.shell-ai-col { width: 320px; max-width: 320px; border-left: 1px solid var(--border); background: var(--bg-surface); display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; }
.ai-panel-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13px; color: var(--accent); display: flex; align-items: center; justify-content: space-between; }
.sudo-indicator { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sudo-indicator.sudo-ok { background: #22c55e; box-shadow: 0 0 6px rgba(34, 197, 94, 0.5); }
.sudo-indicator.sudo-blocked { background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.5); }
.shell-analyze-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius);
  background: transparent; border: 1px solid var(--accent-dim);
  color: var(--accent); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.shell-analyze-btn:hover:not(:disabled) { background: var(--accent-bg); }
.shell-analyze-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.shell-ai-token-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.shell-ai-token-track { flex: 1; height: 3px; background: var(--bg-input); border-radius: 2px; overflow: hidden; }
.shell-ai-token-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s, background 0.3s; }
.shell-ai-token-fill.warn { background: var(--warning); }
.shell-ai-token-text { font-size: 10px; font-family: var(--font-mono); color: var(--text-tertiary); white-space: nowrap; }
.ai-panel-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.ai-message { padding: 8px 12px; border-radius: var(--radius); font-size: 13px; line-height: 1.5; word-break: break-word; }
.ai-message.user { background: var(--bg-elevated); border-left: 3px solid var(--accent-bright); color: var(--text-primary); }
.ai-message.user.analysis { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--bg-elevated)); }
.ai-message.assistant { background: var(--bg-card); border-left: 3px solid var(--accent); }
.ai-message.system { background: var(--bg-elevated); border-left: 3px solid var(--info); font-style: italic; color: var(--text-tertiary); font-size: 12px; }
.ai-message.assistant { background: var(--bg-card); border-left: 3px solid var(--accent); }
.ai-message.thinking { background: var(--bg-elevated); border-left: 3px solid var(--info); font-style: italic; color: var(--text-tertiary); }
.ai-message.tool { background: var(--bg-elevated); border-left: 3px solid var(--warning); }
.ai-message.tool .tool-name { font-weight: 700; color: var(--warning); }
.ai-message.tool .tool-args { font-family: var(--font-mono); font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }
.ai-panel-input { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.ai-panel-input input { flex: 1; font-size: 13px; padding: 6px 10px; }
.ai-panel-input .ai-clear-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent-bg); color: var(--accent); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all 0.15s; font-family: var(--font-sans);
}
.ai-panel-input .ai-clear-btn:hover { background: var(--accent); color: #fff; }

.shell-code-block {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  margin: 8px 0 4px; overflow: hidden;
}
.shell-code-block pre {
  padding: 10px 12px; font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
  overflow-x: auto; color: var(--text-primary); margin: 0;
}
.shell-code-lang {
  padding: 3px 10px; font-size: 10px; font-weight: 600; color: var(--text-tertiary);
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.shell-code-actions {
  display: flex; border-top: 1px solid var(--border); background: var(--bg-surface);
}
.shell-code-actions button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 5px 0; background: transparent; border: none; border-right: 1px solid var(--border);
  color: var(--text-tertiary); font-size: 11px; cursor: pointer; transition: all 0.1s;
  font-family: var(--font-sans);
}
.shell-code-actions button:last-child { border-right: none; }
.shell-code-actions button:hover { background: var(--accent-bg); color: var(--accent); }
.shell-code-actions button.copied { background: var(--accent-bg); color: var(--accent); animation: copy-flash 0.3s ease; }

.shell-mermaid-container { padding: 12px; background: var(--bg); overflow-x: auto; display: flex; justify-content: center; }
.shell-mermaid-container svg { max-width: 100%; height: auto; }
.shell-mermaid-loading { padding: 16px; text-align: center; color: var(--text-tertiary); font-size: 12px; }
.shell-mermaid-error { padding: 10px 12px; color: var(--accent-bright); font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; }

.ai-message table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 12px; display: block; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.ai-message thead, .ai-message tbody { display: table-row-group; }
.ai-message th { background: var(--bg-surface); padding: 4px 8px; text-align: left; font-weight: 600; border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap; }
.ai-message td { padding: 3px 8px; border: 1px solid var(--border); color: var(--text-primary); white-space: nowrap; }
.ai-message tr { display: table-row; }
.ai-message tr:nth-child(even) td { background: var(--bg-surface); }

@keyframes copy-flash {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); background: color-mix(in srgb, var(--accent) 20%, transparent); }
  100% { transform: scale(1); }
}

.shell-analysis-modal {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 720px; max-width: 90vw; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.shell-analysis-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 15px; color: var(--accent);
}
.shell-analysis-modal-body {
  flex: 1; overflow-y: auto; padding: 20px; font-size: 14px; line-height: 1.5;
  color: var(--text-primary); word-break: break-word;
}
.shell-analysis-modal-body table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.shell-analysis-modal-body th { background: var(--bg-surface); padding: 4px 10px; text-align: left; font-weight: 600; border: 1px solid var(--border); color: var(--text-secondary); }
.shell-analysis-modal-body td { padding: 3px 10px; border: 1px solid var(--border); color: var(--text-primary); }
.shell-analysis-modal-body tr:nth-child(even) td { background: var(--bg-surface); }
.shell-analysis-modal-body .msg-h3 { font-size: 18px; font-weight: 700; color: var(--text-primary); margin: 16px 0 6px; display: block; }
.shell-analysis-modal-body .msg-h4 { font-size: 15px; font-weight: 700; color: var(--text-secondary); margin: 12px 0 4px; display: block; }
.shell-analysis-modal-body .msg-h2 { font-size: 20px; font-weight: 700; color: var(--accent); margin: 20px 0 8px; display: block; }
.shell-analysis-modal-body .msg-bullet { display: block; padding-left: 4px; margin: 2px 0; color: var(--text-primary); }
.shell-analysis-modal-body .msg-step { display: flex; gap: 8px; align-items: baseline; margin: 2px 0; }
.shell-analysis-modal-body .msg-step-num { color: var(--accent); font-weight: 700; font-family: var(--font-mono); flex-shrink: 0; }
.shell-analysis-modal-body strong { color: var(--accent-light); }
.shell-analysis-modal-body .inline-code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 13px; color: var(--accent-muted); }

.shell-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.shell-modal {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); min-width: 380px; max-width: 480px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.shell-modal-header {
  padding: 16px 20px; font-size: 14px; font-weight: 700;
  color: var(--text-primary); border-bottom: 1px solid var(--border);
}
.shell-modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.shell-modal-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); margin-bottom: 2px; }
.shell-modal-row { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.shell-modal-field { display: flex; flex-direction: column; }
.shell-modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

.config-window { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.config-tabs-bar {
  display: flex; gap: 4px; padding: 12px 20px; background: var(--bg-surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}

.config-panel-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.config-panel-body { flex: 1; overflow-y: auto; padding: 16px 28px 28px; }
.config-profile-center {
  max-width: 540px; margin: 0 auto; width: 100%;
  display: flex; flex-direction: column; gap: 12px;
}

.config-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: 16px;
}
.config-card-row {
  display: flex; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--border); gap: 16px;
}
.config-card-row:last-of-type { border-bottom: none; }
.config-card-label { width: 130px; flex-shrink: 0; color: var(--text-tertiary); font-size: 13px; }
.config-card-value { color: var(--text-primary); font-size: 14px; flex: 1; }
.config-card-value.mono { font-family: var(--font-mono); }
.config-card-value:not(.mono)[style*="—"] { color: var(--text-disabled); font-style: italic; }
.config-card-actions { display: flex; gap: 8px; padding-top: 16px; }

.config-form-field { margin-bottom: 14px; }
.config-form-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-tertiary); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px; }
.config-form-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; color: var(--text-primary);
  font-size: 13px; font-family: var(--font-mono); outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.config-form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--border-accent); }

.config-card-group { margin-bottom: 20px; }
.config-card-group:last-child { margin-bottom: 0; }
.config-card-group-label { display: block; font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }

.config-providers-list { display: flex; flex-direction: column; gap: 12px; }
.provider-card-v2 {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 20px; transition: border-color 0.2s;
}
.provider-card-v2:hover { border-color: var(--accent-dim); }
.provider-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.provider-card-identity { display: flex; align-items: center; gap: 10px; }
.provider-card-name { font-weight: 600; color: var(--text-primary); font-size: 14px; }
.provider-card-actions { display: flex; gap: 8px; flex-shrink: 0; }
.provider-card-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-tertiary); font-family: var(--font-mono); margin-top: 8px; }
.provider-card-model { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.provider-card-model-label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; }
.provider-card-model-value { font-size: 14px; font-weight: 600; font-family: var(--font-mono); color: var(--accent); }
.provider-card-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

.provider-setup-hint {
  font-size: 13px; color: var(--text-tertiary); margin-bottom: 16px;
  padding: 10px 14px; border-radius: var(--radius); background: var(--bg-surface);
  border-left: 3px solid var(--accent-dim);
}
.provider-setup-token-row { display: flex; gap: 12px; align-items: flex-end; }
.provider-setup-token-input { flex: 1; }
.provider-setup-token-actions { display: flex; gap: 8px; flex-shrink: 0; padding-bottom: 1px; }

.config-update-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.config-update-stats { display: flex; gap: 8px; }
.config-update-buttons { display: flex; gap: 8px; }

.config-update-list { display: flex; flex-direction: column; gap: 2px; }
.config-update-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-radius: var(--radius); background: var(--bg-card); border: 1px solid var(--border); margin-bottom: 6px; }
.config-update-row:hover { border-color: var(--accent-dim); }
.config-update-info { display: flex; align-items: center; gap: 16px; flex: 1; }
.config-update-name { color: var(--text-primary); font-weight: 600; font-size: 13px; min-width: 100px; }
.config-update-versions { color: var(--text-tertiary); font-size: 12px; font-family: var(--font-mono); }

.skill-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.skill-tile { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: border-color 0.15s; }
.skill-tile:hover { border-color: var(--accent-dim); }
.skill-tile-name { font-weight: 600; color: var(--text-primary); font-size: 14px; margin-bottom: 6px; }
.skill-tile-desc { font-size: 12px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.skill-tile-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.skill-detail-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 50; display: flex; align-items: center; justify-content: center; }
.skill-detail-panel { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 90%; max-width: 600px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.skill-detail-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.skill-detail-name { font-weight: 600; font-size: 16px; color: var(--text-primary); }
.skill-detail-body { flex: 1; overflow-y: auto; padding: 20px; }
.skill-detail-section { margin-bottom: 16px; }
.skill-detail-label { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.skill-detail-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.skill-detail-content { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); white-space: pre-wrap; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; line-height: 1.6; max-height: 300px; overflow-y: auto; }
.skill-detail-deps { display: flex; flex-direction: column; gap: 6px; }
.skill-detail-dep { font-size: 12px; color: var(--text-tertiary); display: flex; align-items: center; gap: 8px; }
.skill-detail-dep .badge { font-size: 10px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

.config-toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 10px 24px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 600; z-index: 100; animation: fadeIn 0.2s ease-out;
  box-shadow: 0 4px 24px rgba(255, 0, 51, 0.3);
}

.spin-icon { animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
.mono { font-family: var(--font-mono); }



.section-title { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.actions-stack { display: flex; flex-direction: column; gap: 6px; }

.agent-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--bg-card); margin-bottom: 6px; }
.agent-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.agent-name { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.agent-status { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; color: var(--text-disabled); font-size: 13px; text-align: center; gap: 8px; }

/* ── Dashboard Grid ── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
  height: 100%;
  overflow: hidden;
}
.dash-card {
  position: relative;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
  overflow: hidden;
}

.dash-span-2 { grid-column: span 2; }
.dash-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.dash-label {
  font-size: 11px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.dash-count {
  font-size: 10px; font-family: var(--font-mono);
  background: var(--bg-input); padding: 1px 6px; border-radius: 10px;
}
.dash-count.warn { background: var(--accent-bg); color: var(--accent); }

/* Tools row */
.dash-tools-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.dash-tool-tag {
  font-size: 11px; font-family: var(--font-mono);
  padding: 3px 8px; border-radius: var(--radius);
  background: var(--bg-surface);
}
.dash-tool-tag.ok { color: var(--success); }
.dash-tool-tag.missing { color: var(--error); }

/* Quota */
.dash-quota-list { display: flex; flex-direction: column; gap: 6px; max-height: 270px; overflow-y: auto; }
.dash-quota-row { display: flex; align-items: center; gap: 8px; }
.dash-quota-name {
  font-size: 11px; font-weight: 600; color: var(--text-primary);
  min-width: 80px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-bar {
  flex: 1; height: 4px; background: var(--bg-input); border-radius: 2px; overflow: hidden;
}
.dash-bar-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width 0.3s;
}
.dash-quota-val {
  font-size: 10px; font-family: var(--font-mono); color: var(--text-tertiary);
  white-space: nowrap;
}

/* Consumption */
.dash-consumption-list { display: flex; flex-direction: column; gap: 10px; max-height: 270px; overflow-y: auto; }
.dash-consumption-provider { display: flex; flex-direction: column; gap: 4px; }
.dash-consumption-head { display: flex; align-items: center; justify-content: space-between; }
.dash-consumption-name {
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
}
.dash-consumption-total {
  font-size: 10px; font-family: var(--font-mono); color: var(--text-tertiary);
}
.dash-consumption-days {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.dash-consumption-day {
  font-size: 9px; font-family: var(--font-mono); color: var(--text-tertiary);
  background: var(--bg-input); padding: 1px 5px; border-radius: 4px;
}
.dash-consumption-day strong { color: var(--text-secondary); }

/* Processes */
.dash-proc-list { display: flex; flex-direction: column; gap: 4px; max-height: 270px; overflow-y: auto; }
.dash-proc-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0;
}
.dash-proc-name {
  font-size: 11px; font-weight: 600; color: var(--text-primary);
  font-family: var(--font-mono); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dash-proc-res {
  font-size: 10px; font-family: var(--font-mono); color: var(--text-tertiary); flex-shrink: 0;
}

/* Commands */
.dash-cmd-card .dash-cmd-list { max-height: 220px; }
.dash-cmd-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.dash-cmd-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 8px; border-radius: var(--radius-sm);
  background: var(--bg-surface); cursor: pointer;
  transition: background 0.12s;
}
.dash-cmd-row:hover { background: var(--accent-bg); }
.dash-cmd-left { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.dash-cmd-text {
  font-size: 11px; font-family: var(--font-mono); color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-cmd-time { font-size: 9px; color: var(--text-disabled); }
.dash-cmd-copy { font-size: 13px; color: var(--text-disabled); flex-shrink: 0; }
.dash-cmd-row:hover .dash-cmd-copy { color: var(--accent); }

.dash-cmd-freq { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.dash-cmd-freq-title { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-disabled); letter-spacing: 0.05em; margin-bottom: 2px; }
.dash-cmd-freq-row {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 3px 4px; border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.dash-cmd-freq-row:hover { background: var(--accent-bg); }
.dash-cmd-freq-name { font-size: 12px; font-weight: 600; font-family: var(--font-mono); color: var(--text-primary); width: 100px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-cmd-freq-bar-wrap { flex: 1; height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; }
.dash-cmd-freq-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s ease; }
.dash-cmd-freq-count { font-size: 10px; font-family: var(--font-mono); color: var(--accent); width: 28px; text-align: right; flex-shrink: 0; }

.dash-cmd-top { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

/* Services */
.dash-services { display: flex; flex-direction: column; gap: 6px; }
.dash-svc-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0;
}
.dash-svc-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.dash-svc-val { font-size: 11px; font-family: var(--font-mono); color: var(--text-tertiary); }
.dash-svc-issues { margin-top: 4px; }
.dash-svc-issue { font-size: 10px; color: var(--warning); padding: 2px 0; }

/* Updates */
.dash-updates-list { display: flex; flex-direction: column; gap: 4px; }
.dash-update-row {
  display: flex; justify-content: space-between; align-items: center;
}
.dash-update-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.dash-update-ver { font-size: 11px; font-family: var(--font-mono); color: var(--text-tertiary); }

.dash-empty { font-size: 11px; color: var(--text-disabled); }

/* Graph */
.dash-graph-wrap { display: flex; flex-direction: column; gap: 2px; }
.dash-graph-header { display: flex; justify-content: space-between; align-items: center; }
.dash-graph-label { font-size: 9px; color: var(--text-disabled); text-transform: uppercase; }
.dash-graph-value { font-size: 10px; font-family: var(--font-mono); font-weight: 600; }
.dash-graph-svg { width: 100%; height: 32px; }
.dash-graph-empty { font-size: 10px; color: var(--text-disabled); text-align: center; padding: 8px 0; }

/* Legacy dashboard kept for reference */
.dashboard-layout { display: flex; flex-direction: column; height: 100%; }
.dashboard-content { flex: 1; overflow-y: auto; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 24px; }
.dashboard-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; transition: border-color 0.2s;
}
.dashboard-section:hover { border-color: var(--accent-dim); }
.dashboard-section.full-width { grid-column: 1 / -1; }
.dashboard-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dashboard-section-title {
  font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dashboard-workflows-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dashboard-notifications-inline { display: flex; flex-direction: column; gap: 2px; }
.dashboard-notifications { padding: 0; }
.notif-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 8px 12px; border-radius: var(--radius); margin-bottom: 4px;
}
.notif-row:hover { background: var(--bg-card); }
.notif-time { color: var(--text-disabled); font-size: 11px; font-family: var(--font-mono); flex-shrink: 0; padding-top: 1px; }
.notif-text { font-size: 13px; color: var(--text-secondary); }
.notif-info .notif-text { color: var(--info); }
.notif-ok .notif-text { color: var(--success); }
.notif-warn .notif-text { color: var(--warning); }
.notif-error .notif-text { color: var(--error); }
.dashboard-workflows { padding: 0; display: flex; flex-direction: column; gap: 24px; }
.workflow-section { }
.section-label {
  font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg-surface);
}
.panel-title { font-weight: 700; font-size: 13px; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.panel-subtitle { font-weight: 400; font-size: 12px; color: var(--text-tertiary); margin-left: 8px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.2s ease-out; }

/* ── Studio Feed ── */
.studio-feed-layout { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.studio-feed-scroll-wrap { flex: 1; position: relative; overflow: hidden; }
.studio-feed { height: 100%; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 4px; }
.studio-scroll-btns { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 4px; z-index: 10; }
.studio-scroll-btn {
  width: 32px; height: 32px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-tertiary); cursor: pointer; transition: all 0.15s;
  opacity: 0.7;
}
.studio-scroll-btn:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-dim); opacity: 1; }
.feed-loading { display: flex; align-items: center; justify-content: center; padding: 60px 0; }
.feed-item { display: flex; gap: 10px; padding: 8px 12px; border-radius: var(--radius); animation: fadeIn 0.15s ease-out; }
.feed-item:hover { background: var(--bg-card); }
.feed-item.user { background: var(--bg-card); border-left: 3px solid #FFD740; }
.feed-item.assistant { border-left: 3px solid transparent; }
.feed-item.assistant:hover { border-left-color: var(--accent-dark); }
.feed-item.system { align-items: center; gap: 8px; padding: 6px 12px; }
.feed-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; font-size: 14px; }
.feed-avatar.user-rank { background: rgba(255, 215, 64, 0.15); }
.feed-avatar.ai-rank { background: var(--accent-bg); }
.feed-rank-icon { display: flex; align-items: center; justify-content: center; }
.feed-body { flex: 1; min-width: 0; }
.feed-header { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.feed-rank-badge {
  font-size: 9px; font-weight: 800; font-family: var(--font-mono);
  padding: 1px 6px; border-radius: 3px; border: 1px solid;
  letter-spacing: 0.5px; text-transform: uppercase;
  background: rgba(255, 215, 64, 0.08);
}
.feed-role { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; }
.feed-time { font-size: 10px; color: var(--text-disabled); font-family: var(--font-mono); }
.feed-content { font-size: 14px; line-height: 1.5; color: var(--text-primary); word-break: break-word; }
.feed-system-badge { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-dim); flex-shrink: 0; }
.feed-system-text { font-size: 12px; color: var(--text-tertiary); font-style: italic; flex: 1; }
.feed-system-text.compressed { color: var(--accent); font-style: normal; }
.feed-compressed-indicator {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; margin: 4px 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: all 0.2s ease;
}
.feed-compressed-indicator:hover { background: var(--bg-hover); border-color: var(--accent-dim); }
.feed-compressed-indicator svg { color: var(--accent); flex-shrink: 0; }
.feed-compressed-text { font-size: 12px; color: var(--text-tertiary); flex: 1; }
.feed-compressed-count { font-size: 11px; color: var(--text-disabled); font-family: var(--font-mono); }

.feed-thinking-block {
  background: var(--bg-surface); border: 1px solid var(--border); border-left: 2px solid var(--accent-dim);
  border-radius: var(--radius); margin: 6px 0 8px; overflow: hidden;
  transition: all 0.3s ease;
  max-height: 200px;
  overflow-y: auto;
}
.feed-thinking-block.active {
  border-left-color: var(--warning);
}
.feed-thinking-block.done {
  border-left-color: var(--text-disabled);
  opacity: 0.7;
}
.feed-thinking-block.done .feed-thinking-content {
  max-height: 80px;
  overflow-y: auto;
}
.feed-thinking-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; font-size: 10px; font-weight: 700;
  color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.feed-thinking-header svg { color: var(--warning); }
.feed-thinking-dots { display: inline-flex; gap: 2px; margin-left: 4px; }
.feed-thinking-dots span { width: 4px; height: 4px; border-radius: 50%; background: var(--warning); animation: bounce 1.2s ease-in-out infinite; }
.feed-thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.feed-thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
.feed-thinking-content {
  padding: 8px 10px; font-size: 12px; color: var(--text-tertiary);
  font-style: italic; line-height: 1.5; max-height: 120px; overflow-y: auto;
}

.studio-code-block {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin: 8px 0;
}
.studio-code-header {
  display: flex; align-items: center; justify-content: flex-end;
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
.studio-code-block pre { padding: 12px 16px; font-family: var(--font-mono); font-size: 13px; line-height: 1.5; overflow-x: auto; color: var(--text-primary); margin: 0; }
.studio-code-lang {
  padding: 4px 12px; font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  background: var(--bg-surface); text-transform: uppercase; letter-spacing: 0.5px;
}
.studio-copy-btn {
  padding: 3px 10px; font-size: 10px; font-weight: 600; color: var(--text-tertiary);
  background: transparent; border: none; border-left: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s; font-family: var(--font-sans);
  white-space: nowrap;
}
.studio-copy-btn:hover { background: var(--accent-bg); color: var(--accent); }
.studio-copy-btn.copied { background: var(--accent-bg); color: var(--accent); }

.studio-mermaid-container { padding: 12px; background: var(--bg); overflow-x: auto; display: flex; justify-content: center; }
.studio-mermaid-container svg { max-width: 100%; height: auto; }
.studio-mermaid-loading { padding: 12px; text-align: center; color: var(--text-tertiary); font-size: 12px; }
.studio-mermaid-error { padding: 10px 12px; color: var(--accent-bright); font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; }

.feed-content table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.feed-content th { background: var(--bg-surface); padding: 6px 12px; text-align: left; font-weight: 600; border: 1px solid var(--border); color: var(--text-secondary); }
.feed-content td { padding: 5px 12px; border: 1px solid var(--border); color: var(--text-primary); }
.feed-content tr:nth-child(even) td { background: var(--bg-surface); }
.feed-content hr, .ai-message hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.inline-code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 13px; color: var(--accent-muted); }
.msg-h1 { font-size: 20px; font-weight: 800; color: var(--accent); margin: 16px 0 8px; display: block; }
.msg-h2 { font-size: 17px; font-weight: 700; color: var(--text-primary); margin: 12px 0 6px; display: block; }
.msg-h3 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 10px 0 4px; display: block; }
.msg-h4 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 8px 0 3px; display: block; }
.msg-bullet { display: block; padding-left: 4px; margin: 1px 0; color: var(--text-primary); }
.msg-step { display: flex; gap: 8px; align-items: baseline; margin: 1px 0; }
.msg-step-num { color: var(--accent); font-weight: 700; font-family: var(--font-mono); font-size: 13px; flex-shrink: 0; min-width: 20px; }
.studio-cursor { display: inline-block; width: 8px; height: 16px; background: var(--accent); margin-left: 2px; vertical-align: text-bottom; animation: blink 0.8s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.studio-thinking { display: flex; gap: 4px; padding: 8px 0; }
.studio-thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-dim); animation: bounce 1.2s ease-in-out infinite; }
.studio-thinking span:nth-child(2) { animation-delay: 0.15s; }
.studio-thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-6px); opacity: 1; } }
.studio-input-area { padding: 12px 20px 8px; border-top: 1px solid var(--border); background: var(--bg-surface); }
.studio-token-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.studio-token-track { flex: 1; height: 3px; background: var(--bg-input); border-radius: 2px; overflow: hidden; }
.studio-token-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s, background 0.3s; }
.studio-token-fill.warn { background: var(--warning); }
.studio-token-fill.compressed { height: 2px; }
.studio-token-fill.animating { animation: compress-pulse 0.6s ease-in-out; }
@keyframes compress-pulse {
  0% { height: 3px; opacity: 1; }
  50% { height: 5px; opacity: 0.8; background: var(--accent-light); }
  100% { height: 2px; opacity: 1; }
}
.studio-token-text { font-size: 10px; font-family: var(--font-mono); color: var(--text-tertiary); white-space: nowrap; }
.studio-token-text.compressed { font-size: 9px; }
.studio-token-track.compressed { height: 2px; }
.studio-token-bar.compressed { margin-bottom: 4px; }

.studio-input-row { display: flex; gap: 8px; align-items: flex-end; }
.studio-input-row textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 200px; padding: 10px 14px;
  font-size: 14px; line-height: 1.5; border-radius: var(--radius);
  background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border);
  font-family: var(--font-sans); outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.studio-input-row textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--border-accent); }
.studio-input-row textarea::placeholder { color: var(--text-disabled); }
.studio-send-btn {
  width: 42px; height: 42px; padding: 0; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--accent); color: #fff; border: 1px solid var(--accent);
  cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.studio-send-btn:hover:not(:disabled) { background: var(--accent-bright); border-color: var(--accent-bright); }
.studio-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.studio-stop-btn {
  width: 42px; height: 42px; padding: 0; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--error); color: #fff; border: 1px solid var(--error);
  cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.studio-stop-btn:hover { opacity: 0.8; }

/* ── Image Attachments ── */
.studio-attach-btn {
  width: 42px; height: 42px; padding: 0; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--bg-card); color: var(--text-tertiary);
  border: 1px solid var(--border); cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.studio-attach-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
.studio-attach-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.studio-image-previews {
  display: flex; gap: 10px; padding: 10px 8px; flex-wrap: wrap; justify-content: center;
}
.studio-image-preview {
  position: relative; width: 110px; height: 110px; border-radius: var(--radius-lg);
  overflow: hidden; border: 2px solid var(--border); background: var(--bg-surface);
  transition: border-color 0.2s;
}
.studio-image-preview:hover { border-color: var(--accent-dim); }
.studio-image-preview img {
  width: 100%; height: 100%; object-fit: cover;
}
.studio-image-remove {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
  border-radius: 50%; background: rgba(0,0,0,0.75); color: #fff; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center;
  justify-content: center; line-height: 1; transition: background 0.15s;
  backdrop-filter: blur(4px);
}
.studio-image-remove:hover { background: var(--error); }

/* ── Feed Images (in chat messages) ── */
.feed-images {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px;
}
.feed-image {
  max-width: 240px; max-height: 180px; border-radius: var(--radius);
  border: 1px solid var(--border); object-fit: cover; cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.feed-image:hover { transform: scale(1.03); border-color: var(--accent-dim); }

.studio-input-hint { font-size: 11px; color: var(--text-disabled); text-align: center; margin-top: 6px; }

/* ── Collapsed Messages ── */
.feed-collapsed-messages {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; margin: 4px 0;
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-elevated));
  border: 1px dashed var(--border-accent);
  border-radius: var(--radius); cursor: pointer;
  transition: all 0.2s ease;
}
.feed-collapsed-messages:hover { background: var(--bg-hover); border-color: var(--accent); }
.feed-collapsed-messages svg { color: var(--accent); flex-shrink: 0; }
.feed-collapsed-text { font-size: 11px; color: var(--text-tertiary); flex: 1; }
.feed-collapsed-count { font-size: 10px; color: var(--text-disabled); font-family: var(--font-mono); }
.feed-expanded-messages { animation: fadeIn 0.2s ease-out; }

.feed-summary-block { margin: 4px 0; }
.feed-summary-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: all 0.2s ease;
}
.feed-summary-header:hover { background: var(--bg-hover); border-color: var(--accent-dim); }
.feed-summary-header svg { color: var(--accent); flex-shrink: 0; }
.feed-summary-text { font-size: 11px; color: var(--text-tertiary); flex: 1; font-weight: 600; }
.feed-summary-toggle { font-size: 10px; color: var(--accent); font-family: var(--font-mono); }

.skill-list-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.skills-list { display: flex; flex-direction: column; gap: 2px; }

/* ── Studio Tool Blocks ── */
.studio-tool-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-dim);
  border-radius: var(--radius);
  margin: 6px 0;
  overflow: hidden;
  transition: all 0.3s ease;
}
.studio-tool-block.running {
  border-left-color: var(--warning);
}
.studio-tool-block.error {
  border-left-color: var(--error);
  background: rgba(255, 23, 68, 0.05);
}
.studio-tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.studio-tool-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.studio-tool-name {
  color: var(--text-tertiary);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 12px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.studio-tool-spinner {
  display: inline-flex;
  gap: 2px;
  margin-left: 4px;
}
.studio-tool-spinner span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--warning);
  animation: bounce 1.2s ease-in-out infinite;
}
.studio-tool-spinner span:nth-child(2) { animation-delay: 0.15s; }
.studio-tool-spinner span:nth-child(3) { animation-delay: 0.3s; }
.studio-tool-status {
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.studio-tool-status.ok { color: var(--success); }
.studio-tool-status.error { color: var(--error); }
.studio-tool-args {
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  white-space: pre-wrap;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.studio-tool-result {
  max-height: 200px;
  overflow-y: auto;
}
.studio-tool-result pre {
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
}

/* === XTerm Custom Styling === */
/* Styles for xterm.js integrated with Muyue theme */
.shell-xterm-instance .xterm {
  padding: 4px 8px;
}

.shell-xterm-instance .xterm-viewport {
  background-color: var(--bg-base) !important;
}

.shell-xterm-instance .xterm-screen {
  background-color: var(--bg-base);
}

/* Scrollbar styling for xterm */
.shell-xterm-instance .xterm-viewport::-webkit-scrollbar {
  width: 8px;
}

.shell-xterm-instance .xterm-viewport::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

.shell-xterm-instance .xterm-viewport::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 4px;
}

.shell-xterm-instance .xterm-viewport::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dark);
}

/* Selection styling */
.shell-xterm-instance .xterm-selection {
  background: var(--accent-dim) !important;
}

/* Focus ring styling */
.shell-xterm-instance .xterm:focus .xterm-helper-text-container {
  box-shadow: none;
}

/* Ensure consistent font rendering */
.shell-xterm-instance .xterm .xterm-char-measure-element {
  font-family: var(--font-mono) !important;
}

/* Bell animation styling */
.shell-xterm-instance .xterm-bell {
  animation: xterm-bell-flash 0.3s ease-out;
}

@keyframes xterm-bell-flash {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 0; }
}

/* Cursor styling */
.shell-xterm-instance .xterm-cursor {
  outline: none !important;
}

/* Link styling for web links addon */
.shell-xterm-instance .xterm-link {
  color: var(--accent-light) !important;
  text-decoration: underline;
}

.shell-xterm-instance .xterm-link:hover {
  color: var(--accent-muted) !important;
}

/* ── KaTeX overrides ── */
.katex { font-size: 1em; color: var(--text-primary); }
.katex-display { margin: 12px 0; overflow-x: auto; }

/* ── Raw Markdown Toggle ── */
.studio-raw-markdown {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ── ReactMarkdown prose styles ── */
.feed-content > div:not(.studio-code-block):not(.studio-mermaid-container) {
  line-height: 1.6;
}
.feed-content h1 { font-size: 20px; font-weight: 800; color: var(--accent); margin: 16px 0 8px; }
.feed-content h2 { font-size: 17px; font-weight: 700; color: var(--text-primary); margin: 12px 0 6px; }
.feed-content h3 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 10px 0 4px; }
.feed-content h4 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 8px 0 3px; }
.feed-content h5 { font-size: 12px; font-weight: 600; color: var(--text-tertiary); margin: 6px 0 2px; }
.feed-content h6 { font-size: 11px; font-weight: 600; color: var(--text-tertiary); margin: 6px 0 2px; text-transform: uppercase; }
.feed-content p { margin: 4px 0; }
.feed-content ul { padding-left: 20px; margin: 4px 0; }
.feed-content ol { padding-left: 20px; margin: 4px 0; }
.feed-content li { margin: 2px 0; }
.feed-content blockquote {
  border-left: 3px solid var(--accent-dim);
  padding: 4px 12px;
  margin: 8px 0;
  color: var(--text-tertiary);
  background: var(--bg-surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.feed-content hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.feed-content strong { color: var(--accent-light); font-weight: 700; }
.feed-content em { color: var(--text-secondary); }
.feed-content a { color: var(--accent); text-decoration: underline; }
.feed-content img { max-width: 100%; border-radius: var(--radius); }
.feed-content input[type="checkbox"] {
  margin-right: 6px;
  accent-color: var(--accent);
}
.feed-content del { color: var(--text-disabled); text-decoration: line-through; }
.feed-content sup { font-size: 0.75em; color: var(--text-tertiary); vertical-align: super; }

/* ── highlight.js overrides for dark theme ── */
.hljs { background: var(--bg) !important; color: var(--text-primary) !important; }
.hljs-keyword { color: var(--accent-muted) !important; }
.hljs-string { color: var(--success) !important; }
.hljs-comment { color: var(--text-disabled) !important; font-style: italic; }
.hljs-function { color: var(--accent-light) !important; }
.hljs-number { color: var(--warning) !important; }

/* ── Responsive / Mobile ── */

/* ── Large tablets / small laptops ── */
@media (max-width: 1200px) {
  .dash-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
    height: auto;
    overflow: auto;
  }
  .dash-span-2 { grid-column: span 2; }
  .shell-ai-col { width: 280px; max-width: 280px; }
  .config-profile-center { max-width: 100%; }
  .config-ai-tools-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .skill-tiles { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

/* ── Tablets portrait ── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .header { padding: 0 16px; gap: 8px; }
  .header-nav { margin-left: 16px; }
  .nav-tab { padding: 6px 12px; font-size: 12px; }
  .nav-tab .tab-icon { display: none; }
  .dash-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    height: auto;
    overflow: auto;
    gap: 10px;
    padding: 12px;
  }
  .dash-span-2 { grid-column: span 2; }
  .studio-feed { padding: 16px 12px; }
  .studio-input-area { padding: 10px 12px 6px; }
  .config-panel-body { padding: 12px 16px 16px; }
  .config-card-row { gap: 10px; }
  .config-card-label { width: 110px; }
  .shell-ai-col { width: 240px; max-width: 240px; }
  .shell-analysis-modal { width: 90vw; }
  .shell-modal { min-width: 320px; }
  .grid-2 { grid-template-columns: 1fr; }
  .split-horizontal { flex-direction: column; }
  .split-right { width: 100%; border-left: none; border-top: 1px solid var(--border); max-height: 300px; }
}

/* ── Mobile landscape / small tablets ── */
@media (max-width: 768px) {
  :root { --sidebar-w: 100%; --header-h: 46px; }

  /* Header */
  .header {
    padding: 0 10px;
    gap: 6px;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .header-brand { gap: 4px; flex-shrink: 0; }
  .header-logo { font-size: 14px; letter-spacing: 2px; }
  .header-logo-img { width: 18px !important; height: 18px !important; }
  .header-version { display: none; }
  .header-nav {
    margin-left: 8px;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    flex: 1;
    min-width: 0;
  }
  .header-nav::-webkit-scrollbar { display: none; }
  .nav-tab {
    padding: 5px 8px;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .header-spacer { display: none; }
  .header-clock { font-size: 10px; flex-shrink: 0; }
  .header-indicators { gap: 6px; flex-shrink: 0; }

  /* Statusbar */
  .statusbar { padding: 0 8px; font-size: 10px; }
  .statusbar-sudo { font-size: 9px; padding: 1px 4px; }
  .statusbar-shortcut { display: none; }
  .statusbar-right { display: none; }

  /* Dashboard */
  .dash-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    overflow: auto;
    gap: 8px;
    padding: 10px;
  }
  .dash-span-2 { grid-column: span 1; }
  .dash-card { padding: 10px 12px; }
  .dash-quota-list,
  .dash-consumption-list,
  .dash-proc-list { max-height: 200px; }
  .dash-cmd-card .dash-cmd-list { max-height: 160px; }

  /* Studio */
  .studio-feed { padding: 10px 6px; gap: 2px; }
  .studio-feed-scroll-wrap { }
  .studio-input-area { padding: 8px 6px 4px; }
  .studio-input-row textarea { min-height: 36px; padding: 8px 10px; font-size: 13px; }
  .studio-send-btn, .studio-stop-btn, .studio-attach-btn { width: 36px; height: 36px; }
  .studio-token-bar { gap: 6px; margin-bottom: 6px; }
  .studio-image-previews { gap: 6px; padding: 6px 4px; }
  .studio-image-preview { width: 80px; height: 80px; }
  .studio-scroll-btns { right: 8px; bottom: 8px; }

  /* Feed items */
  .feed-item { padding: 4px 6px; gap: 6px; }
  .feed-avatar { width: 22px; height: 22px; font-size: 12px; }
  .feed-header { gap: 4px; flex-wrap: wrap; }
  .feed-rank-badge { font-size: 8px; padding: 0 4px; }
  .feed-role { font-size: 10px; }
  .feed-time { font-size: 9px; }
  .feed-content { font-size: 13px; }
  .feed-content table { font-size: 11px; }
  .feed-content th, .feed-content td { padding: 3px 6px; }
  .feed-images { gap: 4px; }
  .feed-image { max-width: 160px; max-height: 120px; }

  /* Thinking blocks */
  .feed-thinking-block { max-height: 120px; }
  .feed-thinking-content { max-height: 60px; font-size: 11px; }

  /* Tool blocks */
  .studio-tool-args { font-size: 11px; }
  .studio-tool-result { max-height: 150px; }
  .studio-tool-result pre { font-size: 11px; }

  /* Code blocks */
  .studio-code-block pre { padding: 8px 10px; font-size: 12px; }
  .studio-code-header { }
  .studio-code-lang { font-size: 10px; padding: 3px 8px; }

  /* Messages */
  .message { max-width: 95%; padding: 10px 12px; font-size: 13px; }

  /* Shell / Terminal — AI panel stacks below on narrow screens */
  .shell-ai-col {
    width: 100%;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 45vh;
    flex-shrink: 1;
  }
  .ai-panel-messages { padding: 8px; }
  .ai-message { padding: 6px 8px; font-size: 12px; }
  .ai-panel-input input { font-size: 12px; padding: 5px 8px; }
  .shell-modal-row { grid-template-columns: 1fr; gap: 6px; }

  /* Config */
  .config-tabs-bar { padding: 8px 12px; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .config-tabs-bar::-webkit-scrollbar { display: none; }
  .config-panel-body { padding: 10px 12px 12px; }
  .config-card { padding: 14px 16px; }
  .config-card-row { flex-wrap: wrap; gap: 6px; }
  .config-card-label { width: 100%; margin-bottom: 2px; }
  .config-card-value { width: 100%; }
  .config-form-input { font-size: 12px; padding: 6px 10px; }
  .provider-card-top { flex-wrap: wrap; }
  .provider-card-meta { flex-wrap: wrap; gap: 8px; }
  .provider-card-actions { width: 100%; justify-content: flex-end; }
  .provider-setup-token-row { flex-direction: column; gap: 8px; }
  .provider-setup-token-actions { width: 100%; }
  .config-update-controls { flex-direction: column; gap: 8px; }
  .config-update-info { flex-wrap: wrap; gap: 6px; }
  .config-ai-tools-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .config-ai-tool-card { padding: 10px; min-height: 100px; }

  /* Skills */
  .skill-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .skill-tile { padding: 10px; }
  .skill-detail-panel { width: 95%; max-height: 90vh; }

  /* Grids */
  .grid-2 { grid-template-columns: 1fr; padding: 10px; }
  .split-horizontal { flex-direction: column; }
  .split-right { width: 100%; border-left: none; border-top: 1px solid var(--border); max-height: 300px; }

  /* Onboarding */
  .onboarding-overlay { padding: 12px; }
}

/* ── Mobile portrait ── */
@media (max-width: 480px) {
  :root { --header-h: 42px; }

  /* Header */
  .header { padding: 0 6px; gap: 4px; }
  .header-brand { gap: 2px; }
  .header-logo { font-size: 12px; letter-spacing: 1px; }
  .header-logo-img { width: 16px !important; height: 16px !important; }
  .header-nav { margin-left: 4px; gap: 1px; }
  .nav-tab { padding: 4px 6px; font-size: 10px; gap: 0; }
  .nav-tab .tab-icon { display: none; }
  .header-clock { font-size: 9px; }
  .header-indicators { gap: 4px; }
  .indicator { width: 6px; height: 6px; }

  /* Statusbar */
  .statusbar { height: 24px; padding: 0 6px; }
  .statusbar-sudo { font-size: 8px; padding: 0 3px; }

  /* Dashboard */
  .dash-grid { padding: 6px; gap: 6px; }
  .dash-card { padding: 8px 10px; }
  .dash-label { font-size: 10px; }
  .dash-count { font-size: 9px; }
  .dash-tool-tag { font-size: 10px; padding: 2px 5px; }
  .dash-quota-name { font-size: 10px; min-width: 60px; }
  .dash-consumption-name { font-size: 10px; }
  .dash-consumption-day { font-size: 8px; }
  .dash-proc-name { font-size: 10px; }
  .dash-cmd-text { font-size: 10px; }
  .dash-cmd-freq-name { font-size: 10px; width: 70px; }
  .dash-svc-name { font-size: 10px; }

  /* Studio */
  .studio-feed { padding: 6px 4px; }
  .studio-input-area { padding: 6px 4px 3px; }
  .studio-input-row { gap: 4px; }
  .studio-input-row textarea { min-height: 32px; padding: 6px 8px; font-size: 12px; }
  .studio-send-btn, .studio-stop-btn, .studio-attach-btn { width: 32px; height: 32px; }
  .studio-send-btn svg, .studio-stop-btn svg, .studio-attach-btn svg { width: 14px; height: 14px; }
  .studio-image-preview { width: 60px; height: 60px; }
  .studio-image-remove { width: 18px; height: 18px; font-size: 11px; top: 2px; right: 2px; }
  .studio-input-hint { font-size: 9px; }
  .studio-scroll-btn { width: 28px; height: 28px; }
  .studio-scroll-btn svg { width: 12px; height: 12px; }
  .studio-copy-btn { font-size: 9px; padding: 2px 6px; }

  /* Feed */
  .feed-item { padding: 3px 4px; gap: 4px; }
  .feed-avatar { width: 20px; height: 20px; font-size: 11px; }
  .feed-body { min-width: 0; }
  .feed-header { gap: 3px; margin-bottom: 1px; }
  .feed-rank-badge { font-size: 7px; padding: 0 3px; }
  .feed-role { font-size: 9px; }
  .feed-time { font-size: 8px; }
  .feed-content { font-size: 12px; line-height: 1.4; }
  .feed-content h1 { font-size: 16px; }
  .feed-content h2 { font-size: 14px; }
  .feed-content h3 { font-size: 13px; }
  .feed-content h4 { font-size: 12px; }
  .feed-content table { font-size: 10px; }
  .feed-content th, .feed-content td { padding: 2px 4px; }
  .feed-image { max-width: 120px; max-height: 90px; }
  .feed-system-text { font-size: 11px; }

  /* Thinking */
  .feed-thinking-header { padding: 4px 6px; font-size: 9px; }
  .feed-thinking-content { padding: 4px 6px; font-size: 10px; max-height: 50px; }

  /* Tool blocks */
  .studio-tool-header { padding: 4px 6px; gap: 4px; font-size: 11px; }
  .studio-tool-name { font-size: 11px; }
  .studio-tool-args { padding: 4px 6px; font-size: 10px; }
  .studio-tool-result { max-height: 120px; }
  .studio-tool-result pre { padding: 4px 6px; font-size: 10px; }

  /* Code */
  .studio-code-block pre { padding: 6px 8px; font-size: 11px; }
  .studio-code-lang { font-size: 9px; padding: 2px 6px; }

  /* Markdown content */
  .feed-content blockquote { padding: 3px 8px; }
  .feed-content ul, .feed-content ol { padding-left: 14px; }
  .msg-bullet, .msg-step { font-size: 12px; }
  .msg-h1 { font-size: 16px; }
  .msg-h2 { font-size: 14px; }
  .msg-h3 { font-size: 13px; }
  .msg-h4 { font-size: 12px; }
  .inline-code { font-size: 11px; padding: 1px 4px; }

  /* Messages */
  .message { max-width: 98%; padding: 8px 10px; font-size: 12px; line-height: 1.4; }
  .chat-input-bar { padding: 10px 8px; gap: 6px; }
  .chat-input-bar input { font-size: 13px; }

  /* Shell — only AI panel shrinks, terminal stays full size */
  .shell-ai-col { max-height: 40vh; }
  .ai-panel-header { padding: 8px 10px; font-size: 12px; }
  .ai-panel-messages { padding: 6px; gap: 4px; }
  .ai-message { padding: 5px 6px; font-size: 11px; }
  .ai-panel-input { padding: 6px 8px; gap: 4px; }
  .ai-panel-input input { font-size: 11px; padding: 4px 6px; }

  /* Config */
  .config-tabs-bar { padding: 6px 8px; gap: 1px; }
  .nav-tab { padding: 4px 6px; font-size: 10px; }
  .config-panel-body { padding: 8px 8px 8px; }
  .config-card { padding: 10px 12px; margin-bottom: 10px; border-radius: var(--radius); }
  .config-card-row { padding: 6px 0; gap: 4px; }
  .config-card-label { width: 100%; font-size: 11px; }
  .config-card-value { font-size: 12px; }
  .config-form-label { font-size: 10px; }
  .config-form-input { font-size: 11px; padding: 5px 8px; }
  .provider-card-v2 { padding: 10px 12px; }
  .provider-card-name { font-size: 12px; }
  .provider-card-meta { font-size: 10px; gap: 6px; flex-wrap: wrap; }
  .provider-card-model { margin-top: 8px; padding-top: 8px; gap: 4px; }
  .provider-card-model-value { font-size: 12px; }
  .provider-setup-hint { font-size: 11px; padding: 8px 10px; }
  .config-update-row { padding: 6px 10px; flex-wrap: wrap; gap: 4px; }
  .config-update-name { font-size: 11px; min-width: auto; }
  .config-update-versions { font-size: 10px; }
  .config-ai-tools-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .config-ai-tool-card { padding: 8px; min-height: 80px; }
  .config-ai-tool-name { font-size: 11px; }
  .config-ai-tool-desc { font-size: 10px; }
  .config-toast { padding: 8px 16px; font-size: 12px; bottom: 30px; }

  /* Skills */
  .skill-tiles { grid-template-columns: 1fr 1fr; gap: 6px; }
  .skill-tile { padding: 8px; }
  .skill-tile-name { font-size: 12px; }
  .skill-tile-desc { font-size: 10px; -webkit-line-clamp: 2; }
  .skill-detail-panel { width: 98%; max-height: 95vh; }
  .skill-detail-header { padding: 12px 14px; }
  .skill-detail-name { font-size: 14px; }
  .skill-detail-body { padding: 14px; }
  .skill-detail-content { font-size: 10px; padding: 8px; max-height: 200px; }

  /* Buttons */
  button { font-size: 12px; padding: 6px 12px; }
  button.sm { font-size: 11px; padding: 3px 8px; }
  input, textarea { font-size: 12px; padding: 6px 10px; }

  /* Cards */
  .card { padding: 12px; border-radius: var(--radius); }
  .card-header { font-size: 10px; margin-bottom: 10px; }
  .badge { font-size: 10px; padding: 1px 6px; }
  .chip { font-size: 11px; padding: 4px 8px; }

  /* Empty states */
  .empty-state { padding: 24px 12px; font-size: 12px; }

  /* KaTeX */
  .katex { font-size: 0.85em; }
  .katex-display { margin: 8px 0; overflow-x: auto; }
}

.config-ai-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.config-ai-tool-card {
  display: flex;
  flex-direction: column;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
  min-height: 120px;
}

.config-ai-tool-card:hover {
  border-color: var(--accent-dim);
}

.config-ai-tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.config-ai-tool-icon {
  font-size: 18px;
  line-height: 1;
}

.config-ai-tool-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.config-ai-tool-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
  margin-bottom: 10px;
  flex: 1;
}

/* === Split Panes === */
.shell-split-btn {
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  transition: all 0.15s;
}

.shell-split-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
  color: var(--accent);
}

.shell-agent-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  animation: agent-pulse 2s ease-in-out infinite;
}

.shell-agent-count {
  min-width: 12px;
  text-align: center;
}

@keyframes agent-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.shell-xterm-wrapper.has-splits {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.split-pane-split {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.split-pane-split.row {
  flex-direction: row;
}

.split-pane-split.column {
  flex-direction: column;
}

.split-pane-child {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.split-pane-resizer {
  flex-shrink: 0;
  background: var(--border);
  transition: background 0.15s;
  z-index: 10;
}

.split-pane-split.row > .split-pane-resizer {
  width: 4px;
  cursor: col-resize;
}

.split-pane-split.column > .split-pane-resizer {
  height: 4px;
  cursor: row-resize;
}

.split-pane-resizer:hover,
.split-pane-resizer:active {
  background: var(--accent);
}

.split-pane-leaf {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  border: 1px solid transparent;
}

.split-pane-leaf.active {
  border-color: var(--accent-dim);
}

.split-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.split-pane-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.split-pane-close {
  background: transparent;
  border: none;
  color: var(--text-disabled);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  font-size: 10px;
}

.split-pane-close:hover {
  color: var(--error);
}

.split-pane-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.split-pane-leaf.empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.split-pane-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-disabled);
}

/* === File Editor === */
.file-editor-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.file-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.file-editor-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-editor-dirty {
  color: var(--accent);
  font-size: 14px;
}

.file-editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-editor-lang-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-tertiary);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.file-editor-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.file-editor-body .cm-editor {
  height: 100%;
}
