/* ── Tokens ─────────────────────────────────────────────── */
/* Aligned with the public site design system (css/site.css):
   bold-gradient-modern, indigo→cyan, vanilla no-CDN. */
:root {
  --bg-base:        #07080e;
  --bg-surface:     #0d0f17;
  --bg-elevated:    #141726;
  --bg-overlay:     rgba(16, 19, 34, 0.85);

  --border:         rgba(255,255,255,0.09);
  --border-bright:  rgba(255,255,255,0.16);

  --accent:         #6366f1;
  --accent-2:       #22d3ee;
  --accent-glow:    rgba(99,102,241,0.35);
  --accent-grad:    linear-gradient(120deg, #818cf8 0%, #6366f1 45%, #22d3ee 100%);

  --green:  #4ade80;
  --yellow: #f5a623;
  --red:    #f56565;
  --blue:   #3b82f6;
  --purple: #818cf8;
  --orange: #f6ad55;
  --cyan:   #22d3ee;

  --text-primary:   #eceeff;
  --text-secondary: #a2a7c2;
  --text-muted:     #6b7196;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;

  --sidebar-w: 240px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 32px var(--accent-glow);
}

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

html, body {
  height: 100%;
  font-family: var(--sans);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}

/* Ambient gradient field — matches the public site's mood */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(50% 40% at 100% 0%, rgba(99,102,241,0.16), transparent 60%),
    radial-gradient(42% 38% at 0% 4%, rgba(34,211,238,0.09), transparent 60%);
}

a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Lucide SVG Icon Alignment ──────────────────────────── */
.lucide-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}

/* ── App Shell ──────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 34px; height: 34px;
  background: var(--accent-grad);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
  color: #fff;
}

.logo-text {
  font-weight: 700;
  font-size: 16px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  padding: 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.18s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.nav-link.active {
  background: rgba(99,102,241,0.15);
  color: var(--accent);
}

.nav-link .nav-icon { width: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: white; flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-tier { font-size: 11px; color: var(--text-muted); }

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

.page-header {
  padding: 28px 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.page-content { padding: 24px 32px 40px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: border-color 0.2s ease;
}

.card:hover { border-color: var(--border-bright); }

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

/* ── Stats Grid ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--border-bright);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; }
.stat-value { font-size: 32px; font-weight: 800; line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text-secondary); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13px;
  border: none;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99,102,241,0.4);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 4px 20px rgba(99,102,241,0.55); transform: translateY(-1px); }

.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); border-color: var(--border-bright); }

.btn-danger {
  background: rgba(245,101,101,0.15);
  color: var(--red);
  border: 1px solid rgba(245,101,101,0.25);
}
.btn-danger:hover { background: rgba(245,101,101,0.25); }

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

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }

.form-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  outline: none;
  width: 100%;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.18);
}

.form-input::placeholder { color: var(--text-muted); }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
  cursor: pointer;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }

tbody td {
  padding: 13px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-active   { background: rgba(62,207,142,0.15); color: var(--green); }
.badge-paused   { background: rgba(245,166,35,0.15);  color: var(--yellow); }
.badge-completed{ background: rgba(59,130,246,0.15);  color: var(--blue); }
.badge-archived { background: rgba(79,86,107,0.2);    color: var(--text-muted); }

.badge-free  { background: rgba(79,86,107,0.2);   color: var(--text-secondary); }
.badge-pro   { background: rgba(99,102,241,0.15); color: var(--accent); }
.badge-team  { background: rgba(62,207,142,0.15);  color: var(--green); }

/* Block type chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.chip-goal       { background: rgba(99,102,241,0.2); color: var(--purple); }
.chip-decision   { background: rgba(59,130,246,0.2);  color: var(--blue); }
.chip-code       { background: rgba(62,207,142,0.15); color: var(--green); }
.chip-error      { background: rgba(245,101,101,0.15);color: var(--red); }
.chip-next_step  { background: rgba(245,166,35,0.15); color: var(--yellow); }
.chip-note       { background: rgba(79,209,197,0.15); color: var(--cyan); }

/* ── Progress Bar ───────────────────────────────────────── */
.progress-bar-wrap { margin-bottom: 16px; }
.progress-labels { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12.5px; }
.progress-label { color: var(--text-secondary); }
.progress-pct   { color: var(--text-muted); font-size: 11.5px; }

