/* === Terminal v3: Claude Max web chat + split file panel === */

.terminal-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  min-height: 500px;
}

.terminal-layout-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.terminal-layout-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

/* --- Header bar --- */

.terminal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  flex-shrink: 0;
}

.terminal-header-ctx {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.terminal-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.terminal-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.terminal-session {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.terminal-session:hover { opacity: 1; }

.terminal-session-value {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.64rem;
  color: var(--text-tertiary);
  cursor: pointer;
  user-select: all;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-status {
  display: flex;
  align-items: center;
  gap: 4px;
}

.terminal-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: background 0.2s;
}

.terminal-status-dot.ready { background: #3A8F5C; }
.terminal-status-dot.busy { background: #D4A017; animation: pulse-dot 1.2s infinite; }
.terminal-status-dot.error { background: #C96442; }

.terminal-status-text {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Module info bar --- */

.terminal-module-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  background: var(--bg);
  border-left: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  font-size: 0.76rem;
  flex-shrink: 0;
}

.terminal-module-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  cursor: pointer;
}

.terminal-module-link:hover {
  color: var(--accent);
  background: var(--accent-bg, #f5e6df);
}

.terminal-module-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.15s;
}

.terminal-module-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.terminal-module-status {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

/* footer removed — UUID now in .terminal-input-meta */

/* --- Sidebar (files + projects) --- */

.terminal-sidebar {
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--files-width, 260px);
  width: var(--files-width, 260px);
  min-width: 180px;
  max-width: 400px;
  min-height: 0;
}

/* --- Resize handle --- */

.terminal-resize-handle {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  position: relative;
  flex-shrink: 0;
}

.terminal-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 4px;
  height: 40px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: var(--border-light);
  opacity: 0;
  transition: opacity 0.15s;
}

.terminal-resize-handle:hover::after,
.terminal-resize-handle.dragging::after {
  opacity: 1;
  background: var(--accent);
}

.terminal-resize-handle:hover,
.terminal-resize-handle.dragging {
  background: var(--accent);
  opacity: 0.3;
}

/* --- Messages area --- */

.terminal-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg);
  border-left: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.terminal-messages::-webkit-scrollbar { width: 5px; }
.terminal-messages::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* Welcome */
.terminal-welcome {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.terminal-welcome-icon {
  margin-bottom: 16px;
  opacity: 0.4;
}

.terminal-welcome h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.terminal-welcome p {
  font-size: 0.86rem;
  line-height: 1.6;
  max-width: 480px;
  margin: 0 auto;
}

.terminal-welcome-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.terminal-hint-chip {
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.terminal-hint-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg, #f5e6df);
  transform: translateY(-1px);
}

/* --- Message bubbles with avatars --- */

.terminal-msg {
  max-width: 85%;
  display: flex;
  gap: 10px;
  animation: msg-in 0.25s ease-out;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.terminal-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.terminal-msg.assistant {
  align-self: flex-start;
}

.terminal-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
}

.terminal-msg.user .terminal-msg-avatar {
  background: var(--accent);
  color: white;
}

.terminal-msg.assistant .terminal-msg-avatar {
  background: linear-gradient(135deg, #f5e6df, #e8d5c8);
  color: var(--accent);
}

.terminal-msg-content {
  min-width: 0;
  flex: 1;
}

.terminal-msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.terminal-msg-role {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.terminal-msg-copy {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.terminal-msg:hover .terminal-msg-copy { opacity: 1; }
.terminal-msg-copy:hover { color: var(--accent); }

.terminal-msg-time { font-size: 0.7rem; }

/* Queue badge on message */
.terminal-queued-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--accent-bg, #f5e6df);
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Queue counter near stop button */
.terminal-queue-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: white;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
}

.terminal-msg-body {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.88rem;
  line-height: 1.65;
}

.terminal-msg.user .terminal-msg-body {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.terminal-msg.assistant .terminal-msg-body {
  background: var(--surface);
  border: 1px solid var(--border-light);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* --- Markdown in messages --- */

.terminal-code-block {
  position: relative;
  margin: 8px 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.terminal-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background: var(--bg-secondary, #f0ebe5);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.7rem;
}

.terminal-code-lang {
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  text-transform: lowercase;
}

.terminal-code-copy {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.terminal-code-copy:hover {
  color: var(--accent);
  background: var(--bg);
}

.terminal-code-block pre {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 10px 14px !important;
  background: var(--bg) !important;
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
}

.terminal-msg.assistant .terminal-msg-body pre:not(.terminal-code-block pre) {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 0.82rem;
  line-height: 1.6;
}

.terminal-msg.assistant .terminal-msg-body code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.84em;
}

.terminal-msg.assistant .terminal-msg-body code:not(pre code) {
  background: var(--bg-secondary, #f0ebe5);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent-dark, #b35c38);
}

.terminal-msg.assistant .terminal-msg-body p { margin: 0 0 8px; }
.terminal-msg.assistant .terminal-msg-body p:last-child { margin-bottom: 0; }

.terminal-msg.assistant .terminal-msg-body ul,
.terminal-msg.assistant .terminal-msg-body ol {
  margin: 4px 0 8px 18px;
}

.terminal-msg.assistant .terminal-msg-body h1,
.terminal-msg.assistant .terminal-msg-body h2,
.terminal-msg.assistant .terminal-msg-body h3 {
  margin: 12px 0 6px;
  font-weight: 600;
}

.terminal-msg.assistant .terminal-msg-body h1 { font-size: 1.1rem; }
.terminal-msg.assistant .terminal-msg-body h2 { font-size: 1rem; }
.terminal-msg.assistant .terminal-msg-body h3 { font-size: 0.92rem; }

/* Tables */
.terminal-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.terminal-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.terminal-table-wrap th {
  background: var(--bg-secondary, #f0ebe5);
  font-weight: 600;
  text-align: left;
  padding: 6px 10px;
  border-bottom: 2px solid var(--border-light);
  white-space: nowrap;
}

.terminal-table-wrap td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-light);
}

.terminal-table-wrap tr:last-child td { border-bottom: none; }
.terminal-table-wrap tr:hover td { background: var(--bg); }

/* Metadata */
.terminal-msg-meta {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  font-size: 0.74rem;
  color: var(--text-tertiary);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.terminal-msg-meta span {
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Thinking indicator */
.terminal-thinking {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  font-size: 0.84rem;
  color: var(--text-tertiary);
  animation: msg-in 0.25s ease-out;
  margin-left: 38px;
}

.terminal-thinking-dots {
  display: flex;
  gap: 3px;
}

.terminal-thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinking-bounce 1.4s infinite;
}

.terminal-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.terminal-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* --- Streaming partial response --- */

/* Коллапс длинных промптов */
.terminal-collapsed-prompt {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.terminal-collapsed-label {
  font-weight: 600; font-size: 0.8rem;
  background: rgba(255,255,255,0.25); color: #fff;
  padding: 2px 8px; border-radius: 4px;
}
.terminal-collapsed-preview {
  font-size: 0.78rem; color: rgba(255,255,255,0.8); max-width: 600px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.terminal-expand-btn {
  font-size: 0.72rem; background: rgba(255,255,255,0.2); color: #fff;
  border: 1px solid rgba(255,255,255,0.35); padding: 2px 8px; border-radius: 4px;
  cursor: pointer;
}
.terminal-expand-btn:hover { background: rgba(255,255,255,0.35); }
.terminal-full-prompt { margin-top: 6px; }
.terminal-full-prompt pre {
  font-size: 0.72rem; max-height: 400px; overflow-y: auto;
  background: var(--bg-alt, #f5f0e8); color: var(--text); padding: 8px; border-radius: 4px;
  white-space: pre-wrap; word-break: break-word;
}
.terminal-full-prompt > .btn-sm {
  font-size: 0.72rem; margin-bottom: 4px; background: rgba(255,255,255,0.2);
  color: #fff; border: 1px solid rgba(255,255,255,0.35);
}

.terminal-streaming-msg {
  animation: msg-in 0.25s ease-out;
  border-left: 2px solid var(--accent);
}

.terminal-stream-content {
  font-size: 0.84rem;
  line-height: 1.55;
  max-height: 400px;
  overflow-y: auto;
  word-break: break-word;
}

.terminal-stream-content pre {
  background: var(--bg-alt, #f5f0e8);
  padding: 8px 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 6px 0;
  font-size: 0.8rem;
}

.terminal-stream-tool {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  padding: 4px 0;
  font-style: italic;
  border-top: 1px solid var(--border-light);
  margin-top: 6px;
}

.terminal-stream-indicator {
  display: flex;
  align-items: center;
  padding-top: 6px;
}

/* --- Input area --- */

.terminal-input-area {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 0 0 0 var(--radius-lg);
  border-top: none;
  flex-shrink: 0;
}

.terminal-input-wrap {
  flex: 1;
  position: relative;
}

.terminal-input {
  width: 100%;
  min-height: 42px;
  max-height: 200px;
  padding: 9px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  resize: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.terminal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 100, 60, 0.1);
  background: var(--surface);
}

.terminal-input::placeholder { color: var(--text-tertiary); }

.terminal-send-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.terminal-send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.04);
}

.terminal-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.terminal-stop-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: var(--radius-sm);
  background: #C96442;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.terminal-stop-btn:hover { background: #a84f32; }

/* Model toggle button */
.terminal-model-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  transition: all 0.15s;
  flex-shrink: 0;
}

.terminal-model-btn:hover {
  border-color: var(--accent);
  background: var(--accent-bg, #f5e6df);
}

.terminal-clear-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.terminal-clear-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Error message --- */

.terminal-error {
  padding: 10px 14px;
  background: #fdf0f0;
  border: 1px solid #d35f5f33;
  border-radius: var(--radius-sm);
  color: #a63d3d;
  font-size: 0.84rem;
  line-height: 1.5;
}

/* --- OAuth авторизация --- */

.terminal-oauth-block {
  padding: 16px 18px;
  background: linear-gradient(135deg, #fef9f0 0%, #fdf0e8 100%);
  border: 1px solid #e8a94080;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.terminal-oauth-icon {
  color: #c47a20;
  margin-bottom: 8px;
}

.terminal-oauth-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #8b5e14;
  margin-bottom: 6px;
}

.terminal-oauth-desc {
  font-size: 0.82rem;
  color: #7a6a50;
  margin-bottom: 14px;
  line-height: 1.4;
}

.terminal-oauth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.terminal-oauth-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.terminal-oauth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.terminal-oauth-btn--primary {
  background: var(--accent);
  color: white;
}

.terminal-oauth-btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.terminal-oauth-btn--secondary {
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.terminal-oauth-btn--secondary:hover:not(:disabled) {
  background: #f5f0eb;
  border-color: #c0b5a8;
}

.terminal-oauth-btn--small {
  padding: 4px 10px;
  font-size: 0.78rem;
  background: white;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 6px;
}

.terminal-oauth-btn--small:hover {
  background: #f5f0eb;
}

.terminal-oauth-status {
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  line-height: 1.5;
}

.terminal-oauth-status--loading {
  background: #f0f4fd;
  color: #4a6fa5;
}

.terminal-oauth-status--success {
  background: #edf7ed;
  color: #2e7d32;
}

.terminal-oauth-status--error {
  background: #fdf0f0;
  color: #a63d3d;
}

.terminal-oauth-status--info {
  background: #f8f6f0;
  color: var(--text-primary);
}

.terminal-oauth-link {
  display: block;
  word-break: break-all;
  color: var(--accent);
  font-size: 0.8rem;
  margin: 6px 0;
  text-decoration: underline;
}

.terminal-oauth-hint {
  font-size: 0.78rem;
  color: #7a6a50;
  margin: 8px 0 6px;
}

.terminal-oauth-code-input {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  align-items: center;
}

.terminal-oauth-code-input input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d4c8b8;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: 'SFMono-Regular', 'Consolas', monospace;
  background: #fff;
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.terminal-oauth-code-input input:focus {
  outline: none;
  border-color: var(--accent, #c96442);
  background: #fefcfa;
}

.terminal-oauth-code-input input::placeholder {
  color: #a89880;
}

.terminal-oauth-manual {
  margin-top: 8px;
  font-size: 0.8rem;
}

.terminal-oauth-manual summary {
  cursor: pointer;
  color: #7a6a50;
  font-size: 0.78rem;
}

.terminal-oauth-manual summary:hover {
  color: var(--text-primary);
}

.terminal-oauth-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.terminal-oauth-steps code {
  display: block;
  padding: 4px 10px;
  background: #f5f0eb;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  user-select: all;
}

.terminal-oauth-steps span {
  font-size: 0.78rem;
  color: #7a6a50;
}

/* --- Files panel (tree only) --- */

.terminal-files {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--surface);
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-left: none;
}

.terminal-files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  background: var(--bg);
}

.terminal-files-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}

.terminal-files-actions {
  display: flex;
  gap: 2px;
}

.terminal-files-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px;
  transition: color 0.15s;
  display: flex;
  align-items: center;
}

.terminal-files-btn:hover { color: var(--accent); }

/* Breadcrumbs path */
.terminal-files-path {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 3px 10px;
  font-size: 0.64rem;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  color: var(--text-tertiary);
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  overflow-x: auto;
  flex-shrink: 0;
}

.terminal-files-path::-webkit-scrollbar { height: 0; }

.terminal-breadcrumb {
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color 0.15s;
  padding: 1px 2px;
  border-radius: 2px;
}

.terminal-breadcrumb:hover {
  color: var(--accent);
  background: var(--accent-bg, #f5e6df);
}

.terminal-breadcrumb-sep {
  color: var(--border-light);
  padding: 0 1px;
  user-select: none;
}

/* File tree */
.terminal-files-tree {
  flex: 1 1 0;
  min-height: 40px;
  overflow-y: auto;
  padding: 2px 0;
  font-size: 0.76rem;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
}

.terminal-files-tree::-webkit-scrollbar { width: 4px; }
.terminal-files-tree::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.ft-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px calc(8px + var(--depth, 0) * 16px);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.ft-item:hover { background: var(--bg); }

.ft-item.active {
  background: var(--accent-bg, #f5e6df);
  color: var(--accent);
}

.ft-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ft-item.ft-dir .ft-icon:first-child {
  transition: transform 0.15s;
}

.ft-item.ft-dir.open .ft-icon:first-child {
  transform: rotate(90deg);
}

.ft-dir-children { display: none; }
.ft-dir-children.open { display: block; }

.ft-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.ft-size {
  margin-left: auto;
  font-size: 0.62rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
  opacity: 0.7;
}

/* --- Projects panel (below files) --- */

.terminal-projects {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 120px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-left: none;
  border-top: none;
}

.terminal-projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  background: var(--bg);
}

.terminal-projects-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 0;
  font-size: 0.76rem;
}

.terminal-projects-list::-webkit-scrollbar { width: 4px; }
.terminal-projects-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.tp-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.tp-item:hover { background: var(--bg); }

.tp-item.active {
  background: var(--accent-bg, #f5e6df);
  color: var(--accent);
}

.tp-item-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: var(--text-tertiary);
}

.tp-item.active .tp-item-icon { color: var(--accent); }

.tp-item-id {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.68rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
  min-width: 52px;
}

.tp-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.tp-item-status {
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Project groups (collapsible) */
.tp-group-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-tertiary);
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  user-select: none;
  transition: color 0.15s;
}

.tp-group-header:hover { color: var(--text-secondary); }

.tp-group-chevron {
  display: flex;
  transition: transform 0.15s;
}

.tp-group-header.open .tp-group-chevron {
  transform: rotate(90deg);
}

.tp-group-count {
  margin-left: auto;
  font-size: 0.62rem;
  opacity: 0.6;
  font-weight: 400;
}

.tp-group-items {
  display: none;
}

.tp-group-items.open {
  display: block;
}

/* Card link (external arrow) */
.tp-item-link {
  display: none;
  align-items: center;
  color: var(--text-tertiary);
  padding: 1px 2px;
  border-radius: 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.tp-item:hover .tp-item-link {
  display: flex;
}

.tp-item-link:hover {
  color: var(--accent);
}

/* --- File viewer (separate right column, 1/3 screen) --- */

.terminal-file-viewer {
  display: none;
  flex-direction: column;
  flex: 0 0 33vw;
  max-width: 45vw;
  min-width: 280px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-left: none;
  border-top-right-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.terminal-file-viewer.open {
  display: flex;
}

.terminal-file-viewer.fullwidth {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: none;
  flex: none;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  border-radius: 0;
  border: none;
}

.terminal-file-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: var(--bg-secondary, #f0ebe5);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  gap: 4px;
}

#terminal-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.terminal-file-viewer-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.terminal-file-viewer-header button {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 3px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.terminal-file-viewer-header button:hover {
  color: var(--accent);
  background: var(--bg);
}

.terminal-file-content {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1.55;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  background: var(--bg);
  color: var(--text);
  tab-size: 4;
  white-space: pre;
}

.terminal-file-content::-webkit-scrollbar { width: 4px; height: 4px; }
.terminal-file-content::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* Syntax highlighting */
.terminal-file-content .syn-kw { color: #8B5CF6; } /* keywords */
.terminal-file-content .syn-str { color: #059669; } /* strings */
.terminal-file-content .syn-cm { color: #9CA3AF; font-style: italic; } /* comments */
.terminal-file-content .syn-num { color: #D97706; } /* numbers */
.terminal-file-content .syn-fn { color: #2563EB; } /* functions */
.terminal-file-content .syn-var { color: #DC2626; } /* variables ($, this) */
.terminal-file-content .syn-tag { color: #E44D26; } /* HTML tags */
.terminal-file-content .syn-attr { color: #9333EA; } /* HTML attributes */
.terminal-file-content .syn-op { color: #6B7280; } /* operators */

/* Line numbers in viewer */
.terminal-file-line {
  display: flex;
}

.terminal-file-ln {
  display: inline-block;
  width: 40px;
  padding: 0 8px 0 8px;
  text-align: right;
  color: var(--text-tertiary);
  opacity: 0.5;
  user-select: none;
  flex-shrink: 0;
  border-right: 1px solid var(--border-light);
  margin-right: 10px;
}

.terminal-file-lc {
  flex: 1;
  min-width: 0;
}

/* Sidebar rounded corners when viewer is closed */
.terminal-sidebar:last-child .terminal-files {
  border-top-right-radius: var(--radius-lg);
}
.terminal-sidebar:last-child .terminal-projects {
  border-bottom-right-radius: var(--radius-lg);
}

/* When viewer IS open, remove right radius from sidebar panels */
.terminal-sidebar:has(~ .terminal-file-viewer.open) .terminal-files,
.terminal-sidebar:has(~ .terminal-file-viewer.open) .terminal-projects {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* --- System messages (inline notifications) --- */

.terminal-msg.system {
  align-self: center;
  max-width: 90%;
  gap: 0;
}

.terminal-msg.system .terminal-msg-body {
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 0.76rem;
  color: var(--text-tertiary);
  text-align: center;
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-msg.system .terminal-msg-body::before,
.terminal-msg.system .terminal-msg-body::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* --- Pipeline messages in Terminal --- */

.terminal-msg.pipeline-start,
.terminal-msg.pipeline-done {
  align-self: center;
  max-width: 95%;
  gap: 0;
}

.terminal-msg.pipeline-start .terminal-msg-body {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.terminal-msg.pipeline-start svg { color: var(--accent); flex-shrink: 0; }

.terminal-msg.pipeline-done .terminal-msg-body {
  background: color-mix(in srgb, var(--status-published) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-published) 25%, transparent);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.terminal-msg.pipeline-done svg { color: var(--status-published); flex-shrink: 0; }

.tpl-meta {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-left: 4px;
}

.tpl-files {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.72rem;
  font-family: var(--font-mono, monospace);
}

.tpl-files .file-added::before { content: "+ "; color: var(--status-dev); font-weight: 600; }
.tpl-files .file-modified::before { content: "~ "; color: var(--status-spec); font-weight: 600; }

.tpl-actions {
  flex-basis: 100%;
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.tpl-actions .btn-sm {
  font-size: 0.72rem;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  background: none;
  transition: background 0.15s;
}

.tpl-actions .btn-sm:hover {
  background: var(--accent-light);
}

/* --- Slash-command autocomplete --- */

.terminal-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 4px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  max-height: 260px;
  overflow-y: auto;
  z-index: 10;
}

.terminal-autocomplete::-webkit-scrollbar { width: 4px; }
.terminal-autocomplete::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.terminal-ac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.terminal-ac-item:hover,
.terminal-ac-item.selected {
  background: var(--accent-bg, #f5e6df);
}

.terminal-ac-cmd {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 90px;
}

.terminal-ac-desc {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.terminal-ac-ctx {
  font-size: 0.66rem;
  color: var(--text-tertiary);
  margin-left: auto;
  flex-shrink: 0;
}

/* --- Action result (deploy/test steps) --- */

.terminal-action-result {
  align-self: flex-start;
  max-width: 85%;
  margin-left: 38px;
  animation: msg-in 0.25s ease-out;
}

.terminal-action-result-box {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.terminal-action-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.terminal-action-result-header:hover {
  background: var(--accent-bg, #f5e6df);
}

.terminal-action-result-toggle {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.terminal-action-result-steps {
  padding: 6px 0;
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
}

.terminal-action-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 14px;
}

.terminal-action-step-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.terminal-action-step.ok .terminal-action-step-icon { color: #3A8F5C; }
.terminal-action-step.fail .terminal-action-step-icon { color: #C96442; }

.terminal-action-step-text {
  flex: 1;
  color: var(--text-secondary);
}

.terminal-action-step-detail {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-action-result-summary {
  padding: 6px 14px;
  border-top: 1px solid var(--border-light);
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.terminal-action-result-summary.ok { color: #3A8F5C; }
.terminal-action-result-summary.fail { color: #C96442; }

.terminal-action-result-steps.collapsed { display: none; }

/* --- Responsive --- */

@media (max-width: 768px) {
  .terminal-layout {
    height: calc(100vh - 160px);
  }

  .terminal-sidebar,
  .terminal-resize-handle,
  .terminal-file-viewer {
    display: none !important;
  }

  .terminal-header {
    flex-wrap: wrap;
    gap: 6px;
  }

  .terminal-header select { max-width: none; }
  .terminal-session { display: none; }

  .terminal-msg { max-width: 95%; }

  .terminal-input-area {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }

  .terminal-module-bar { display: none !important; }
}

/* ===== WORKSPACE v4 ADDITIONS ===== */

/* --- Panel toggle buttons in header --- */

.terminal-panel-toggle {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.terminal-panel-toggle:hover {
  border-color: var(--border-light);
  color: var(--accent);
  background: var(--accent-bg, #f5e6df);
}

.terminal-panel-toggle.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg, #f5e6df);
}

/* --- LEFT: Projects panel --- */

.terminal-projects-panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--projects-width, 220px);
  width: var(--projects-width, 220px);
  min-width: 160px;
  max-width: 340px;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  overflow: hidden;
  transition: width 0.2s ease, opacity 0.15s ease, flex-basis 0.2s ease;
}

/* collapsed handled in workspace v4 section */

.terminal-projects-panel .terminal-projects-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  background: var(--bg);
}

.terminal-projects-search-wrap {
  padding: 0;
}

.terminal-projects-search {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.76rem;
  font-family: inherit;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.terminal-projects-search:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.terminal-projects-search::placeholder { color: var(--text-tertiary); }

/* Marketplace filter tabs */
.terminal-mkt-tabs {
  display: flex;
  gap: 2px;
}

.terminal-mkt-btn {
  flex: 1;
  padding: 3px 6px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-tertiary);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.15s;
}

.terminal-mkt-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.terminal-mkt-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Projects list scroll */
.terminal-projects-panel .terminal-projects-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 0;
  font-size: 0.76rem;
}

.terminal-projects-panel .terminal-projects-list::-webkit-scrollbar { width: 3px; }
.terminal-projects-panel .terminal-projects-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* Hide old .terminal-projects (was in sidebar) */
.terminal-sidebar .terminal-projects { display: none; }

/* Adjust left resize handle */
#terminal-resize-left {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  position: relative;
  flex-shrink: 0;
}

#terminal-resize-left::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 4px;
  height: 40px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: var(--border-light);
  opacity: 0;
  transition: opacity 0.15s;
}

#terminal-resize-left:hover::after,
#terminal-resize-left.dragging::after {
  opacity: 1;
  background: var(--accent);
}

#terminal-resize-left:hover,
#terminal-resize-left.dragging {
  background: var(--accent);
  opacity: 0.3;
}

/* When projects collapsed — hide left resize handle */
.terminal-projects-panel.collapsed + #terminal-resize-left {
  display: none;
}

/* --- PIPELINE STRIP in module bar --- */

.terminal-pipeline-strip {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.tps-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  border: 1.5px solid var(--border-light);
  transition: all 0.2s;
  cursor: default;
  flex-shrink: 0;
  position: relative;
}

.tps-dot[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  font-size: 0.64rem;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 10000;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.tps-dot.done {
  background: var(--success, #3A8F5C);
  border-color: var(--success, #3A8F5C);
}

.tps-dot.current {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.2);
  width: 10px;
  height: 10px;
}

.tps-dot.future {
  background: var(--border-light);
  border-color: var(--border-light);
  opacity: 0.5;
}

.tps-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  margin-left: 4px;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

/* --- Module bar: expanded action buttons --- */

.terminal-module-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.terminal-module-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.73rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.terminal-module-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.terminal-module-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white !important;
}

.terminal-module-btn--primary:hover {
  background: var(--accent-hover, #b35c38);
  border-color: var(--accent-hover, #b35c38);
  color: white !important;
}

.terminal-module-btn--next {
  border-color: var(--success, #3A8F5C);
  color: var(--success, #3A8F5C);
}

.terminal-module-btn--next:hover {
  background: var(--success, #3A8F5C);
  color: white;
}

/* --- Module bar: rearranged layout --- */

.terminal-module-bar {
  flex-wrap: nowrap;
  overflow: visible;
  position: relative;
  z-index: 10;
}

/* --- "Send to chat" in file viewer --- */

.terminal-file-viewer-header button[onclick*="SendFileToChat"] {
  color: var(--accent);
}

/* --- Header layout update (toggles on sides) --- */

.terminal-header {
  justify-content: flex-start;
  gap: 6px;
}

.terminal-header .terminal-header-ctx {
  flex: 1;
}

.terminal-header .terminal-status {
  flex-shrink: 0;
}

/* --- Responsive: hide left panel on small screens --- */

@media (max-width: 900px) {
  .terminal-projects-panel,
  #terminal-resize-left {
    display: none !important;
  }
}

/* --- Flash animation for new files --- */

@keyframes file-flash {
  0% { background: rgba(201, 100, 66, 0.25); }
  100% { background: transparent; }
}

.ft-item.flash {
  animation: file-flash 1.5s ease-out;
}

/* --- Module bar: status badge update --- */

/* --- Fullscreen mode --- */

.terminal-layout.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100vh !important;
  z-index: 9999;
  background: var(--bg);
  border-radius: 0;
}

.terminal-layout.fullscreen .terminal-header {
  border-radius: 0;
}

/* --- Collapsed panels → vertical strip --- */

.terminal-projects-panel.collapsed {
  width: 32px !important;
  flex: 0 0 32px !important;
  min-width: 32px !important;
  opacity: 1;
  overflow: hidden;
  border-right: 1px solid var(--border-light);
  cursor: pointer;
}

.terminal-projects-panel.collapsed .terminal-projects-header,
.terminal-projects-panel.collapsed .terminal-projects-list {
  display: none;
}

.terminal-projects-panel.collapsed::after {
  content: 'P';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  content: 'ПРОЕКТЫ';
}

.terminal-sidebar.collapsed {
  width: 32px !important;
  flex: 0 0 32px !important;
  min-width: 32px !important;
  opacity: 1;
  overflow: hidden;
  border-left: 1px solid var(--border-light);
  cursor: pointer;
}

.terminal-sidebar.collapsed .terminal-files {
  display: none;
}

.terminal-sidebar.collapsed::after {
  content: 'ФАЙЛЫ';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-tertiary);
  writing-mode: vertical-lr;
  text-orientation: mixed;
}

/* --- Input meta row (ctx name + UUID) --- */

.terminal-input-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 14px 0;
  flex-shrink: 0;
}

.terminal-input-ctx-name {
  font-size: 0.66rem;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.terminal-input-meta .terminal-session {
  margin-left: auto;
  opacity: 0.35;
  flex-shrink: 0;
}

.terminal-input-meta .terminal-session:hover { opacity: 0.7; }

.terminal-input-meta .terminal-session-value {
  max-width: 90px;
}

/* --- Header ctx as link --- */

a.terminal-header-ctx {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  cursor: pointer;
}

a.terminal-header-ctx:hover {
  color: var(--accent);
}

/* --- Pipeline dot tooltips: always on top --- */

.tps-dot[title]:hover::after {
  z-index: 10000;
}

/* --- Admin icon in header (right of title) --- */

.terminal-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  text-decoration: none;
  transition: all 0.15s;
  flex-shrink: 0;
}

.terminal-header-icon:hover {
  color: var(--accent);
  background: var(--accent-bg, #f5e6df);
}

/* --- Actions group (Deploy/Test/Deploy&Test) --- */

.terminal-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.terminal-actions-group .terminal-module-btn {
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--border-light);
}

.terminal-actions-group .terminal-module-btn:last-child {
  border-right: none;
}

/* --- Clickable pipeline dots --- */

.tps-dot.clickable {
  cursor: pointer;
  opacity: 1;
  border-color: var(--accent);
  border-style: dashed;
}

.tps-dot.clickable:hover {
  transform: scale(1.5);
  background: var(--accent);
  border-color: var(--accent);
  border-style: solid;
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.25);
}

/* --- Chat adaptive: narrow when files open --- */

.terminal-layout-chat {
  min-width: 280px;
}

.terminal-messages .terminal-msg {
  overflow-wrap: break-word;
  word-break: break-word;
}

.terminal-messages .terminal-code-block {
  overflow-x: auto;
}

.terminal-messages .terminal-code-block pre {
  max-width: 100%;
  overflow-x: auto;
}

/* --- Products without folder --- */

.tp-item.no-folder {
  opacity: 0.5;
}

.tp-item.no-folder .tp-item-id {
  font-style: italic;
}

/* --- AI processing indicator: soft color shimmer --- */

@keyframes ai-shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.tp-item.ai-busy {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(201, 100, 66, 0.06) 25%,
    rgba(201, 100, 66, 0.12) 50%,
    rgba(201, 100, 66, 0.06) 75%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: ai-shimmer 3s ease-in-out infinite;
}

.tp-item.ai-busy::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  animation: pulse-dot 1.2s infinite;
}

.tp-item {
  position: relative;
}

/* --- Terminal: Generated Ideas Cards --- */

.tg-summary {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.tg-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tg-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.2s;
}

.tg-card:hover {
  border-color: var(--accent);
}

.tg-card--done {
  opacity: 0.5;
  pointer-events: none;
}

.tg-card-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.tg-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
}

.tg-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.tg-cat {
  font-size: 0.74rem;
  color: var(--text-tertiary);
  margin-left: auto;
}

.tg-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 6px;
}

.tg-row {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 3px;
  line-height: 1.4;
}

.tg-row b {
  color: var(--text-primary);
  font-weight: 500;
}

.tg-row a {
  color: var(--accent);
}

.tg-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 6px 0;
}

.tg-tag {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-alt, #f5f0e8);
  color: var(--text-secondary);
}

.tg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.tg-btn {
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
}

.tg-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tg-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.tg-btn--run {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tg-btn--spec {
  background: var(--status-spec, #8b5cf6);
  color: #fff;
  border-color: var(--status-spec, #8b5cf6);
}

.tg-btn--dev {
  background: var(--status-dev, #3b82f6);
  color: #fff;
  border-color: var(--status-dev, #3b82f6);
}

.tg-btn--full {
  background: var(--text-primary);
  color: var(--bg);
  border-color: var(--text-primary);
}

.tg-btn--full:hover:not(:disabled),
.tg-btn--spec:hover:not(:disabled),
.tg-btn--dev:hover:not(:disabled) {
  opacity: 0.85;
  filter: brightness(1.1);
}

.tg-card-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 4px 0 0;
  font-style: italic;
}

.tg-card-status--ok { color: var(--status-published, #22c55e); }
.tg-card-status--err { color: var(--status-idea, #ef4444); }

