:root {
  --bg: #f8f9fc;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e8ebf2;
  --border: #e2e5ee;
  --border-hover: #c9cdd8;
  --text: #1a1d26;
  --text-secondary: #5c6070;
  --text-muted: #9398a8;
  --accent: #7c5cfc;
  --accent-hover: #6a48e6;
  --accent-dim: rgba(124, 92, 252, 0.08);
  --accent-2: #3b82f6;
  --accent-2-dim: rgba(59, 130, 246, 0.08);
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.10);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.08);
  --surface-0: #ffffff;
  --surface-1: #f4f6fb;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ── Login ─────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f0eeff 0%, #f8f9fc 40%, #eef6ff 100%);
}

.login-card {
  width: 340px;
  padding: 36px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), 0 8px 32px rgba(124, 92, 252, 0.06);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.login-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: all 0.15s;
}

.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.login-card button {
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.login-card button:hover { background: var(--accent-hover); }

/* ── App Shell ─────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 230px 1fr 250px;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────── */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.icon-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: all 0.12s;
}

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

.project-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border-radius: var(--radius);
  transition: background 0.1s;
}

.project-item:hover { background: var(--surface-2); }

.project-item.active { background: var(--accent-dim); }
.project-item.active .name { color: var(--accent); }

.project-info-btn {
  flex: 1;
  min-width: 0;
  display: block;
  padding: 7px 10px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius);
}

.project-info-btn .name {
  display: block;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-info-btn .meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.project-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s;
}

.project-item:hover .project-actions { opacity: 1; }

.project-action-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.project-action-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

.project-action-btn.edit:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.project-action-btn.delete:hover {
  background: var(--danger-dim);
  color: var(--danger);
}

/* ── Modal ─────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(120, 120, 140, 0.08);
  backdrop-filter: blur(6px) saturate(110%);
  -webkit-backdrop-filter: blur(6px) saturate(110%);
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.visible { opacity: 1; }

.modal-overlay.hidden { display: none !important; }

.modal {
  width: min(440px, 90vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.04),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  transform: translateY(12px) scale(0.96);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.visible .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.modal-close {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--text-secondary);
  transform: rotate(90deg);
}

.modal-body {
  padding: 20px 26px 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.modal-body input {
  padding: 10px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  outline: none;
  font-size: 13px;
  transition: all 0.15s;
}

.modal-body input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: var(--surface);
}

/* ── Custom Select ────────────────────────────── */

.custom-select {
  position: relative;
  margin-top: 6px;
}

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.custom-select-trigger:hover {
  border-color: var(--border-hover);
}

.custom-select.open .custom-select-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: var(--surface);
}

.custom-select-arrow {
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.custom-select.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  list-style: none;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  padding: 4px;
  z-index: 10;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-select.open .custom-select-options {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.custom-select-option {
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.1s;
}

.custom-select-option:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.custom-select-option.selected {
  color: var(--accent);
  font-weight: 500;
  background: var(--accent-dim);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.modal-actions .spacer { flex: 1; }

.btn-primary {
  padding: 9px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(124, 92, 252, 0.25);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  padding: 9px 18px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hover);
}

.btn-danger {
  padding: 9px 18px;
  background: var(--danger-dim);
  color: var(--danger);
  border: 1.5px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.2);
}

/* ── Workspace ─────────────────────────────────── */

.workspace {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

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

.tab {
  padding: 11px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}

.tab:hover { color: var(--text-secondary); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  flex: 1;
  overflow: auto;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* ── Session bar ──────────────────────────────── */

.session-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.session-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  min-height: 30px;
  align-items: center;
}

.session-tabs::-webkit-scrollbar { height: 0; }

.session-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}

.session-tab:hover { background: var(--surface-3); }

.session-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(124, 92, 252, 0.15);
  font-weight: 500;
}

.session-tab .session-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  background: none;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.1s;
}

.session-tab .session-close:hover {
  background: var(--danger-dim);
  color: var(--danger);
}

.session-tab.stopped {
  opacity: 0.5;
}

.session-tab .status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.session-tab.stopped .status-indicator {
  background: var(--text-muted);
}

.session-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.view-mode-toggle {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.view-mode-btn {
  padding: 4px 10px;
  background: none;
  border: none;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}

.view-mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.session-new-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.12s;
}

.session-new-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Chat ──────────────────────────────────────── */

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  font-family: "SF Mono", "Fira Code", "Cascadia Code", "Menlo", monospace;
  font-size: 12.5px;
  line-height: 1.65;
}

