/* ─── Reset & Variables ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d0d;
  --surface:   #161616;
  --surface2:  #1e1e1e;
  --surface3:  #252525;
  --border:    #2a2a2a;
  --primary:   #7c3aed;
  --primary-h: #6d28d9;
  --primary-l: #a78bfa;
  --text:      #f0f0f0;
  --text-m:    #999;
  --text-d:    #555;
  --success:   #22c55e;
  --error:     #ef4444;
  --warning:   #f59e0b;
  --info:      #3b82f6;
  --term-bg:   #050505;
  --term-text: #c8ffc8;
  --radius:    10px;
  --radius-sm: 6px;
  --transition: 0.15s ease;
  --nav-h:     60px;
  --header-h:  56px;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', 'Courier New', monospace;
}

html { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ──────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
}

.logo-icon {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

.header-actions { display: flex; gap: 8px; align-items: center; }

#settings-nav-btn.active {
  color: var(--primary-l);
  border-color: var(--primary);
  background: rgba(124,58,237,0.15);
}

#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + 16px);
}

nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-m);
  cursor: pointer;
  border: none;
  background: none;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  padding: 8px 0;
}

.nav-tab .icon { font-size: 20px; line-height: 1; }

.nav-tab.active {
  color: var(--primary-l);
}

.nav-tab.active .icon {
  filter: drop-shadow(0 0 6px var(--primary));
}

/* ─── Pages ───────────────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ─── Settings Section Labels ─────────────────────────────────────────── */
.settings-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-d);
  padding: 16px 2px 6px;
  margin-bottom: 0;
}
.settings-section:first-child { padding-top: 4px; }

/* ─── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-m);
  margin-bottom: 12px;
}

/* ─── Forms ───────────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; color: var(--text-m); margin-bottom: 6px; }

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 10px 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.2);
}

textarea {
  resize: vertical;
  min-height: 80px;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }

.btn-ghost {
  background: transparent;
  color: var(--text-m);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface3); color: var(--text); }

.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-full { width: 100%; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ─── Terminal ────────────────────────────────────────────────────────── */
.terminal {
  background: var(--term-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--term-text);
  overflow-y: auto;
  max-height: 45vh;
  min-height: 120px;
  white-space: pre-wrap;
  word-break: break-all;
  position: relative;
}

.terminal.empty::after {
  content: 'Ausgabe erscheint hier…';
  color: var(--text-d);
  font-family: inherit;
}

.term-stderr { color: #fca5a5; }
.term-system { color: var(--text-d); font-style: italic; }

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

/* ─── Job Status Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-pending   { background: rgba(100,100,100,0.2); color: var(--text-m); }
.badge-running   { background: rgba(59,130,246,0.2);  color: var(--info); }
.badge-completed { background: rgba(34,197,94,0.2);   color: var(--success); }
.badge-failed    { background: rgba(239,68,68,0.2);   color: var(--error); }
.badge-cancelled { background: rgba(245,158,11,0.2);  color: var(--warning); }

.badge-running::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--info);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ─── Job List ────────────────────────────────────────────────────────── */
.job-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.job-item:hover { border-color: var(--primary); background: var(--surface2); }
.job-item:active { background: var(--surface3); }

.job-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.job-command {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
  flex: 1;
}

.job-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-d);
  align-items: center;
}

.job-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-m);
  background: var(--surface2);
  border-radius: 4px;
  padding: 6px 8px;
  overflow: hidden;
  max-height: 50px;
  white-space: pre-wrap;
  word-break: break-all;
  border-left: 2px solid var(--border);
  margin-top: 8px;
}