.progress-track {
  height: 6px; border-radius: 99px;
  background: rgba(255,255,255,0.07);
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: var(--accent-grad);
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.progress-fill.warn { background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.progress-fill.danger { background: linear-gradient(90deg, var(--red), #e53e3e); }

/* ── Project Cards ──────────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex; flex-direction: column; gap: 10px;
}
.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(99,102,241,0.18);
}
.project-name { font-size: 15px; font-weight: 700; }
.project-slug { font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
.project-url  { font-size: 12px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-meta { display: flex; gap: 12px; font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* ── Context Blocks ─────────────────────────────────────── */
.block-list { display: flex; flex-direction: column; gap: 10px; }

.block-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: border-color 0.2s;
}
.block-item:hover { border-color: var(--border-bright); }

.block-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.block-priority {
  margin-left: auto;
  font-size: 11px; color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px; border-radius: 6px;
}
.block-content {
  font-size: 13.5px; color: var(--text-primary);
  line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.block-code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px; padding: 12px;
  overflow-x: auto;
}
.block-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.block-date { font-size: 11px; color: var(--text-muted); }

/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: flex-start; justify-content: flex-end;
  animation: fadeIn 0.15s ease;
}

.modal-panel {
  width: min(620px, 96vw);
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  animation: slideIn 0.2s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}

.modal-title { font-size: 16px; font-weight: 700; }
.modal-subtitle { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 8px; border: none;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.modal-close:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }

.modal-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Confirm dialog ─────────────────────────────────────── */
.confirm-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
.confirm-backdrop.closing { animation: fadeIn 0.12s ease reverse; }

.confirm-panel {
  width: min(420px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px 26px 22px;
  text-align: center;
  animation: popIn 0.18s cubic-bezier(0.34,1.56,0.64,1);
}

.confirm-icon {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-glow);
  color: var(--accent);
}
.confirm-icon.danger {
  background: rgba(245,101,101,0.16);
  color: var(--red);
}

.confirm-title { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.confirm-message {
  font-size: 13.5px; line-height: 1.55;
  color: var(--text-secondary);
  margin-top: 8px;
}
.confirm-actions {
  display: flex; gap: 10px; justify-content: center;
  margin-top: 22px;
}
.confirm-actions .btn { min-width: 104px; justify-content: center; }

@keyframes popIn {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Payment / Upgrade Modal ────────────────────────────── */
.pay-modal {
  position: relative;
  width: min(520px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 26px 26px 22px;
  animation: popIn 0.18s cubic-bezier(0.34,1.56,0.64,1);
}
.pay-modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}
.pay-modal-close:hover { background: var(--bg-base); color: var(--text-primary); }

/* ── Login / Auth Screen ────────────────────────────────── */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 60% 40% at 50% -10%, rgba(99,102,241,0.18) 0%, transparent 70%);
}

.auth-card {
  width: min(420px, 94vw);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px;
  box-shadow: var(--shadow-md);
}

.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-logo-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-glow);
  color: #fff;
}
.auth-logo-text { font-size: 20px; font-weight: 800; background: var(--accent-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 3px; }
.auth-tab {
  flex: 1; padding: 8px; border-radius: 6px; border: none;
  background: none; color: var(--text-muted); font-weight: 600; font-size: 13.5px;
  transition: all 0.18s;
}
.auth-tab.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }

.auth-error {
  background: rgba(245,101,101,0.12); border: 1px solid rgba(245,101,101,0.3);
  color: var(--red); border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 13px; margin-bottom: 14px; display: none;
}
.auth-error.show { display: block; }

/* ── Key reveal box ─────────────────────────────────────── */
.key-reveal {
  background: var(--bg-base);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px; color: var(--accent);
  word-break: break-all;
  margin: 12px 0;
  position: relative;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  padding: 3px 9px; font-size: 11px;
  background: rgba(99,102,241,0.2); border: none;
  border-radius: 5px; color: var(--accent); cursor: pointer;
}
.copy-btn:hover { background: rgba(99,102,241,0.35); }

/* ── Filters ────────────────────────────────────────────── */
.filters-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-select {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 13px; outline: none;
}
.filter-select:focus { border-color: var(--accent); }

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-icon { opacity: 0.35; color: var(--text-secondary); line-height: 1; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-desc  { font-size: 13px; color: var(--text-muted); }

/* ── Loading ────────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}

.loading-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; }

/* ── Toast ──────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }

.toast {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 18px;
  font-size: 13.5px; color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
  display: flex; align-items: center; gap: 10px;
  max-width: 320px;
}
.toast.success { border-color: rgba(62,207,142,0.3); }
.toast.error   { border-color: rgba(245,101,101,0.3); }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.toast.success .toast-dot { background: var(--green); }
.toast.error   .toast-dot { background: var(--red); }

/* ── Animations ─────────────────────────────────────────── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* ── Mobile nav: hamburger + off-canvas drawer ──────────── */
.menu-toggle {
  display: none;                 /* desktop: hidden (shown < 700px) */
  position: fixed;
  top: 12px; left: 12px;
  z-index: 220;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.menu-toggle:hover { background: var(--bg-elevated); }
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 205;
}
.sidebar-backdrop.show { display: block; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 700px) {
  /* Sidebar slides in from the left instead of vanishing */
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(82vw, 280px);
    transform: translateX(-100%);
    z-index: 210;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
  }
  #sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .page-header, .page-content { padding-left: 16px; padding-right: 16px; }
  .page-header { padding-left: 64px; }   /* clear the fixed hamburger */
}