/* shared row styling — divider between every block */
.chat-messages > div:not(.empty-state) {
  padding: 12px 24px;
  border-bottom: 1px solid var(--surface-3);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-messages > div:not(.empty-state):last-child {
  border-bottom: none;
}

/* line-prefix label */
.msg-prefix {
  display: inline-block;
  font-weight: 600;
  margin-right: 10px;
  user-select: none;
}

/* User message */
.msg-user {
  color: var(--text);
  background: var(--surface-2);
}
.msg-user .msg-prefix {
  color: var(--accent);
}

/* Assistant text */
.msg-assistant {
  color: var(--text);
}
.msg-assistant .msg-prefix {
  color: var(--accent-2);
}

/* Tool call (verbose) */
.msg-tool {
  color: var(--text-secondary);
  background: var(--bg);
}

.msg-tool-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
}

.msg-tool-header .tool-prefix {
  color: var(--text-muted);
  font-weight: 600;
  user-select: none;
}

.msg-tool-header .tool-name {
  color: var(--accent-2);
  font-weight: 600;
}

.msg-tool-header .tool-input {
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-tool-header .tool-chevron {
  color: var(--text-muted);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.msg-tool.expanded .tool-chevron { transform: rotate(90deg); }

.msg-tool-body {
  display: none;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--surface-3);
  border-radius: 4px;
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
  color: var(--text-secondary);
}

.msg-tool.expanded .msg-tool-body { display: block; }

.msg-tool-result .tool-name {
  color: var(--green);
}

/* tool group (collapsed by default, shows "used N tools") */
.chat-messages > div.msg-tool-group {
  padding: 0;
  border-bottom: none;
  white-space: normal;
  margin: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-1);
  overflow: hidden;
  box-sizing: border-box;
  max-width: calc(100% - 24px);
}
.msg-tool-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.msg-tool-group-header:hover { background: var(--surface-2); }
.msg-tool-group-header .chevron {
  display: inline-block;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.msg-tool-group.expanded .msg-tool-group-header .chevron { transform: rotate(90deg); }
.msg-tool-group-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 6px;
}
.msg-tool-group.expanded .msg-tool-group-body { display: block; }
.msg-tool-item {
  padding: 8px 10px;
  border-radius: 5px;
  background: var(--surface);
  overflow: hidden;
}
.msg-tool-item + .msg-tool-item { margin-top: 6px; }
.msg-tool-item .tool-item-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-2);
  margin-bottom: 4px;
  font-family: ui-monospace, monospace;
}
.msg-tool-item .tool-item-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 0;
  max-width: 100%;
}

/* Session divider ("New session" marker between resumed history and new turn) */
.chat-messages > div.msg-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: none;
  white-space: normal;
}
.msg-divider::before,
.msg-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.msg-divider span {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}

/* Status / loading */
.msg-status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.msg-status .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Done summary */
.msg-done {
  color: var(--text-muted);
  font-size: 11px;
  background: var(--bg);
}

.msg-done .msg-prefix {
  color: var(--green);
}

/* Error */
.msg-error {
  color: var(--danger);
  background: var(--danger-dim);
}
.msg-error .msg-prefix {
  color: var(--danger);
}

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 9px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: none;
  outline: none;
  font-size: 13px;
  transition: border-color 0.12s;
}

.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.composer button {
  padding: 9px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
}

.composer button:hover { background: var(--accent-hover); }

.composer button:disabled,
.composer textarea:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Docs (Finder column view) ─────────────────── */

.docs-finder {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.docs-finder-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  min-height: 40px;
}

.docs-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--surface-2, #f1f1f5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
}

.docs-back-btn:hover:not(:disabled) {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-dim);
}

.docs-back-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.docs-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.docs-breadcrumb-item {
  background: none;
  border: none;
  padding: 4px 6px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.docs-breadcrumb-item:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

.docs-breadcrumb-item.current {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}

.docs-breadcrumb-item.current:hover {
  background: none;
}

.docs-breadcrumb-sep {
  color: var(--text-muted);
  user-select: none;
  font-size: 11px;
}

.docs-columns {
  flex: 1;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--surface);
}

.docs-column {
  flex: 0 0 180px;
  min-width: 180px;
  max-width: 180px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg, #fff);
  overflow: hidden;
}

.docs-column.docs-column-file {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  background: var(--surface);
}

.docs-column-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.docs-column-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.docs-column-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.08s;
}