/* ─── Login Screen ────────────────────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.login-box {
  width: 100%;
  max-width: 360px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .big-icon {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 12px;
  box-shadow: 0 8px 32px rgba(124,58,237,0.4);
}

.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-logo p  { color: var(--text-m); font-size: 13px; margin-top: 4px; }

.form-group { margin-bottom: 14px; }

#login-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
  min-height: 20px;
}

/* ─── Toasts ──────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: slideUp 0.2s ease;
  pointer-events: auto;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error); }
.toast.info    { border-left: 3px solid var(--info); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Spinner ─────────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toggle ──────────────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 14px; }
.toggle-desc  { font-size: 12px; color: var(--text-m); margin-top: 2px; }

.toggle {
  position: relative;
  width: 44px; height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle input:checked + .toggle-track { background: var(--primary); border-color: var(--primary); }
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-track::after { transform: translateX(20px); }

/* ─── Divider ─────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* ─── Empty state ─────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-m);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── Modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: none;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideSheet 0.2s ease;
}
@keyframes slideSheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-weight: 600; font-size: 16px; }
.modal-body  { padding: 16px; overflow-y: auto; flex: 1; }

/* ─── Connection indicator ────────────────────────────────────────────── */
.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-d);
  transition: background 0.3s;
}
.conn-dot.connected    { background: var(--success); }
.conn-dot.connecting   { background: var(--warning); animation: pulse 1s infinite; }
.conn-dot.disconnected { background: var(--error); }

/* ─── Args builder ────────────────────────────────────────────────────── */
.arg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.arg-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.arg-chip button {
  background: none;
  border: none;
  color: var(--text-m);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

/* Badge in Einstellungen */
.nicos-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-l);
  margin-bottom: 12px;
  box-shadow: 0 0 12px rgba(124,58,237,0.2);
}

/* ─── Chat ────────────────────────────────────────────────────────────── */
#page-chat {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: var(--nav-h);
  display: none;
  flex-direction: column;
  background: var(--bg);
  z-index: 10;
}

#page-chat.active {
  display: flex;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
}

.chat-welcome-icon { font-size: 28px; flex-shrink: 0; }
.chat-welcome-text { font-size: 14px; line-height: 1.6; color: var(--text-m); }
.chat-welcome-text strong { color: var(--text); }

.chat-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble-ai {
  align-self: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
  font-family: inherit;
}

.chat-bubble-ai.streaming::after {
  content: '▋';
  animation: blink 0.8s steps(1) infinite;
  color: var(--primary-l);
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.chat-bubble-ai.error { border-color: var(--error); color: var(--error); }

/* ─── Thinking ────────────────────────────────────────────────────────── */
.chat-thinking {
  display: none;
  max-width: 88%;
  margin-bottom: 6px;
}

.chat-thinking summary {
  font-size: 11px;
  color: var(--primary-l);
  cursor: pointer;
  list-style: none;
  padding: 3px 0;
  user-select: none;
}
.chat-thinking summary::-webkit-details-marker { display: none; }
.chat-thinking summary::before { content: '▶ '; font-size: 9px; }
.chat-thinking[open] summary::before { content: '▼ '; }

.chat-thinking-text {
  font-size: 11px;
  color: var(--text-d);
  font-style: italic;
  line-height: 1.5;
  padding: 6px 10px;
  margin-top: 4px;
  background: var(--surface2);
  border-left: 2px solid var(--primary);
  border-radius: 4px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

/* ─── Aktivitätslog ───────────────────────────────────────────────────── */
.chat-activity {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
  max-width: 88%;
}

.chat-activity:empty { display: none; }

.activity-item {
  font-size: 11px;
  color: var(--text-d);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Token-Stats ─────────────────────────────────────────────────────── */
.chat-stats {
  font-size: 10px;
  color: var(--text-d);
  margin-top: 4px;
  padding: 0 4px;
}
.chat-stats:empty { display: none; }

.chat-meta {
  font-size: 10px;
  color: var(--text-d);
  margin-top: 3px;
  padding: 0 4px;
}
.chat-meta-user { text-align: right; }

/* ─── Modell-Auswahl ──────────────────────────────────────────────────── */
.chat-model-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px 4px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.model-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-m);
  cursor: pointer;
  transition: all 0.15s;
}

.model-chip:hover {
  border-color: var(--primary);
  color: var(--primary-l);
}

.model-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.clear-history-btn {
  border-color: var(--border);
  color: var(--text-d);
  font-size: 13px;
}
.clear-history-btn:hover {
  border-color: var(--error);
  color: var(--error);
  background: var(--surface3);
}

.new-chat-btn {
  margin-left: auto;
  border-color: var(--border);
  color: var(--text-d);
}
.new-chat-btn:hover {
  border-color: var(--text-m);
  color: var(--text);
  background: var(--surface3);
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  align-items: flex-end;
  flex-shrink: 0;
}

.chat-input-bar textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.4;
  overflow-y: auto;
}

.chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  padding: 0;
  font-size: 16px;
  flex-shrink: 0;
}

/* ─── Berechtigungsdialog ─────────────────────────────────────────────── */
/* ─── Project Error Banner ────────────────────────────────────────────── */
.project-error-banner {
  position: fixed;
  bottom: 60px; /* above nav */
  left: 12px;
  right: 12px;
  background: #1e1b2e;
  border: 1px solid #f59e0b;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 500;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  animation: slideUp 0.2s ease;
}
.project-error-banner[hidden] { display: none; }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.peb-icon { font-size: 20px; flex-shrink: 0; }
.peb-body { flex: 1; min-width: 0; }
.peb-title { font-size: 13px; font-weight: 600; color: #f59e0b; }
.peb-sub   { font-size: 11px; color: var(--text-d); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peb-actions { display: flex; gap: 6px; flex-shrink: 0; }

.perm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(6px);
}
.perm-overlay.open { display: flex; }

.perm-dialog {
  background: var(--surface);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 24px 20px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 0 40px rgba(245,158,11,0.2);
  animation: slideUp 0.15s ease;
}

.perm-icon   { font-size: 36px; margin-bottom: 10px; }
.perm-title  { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.perm-tool   { font-size: 14px; font-weight: 600; color: var(--warning); margin-bottom: 6px; }
.perm-detail {
  font-size: 12px; color: var(--text-m);
  background: var(--surface2); border-radius: 6px;
  padding: 8px 10px; margin-bottom: 20px;
  font-family: var(--font-mono); word-break: break-all;
  max-height: 80px; overflow-y: auto; text-align: left;
}
.perm-actions { display: flex; gap: 10px; }
.perm-actions .btn { flex: 1; }

/* ─── Bridge-Tag ─────────────────────────────────────────────────────── */
.bridge-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  background: #1e3a5f;
  color: #60a5fa;
  border: 1px solid #2563eb;
  border-radius: 3px;
  padding: 0 4px;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

/* ─── Chat Status-Leiste ──────────────────────────────────────────────── */
.chat-status-bar {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 11px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  min-height: 32px;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-status-bar.csb-running,
.chat-status-bar.csb-done,
.chat-status-bar.csb-error { display: flex; }

.chat-status-bar.csb-running { border-top-color: var(--primary); }
.chat-status-bar.csb-done    { border-top-color: var(--success); }
.chat-status-bar.csb-error   { border-top-color: var(--error); }

.csb-activity {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.csb-running .csb-activity { color: var(--primary-l); }
.csb-done    .csb-activity { color: var(--success); }
.csb-error   .csb-activity { color: var(--error); }

.csb-tokens { color: var(--text-d); white-space: nowrap; }
.csb-time   { color: var(--text-d); white-space: nowrap; font-family: var(--font-mono); font-size: 10px; }

.csb-dismiss {
  background: none; border: none;
  color: var(--text-d); cursor: pointer;
  font-size: 14px; line-height: 1;
  padding: 0 2px; flex-shrink: 0;
}
.csb-dismiss:hover { color: var(--text); }

/* ─── Aufträge-Seite ─────────────────────────────────────────────────── */
.auf-chat-item { border-left: 3px solid var(--primary); }

.auf-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.auf-type-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-d);
  white-space: nowrap;
}

.auf-date {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-d);
  white-space: nowrap;
}

.auf-prompt {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-word;
}

.auf-preview {
  font-size: 11px;
  color: var(--text-m);
  border-left: 2px solid var(--border);
  padding-left: 8px;
  margin-bottom: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60px;
  overflow: hidden;
}

.auf-stats {
  font-size: 10px;
  color: var(--text-d);
}

/* ─── Chat-Datum & Session-Trenner ───────────────────────────────────── */
.chat-date-sep {
  text-align: center;
  font-size: 11px;
  color: var(--text-d);
  padding: 8px 0 4px;
  position: relative;
}
.chat-date-sep::before, .chat-date-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}
.chat-date-sep::before { left: 0; }
.chat-date-sep::after  { right: 0; }

