:root {
  --bg-base: #0b0f17;
  --bg-surface: #111827;
  --bg-elevated: #1a2234;
  --bg-hover: #232e45;
  --bg-user-bubble: #1e3a8a;
  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --success: #10b981;
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.4);
}

/* Buttons & Inputs */
.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.primary-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}
.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.danger-btn {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-weight: 600;
  cursor: pointer;
}
.danger-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

.ghost-btn {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ghost-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.ghost-btn.small {
  padding: 4px 9px;
  font-size: 12px;
}
.ghost-btn.tiny {
  padding: 3px 8px;
  font-size: 12px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.text-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}
.text-link-btn:hover {
  text-decoration: underline;
}

.full-width {
  width: 100%;
}

input[type="text"],
input[type="password"],
input[type="search"],
.select-control {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}
input:focus, .select-control:focus {
  border-color: var(--accent);
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 20%, #172554 0%, #0b0f17 65%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  font-weight: bold;
  flex-shrink: 0;
}
.brand-logo.small {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  font-size: 14px;
}
.login-brand h1 {
  font-size: 18px;
  font-weight: 700;
}
.login-brand p {
  font-size: 12px;
  color: var(--text-secondary);
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-form label {
  font-size: 12px;
  color: var(--text-secondary);
}
.password-field {
  display: flex;
  gap: 6px;
}
.password-field input {
  flex: 1;
}
.form-error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* Main App Shell */
.app-shell {
  display: flex;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* Left Sidebar */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease, transform 0.2s ease;
  z-index: 30;
}
.sidebar.collapsed {
  margin-left: -280px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand-title {
  font-weight: 700;
  font-size: 15px;
}
.tier-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.sidebar-actions {
  padding: 4px 12px 10px;
}

.workspace-box {
  padding: 8px 12px 10px;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.section-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.history-search-box {
  padding: 10px 12px 6px;
}
.history-search-box input {
  width: 100%;
  font-size: 12px;
  padding: 6px 9px;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.conv-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s;
}
.conv-item:hover {
  background: var(--bg-elevated);
}
.conv-item.active {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.35);
}
.conv-main {
  min-width: 0;
  flex: 1;
}
.conv-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.conv-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
}
.conv-cwd {
  background: rgba(148, 163, 184, 0.1);
  padding: 0 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-hide-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.conv-item:hover .conv-hide-btn {
  opacity: 1;
}
.conv-hide-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: pulseAnim 1.2s infinite ease-in-out;
}
@keyframes pulseAnim {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.2); }
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}
.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.online {
  background: var(--success);
}
.status-dot.offline {
  background: var(--warning);
}
.footer-btns {
  display: flex;
  gap: 6px;
}

/* Center Chat Main */
.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

.topbar {
  min-height: 54px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(17, 24, 39, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.session-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.session-heading h2 {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.cwd-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cwd-pill:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.control-group {
  display: flex;
  align-items: center;
  gap: 5px;
}
.control-label {
  font-size: 11px;
  color: var(--text-muted);
}
.select-control.compact {
  padding: 4px 8px;
  font-size: 12px;
  background: var(--bg-elevated);
}

.readonly-banner {
  background: var(--warning-soft);
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  padding: 8px 16px;
  font-size: 12px;
}

/* Messages Viewport */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 24px;
  scroll-behavior: auto;
}

.welcome-state {
  max-width: 720px;
  margin: 40px auto;
  text-align: center;
}
.welcome-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
}
.welcome-state h3 {
  font-size: 20px;
  margin-bottom: 8px;
}
.welcome-state p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}
.welcome-state code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.starter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  text-align: left;
}
.starter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.starter-card:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
}
.starter-card strong {
  font-size: 13px;
  color: var(--text-primary);
}
.starter-card span {
  font-size: 12px;
  color: var(--text-secondary);
}