.docs-column-item:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.docs-column-item.active {
  background: var(--accent);
  color: #fff;
}

.docs-column-item.active:hover {
  background: var(--accent);
}

.docs-column-item .docs-item-icon {
  flex: 0 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.docs-column-item .docs-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docs-column-item .docs-item-arrow {
  flex: 0 0 10px;
  color: var(--text-muted);
  font-size: 10px;
}

.docs-column-item.active .docs-item-arrow {
  color: rgba(255, 255, 255, 0.7);
}

.docs-column-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.docs-file-body {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  overflow-x: hidden;
  line-height: 1.75;
  font-size: 13px;
  color: var(--text-secondary);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.docs-file-body h1,
.docs-file-body h2,
.docs-file-body h3,
.docs-file-body h4 {
  color: var(--text);
  margin: 1.4em 0 0.5em;
  line-height: 1.35;
}

.docs-file-body h1 { font-size: 1.5em; }
.docs-file-body h2 { font-size: 1.25em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.docs-file-body h3 { font-size: 1.1em; }
.docs-file-body h4 { font-size: 1em; }
.docs-file-body p { margin: 0.6em 0; }
.docs-file-body ul,
.docs-file-body ol { padding-left: 1.4em; margin: 0.6em 0; }
.docs-file-body li { margin: 0.2em 0; }
.docs-file-body blockquote {
  margin: 0.6em 0;
  padding: 0.4em 0.9em;
  border-left: 3px solid var(--accent-dim);
  color: var(--text-muted);
  background: var(--surface);
  border-radius: 4px;
}
.docs-file-body code {
  background: var(--surface-3, rgba(15, 23, 42, 0.06));
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.92em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-word;
}
.docs-file-body pre {
  background: rgba(15, 23, 42, 0.045);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0.8em 0;
}
.docs-file-body pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}
.docs-file-body a { color: var(--accent); text-decoration: none; }
.docs-file-body a:hover { text-decoration: underline; }
.docs-file-body img { max-width: 100%; height: auto; }
.docs-file-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0.8em 0;
}
.docs-file-body th,
.docs-file-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 0.95em;
  text-align: left;
}
.docs-file-body th { background: var(--surface); }
.docs-file-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.2em 0;
}

/* ── Library ───────────────────────────────────── */

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding: 20px;
}

.library-item {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
}

.library-item:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.library-item .name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.library-item .desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}

.library-item .tag {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 10px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
}

/* ── Detail Panel ──────────────────────────────── */

.detail-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.detail-content {
  font-size: 13px;
}

.detail-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface-3);
}

.detail-row:last-child { border-bottom: none; }

.detail-key {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-val {
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: none;
  line-height: 1.5;
}

/* ── Runtime panel ─────────────────────────────── */

.runtime-services {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.runtime-service-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.runtime-service-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.runtime-service-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runtime-service-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--text-muted);
}