.chat-session-divider {
  text-align: center;
  font-size: 11px;
  color: var(--primary-l);
  padding: 12px 0 4px;
  opacity: 0.6;
}

/* ─── Chat-Verlauf ────────────────────────────────────────────────────── */
.hist-chat-item {
  border-left: 3px solid var(--primary);
  padding: 10px 12px;
}

.hist-chat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.hist-model-tag {
  font-size: 10px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 0.04em;
}

.hist-date {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-d);
}

.hist-user-msg {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface3);
  border-radius: 12px 12px 12px 4px;
  padding: 7px 11px;
  margin-bottom: 6px;
  word-break: break-word;
  white-space: pre-wrap;
}

.hist-ai-msg {
  font-size: 12px;
  color: var(--text-m);
  padding: 6px 10px;
  border-left: 2px solid var(--border);
  margin-bottom: 6px;
  word-break: break-word;
  white-space: pre-wrap;
  max-height: 80px;
  overflow: hidden;
}

.hist-activities {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 5px;
}

.hist-act-chip {
  font-size: 10px;
  color: var(--text-d);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.hist-stats {
  font-size: 10px;
  color: var(--text-d);
  margin-top: 2px;
}

/* ─── Scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  #main-content { padding: 20px; max-width: 700px; margin: 0 auto; }
  .terminal { max-height: 55vh; }
}

/* ─── Projekt-System ──────────────────────────────────────────────────── */
.auf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.auf-heading { font-size: 16px; font-weight: 600; }

.project-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s;
}
.project-item:active { border-color: var(--primary); }

.project-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auf-mode-icon { font-size: 14px; flex-shrink: 0; }

.auf-desc {
  font-size: 12px;
  color: var(--text-m);
  margin: 4px 0 6px;
  word-break: break-word;
}

.auf-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-d);
  margin-top: 4px;
}

.auf-progress-bar {
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  margin: 6px 0 2px;
  overflow: hidden;
}
.auf-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width .3s;
}
.auf-step-info {
  font-size: 10px;
  color: var(--text-d);
}

/* ─── Modal groß ──────────────────────────────────────────────────────── */
.modal-sheet-tall {
  max-height: 92vh;
}

/* ─── Schritt-Formular ────────────────────────────────────────────────── */
.step-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.step-row textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text);
  resize: vertical;
  font-family: inherit;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.req { color: var(--error); }

/* ─── Schritt-Detail ──────────────────────────────────────────────────── */
.step-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.step-detail-row:last-child { border-bottom: none; }

.step-output-preview {
  font-size: 11px;
  color: var(--text-m);
  border-left: 2px solid var(--border);
  padding-left: 8px;
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 80px;
  overflow: hidden;
}

