:root {
  --bg: #0c1120;
  --surface: #131c2e;
  --surface-2: #1a2540;
  --surface-3: #243050;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --border: #1e293b;
  --border-light: #2d3a52;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 32px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

/* Dev environment overrides */
html.env-dev {
  --bg: #0f1a0f;
  --surface: #142014;
  --surface-2: #1a2e1a;
  --surface-3: #243824;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-glow: rgba(34, 197, 94, 0.25);
  --border: #1e3b1e;
  --border-light: #2d522d;
}

html.env-dev body::before {
  content: '🛠 DEV ENVIRONMENT';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  background: linear-gradient(90deg, #16a34a, #22c55e);
  color: #fff;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 3px 0;
}

html.env-dev body {
  padding-top: 22px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Login Modal ─────────────────────────────────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-logo .icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
}

.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.login-logo p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.field input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.93rem;
  padding: 0.6rem 0.85rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field input::placeholder {
  color: var(--text-muted);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0.55rem 1.1rem;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-full { width: 100%; padding: 0.7rem; font-size: 0.95rem; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-light);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }

.btn-accent {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-accent:hover:not(:disabled) {
  background: var(--accent);
  color: white;
}

.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error);
}
.btn-danger:hover:not(:disabled) {
  background: var(--error);
  color: white;
}

.btn-generate {
  flex-shrink: 0;
  padding: 0.65rem 1.4rem;
  font-size: 0.95rem;
  white-space: nowrap;
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-top: 0.85rem;
}
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid rgba(239,68,68,0.3); }
.alert-success { background: rgba(34,197,94,0.1); color: #22c55e; border: 1px solid rgba(34,197,94,0.3); }

/* ── App layout ──────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.deploy-badge {
  font-size: 0.72rem;
  font-family: monospace;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
  opacity: 0.85;
}
.deploy-badge:empty { display: none; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.card .hint {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

/* ── Generate form ───────────────────────────────────────────────────────── */
.url-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.form-action-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.deploy-target-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.deploy-target-label {
  font-weight: 500;
}

.deploy-target-option {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: var(--text);
}

.deploy-target-option input[type=radio] {
  accent-color: var(--accent);
  cursor: pointer;
}

.url-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.93rem;
  padding: 0.65rem 1rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}

.url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.url-input::placeholder { color: var(--text-muted); }

/* ── Active job progress ─────────────────────────────────────────────────── */
.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.job-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.job-url-line {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  word-break: break-all;
}