.runtime-service-meta .meta-row {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.runtime-service-meta .meta-key {
  flex: 0 0 auto;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.runtime-service-meta .meta-val {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.runtime-service-meta a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-family: inherit;
}

.runtime-service-meta a:hover { text-decoration: underline; }

.runtime-service-actions {
  display: flex;
  gap: 6px;
}

.runtime-service-actions .runtime-btn {
  padding: 4px 8px;
  font-size: 11px;
}

.runtime-manifest-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 999px;
  text-transform: uppercase;
  background: rgba(95, 99, 244, 0.16);
  color: var(--accent);
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.runtime-manifest-badge.hidden { display: none; }

.runtime-actions-global {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.runtime-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-3, #eee);
  color: var(--text-muted);
}

.runtime-status-pill .dot {
  width: 6px;
  height: 6px;
}

.runtime-status-pill.running { background: rgba(80, 180, 100, 0.18); color: #2f8a4d; }
.runtime-status-pill.running .dot { background: #3aa05a; box-shadow: 0 0 6px rgba(80, 180, 100, 0.6); }
.runtime-status-pill.stopped { background: rgba(140, 140, 150, 0.18); color: var(--text-muted); }
.runtime-status-pill.stopped .dot { background: var(--text-muted); }
.runtime-status-pill.crashed { background: rgba(232, 98, 124, 0.18); color: #c2415c; }
.runtime-status-pill.crashed .dot { background: #c2415c; box-shadow: 0 0 6px rgba(232, 98, 124, 0.6); }

.runtime-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.runtime-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
}

.runtime-btn:hover:not(:disabled) {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-dim);
}

.runtime-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.runtime-btn-start:hover:not(:disabled) {
  background: rgba(80, 180, 100, 0.15);
  color: #2f8a4d;
  border-color: rgba(80, 180, 100, 0.4);
}

.runtime-btn-stop:hover:not(:disabled) {
  background: rgba(232, 98, 124, 0.15);
  color: #c2415c;
  border-color: rgba(232, 98, 124, 0.4);
}

/* ── Status ────────────────────────────────────── */

.status-dot {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green-dim); }
.dot.error { background: var(--danger); box-shadow: 0 0 6px var(--danger-dim); }

.status-text {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Utilities ─────────────────────────────────── */

.empty-state {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px;
  text-align: center;
}

.text-muted { color: var(--text-muted); }

.error-text {
  min-height: 16px;
  color: var(--danger);
  font-size: 12px;
}

.hidden { display: none !important; }

/* ── Responsive ────────────────────────────────── */

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: 100vh;
  }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .detail-panel { display: none; }
  .docs-column { flex-basis: 70vw; min-width: 70vw; max-width: 70vw; }
  .docs-column.docs-column-file { flex-basis: 90vw; min-width: 90vw; max-width: 90vw; }
}

/* ── Scrollbar ─────────────────────────────────── */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Skills tab ────────────────────────────────── */

/* ── Extensions layout ──────────────────────────── */
.ext-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.ext-nav {
  display: flex;
  flex-direction: column;
  width: 130px;
  min-width: 130px;
  padding: 12px 8px;
  gap: 2px;
  border-right: 1px solid var(--border);
  background: var(--surface-0);
}
.ext-nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ext-nav-item:hover { background: var(--surface-1); color: var(--text-primary); }
.ext-nav-item.active { background: var(--accent-subtle); color: var(--accent); font-weight: 600; }
.ext-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.ext-panel { display: none; flex: 1; flex-direction: column; overflow: auto; }
.ext-panel.active { display: flex; }

.ext-filter {
  width: 120px;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}
.ext-filter:focus {
  border-color: var(--accent);
  width: 180px;
}
.ext-filter::placeholder { color: var(--text-muted); }

.global-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
}
.global-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ── Ask Claude context toggle ──────────────────── */
.ext-ask-ctx { display: flex; gap: 2px; margin-left: 8px; }
.ext-ask-ctx-btn {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ext-ask-ctx-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.skills-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.skills-title { font-size: 15px; font-weight: 600; }

.skill-list {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.skill-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 8px 0 2px;
}
.skill-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
}
.skill-main { flex: 1; min-width: 0; }
.skill-name { font-size: 14px; font-weight: 600; }
.skill-name .skill-slug {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
  font-family: ui-monospace, monospace;
}
.skill-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.skill-meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.skill-version { font-size: 11px; color: var(--text-muted); font-family: ui-monospace, monospace; }
.skill-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
}
.skill-item.status-up_to_date .skill-badge { background: #1f3a2a; color: #7cd9a6; }
.skill-item.status-update_available .skill-badge { background: #3a321f; color: #e0c66f; }
.skill-item.status-locally_modified .skill-badge { background: #3a2a1f; color: #e09c6f; }
.skill-item.status-conflict .skill-badge,
.skill-item.status-source_removed .skill-badge,
.skill-item.status-missing .skill-badge { background: #3a1f1f; color: #e07f7f; }

.skill-actions { display: flex; gap: 6px; flex-shrink: 0; }
.skill-actions button { font-size: 12px; padding: 6px 12px; }


/* ── MCP tab ───────────────────────────────────── */

.mcp-list {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.mcp-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mcp-card.enabled {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 1px var(--accent-dim);
}
.mcp-card[draggable="true"] { cursor: grab; }
.mcp-card.dragging { opacity: 0.4; }
.mcp-card.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.mcp-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mcp-card-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mcp-card-title .mcp-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.mcp-card-title .mcp-slug {
  font-size: 11px;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}
.mcp-card-actions { display: flex; gap: 4px; }

.mcp-transport {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.mcp-transport.stdio { background: var(--accent-dim); color: var(--accent); }
.mcp-transport.http  { background: rgba(30, 150, 120, 0.12); color: #1e9678; }
.mcp-transport.sse   { background: rgba(220, 140, 30, 0.14); color: #b0701a; }

.mcp-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.mcp-desc:empty { display: none; }

.mcp-meta {
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-muted);
  word-break: break-all;
}
.mcp-meta.md-preview {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-height: 120px;
  overflow: hidden;
  position: relative;
  line-height: 1.5;
}
.mcp-meta.md-preview h1, .mcp-meta.md-preview h2, .mcp-meta.md-preview h3 {
  font-size: 12px;
  font-weight: 600;
  margin: 4px 0 2px;
  color: var(--text-secondary);
}
.mcp-meta.md-preview p { margin: 2px 0; }
.mcp-meta.md-preview ul, .mcp-meta.md-preview ol { margin: 2px 0; padding-left: 18px; }
.mcp-meta.md-preview code {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 3px;
}
.mcp-meta.md-preview pre {
  font-size: 10px;
  background: var(--surface-2);
  padding: 4px 8px;
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0;
}
.mcp-meta.md-preview table { font-size: 10px; border-collapse: collapse; margin: 4px 0; }
.mcp-meta.md-preview th, .mcp-meta.md-preview td { border: 1px solid var(--border); padding: 2px 6px; }

.mcp-binding {
  border-top: 1px solid var(--surface-3);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mcp-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.mcp-toggle input { width: 14px; height: 14px; accent-color: var(--accent); }
.mcp-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.mcp-kv { display: flex; flex-direction: column; gap: 4px; }
.mcp-kv .field-label {
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
  font-size: 11px;
}
.mcp-kv input {
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-family: ui-monospace, monospace;
}
.mcp-kv input:focus {
  border-color: var(--accent);
  outline: none;
}
.mcp-binding-actions { display: flex; justify-content: flex-end; }
.mcp-binding-actions button { font-size: 12px; padding: 6px 12px; }

.modal.modal-wide { width: min(560px, 92vw); }
.modal.modal-tall {
  width: min(640px, 94vw);
  height: min(720px, 90vh);
  display: flex;
  flex-direction: column;
}
.modal.modal-tall .modal-header { flex-shrink: 0; }
.mcp-header-actions { display: flex; gap: 8px; }

.mcp-ask-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.mcp-ask-body #ext-ask-messages {
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.mcp-ask-body .composer {
  flex-shrink: 0;
}

.mcp-proposal {
  margin: 10px 16px;
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  background: var(--surface-1);
  overflow: hidden;
}
.mcp-proposal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--accent-dim);
}
.mcp-proposal-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.mcp-proposal-use { font-size: 12px; padding: 4px 12px; }
.mcp-proposal-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mcp-proposal-row {
  display: flex;
  gap: 10px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  line-height: 1.5;
}
.mcp-proposal-row .k {
  color: var(--text-muted);
  min-width: 90px;
  flex-shrink: 0;
}
.mcp-proposal-row .v {
  color: var(--text);
  word-break: break-all;
  flex: 1;
}

#modal-ext-ask .modal-header #ext-ask-reset {
  padding: 4px 10px;
  font-size: 11px;
  margin-right: 6px;
}
.form-row-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.mcp-stdio-fields,
.mcp-http-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 2px;
}
.mcp-stdio-fields.hidden,
.mcp-http-fields.hidden { display: none; }
.modal-body textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}
.modal-body textarea:focus {
  outline: none;
  border-color: var(--accent);
}


/* ── Skill Hub full-screen view ─────────────────── */

.app-shell.hidden { display: none !important; }

.skill-hub-view {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: 48px 1fr;
  grid-template-columns: 220px 240px 1fr auto;
  grid-template-areas:
    "top top top top"
    "sideA sideB main chat";
  background: var(--surface-0);
  color: var(--text);
  z-index: 50;
}
.skill-hub-view.hidden { display: none; }

.hub-topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.hub-topbar .spacer { flex: 1; }
.hub-topbar-title { font-size: 14px; font-weight: 600; }
.hub-topbar button { font-size: 12px; padding: 6px 12px; display: inline-flex; align-items: center; gap: 4px; }

.hub-side-skills { grid-area: sideA; }
.hub-side-files { grid-area: sideB; }
.hub-side-skills, .hub-side-files {
  border-right: 1px solid var(--border);
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.hub-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.hub-side-header-actions { display: flex; gap: 4px; }
.hub-side-header .icon-btn {
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center; justify-content: center;
  padding: 0;
  font-size: 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
}
.hub-side-header .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.hub-side-list, .hub-tree {
  flex: 1; overflow-y: auto; padding: 4px 0;
}

.hub-skill-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.hub-skill-row:hover { background: var(--surface-2); }
.hub-skill-row.active { background: var(--surface-3); }
.hub-skill-row .name { font-size: 13px; font-weight: 500; }
.hub-skill-row .meta { font-size: 10px; color: var(--text-muted); font-family: ui-monospace, monospace; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.tree-row:hover { background: var(--surface-2); }
.tree-row.active { background: var(--surface-3); }
.tree-chev { width: 12px; font-size: 10px; color: var(--text-muted); text-align: center; }
.tree-icon { font-size: 11px; opacity: 0.8; }
.tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hub-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.hub-main .empty-state { margin: auto; padding: 40px; }
.hub-editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.hub-editor-area.hidden { display: none; }

.hub-meta-bar {
  display: grid;
  grid-template-columns: 140px 1fr 100px auto;
  grid-template-areas:
    "slug name version actions"
    "desc desc desc desc";
  column-gap: 12px;
  row-gap: 10px;
  align-items: end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.hub-meta-bar label.inline { display: flex; flex-direction: column; gap: 4px; margin: 0; min-width: 0; }
.hub-meta-bar label[data-field="slug"] { grid-area: slug; }
.hub-meta-bar label[data-field="name"] { grid-area: name; }
.hub-meta-bar label[data-field="version"] { grid-area: version; }
.hub-meta-bar label[data-field="description"] { grid-area: desc; }
.hub-meta-bar .hub-meta-actions { grid-area: actions; }
.hub-meta-bar .field-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 500;
}
.hub-meta-bar input {
  font-size: 12px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hub-meta-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.hub-meta-bar input[readonly] {
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: default;
}
.hub-meta-bar .hub-meta-actions { display: flex; gap: 4px; }

.hub-file-editor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.hub-file-editor-header .spacer { flex: 1; }
.hub-file-path {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hub-file-editor-header .icon-action { margin-left: 2px; }
.hub-preview-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(124, 92, 252, 0.25);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  cursor: help;
}
.hub-preview-badge.hidden { display: none; }

#hub-file-content {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  border: none;
  border-radius: 0;
  padding: 16px 20px;
  background: var(--surface-0);
  color: var(--text);
}
#hub-file-content:focus { outline: none; }

/* chat pane */
.hub-chat-pane {
  grid-area: chat;
  width: 400px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface-1);
  overflow: hidden;
}
.hub-chat-pane.hidden { display: none; }
.hub-chat-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.hub-chat-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.hub-chat-path {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}
.hub-chat-bar .spacer { flex: 1; }
.hub-chat-bar .pill-action { margin-left: 2px; }

.hub-chat-pane #hub-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.hub-chat-pane #hub-chat-messages .empty-state {
  padding: 32px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}
.hub-chat-pane .composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
}

/* ── Instruction editor (full-screen) ──────────── */
#instr-editor-view {
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "top top"
    "main chat";
}
.instr-editor-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  padding: 0;
}
.instr-editor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  font-size: 13px;
}
.instr-editor-header .spacer { flex: 1; }
#instr-editor-content {
  flex: 1;
  width: 100%;
  border: none;
  padding: 16px 20px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