/* ─── Verbesserungs-Box ───────────────────────────────────────────────── */
.improvement-box {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
  margin-top: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─── Live-Output im Detail-Modal ────────────────────────────────────── */
.pd-live-box {
  margin-top: 8px;
  max-height: 200px;
  font-size: 11px;
}

/* ─── Chat → Aufgabe Button ───────────────────────────────────────────── */
.chat-task-suggest-btn {
  display: block;
  margin: 8px auto;
  animation: fadeIn .3s ease;
}

/* ─── Settings ────────────────────────────────────────────────────────── */
.card input[type="time"],
.card input[type="number"],
.card input[type="text"],
.card select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

/* ─── File Explorer ─────────────────────────────────────────────────── */
.file-section-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 0 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.file-section-tabs::-webkit-scrollbar { display: none; }
.file-sec-btn {
  flex-shrink: 0;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-m);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.file-sec-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.file-toolbar {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.file-breadcrumb {
  font-size: 12px;
  color: var(--text-d);
  padding: 4px 0 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}
.file-bc-part {
  cursor: pointer;
  color: var(--accent);
  text-decoration: none;
}
.file-bc-part:hover { text-decoration: underline; }
.file-bc-sep { color: var(--text-d); margin: 0 2px; }

.file-list {
  flex: 1;
  overflow-y: auto;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.1s;
  user-select: none;
}
.file-item:hover  { background: var(--surface2); }
.file-item.selected {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.file-item-icon { font-size: 18px; flex-shrink: 0; width: 24px; text-align: center; }
.file-item-name { flex: 1; font-size: 13px; color: var(--text); word-break: break-all; }
.file-item-meta { font-size: 11px; color: var(--text-d); flex-shrink: 0; }

/* ── Editor ─────────────────────────────────────────────────────────── */
.file-editor-panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 400;
  display: flex;
  flex-direction: column;
}
.file-editor-panel[hidden] { display: none; }
.file-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-h);
  gap: 10px;
  flex-shrink: 0;
}
.file-editor-area {
  flex: 1;
  resize: none;
  background: var(--bg);
  color: var(--text);
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  border: none;
  outline: none;
  overflow-y: auto;
}
.file-preview-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}
.file-preview-area[hidden] { display: none; }
.file-preview-area h1,.file-preview-area h2,.file-preview-area h3 {
  color: var(--text-h); margin: 1em 0 0.4em; font-weight: 700;
}
.file-preview-area code {
  background: var(--surface2); padding: 2px 5px; border-radius: 4px;
  font-family: monospace; font-size: 12px;
}
.file-preview-area pre {
  background: var(--surface2); padding: 12px; border-radius: 8px; overflow-x: auto;
}
.file-preview-area pre code { background: none; padding: 0; }

/* ─── Step Output Expandable ─────────────────────────────────────────── */
.step-out-toggle {
  margin-top: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-m);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  display: inline-block;
}
.step-out-toggle:hover { background: var(--bg-2); color: var(--text); }

.step-output-full {
  margin-top: 6px;
  background: var(--bg-0, #0d1117);
  color: var(--text, #e6edf3);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 11px;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
}

/* ─── Project Detail Status Message ─────────────────────────────────── */
.pd-status-msg {
  margin-top: 6px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 500;
}
.pd-status-msg.running { background: rgba(59,130,246,.12); color: #60a5fa; }
.pd-status-msg.done    { background: rgba(34,197,94,.12);  color: #4ade80; }
.pd-status-msg.error   { background: rgba(239,68,68,.12);  color: #f87171; }
.pd-status-msg.warn    { background: rgba(234,179,8,.12);  color: #facc15; }

/* ─── Modal breiter ──────────────────────────────────────────────────── */
@media (min-width: 700px) {
  .modal-sheet { max-width: min(900px, 95vw); }
}

/* ─── Agent Reply Box ────────────────────────────────────────────────── */
.pd-reply-box {
  background: var(--bg-2, rgba(255,255,255,.04));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 4px;
  width: 100%;
}
.pd-reply-label {
  font-size: 11px;
  color: var(--text-m);
  margin-bottom: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.pd-reply-quick {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.pd-reply-quick-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}
.pd-reply-quick-btn:hover { background: var(--bg-2); border-color: var(--primary); }
.pd-reply-input-row {
  display: flex;
  gap: 6px;
}
.pd-reply-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
}
.pd-reply-input:focus { border-color: var(--primary); }
