:root {
  --bg: #0a0a0a;
  --bg2: #111111;
  --bg3: #161616;
  --border: #1e1e1e;
  --accent: #76B900;
  --text: #e0e0e0;
  --text-dim: #888;
  --text-muted: #444;
  --danger: #c0392b;
  --danger-text: #e74c3c;
}

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

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

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #2e2e2e; }

/* ── App shell ── */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 15px;
  color: #0a0a0a;
  flex-shrink: 0;
  letter-spacing: -1px;
}

.logo-text { font-weight: 600; font-size: 15px; }

.topbar-spacer { flex: 1; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}
.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb-sep { color: var(--text-muted); }
.breadcrumb-current { color: var(--text); font-weight: 500; }

.lang-toggle {
  display: flex;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}
.lang-btn {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.lang-btn.active { background: var(--border); color: var(--text); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #0a0a0a;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: opacity 0.12s, background 0.12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:hover { opacity: 0.82; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #0a0a0a; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--bg3); color: var(--text); border-color: var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 5px 7px; }

/* ── Body ── */
.body { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 200px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 12px 0;
}
.sidebar-section { padding: 0 10px 14px; }
.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0 6px;
  margin-bottom: 5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg3); color: var(--text); }

.sidebar-divider { height: 1px; background: var(--border); margin: 0 10px 12px; }

.recent-app {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: none;
  overflow: hidden;
  transition: background 0.1s;
}
.recent-app:hover { background: var(--bg3); color: var(--text); }
.recent-app-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.live { background: var(--accent); }
.status-dot.draft { background: var(--text-muted); }

/* ── Main content ── */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

/* ── Dashboard hero ── */
.dashboard-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px 24px;
}
.hero-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
}
.prompt-wrap { width: 100%; max-width: 640px; position: relative; }
.prompt-box {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px 52px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 110px;
  transition: border-color 0.15s;
  display: block;
}
.prompt-box:focus { border-color: var(--accent); }
.prompt-actions {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.chip:hover { border-color: var(--text-muted); color: var(--text); }
.prompt-send { margin-left: auto; }

/* ── Apps section ── */
.apps-section { padding: 0 24px 24px; }
.apps-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

/* ── App card ── */
.app-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: border-color 0.12s;
  color: var(--text);
}
.app-card:hover { border-color: #333; }
.app-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.app-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  color: var(--text-dim);
}
.app-card-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.app-card-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.45;
  min-height: 2.9em;
}
.app-card-footer { display: flex; align-items: center; gap: 6px; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
}
.status-badge.live { color: var(--accent); }
.app-card-time { margin-left: auto; font-size: 11px; color: var(--text-muted); }

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
  gap: 10px;
  font-size: 13px;
}
.empty-state-icon { font-size: 28px; opacity: 0.25; }

/* ── Workspace ── */
.workspace-body { display: flex; flex: 1; overflow: hidden; }

/* ── Chat panel ── */
.chat-panel {
  width: 220px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.chat-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  flex-shrink: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg { max-width: 100%; display: flex; flex-direction: column; }
.chat-msg-user { align-items: flex-end; }
.chat-msg-bot { align-items: flex-start; }
.chat-bubble {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
  max-width: 100%;
}
.chat-msg-user .chat-bubble {
  background: var(--accent);
  color: #0a0a0a;
  border-bottom-right-radius: 2px;
}
.chat-msg-bot .chat-bubble {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}
.chat-typing { display: flex; gap: 3px; padding: 8px 10px; align-items: center; }
.chat-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── Progress checklist ── */
.progress-list {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.progress-list-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}
.progress-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  font-size: 11px;
  color: var(--text-muted);
}
.progress-item.active { color: var(--text); }
.progress-item.done { color: var(--accent); }
.progress-check {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 8px;
}
.progress-item.active .progress-check { border-color: var(--text-dim); }
.progress-item.done .progress-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
}

/* ── Chat input ── */
.chat-input-area {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 34px;
  max-height: 100px;
  transition: border-color 0.12s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-send-btn {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: #0a0a0a;
  transition: opacity 0.12s;
}
.chat-send-btn:hover { opacity: 0.82; }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Preview panel ── */
.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Workspace top tabs (in topbar) ── */
.workspace-tabs { display: flex; gap: 2px; }
.workspace-tab {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.workspace-tab.active {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border);
}
.workspace-tab:hover:not(.active) { color: var(--text); }

/* ── Tab panels ── */
.tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}
.tab-panel.active { display: flex; }