.messages-list {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* User Message */
.msg-user {
  display: flex;
  justify-content: flex-end;
}
.msg-user-bubble {
  max-width: 82%;
  background: var(--bg-user-bubble);
  border: 1px solid rgba(96, 165, 250, 0.3);
  color: #f8fafc;
  padding: 10px 14px;
  border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}

/* Assistant Turn */
.msg-assistant {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(17, 24, 39, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}
.assistant-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #cbd5e1;
}

/* Thought Block */
.thought-card {
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.65);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.thought-summary {
  padding: 7px 11px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 7px;
}
.thought-summary:hover {
  background: rgba(255, 255, 255, 0.03);
}
.thought-body {
  padding: 9px 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* Tool Call Card */
.tool-card {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.tool-header {
  padding: 7px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
}
.tool-header:hover {
  background: var(--bg-elevated);
}
.tool-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tool-name-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  flex-shrink: 0;
}
.tool-title-text {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.tool-body {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  background: #090d14;
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.tool-pre {
  white-space: pre-wrap;
  word-break: break-all;
  color: #cbd5e1;
  max-height: 280px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px;
  border-radius: 4px;
}

/* Diff View inside Tool Card */
.diff-box {
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  overflow: hidden;
}
.diff-path {
  background: var(--bg-elevated);
  padding: 4px 8px;
  font-size: 11px;
  color: #93c5fd;
  cursor: pointer;
}
.diff-line-del {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  padding: 1px 8px;
  white-space: pre-wrap;
}
.diff-line-add {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
  padding: 1px 8px;
  white-space: pre-wrap;
}

/* Interactive Permission Card */
.permission-card {
  border: 1px solid rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.1);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.perm-title {
  font-weight: 600;
  color: #fcd34d;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.perm-detail {
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
}
.perm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Markdown Body */
.markdown-body {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
.markdown-body > *:first-child {
  margin-top: 0;
}
.markdown-body > *:last-child {
  margin-bottom: 0;
}
.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body table,
.markdown-body details {
  margin-bottom: 10px;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 16px 0 8px;
  font-weight: 600;
  line-height: 1.35;
}
.markdown-body h1 { font-size: 19px; }
.markdown-body h2 { font-size: 17px; }
.markdown-body h3 { font-size: 15px; }
.markdown-body ul, .markdown-body ol {
  padding-left: 22px;
}
.markdown-body li {
  margin-bottom: 4px;
}
.markdown-body code:not(pre code) {
  background: rgba(148, 163, 184, 0.16);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.markdown-body a {
  color: #60a5fa;
  text-decoration: none;
}
.markdown-body a:hover {
  text-decoration: underline;
}
.markdown-body a.file-link {
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-secondary);
}
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  text-align: left;
}
.markdown-body th {
  background: var(--bg-elevated);
}

.code-block-wrapper {
  margin: 10px 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0d1117;
}
.code-block-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: #161b22;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.code-copy-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  cursor: pointer;
}
.code-copy-btn:hover {
  color: #fff;
  border-color: var(--border-strong);
}
.code-block-wrapper pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
}

.turn-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.08);
  font-size: 11px;
  color: var(--text-muted);
}

/* Composer */
.composer-wrapper {
  padding: 8px 16px 14px;
  background: linear-gradient(180deg, rgba(11, 15, 23, 0) 0%, var(--bg-base) 25%);
  position: relative;
}
.composer-box {
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.composer-box:focus-within {
  border-color: var(--accent);
}
#promptInput {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  min-height: 26px;
  max-height: 200px;
  line-height: 1.5;
  font-size: 14px;
}
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.composer-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.composer-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Slash Command Menu */
.slash-menu {
  position: absolute;
  bottom: calc(100% - 4px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 860px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 25;
  padding: 4px;
}
.slash-item {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.slash-item:hover, .slash-item.active {
  background: var(--accent-soft);
}
.slash-cmd {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #93c5fd;
  flex-shrink: 0;
}
.slash-desc {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Right Drawer: File Explorer & Preview */
.file-drawer {
  width: 420px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: margin-right 0.2s ease, transform 0.2s ease;
  z-index: 28;
}
.file-drawer.collapsed {
  margin-right: -420px;
}

.drawer-header {
  min-height: 54px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-tabs {
  display: flex;
  gap: 4px;
}
.drawer-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.drawer-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.count-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 0 5px;
  border-radius: 999px;
}
.drawer-header-actions {
  display: flex;
  gap: 4px;
}

.drawer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.file-breadcrumb-bar {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.15);
}
.file-current-dir {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-tree-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
}
.file-row:hover {
  background: var(--bg-elevated);
}
.file-row-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.file-row-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-row-name.hidden-file {
  color: var(--text-muted);
}
.file-row-size {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* File Preview Pane */
.file-preview-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.preview-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
}
.preview-title-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.preview-filename {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}
.preview-meta-bar {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-content-body {
  flex: 1;
  overflow: auto;
  background: #0d1117;
}

.code-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}
.code-table td {
  padding: 0 8px;
  vertical-align: top;
}
.code-line-num {
  width: 1%;
  min-width: 38px;
  text-align: right;
  color: var(--text-muted);
  user-select: none;
  border-right: 1px solid rgba(148, 163, 184, 0.12);
}
.code-line-text {
  white-space: pre;
}
.code-line-row.highlighted {
  background: rgba(245, 158, 11, 0.18);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 540px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
}
.modal-card.small {
  max-width: 380px;
}
.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 15px;
}
.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-body label {
  font-size: 12px;
  color: var(--text-secondary);
}
.row-gap, .mkdir-row {
  display: flex;
  gap: 8px;
}
.row-gap input, .mkdir-row input {
  flex: 1;
}
.dir-browser-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.muted-mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-dir-list {
  height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  padding: 4px;
}
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.mobile-only {
  display: none;
}

/* Responsive Mobile & Tablet */
@media (max-width: 960px) {
  .mobile-only {
    display: inline-flex;
  }
  .hide-xs {
    display: none;
  }
  .mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 26;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    margin-left: 0 !important;
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .file-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(100vw, 420px);
    margin-right: 0 !important;
    transform: translateX(100%);
  }
  .file-drawer.mobile-open {
    transform: translateX(0);
  }
  .starter-grid {
    grid-template-columns: 1fr;
  }
  .control-label {
    display: none;
  }
  .session-heading h2 {
    max-width: 140px;
  }
  .cwd-pill {
    max-width: 120px;
  }
}