.log-panel {
  background: #050a14;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.7;
  max-height: 340px;
  overflow-y: auto;
  color: #94a3b8;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line { display: block; }
.log-success { color: #22c55e; }
.log-ok      { color: #4ade80; }
.log-section { color: #60a5fa; font-weight: 600; }
.log-warn    { color: #fbbf24; }
.log-error   { color: #f87171; }

.job-error-msg {
  margin-top: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  word-break: break-word;
  white-space: pre-wrap;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

.badge-running  { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-success  { background: var(--success-bg);     color: var(--success); }
.badge-error    { background: var(--error-bg);        color: var(--error); }
.badge-pending  { background: rgba(100,116,139,0.15); color: #94a3b8; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(59,130,246,0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result card ─────────────────────────────────────────────────────────── */
.result-card {
  border-color: rgba(34,197,94,0.35);
  background: linear-gradient(135deg, var(--surface) 60%, rgba(34,197,94,0.05));
}

.result-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.result-icon { font-size: 2rem; line-height: 1; }

.result-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  direction: rtl;
  text-align: right;
}

.result-subtitle {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.result-links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.1rem;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.result-link:hover {
  background: var(--surface-3);
  border-color: var(--accent);
  transform: translateX(3px);
}

.result-link-icon { font-size: 1.4rem; flex-shrink: 0; }

.result-link-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.result-link-url {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  word-break: break-all;
}

.result-link-arrow {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 1rem;
}

.result-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

/* ── Error card ──────────────────────────────────────────────────────────── */
.error-card {
  border-color: rgba(239,68,68,0.35);
}

.error-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.error-header h2 { font-size: 1rem; color: var(--error); margin: 0; }

.error-body {
  font-size: 0.83rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  word-break: break-word;
}

/* ── History ─────────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2 { margin: 0; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 2rem 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.history-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  transition: border-color 0.15s;
}

.history-item:hover { border-color: var(--border-light); }
.history-item-running { border-color: rgba(59,130,246,0.4); }

.history-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.history-info { flex: 1; min-width: 0; }

.history-business {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.15rem;
  direction: rtl;
  text-align: right;
}

.history-url {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.history-cost {
  display: inline-block;
  margin-inline-start: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-light, #334155);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}

.history-error {
  font-size: 0.73rem;
  color: var(--error);
  margin-top: 0.3rem;
  word-break: break-word;
}

.history-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.history-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 6px;
  padding: 0.25rem 0.65rem;
  transition: background 0.15s;
}

.history-link:hover { background: rgba(59,130,246,0.2); }

.history-link-btn {
  cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
}

.history-link-danger {
  color: var(--error);
  border-color: var(--error);
}
.history-link-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.history-link-delete {
  color: var(--error);
  border-color: var(--error);
}
.history-link-delete:hover {
  background: #ef4444;
  color: #fff;
}

.btn-danger-ghost {
  color: var(--error, #ef4444);
  border: 1px solid var(--error, #ef4444);
}
.btn-danger-ghost:hover {
  background: #ef4444;
  color: #fff;
}

.history-link-accent {
  color: var(--accent);
  border-color: var(--accent);
}
.history-link-accent:hover {
  background: rgba(59, 130, 246, 0.2);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .url-row { flex-direction: column; }
  .btn-generate { width: 100%; }
  .result-header { flex-direction: column; gap: 0.5rem; }
}

/* ── Sites Database Table ────────────────────────────────────────────────── */
.sites-card { overflow: hidden; }

.sites-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 520px;
  -webkit-overflow-scrolling: touch;
  margin-top: 0.25rem;
}

.sites-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 720px;
}

.sites-table thead tr {
  background: var(--surface-3);
  border-bottom: 2px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 1;
}

.sites-table th {
  padding: 0.55rem 0.85rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

.sites-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.sites-table tbody tr:last-child { border-bottom: none; }

.sites-table tbody tr:hover { background: var(--surface-2); }

.sites-table td {
  padding: 0.6rem 0.85rem;
  color: var(--text);
  vertical-align: middle;
}

.sites-td-name {
  font-weight: 600;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sites-td-mono {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.site-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 5px;
  padding: 0.2rem 0.5rem;
  transition: background 0.15s;
  white-space: nowrap;
}
.site-link:hover { background: rgba(59,130,246,0.2); }

.badge-info {
  background: rgba(139,92,246,0.15);
  color: #a78bfa;
}

.badge-paid {
  background: rgba(245,158,11,0.15);
  color: #fbbf24;
}

.sites-error {
  font-size: 0.7rem;
  color: var(--error);
  font-family: var(--font-mono);
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.sites-delete-btn {
  padding: 3px 8px;
  border: 1px solid #ef4444;
  border-radius: 5px;
  background: transparent;
  color: #ef4444;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.sites-delete-btn:hover {
  background: #ef4444;
  color: #fff;
}
.sites-deleted-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sites-domain-btn {
  padding: 2px 7px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  margin-left: 4px;
}
.sites-domain-btn:hover {
  background: var(--accent);
  color: #fff;
}
.sites-domain-btn-remove {
  border-color: var(--text-muted);
  color: var(--text-muted);
}
.sites-domain-btn-remove:hover {
  background: var(--text-muted);
  color: #fff;
}
.custom-domain-tag {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 500;
}

/* ── Domain Lookup ───────────────────────────────────────────────────────── */
.domain-lookup-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.domain-lookup-input {
  flex: 1;
  min-width: 220px;
  max-width: 380px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
}
.domain-lookup-result {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.domain-lookup-ok    { color: var(--green, #22c55e); }
.domain-lookup-error { color: #ef4444; }

/* Slug cell */
.sites-slug {
  font-family: 'Fira Mono', monospace;
  font-size: 0.72rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  cursor: pointer;
  user-select: all;
}
.sites-slug:hover { border-color: var(--accent); color: var(--accent); }
.sites-domain-url {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0.8;
}
.sites-domain-url:hover { color: var(--accent); opacity: 1; }

/* Copy toast */
.copy-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1.2rem;
  font-size: 0.8rem;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 9999;
}
.copy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Pipeline Mode Selector ──────────────────────────────────────────────── */
.pipeline-mode-row {
  margin-top: 0.75rem;
}

.pipeline-mode-label-row {
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.pipeline-modes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
}

@media (max-width: 580px) {
  .pipeline-modes { grid-template-columns: 1fr; }
}

.pipeline-mode {
  background: var(--surface-2);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: block;
  user-select: none;
}

.pipeline-mode:hover { background: var(--surface-3); border-color: rgba(59,130,246,0.5); }

.pipeline-mode.pm-selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}

.pipeline-mode input[type=radio] { display: none; }

.pipeline-mode-title {
  display: block;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.pipeline-mode-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  line-height: 1.4;
}

/* ── Stage pills ─────────────────────────────────────────────────────────── */
.ps-row {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: nowrap;
}

.ps {
  font-size: 0.63rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.6;
}

/* active / will run */
.ps-run   { background: rgba(34,197,94,0.14);  color: #4ade80; border: 1px solid rgba(34,197,94,0.25); }
/* from cache / reused */
.ps-cache { background: rgba(59,130,246,0.12);  color: #7dd3fc; border: 1px solid rgba(59,130,246,0.2); }
/* skipped entirely */
.ps-skip  { background: rgba(100,116,139,0.1);  color: #4b5563; border: 1px solid rgba(100,116,139,0.2); }
/* new resource created */
.ps-new   { background: rgba(168,85,247,0.14);  color: #c084fc; border: 1px solid rgba(168,85,247,0.25); }
/* forced re-run (hot) */
.ps-hot   { background: rgba(239,68,68,0.12);   color: #f87171; border: 1px solid rgba(239,68,68,0.2); }

.ps-sep { color: var(--text-muted); font-size: 0.58rem; flex-shrink: 0; }

/* ── Result action cards ─────────────────────────────────────────────────── */
.result-actions-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.result-action-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.45rem;
}

@media (max-width: 580px) {
  .result-action-row { grid-template-columns: 1fr; }
}

.result-action-card {
  background: var(--surface-2);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  width: 100%;
  display: block;
}

.result-action-card:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.result-action-card:active:not(:disabled) { transform: scale(0.98); }
.result-action-card:disabled { opacity: 0.5; cursor: not-allowed; }

.result-action-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.result-action-desc {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  line-height: 1.3;
}

.result-secondary-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
  align-items: center;
}

.checkbox-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-secondary, #888);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: border-color 0.15s, color 0.15s;
}
.checkbox-option:hover {
  border-color: var(--border, #333);
  color: var(--text, #eee);
}
.checkbox-option input[type="checkbox"] {
  accent-color: #e55;
  cursor: pointer;
}

/* ── Log Viewer Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  width: 100%;
  max-width: 860px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
  line-height: 1;
}

.modal-close-btn:hover { color: var(--text); }

.log-modal-pre {
  margin: 0;
  padding: 1rem;
  overflow-y: auto;
  font-family: 'Fira Mono', 'Cascadia Code', monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1;
}

/* ── Chat Mobile Responsive ──────────────────────────────────────────────── */
.cs-msg-bubble {
  max-width: 75%;
}

.cs-mobile-back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2em;
  cursor: pointer;
  padding: 0.3rem;
}

@media (max-width: 640px) {
  /* Main chat container - fixed position when active */
  .cs-chat-container {
    flex-direction: column !important;
    height: auto !important;
  }

  /* When chat is active, make it fill the viewport */
  .cs-chat-container.cs-chat-active {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    height: 100dvh !important;
    background: var(--bg);
  }

  /* Contacts panel: full width, show/hide */
  #cs-contacts-panel {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-light);
    max-height: 100%;
    flex: 1;
  }

  /* Chat area */
  .cs-chat-area {
    flex: 1;
    display: none !important;
  }

  /* When a chat is active, hide contacts, show chat */
  .cs-chat-container.cs-chat-active #cs-contacts-panel {
    display: none !important;
  }
  .cs-chat-container.cs-chat-active .cs-chat-area {
    display: flex !important;
    height: 100% !important;
  }

  /* Show back button on mobile */
  .cs-mobile-back-btn {
    display: inline-flex;
  }

  /* Smaller padding/fonts on mobile */
  #cs-messages {
    padding: 0.5rem !important;
    flex: 1;
    min-height: 0;
  }
  #cs-input-bar {
    padding: 0.5rem !important;
    flex-shrink: 0;
  }

  /* Make the chat card edge-to-edge on mobile */
  .cs-card {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    width: calc(100% + 2.5rem);
  }

  /* Message bubbles: wider on mobile */
  .cs-msg-bubble {
    max-width: 92% !important;
  }

  /* Input area full width */
  #cs-message {
    font-size: 16px !important; /* prevent iOS zoom */
  }
}