/* ── Two-col layout ─────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.section-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; }

hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Welcome Banner ─────────────────────────────────────── */
.welcome-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  margin-bottom: 24px;
  position: relative; overflow: hidden;
}
.welcome-banner::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 100% at 100% 50%, rgba(99,102,241,0.12) 0%, transparent 60%);
  pointer-events: none;
}
.welcome-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.welcome-sub { font-size: 13.5px; color: var(--text-secondary); }

/* ── Setup Guide ───────────────────────────────────────── */
.setup-section { margin-bottom: 20px; }
.setup-section h3 { font-size: 16px; font-weight: 700; margin: 0; }

.setup-section-header {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.setup-section-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(99,102,241,0.12); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.setup-section-desc { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Step indicators with connecting line */
.setup-steps { display: flex; flex-direction: column; gap: 0; }
.setup-step { display: flex; gap: 16px; }

.step-indicator { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.step-number {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.step-number.last { margin-bottom: 0; }
.step-line {
  width: 2px; flex: 1; min-height: 20px;
  background: linear-gradient(180deg, var(--accent) 0%, transparent 100%);
  opacity: 0.3;
}

.step-body { padding-bottom: 24px; flex: 1; min-width: 0; }
.step-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }

.step-code {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-base); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; margin-top: 6px;
  font-family: var(--mono); font-size: 12.5px;
  color: var(--green); overflow-x: auto;
}
.step-code.lg { font-size: 12px; padding: 12px 16px; }
.step-code code { flex: 1; white-space: pre; }

.code-copy-btn {
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 5px;
  padding: 4px 8px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; transition: all 0.15s;
}
.code-copy-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,0.1); }

.step-alt { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.step-alt code {
  background: rgba(255,255,255,0.06); padding: 1px 5px;
  border-radius: 4px; font-size: 11.5px; color: var(--text-secondary);
}

.step-warning {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--yellow); margin-top: 4px;
}
.step-warning a { color: var(--accent); }

.api-key-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-base); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 14px; margin-top: 4px;
  font-family: var(--mono); font-size: 12.5px; color: var(--accent);
}
.key-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
  box-shadow: 0 0 6px rgba(62,207,142,0.5);
}

/* ── Tool List (horizontal rows with real icons) ─────────── */
.tool-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
@media (max-width: 800px) { .tool-list { grid-template-columns: 1fr; } }

.tool-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
  width: 100%;
  font-family: inherit;
  color: inherit;
}
.tool-row:hover {
  border-color: var(--border-bright);
  border-left-color: var(--tool-color, var(--accent));
  background: rgba(255,255,255,0.025);
}
.tool-row.active {
  border-color: var(--border-bright);
  border-left-color: var(--tool-color, var(--accent));
  background: rgba(255,255,255,0.04);
}

.tool-row-icon { flex-shrink: 0; display: flex; align-items: center; }
.tool-img { display: block; flex-shrink: 0; }
.tool-row-body { flex: 1; min-width: 0; }
.tool-row-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.tool-row-desc { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-row-arrow { color: var(--text-muted); flex-shrink: 0; opacity: 0.4; transition: all 0.15s; }
.tool-row:hover .tool-row-arrow,
.tool-row.active .tool-row-arrow { opacity: 1; color: var(--tool-color, var(--accent)); transform: translateX(2px); }

/* ── Tool Detail Panel ─────────────────────────────────── */
.tool-detail-panel {
  margin-top: 12px; padding: 0;
  background: var(--bg-base); border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: fadeIn 0.15s ease;
  overflow: hidden;
}

.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  border-left: 3px solid var(--tool-color, var(--accent));
}
.detail-header-left { display: flex; align-items: center; gap: 12px; }
.detail-title { font-size: 14px; font-weight: 700; }
.detail-desc { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.detail-close {
  width: 26px; height: 26px; border-radius: 6px; border: none;
  background: rgba(255,255,255,0.06); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex-shrink: 0;
}
.detail-close:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }

.detail-body { padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.detail-method { display: flex; flex-direction: column; gap: 8px; }
.detail-method-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
}

.method-badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 4px;
  background: rgba(255,255,255,0.08); color: var(--text-muted);
}
.method-badge.recommended { background: rgba(62,207,142,0.15); color: var(--green); }