/* Icon-only action button — ghost by default, colored on hover */
.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.icon-action svg { width: 15px; height: 15px; }
.icon-action:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.icon-action.primary:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(124, 92, 252, 0.25);
}
.icon-action.danger:hover {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.25);
}
.icon-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: transparent !important;
  color: var(--text-muted) !important;
  border-color: transparent !important;
}

/* Pill-style action with icon + text (used in chat bar) */
.pill-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pill-action svg { width: 13px; height: 13px; }
.pill-action:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hover);
}
.pill-action.primary {
  color: var(--accent);
  border-color: rgba(124, 92, 252, 0.3);
  background: var(--accent-dim);
}
.pill-action.primary:hover {
  background: rgba(124, 92, 252, 0.14);
  border-color: rgba(124, 92, 252, 0.45);
}
.pill-action.danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.25);
}
.pill-action.danger:hover {
  background: var(--danger-dim);
  border-color: rgba(239, 68, 68, 0.4);
}
.pill-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: transparent !important;
}

@media (max-width: 1100px) {
  .skill-hub-view { grid-template-columns: 200px 220px 1fr; grid-template-areas: "top top top" "sideA sideB main"; }
  .hub-chat-pane { position: fixed; top: 48px; right: 0; bottom: 0; width: 380px; grid-area: unset; }
}