/* Settings & Secrets: scrollable */
#tab-settings, #tab-secrets {
  overflow-y: auto;
  padding: 20px;
  flex-direction: column;
}

/* ── Browser chrome ── */
.browser-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  flex-shrink: 0;
}
.browser-dots { display: flex; gap: 5px; }
.browser-dot { width: 10px; height: 10px; border-radius: 50%; background: #2a2a2a; }
.browser-url {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.browser-url-lock { color: var(--accent); font-size: 9px; flex-shrink: 0; }
.browser-url-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.preview-frame { flex: 1; border: none; background: #fff; width: 100%; display: block; }
.preview-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}
.preview-placeholder-icon { font-size: 32px; opacity: 0.15; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s;
}
.form-input:focus { border-color: var(--accent); }
textarea.form-input { resize: vertical; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 13px;
}
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.18s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  bottom: 3px;
  background: #666;
  border-radius: 50%;
  transition: transform 0.18s, background 0.18s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #0a0a0a; }

/* ── Secrets table ── */
.secrets-table { width: 100%; border-collapse: collapse; margin-bottom: 2px; }
.secrets-table th {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.secrets-table td { padding: 4px 4px; }
.secrets-table input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  color: var(--text);
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  width: 100%;
  outline: none;
  transition: border-color 0.12s;
}
.secrets-table input:focus { border-color: var(--accent); }
.btn-del-row {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-del-row:hover { color: var(--text); background: var(--bg3); }

/* ── Bottom bar ── */
.bottom-panel { border-top: 1px solid var(--border); flex-shrink: 0; }
.bottom-tabs { display: flex; }
.bottom-tab {
  padding: 6px 14px;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.bottom-tab:hover:not(.disabled) { color: var(--text); background: var(--bg3); }
.bottom-tab.disabled { opacity: 0.35; cursor: default; }
.bottom-tab.disabled:hover { background: transparent; color: var(--text-muted); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 16px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s, transform 0.18s;
  z-index: 200;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--accent); color: var(--accent); }
.toast.error { border-color: #c0392b; color: #e74c3c; }

/* ── Publish spinner ── */
.publish-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid #0a0a0a;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.55s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Danger zone ── */
.danger-zone {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.danger-label {
  font-size: 11px;
  font-weight: 700;
  color: #c0392b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── RTL ── */
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .chat-panel { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .chat-msg-user { align-items: flex-start; }
[dir="rtl"] .chat-msg-bot { align-items: flex-end; }
[dir="rtl"] .chat-msg-user .chat-bubble { border-bottom-right-radius: 8px; border-bottom-left-radius: 2px; }
[dir="rtl"] .chat-msg-bot .chat-bubble { border-bottom-left-radius: 8px; border-bottom-right-radius: 2px; }
[dir="rtl"] .toast { right: auto; left: 20px; }
[dir="rtl"] .prompt-send { margin-left: 0; margin-right: auto; }

/* ── Auth tabs ── */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin: -24px -24px 0;
  padding: 0 24px;
}
.auth-tab {
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}
.auth-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.auth-tab:hover:not(.active) { color: var(--text); }

.auth-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 16px;
  line-height: 1.5;
}

.form-error {
  font-size: 12px;
  color: #e74c3c;
  padding: 6px 0 2px;
}

/* ── User menu ── */
.user-menu {
  position: absolute;
  top: 44px;
  right: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 180px;
  z-index: 50;
  overflow: hidden;
}
#auth-area { position: relative; display: flex; align-items: center; gap: 8px; }
.user-menu-email {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.user-menu-item:hover { background: var(--border); }

/* ── Save banner (workspace public mode) ── */
.save-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #0f1a00;
  border-top: 1px solid var(--accent);
  font-size: 12px;
  color: var(--accent);
  flex-shrink: 0;
}
.save-banner span { flex: 1; }
.save-banner-close {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.7;
}
.save-banner-close:hover { opacity: 1; }

[dir="rtl"] .user-menu { right: auto; left: 0; }
[dir="rtl"] .user-menu-item { text-align: right; }

/* ── Build stream ── */
.build-stream { background: #070707; flex-shrink: 0; max-height: 200px; overflow-y: auto; transition: max-height .25s ease; border-top: 1px solid var(--border); }
.build-stream.hidden { max-height: 0; border-top: none; overflow: hidden; }
.bs-header { padding: 5px 10px 4px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #111; position: sticky; top: 0; background: #070707; z-index: 1; }
.bs-title { font-size: 10px; font-weight: 700; color: #444; text-transform: uppercase; letter-spacing: .07em; }
.bs-toggle { background: none; border: none; color: #444; cursor: pointer; font-size: 11px; padding: 0 2px; }
.build-lines { padding: 4px 0 6px; }
.bl { padding: 1px 10px; font-size: 11px; font-family: 'SF Mono', 'Fira Code', monospace; line-height: 1.7; color: #555; }
.bl.file { color: var(--accent); }
.bl.cmd  { color: #4a7000; }
.bl.done { color: var(--accent); font-weight: 600; }
.bl.err  { color: #c0392b; }

/* ── File tree ── */
.file-tree { width: 180px; border-right: 1px solid var(--border); flex-shrink: 0; display: flex; flex-direction: column; overflow: hidden; }
.tree-header { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.tree-body { flex: 1; overflow-y: auto; padding: 4px 0; }
.tree-item { display: flex; align-items: center; gap: 5px; padding: 3px 10px; font-size: 12px; color: var(--text-dim); cursor: pointer; transition: background .1s; white-space: nowrap; overflow: hidden; position: relative; user-select: none; }
.tree-item:hover { background: var(--bg3); color: var(--text); }
.tree-item.active { background: var(--bg3); color: var(--text); }
.tree-item.modified { color: var(--accent); }
.tree-item.modified::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); position: absolute; right: 8px; top: 50%; transform: translateY(-50%); flex-shrink: 0; }
.tree-folder-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; padding: 6px 10px 2px; }
.tree-indent { padding-left: 20px; }
.tree-icon { font-size: 11px; flex-shrink: 0; opacity: .6; }

/* ── Template cards ── */
.templates-strip { padding: 0 24px 24px; }
.strip-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 12px; }
.templates-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.templates-scroll::-webkit-scrollbar { height: 3px; }
.tpl-card { flex-shrink: 0; width: 150px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 14px; cursor: pointer; transition: border-color .12s, transform .1s; }
.tpl-card:hover { border-color: #333; transform: translateY(-1px); }
.tpl-icon { font-size: 20px; margin-bottom: 10px; }
.tpl-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.tpl-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.tpl-cat { margin-top: 8px; font-size: 10px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }

/* ── File viewer overlay ── */
.file-viewer { position: absolute; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; }
.file-viewer.hidden { display: none; }
.fv-header { padding: 8px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.fv-path { font-size: 12px; font-family: monospace; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; line-height: 1; flex-shrink: 0; }
.fv-content { flex: 1; overflow: auto; padding: 16px; }
.fv-content pre { font-size: 12px; font-family: 'SF Mono', 'Fira Code', monospace; line-height: 1.65; color: #aaa; white-space: pre-wrap; word-break: break-all; }

/* ── Builds history ── */
.build-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.build-item:last-child { border-bottom: none; }
.build-status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.build-status.success { background: var(--accent); }
.build-status.failed  { background: #c0392b; }
.build-status.running { background: #cc0; }
.build-msg { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.build-time { color: var(--text-muted); flex-shrink: 0; }
.build-rollback { background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer; flex-shrink: 0; transition: all .1s; }
.build-rollback:hover { border-color: var(--text-dim); color: var(--text); }

[dir="rtl"] .file-tree { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .tree-item.modified::after { right: auto; left: 8px; }

/* ── Terminal panel ── */
.terminal-panel { flex-shrink: 0; border-top: 1px solid var(--border); background: #050505; display: flex; flex-direction: column; transition: height .2s ease; height: 0; overflow: hidden; }
.terminal-panel.open { height: 280px; }
.terminal-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; border-bottom: 1px solid #111; flex-shrink: 0; background: #080808; }
.terminal-title { font-size: 11px; font-weight: 700; color: #555; text-transform: uppercase; letter-spacing: .07em; display: flex; align-items: center; gap: 8px; }
.terminal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.terminal-actions { display: flex; gap: 4px; }
.terminal-btn { background: none; border: none; color: #555; cursor: pointer; font-size: 12px; padding: 2px 6px; border-radius: 4px; transition: color .1s; font-family: inherit; }
.terminal-btn:hover { color: var(--text); background: #111; }
.terminal-output { flex: 1; overflow-y: auto; padding: 8px 12px; font-family: 'SF Mono','Fira Code','Consolas',monospace; font-size: 12px; line-height: 1.6; color: #aaa; white-space: pre-wrap; word-break: break-all; }
.terminal-output .t-prompt { color: var(--accent); }
.terminal-output .t-err { color: #e74c3c; }
.terminal-output .t-cmd { color: #e0e0e0; font-weight: 500; }
.terminal-input-row { display: flex; align-items: center; gap: 0; padding: 6px 12px; border-top: 1px solid #111; flex-shrink: 0; }
.terminal-ps1 { font-family: 'SF Mono','Fira Code',monospace; font-size: 12px; color: var(--accent); flex-shrink: 0; margin-right: 6px; }
.terminal-input { flex: 1; background: transparent; border: none; color: #e0e0e0; font-family: 'SF Mono','Fira Code',monospace; font-size: 12px; outline: none; padding: 0; }

/* ── Diff viewer ── */
.diff-panel { padding: 12px; overflow-y: auto; flex: 1; }
.diff-hunk { margin-bottom: 16px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.diff-hunk-header { padding: 5px 12px; background: #0d0d1a; font-size: 11px; font-family: monospace; color: #666; border-bottom: 1px solid var(--border); }
.diff-line { display: flex; font-family: 'SF Mono','Fira Code',monospace; font-size: 12px; line-height: 1.5; padding: 1px 12px; }
.diff-line.add { background: #0a1a00; color: #76B900; }
.diff-line.del { background: #1a0000; color: #e74c3c; text-decoration: line-through; opacity: .7; }
.diff-line.ctx { color: #555; }
.diff-gutter { width: 32px; flex-shrink: 0; color: #333; user-select: none; }
.diff-empty { color: var(--text-muted); font-size: 13px; padding: 24px; text-align: center; }

/* ── Database panel ── */
.db-panel { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.db-toolbar { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.db-tables { display: flex; flex: 1; overflow: hidden; }
.db-sidebar { width: 160px; border-right: 1px solid var(--border); overflow-y: auto; padding: 8px 0; flex-shrink: 0; }
.db-table-item { padding: 6px 14px; font-size: 13px; color: var(--text-dim); cursor: pointer; transition: background .1s; }
.db-table-item:hover { background: var(--bg3); color: var(--text); }
.db-table-item.active { background: var(--bg3); color: var(--accent); font-weight: 600; }
.db-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.db-grid-wrap { flex: 1; overflow: auto; }
.db-grid { width: 100%; border-collapse: collapse; font-size: 12px; }
.db-grid th { padding: 7px 12px; text-align: left; background: #0d0d0d; color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }
.db-grid td { padding: 7px 12px; border-bottom: 1px solid #0f0f0f; color: var(--text-dim); font-family: 'SF Mono','Fira Code',monospace; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-grid tr:hover td { background: var(--bg3); color: var(--text); }
.db-query-wrap { border-top: 1px solid var(--border); flex-shrink: 0; padding: 10px; }
.db-query-input { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; color: var(--text); font-family: 'SF Mono','Fira Code',monospace; font-size: 12px; outline: none; resize: none; min-height: 60px; box-sizing: border-box; }
.db-query-input:focus { border-color: var(--accent); }
.db-query-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.db-result-info { font-size: 11px; color: var(--text-muted); }
.db-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 10px; color: var(--text-muted); font-size: 13px; }
.db-empty-icon { font-size: 32px; opacity: .2; }

/* ── Deploy panel ── */
.deploy-panel { flex: 1; overflow-y: auto; padding: 20px; }
.deploy-section { margin-bottom: 24px; }
.deploy-section-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.deploy-card { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.deploy-version { font-size: 12px; font-family: monospace; color: var(--accent); flex-shrink: 0; }
.deploy-info { flex: 1; overflow: hidden; }
.deploy-meta { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deploy-date { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.deploy-status-badge { padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.deploy-status-badge.live { background: #0f1a00; color: var(--accent); }
.deploy-status-badge.old  { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.domain-check { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.domain-ok   { color: var(--accent); }
.domain-fail { color: #e74c3c; }

/* ── Analytics panel ── */
.analytics-panel { flex: 1; overflow-y: auto; padding: 20px; }
.analytics-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.analytics-stat { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.analytics-stat-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.analytics-stat-val { font-size: 24px; font-weight: 800; color: var(--text); }
.analytics-chart { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 16px; }
.analytics-chart-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart-bar { background: var(--accent); border-radius: 2px 2px 0 0; width: 100%; opacity: .7; min-height: 2px; transition: opacity .15s; }
.chart-bar:hover { opacity: 1; }
.chart-label { font-size: 9px; color: var(--text-muted); transform: rotate(-45deg); white-space: nowrap; }
.analytics-top-paths { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.atp-header { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.atp-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid #0f0f0f; }
.atp-row:last-child { border-bottom: none; }
.atp-path { flex: 1; font-family: monospace; font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; }
.atp-count { font-size: 12px; font-weight: 700; color: var(--accent); flex-shrink: 0; }

/* ── Domain config modal ── */
.nginx-config { background: #050505; border: 1px solid var(--border); border-radius: 6px; padding: 12px; font-family: 'SF Mono','Fira Code',monospace; font-size: 12px; color: #76B900; overflow-x: auto; white-space: pre; margin-top: 12px; max-height: 180px; overflow-y: auto; }
.copy-btn { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }

/* ── API Keys panel ── */
.key-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.key-row:last-child { border-bottom: none; }
.key-prefix { font-family: monospace; font-size: 13px; color: var(--text); flex-shrink: 0; }
.key-name { font-size: 13px; color: var(--text-dim); flex: 1; }
.key-date { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.key-revoke { background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 4px; padding: 3px 8px; font-size: 11px; cursor: pointer; flex-shrink: 0; }
.key-revoke:hover { border-color: #c0392b; color: #e74c3c; }
.key-new-display { background: #0a1a00; border: 1px solid var(--accent); border-radius: 8px; padding: 14px; margin-top: 12px; }
.key-new-value { font-family: monospace; font-size: 13px; color: var(--accent); word-break: break-all; }
.key-warning { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ── File rename inline ── */
.tree-item input.rename-input { position: absolute; left: 0; right: 0; top: 0; bottom: 0; background: var(--bg3); border: 1px solid var(--accent); border-radius: 0; padding: 0 10px; color: var(--text); font-size: 12px; font-family: inherit; outline: none; z-index: 5; width: 100%; box-sizing: border-box; }

/* ── Search results ── */
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg3); border: 1px solid var(--border); border-top: none; border-radius: 0 0 6px 6px; z-index: 50; max-height: 240px; overflow-y: auto; }
.search-result { padding: 7px 12px; cursor: pointer; border-bottom: 1px solid #0f0f0f; transition: background .1s; }
.search-result:hover { background: var(--border); }
.search-result:last-child { border-bottom: none; }
.sr-file { font-size: 11px; color: var(--accent); margin-bottom: 2px; font-family: monospace; }
.sr-text { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-wrap { position: relative; padding: 6px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.search-input { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 5px 8px; color: var(--text); font-size: 12px; font-family: inherit; outline: none; box-sizing: border-box; }
.search-input:focus { border-color: var(--accent); }

/* ── Drop zone ── */
.drop-zone-active .tree-body { outline: 2px dashed var(--accent); outline-offset: -4px; background: rgba(118,185,0,0.04); }

/* ── Explain overlay ── */
.explain-overlay { position: absolute; bottom: 0; left: 0; right: 0; background: var(--bg3); border-top: 1px solid var(--border); padding: 14px; max-height: 40%; overflow-y: auto; z-index: 15; font-size: 13px; line-height: 1.6; color: var(--text-dim); }
.explain-overlay.hidden { display: none; }
.explain-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.explain-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1; }

/* ── Tab panel sizing for new tabs ── */
#tab-database, #tab-deploy, #tab-analytics { padding: 0; }

/* ── Quick action bar (bottom of file tree) ── */
.tree-actions { border-top: 1px solid var(--border); padding: 6px 8px; display: flex; gap: 4px; flex-shrink: 0; }
.tree-action-btn { flex: 1; background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: 4px; padding: 4px; font-size: 10px; cursor: pointer; transition: all .1s; text-align: center; font-family: inherit; }
.tree-action-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--text-muted); }

[dir="rtl"] .terminal-ps1 { direction: ltr; }
[dir="rtl"] .db-sidebar { border-right: none; border-left: 1px solid var(--border); }

/* Fix #10 RTL: code/terminal/diff must stay LTR regardless of document direction */
[dir="rtl"] .build-lines,
[dir="rtl"] .terminal-output,
[dir="rtl"] .fv-content pre,
[dir="rtl"] .db-query-input,
[dir="rtl"] .nginx-config,
[dir="rtl"] .key-prefix,
[dir="rtl"] .key-new-value { direction: ltr; text-align: left; }

/* Fix #15: workspace-wrapper class (replaces inline style) */
.workspace-wrapper { display: flex; flex: 1; overflow: hidden; flex-direction: column; }

/* Settings cards */
.settings-card { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 18px; }
.settings-card-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 2px; }

/* Mobile menu button (hidden on desktop) */
.mobile-menu-btn { display: none; }
.mobile-tree-btn { display: none; }
.mobile-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 25; }

/* ══════════════════════════════════════════
   RESPONSIVE — Tablet (≤ 900px)
   ══════════════════════════════════════════ */
@media (max-width: 900px) {
  /* Workspace: hide file tree, show toggle button */
  .file-tree { display: none; position: fixed; left: 0; top: 48px; bottom: 0; z-index: 30; background: var(--bg); border-right: 1px solid var(--border); }
  .file-tree.mobile-open { display: flex; }
  .mobile-tree-btn { display: flex; }

  /* Workspace tabs scroll horizontally */
  .workspace-tabs { overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; flex-shrink: 1; }
  .workspace-tabs::-webkit-scrollbar { display: none; }
  .workspace-tab { white-space: nowrap; flex-shrink: 0; padding: 5px 10px; font-size: 12px; }

  /* Chat panel narrower */
  .chat-panel { width: 240px; }

  /* Bottom tabs scroll */
  .bottom-tabs { overflow-x: auto; scrollbar-width: none; }
  .bottom-tabs::-webkit-scrollbar { display: none; }
  .bottom-tab { white-space: nowrap; flex-shrink: 0; }

  /* Analytics grid 2-col */
  .analytics-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════
   RESPONSIVE — Mobile (≤ 600px)
   ══════════════════════════════════════════ */
@media (max-width: 600px) {
  /* Dashboard: hide sidebar, show hamburger */
  .sidebar { display: none; position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; background: var(--bg); border-right: 1px solid var(--border); width: 220px; }
  .sidebar.mobile-open { display: flex; }
  .mobile-menu-btn { display: flex; }

  /* Topbar: hide logo text on very small screens */
  .logo-text { display: none; }

  /* Workspace: stack chat + preview vertically */
  .workspace-body { flex-direction: column; }
  .chat-panel { width: 100% !important; height: 260px; border-right: none; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .preview-panel { flex: 1; min-height: 0; }
  .file-tree { top: 48px; }

  /* Terminal shorter */
  .terminal-panel.open { height: 220px; }

  /* Dashboard hero */
  .hero-title { font-size: 18px; }
  .prompt-box { min-height: 80px; padding-bottom: 44px; }

  /* Apps grid single column */
  .apps-grid { grid-template-columns: 1fr; }

  /* Templates grid */
  .templates-scroll { gap: 8px; }
  .tpl-card { width: 140px; padding: 12px; }

  /* Hide workspace tabs text, show icons only approach — keep scrolling */
  .workspace-tab { padding: 5px 8px; font-size: 11px; }

  /* Topbar spacing */
  .topbar { padding: 0 10px; gap: 6px; }
  .lang-btn { padding: 3px 7px; font-size: 11px; }
  .btn-sm { padding: 5px 10px; font-size: 12px; }

  /* Modal full-width */
  .modal { margin: 16px; width: calc(100% - 32px); max-width: none; }

  /* Analytics single col */
  .analytics-stats { grid-template-columns: 1fr; }

  /* DB layout stack */
  .db-tables { flex-direction: column; }
  .db-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 80px; overflow-x: auto; overflow-y: hidden; display: flex; flex-direction: row; padding: 4px; }
  .db-table-item { white-space: nowrap; padding: 6px 10px; }
}

/* RTL mobile */
[dir="rtl"] .sidebar { left: auto; right: 0; border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .file-tree { left: auto; right: 0; border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] @media (max-width: 600px) {
  .db-sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}