.config-paths-list { display: flex; flex-direction: column; gap: 4px; }
.config-path-row { display: flex; align-items: flex-start; gap: 8px; }
.config-os-badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 4px; white-space: nowrap; flex-shrink: 0;
  background: rgba(255,255,255,0.06); color: var(--text-muted);
  min-width: 68px; text-align: center; margin-top: 1px;
}
.config-file-path {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--yellow); word-break: break-all; line-height: 1.5;
}

.step-code.multi { position: relative; align-items: flex-start; }
.step-code.multi code { white-space: pre; overflow-x: auto; }
.code-copy-btn.top-right { align-self: flex-start; flex-shrink: 0; }

.detail-note {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(59,130,246,0.07); border: 1px solid rgba(59,130,246,0.18);
  border-radius: 8px; padding: 12px 14px;
  font-size: 12.5px; color: var(--text-secondary); line-height: 1.6;
}
.detail-note-icon { flex-shrink: 0; margin-top: 1px; color: rgba(59,130,246,0.8); }
.detail-note-text { flex: 1; min-width: 0; }
.detail-note strong { color: var(--text-primary); }
.detail-note code {
  font-family: var(--mono); font-size: 11px;
  background: rgba(255,255,255,0.08); color: var(--text-primary);
  padding: 1px 5px; border-radius: 4px;
  white-space: nowrap;
}

/* ── Auto-Sync Flow ────────────────────────────────────── */
.sync-flow {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 20px 0 24px;
  margin-bottom: 16px;
}

.sync-node {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 18px; border-radius: var(--radius-sm);
  background: var(--bg-base); border: 1px solid var(--border);
  min-width: 130px; text-align: center; flex-shrink: 0;
}
.sync-node-center {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(99,102,241,0.12);
  background: rgba(99,102,241,0.04);
}
.sync-node-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(99,102,241,0.1); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px; flex-shrink: 0;
}
.sync-node-center .sync-node-icon {
  background: var(--accent-grad); color: #fff;
  box-shadow: 0 2px 10px rgba(99,102,241,0.4);
}
.sync-node-label { font-size: 12.5px; font-weight: 600; }
.sync-node-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sync-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 700px) { .sync-methods { grid-template-columns: 1fr; } }

.sync-method {
  background: var(--bg-base); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
}
.sync-method-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; margin-bottom: 8px;
  color: var(--text-primary);
}
.sync-badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 4px;
  background: rgba(255,255,255,0.08); color: var(--text-muted);
}
.sync-badge.auto { background: rgba(62,207,142,0.15); color: var(--green); }

/* ── Connection Test ───────────────────────────────────── */
.connection-test { display: flex; flex-direction: column; gap: 12px; }

.test-running {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-secondary);
}
.test-running .spinner { width: 16px; height: 16px; margin: 0; }

.test-result-card {
  border-radius: var(--radius-sm); padding: 16px;
  border: 1px solid var(--border);
}
.test-result-card.success {
  background: rgba(62,207,142,0.06);
  border-color: rgba(62,207,142,0.25);
}
.test-result-card.failure {
  background: rgba(245,101,101,0.06);
  border-color: rgba(245,101,101,0.25);
}

.test-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; margin-bottom: 10px;
}
.test-result-card.success .test-status { color: var(--green); }
.test-result-card.failure .test-status { color: var(--red); }

.test-details { display: flex; gap: 20px; flex-wrap: wrap; }
.test-detail {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 12px;
}
.test-detail span:first-child { color: var(--text-muted); font-weight: 500; text-transform: uppercase; font-size: 10px; letter-spacing: 0.05em; }
.test-detail span:last-child { color: var(--text-primary); font-weight: 600; }

.test-detail-msg { font-size: 13px; color: var(--text-secondary); }
.test-detail-msg code { background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

@media (max-width: 600px) {
  .sync-flow { flex-direction: column; }
  .sync-connector { width: 2px; height: 32px; }
  .sync-connector-line { width: 2px; height: 100%; }
}



/* ── Auth links + notes (login / forgot / reset / verify) ─────── */
.auth-link {
  color: var(--accent-2);
  font-size: 13.5px;
  text-decoration: none;
  cursor: pointer;
}
.auth-link:hover { text-decoration: underline; }

.auth-note {
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.22);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.auth-note .lucide-icon { color: var(--accent-2); flex-shrink: 0; }

/* ── Toggle switch (settings notifications) ──────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.toggle-row:first-of-type { border-top: none; }
.toggle-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.toggle-desc  { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  transition: background .18s ease, border-color .18s ease;
}
.toggle-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 3px; top: 50%; transform: translateY(-50%);
  background: var(--text-secondary); border-radius: 50%;
  transition: transform .18s ease, background .18s ease;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent); border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translate(18px, -50%); background: #fff;
}
.toggle-switch input:disabled + .toggle-slider { opacity: 0.5; cursor: default; }
