/* ═══════════════════════════════════════════
   ANALYTIX HUB — styles.css
   Brand tokens from brand-tokens.json
═══════════════════════════════════════════ */

:root {
  /* Purple ramp */
  --purple-950: #170A4D;
  --purple-900: #1F1262;
  --purple-800: #2A1B7A;
  --purple-700: #3D27A5;
  --purple-600: #5538DA;
  --purple-500: #6F4FE8;
  --purple-400: #7C5CFF;
  --purple-300: #A78BFA;
  --purple-200: #C9B8FF;
  --purple-100: #E9DFFF;
  --purple-50:  #F4EFFF;

  /* Surfaces */
  --bg:           #FAFAFA;
  --panel:        #FFFFFF;
  --panel-2:      #F7F5FE;
  --border:       #E8E3F5;
  --border-strong:#D4C9F0;

  /* Text */
  --text:    #1A1233;
  --muted:   #6C6586;
  --muted-2: #9F98B6;

  /* Semantic */
  --danger:  #DC2D5E;
  --success: #1B8A5A;

  /* Shape */
  --radius:      10px;
  --radius-sm:   6px;
  --radius-pill: 999px;

  /* Shadow (purple-tinted) */
  --shadow-sm:   0 1px 3px rgba(31,18,98,0.06);
  --shadow:      0 2px 8px rgba(31,18,98,0.08);
  --shadow-lift: 0 8px 28px rgba(31,18,98,0.14);

  /* Layout */
  --sidebar-w: 210px;
  --topbar-h:  56px;
}

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

html, body {
  height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── Logo mark ─── */
.logo-mark {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--purple-400), var(--purple-700));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.logo-mark-sm {
  width: 32px; height: 32px;
  font-size: 15px;
  border-radius: 9px;
}

/* ═══════════════════════════════════════════
   LOGIN SCREEN
═══════════════════════════════════════════ */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 50% at 50% -10%, var(--purple-50) 0%, transparent 70%);
}

.login-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow-lift);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand-name {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.login-brand-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--muted-2);
  font-weight: 500;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-input {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.95rem;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  text-align: center;
  letter-spacing: 0.1em;
}
.login-input:focus {
  outline: none;
  border-color: var(--purple-400);
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--purple-100);
}

.login-error {
  font-size: 0.8rem;
  color: var(--danger);
  text-align: center;
  font-weight: 500;
}

.login-hint {
  font-size: 0.74rem;
  color: var(--muted-2);
  text-align: center;
}

/* ═══════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--purple-400);
  color: #fff;
}
.btn-primary:hover { background: var(--purple-500); box-shadow: var(--shadow); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { border-color: var(--purple-300); color: var(--purple-600); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #f5c2cf;
}
.btn-danger:hover { background: #fef0f4; }

.btn-full { width: 100%; }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; }

/* ═══════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ─── */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.75rem;
  gap: 0;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0.5rem 1.1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.sidebar-brand-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.sidebar-brand-sub {
  font-size: 0.68rem;
  color: var(--muted-2);
  font-weight: 500;
  text-transform: lowercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 1rem;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0 0.6rem;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--purple-50); color: var(--purple-600); }
.nav-item.active {
  background: var(--purple-400);
  color: #fff;
  font-weight: 600;
}
.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.nav-icon { font-size: 0.9rem; width: 1.1rem; text-align: center; }
.nav-text { flex: 1; }
.nav-badge {
  background: var(--purple-100);
  color: var(--purple-700);
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
  margin-bottom: auto;
}

.sidebar-links-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem 0 0.75rem;
  margin-bottom: 4px;
}

.add-quicklink-btn {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--muted-2);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  flex-shrink: 0;
}
.add-quicklink-btn:hover {
  background: var(--purple-50);
  color: var(--purple-500);
  border-color: var(--purple-300);
}

.quick-link-item {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.quick-link-item:hover .quick-link-remove { opacity: 1; }

.quick-link-remove {
  background: none;
  border: none;
  color: var(--muted-2);
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0 6px 0 0;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
  flex-shrink: 0;
  line-height: 1;
}

.quick-link {
  display: block;
  padding: 0.4rem 0.75rem;
  font-size: 0.83rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-pill);
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-link:hover { background: var(--purple-50); color: var(--purple-600); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-storage {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 6px;
}
.sidebar-storage-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.sidebar-storage-fill {
  height: 100%;
  background: var(--purple-400);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}
.sidebar-storage-fill.warn { background: #F59E0B; }
.sidebar-storage-fill.danger { background: var(--danger); }
.sidebar-storage-label {
  font-size: 0.68rem;
  color: var(--muted-2);
  white-space: nowrap;
  flex-shrink: 0;
}

.neon-status {
  font-size: 0.72rem;
  color: var(--muted-2);
  transition: color 0.2s;
}
.neon-status.ok      { color: #16A34A; }
.neon-status.syncing { color: var(--purple-400); }
.neon-status.error   { color: var(--danger); }

.settings-nav-btn {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.83rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.settings-nav-btn:hover,
.settings-nav-btn.active {
  background: var(--purple-50);
  color: var(--purple-600);
  border-color: var(--purple-200);
}

.lock-btn {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-2);
  font-size: 0.83rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.lock-btn:hover { background: #fef0f4; color: var(--danger); border-color: #f5c2cf; }

/* ─── Sort pills ─── */
.sort-pills {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px;
}
.sort-pill {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}
.sort-pill:hover { color: var(--text); }
.sort-pill.active {
  background: var(--panel);
  color: var(--purple-600);
  box-shadow: var(--shadow-sm);
}

/* ─── Arrange mode ─── */
.arrange-btn.active {
  background: var(--purple-400);
  color: #fff;
  border-color: var(--purple-400);
}
.arrange-btn.active:hover { background: var(--purple-500); border-color: var(--purple-500); }

.drag-handle {
  font-size: 1rem;
  color: var(--muted-2);
  cursor: grab;
  padding: 0 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  user-select: none;
}
.tool-card:hover .drag-handle,
.tool-row:hover .drag-handle { opacity: 1; }
.arrange-mode .drag-handle { opacity: 0.6; }

.tool-card.dragging,
.tool-row.dragging { opacity: 0.4; }

.tool-card.drop-target { outline: 2px solid var(--purple-400); outline-offset: 2px; }
.tool-row.drop-target { border-color: var(--purple-400); box-shadow: 0 0 0 3px var(--purple-100); }

/* ─── Views bar ─── */
.views-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}
.views-bar-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
  flex-shrink: 0;
}
.views-chips {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
}
.view-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 10px;
  background: var(--purple-50);
  border: 1px solid var(--purple-200);
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--purple-700);
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}
.view-chip:hover { background: var(--purple-100); }
.view-chip-delete {
  display: flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--purple-200);
  color: var(--purple-700);
  font-size: 0.6rem;
  cursor: pointer;
  transition: background 0.1s;
}
.view-chip-delete:hover { background: var(--purple-300); }
.views-save-btn {
  background: none;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: border-color 0.1s, color 0.1s;
  flex-shrink: 0;
}
.views-save-btn:hover { border-color: var(--purple-400); color: var(--purple-600); }

/* ─── Settings section ─── */
.section-settings {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.settings-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}
.settings-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.settings-section-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.settings-block-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-2);
}
.settings-block-desc {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
  max-width: 520px;
}
.settings-storage-meter {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-storage-bar {
  width: 220px;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.settings-storage-fill {
  height: 100%;
  background: var(--purple-400);
  border-radius: var(--radius-pill);
  transition: width 0.3s;
}
.settings-storage-label {
  font-size: 0.78rem;
  color: var(--muted-2);
}
.settings-stages-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-stage-row {
  display: grid;
  grid-template-columns: 100px 1fr 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.settings-stage-preview {
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}
.settings-color-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-color-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.color-picker-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 2px;
  background: var(--panel);
  transition: border-color 0.1s;
}
.color-picker-btn:hover { border-color: var(--purple-400); }
input[type="color"] {
  width: 24px; height: 24px;
  border: none;
  padding: 0;
  border-radius: 3px;
  cursor: pointer;
  background: none;
}
.settings-reset-btn {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.1s, border-color 0.1s;
  white-space: nowrap;
}
.settings-reset-btn:hover { color: var(--danger); border-color: #f5c2cf; }

/* ─── Main area ─── */
.main {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ─── Apps section ─── */
.section-apps { display: flex; flex-direction: column; height: 100%; }

.main-topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 1rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-wrap { position: relative; }

.search-input {
  padding: 0.45rem 1rem 0.45rem 2rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  width: 200px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, width 0.15s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239F98B6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.6rem center;
}
.search-input:focus {
  outline: none;
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px var(--purple-100);
  width: 240px;
  background-color: var(--panel);
}
.search-input::placeholder { color: var(--muted-2); }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  align-content: start;
}

/* ─── Tool card ─── */
.tool-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: var(--shadow-sm);
}
.tool-card:hover {
  box-shadow: var(--shadow-lift);
  transform: translateY(-1px);
  border-color: var(--purple-200);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.card-icon {
  width: 40px; height: 40px;
  background: var(--purple-50);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}

.card-status {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: var(--radius-pill);
  padding: 2px 9px;
}
.status-live    { background: #DCFCE7; color: #15803D; }
.status-beta    { background: #FEF3C7; color: #B45309; }
.status-archive { background: var(--purple-100); color: var(--purple-700); }

.card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
  letter-spacing: -0.01em;
}
.card-desc {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0.9rem;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.card-access {
  font-size: 0.74rem;
  color: var(--muted-2);
  font-weight: 500;
}

.card-open {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--purple-400);
}

.card-edit-btn {
  background: none;
  border: none;
  color: var(--muted-2);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.1s, color 0.1s;
  margin-left: 0.5rem;
}
.card-edit-btn:hover { background: var(--purple-50); color: var(--purple-600); }

/* ─── Star / pin buttons ─── */
.card-star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted-2);
  padding: 2px 4px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.12s, transform 0.12s;
}
.card-star-btn:hover { color: #F59E0B; transform: scale(1.15); }
.card-star-btn.active { color: #F59E0B; }

.row-star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted-2);
  padding: 2px 5px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.12s, transform 0.12s;
  flex-shrink: 0;
}
.row-star-btn:hover { color: #F59E0B; transform: scale(1.15); }
.row-star-btn.active { color: #F59E0B; }

/* ─── Pinned section headers (cards grid) ─── */
.grid-full-row { grid-column: 1 / -1; }
.grid-pinned-header {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #D97706;
  padding: 2px 0 4px;
}
.grid-divider {
  grid-column: 1 / -1;
  border-top: 1.5px solid var(--border);
  margin: 2px 0 4px;
}

/* ─── Pinned section headers (beta rows) ─── */
.rows-pinned-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #D97706;
  padding: 4px 0 6px 4px;
}
.rows-pinned-divider {
  border-top: 1.5px solid var(--border);
  margin: 4px 0 8px;
}

/* ─── Beta row layout ─── */
.tools-list {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
}

.beta-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.beta-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  font-family: inherit;
}

.beta-filter-pill:hover { background: var(--purple-50); border-color: var(--purple-200); color: var(--purple-600); }

.beta-filter-pill.active {
  background: var(--purple-50);
  border-color: var(--purple-300);
  color: var(--purple-600);
  font-weight: 600;
}

.beta-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--muted);
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
}

.beta-filter-pill.active .beta-filter-count {
  background: var(--purple-200);
  color: var(--purple-700);
}

.beta-filter-pill.empty {
  opacity: 0.45;
}
.beta-filter-pill.empty:hover {
  opacity: 0.7;
}

.tool-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  overflow: hidden;
}
.tool-row:hover { box-shadow: var(--shadow); border-color: var(--purple-200); }
.tool-row.expanded { border-color: var(--purple-300); box-shadow: var(--shadow); }

.tool-row-header {
  display: grid;
  grid-template-columns: 130px 36px 1fr auto auto auto 28px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  user-select: none;
}

.tool-row-chevron {
  color: var(--muted-2);
  font-size: 0.7rem;
  text-align: center;
  transition: transform 0.2s ease;
  line-height: 1;
}
.tool-row.expanded .tool-row-chevron { transform: rotate(180deg); }

/* Expanded body */
.tool-row-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  border-top: 0px solid var(--border);
}
.tool-row.expanded .tool-row-body {
  max-height: 600px;
  border-top-width: 1px;
}

.tool-row-detail {
  padding: 1rem 1.25rem 1.25rem;
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.tool-row-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}
.meta-chip a { color: var(--purple-600); text-decoration: none; }
.meta-chip a:hover { text-decoration: underline; }

.tool-row-notes {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.tool-row-notes-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.tool-row-notes-body {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
}
.tool-row-notes-body ul,
.tool-row-notes-body ol { padding-left: 1.2rem; margin: 0.2rem 0; }
.tool-row-notes-body li { margin: 0.15rem 0; }
.tool-row-notes-body p { margin: 0.2rem 0; }
.tool-row-notes-body strong { font-weight: 700; }
.tool-row-notes-body em { font-style: italic; }
.tool-row-notes-empty {
  font-size: 0.83rem;
  color: var(--muted-2);
  font-style: italic;
}

.tool-row-detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

/* ─── Category badges + filter ─── */
.cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.card-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 0.9rem;
}
.tool-row-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.category-filter {
  padding: 0.4rem 1.8rem 0.4rem 0.85rem;
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239F98B6' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 0.7rem center;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  max-width: 170px;
}
.category-filter:hover { border-color: var(--purple-300); color: var(--purple-600); }
.category-filter:focus { outline: none; border-color: var(--purple-400); }

.tool-row-icon {
  width: 32px; height: 32px;
  background: var(--purple-50);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}
.tool-row-icon img { width: 100%; height: 100%; object-fit: contain; }

.tool-row-info { min-width: 0; }
.tool-row-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-row-desc {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.tool-row-notes-preview {
  font-size: 0.72rem;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  margin-top: 1px;
}

.tool-row-access {
  font-size: 0.74rem;
  color: var(--muted-2);
  white-space: nowrap;
}

.tool-row-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--muted-2);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}
.tool-row-btn:hover { background: var(--purple-50); color: var(--purple-600); }
.tool-row-btn.open { color: var(--purple-400); font-weight: 600; }

.tool-row-add {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted-2);
  font-size: 0.83rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.tool-row-add:hover {
  border-color: var(--purple-300);
  color: var(--purple-500);
  background: var(--purple-50);
}

/* Add tool card */
.tool-card-add {
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 140px;
  cursor: pointer;
  color: var(--muted-2);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
  font-family: inherit;
}
.tool-card-add:hover {
  border-color: var(--purple-300);
  color: var(--purple-500);
  background: var(--purple-50);
}
.tool-card-add-icon { font-size: 1.5rem; }
.tool-card-add-label { font-size: 0.83rem; font-weight: 500; }

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--muted-2);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.88rem; }

/* ═══════════════════════════════════════════
   IDEAS / NOTES SECTION
═══════════════════════════════════════════ */

.section-ideas {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100%;
  overflow: hidden;
}

.notes-list-pane {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notes-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.notes-count {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.notes-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.5rem;
}

.note-row {
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s ease;
  margin-bottom: 2px;
}
.note-row:hover { background: var(--purple-50); }
.note-row.active {
  background: var(--purple-100);
}
.note-row-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-row-preview {
  font-size: 0.78rem;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notes-editor-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.note-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--muted-2);
}
.note-placeholder-icon { font-size: 2rem; }
.note-placeholder p { font-size: 0.88rem; }

.note-editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 1.5rem;
  gap: 0.75rem;
}

.note-editor-toprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.note-meta {
  font-size: 0.74rem;
  color: var(--muted-2);
  font-weight: 500;
}

.note-save-status {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.note-save-status.visible { opacity: 1; }

.note-title-input {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  border: none;
  background: transparent;
  font-family: inherit;
  letter-spacing: -0.015em;
  line-height: 1.2;
  padding: 0;
}
.note-title-input:focus { outline: none; }
.note-title-input::placeholder { color: var(--muted-2); }

/* Note RTE toolbar */
.note-rte-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  padding: 4px 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.note-rte-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.note-rte-btn:hover { background: var(--purple-50); color: var(--purple-600); }
.note-rte-btn.active { background: var(--purple-100); color: var(--purple-600); }
.note-rte-sep {
  width: 1px; height: 16px;
  background: var(--border);
  margin: 0 3px;
  flex-shrink: 0;
}

/* Note body (contenteditable RTE) */
.note-body-rte {
  flex: 1;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.75;
  padding: 0.5rem 0;
  overflow-y: auto;
  outline: none;
  min-height: 120px;
}
.note-body-rte:empty::before {
  content: attr(data-placeholder);
  color: var(--muted-2);
  pointer-events: none;
}
.note-body-rte h1 { font-size: 1.5rem; font-weight: 700; margin: 0.75rem 0 0.35rem; line-height: 1.2; }
.note-body-rte h2 { font-size: 1.2rem; font-weight: 700; margin: 0.65rem 0 0.3rem; line-height: 1.3; }
.note-body-rte h3 { font-size: 1rem; font-weight: 700; margin: 0.5rem 0 0.25rem; }
.note-body-rte p { margin: 0.2rem 0; }
.note-body-rte ul, .note-body-rte ol { padding-left: 1.4rem; margin: 0.35rem 0; }
.note-body-rte li { margin: 0.15rem 0; }
.note-body-rte blockquote {
  border-left: 3px solid var(--purple-300);
  padding: 0.3rem 0 0.3rem 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0;
  font-style: italic;
}
.note-body-rte hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.75rem 0;
}
.note-body-rte strong { font-weight: 700; }
.note-body-rte em { font-style: italic; }
.note-body-rte u { text-decoration: underline; }
.note-body-rte s { text-decoration: line-through; }
.note-body-rte a { color: var(--purple-600); text-decoration: underline; }
.note-body-rte a:hover { color: var(--purple-400); }
.note-body-rte code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 0.85em;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Inline images */
.note-inline-img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  display: block;
  margin: 0.6rem 0;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}
.note-inline-img:hover { box-shadow: var(--shadow-lift); }
.note-inline-img.selected { outline: 2px solid var(--purple-400); }

/* File attachment chips */
.note-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  color: var(--purple-600);
  font-weight: 500;
  text-decoration: none;
  margin: 2px 0;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.note-file-chip:hover {
  background: var(--purple-50);
  border-color: var(--purple-200);
  text-decoration: none;
}

/* Drag-over visual */
.note-body-rte.drag-over {
  outline: 2px dashed var(--purple-400);
  outline-offset: 4px;
  background: var(--purple-50);
  border-radius: var(--radius-sm);
}

.note-editor-actions {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── Rich text editor ─── */
.notes-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.notes-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rte-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
}
.rte-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
}
.rte-btn:hover { background: var(--purple-50); color: var(--purple-600); }
.rte-sep {
  width: 1px; height: 14px;
  background: var(--border);
  margin: 0 2px;
}
.rte-editor {
  min-height: 120px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.rte-editor:focus {
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px var(--purple-100);
  background: var(--panel);
}
.rte-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted-2);
  pointer-events: none;
}
.rte-editor ul, .rte-editor ol {
  padding-left: 1.2rem;
  margin: 0.25rem 0;
}
.rte-editor li { margin: 0.1rem 0; }
.rte-editor strong { font-weight: 700; }
.rte-editor em { font-style: italic; }
.rte-editor a { color: var(--purple-600); text-decoration: underline; }

/* ─── Floating image resize toolbar ─── */
.note-img-toolbar {
  position: fixed;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 7px;
  background: var(--text);
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transform: translateX(-50%);
  pointer-events: auto;
}
.note-img-toolbar button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, color 0.1s;
  font-family: inherit;
}
.note-img-toolbar button:hover { background: rgba(255,255,255,0.18); color: #fff; }
.note-img-tb-sep {
  width: 1px; height: 16px;
  background: rgba(255,255,255,0.2);
  margin: 0 2px;
}

/* ═══════════════════════════════════════════
   MODAL
═══════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 18, 51, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}

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

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lift);
  animation: slideUp 0.15s ease;
}
.modal-body {
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.modal-close {
  background: var(--panel-2);
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, color 0.1s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: -0.4rem;
}

.field-input {
  width: 100%;
  padding: 0.55rem 0.9rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field-input:focus {
  outline: none;
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px var(--purple-100);
  background: var(--panel);
}
.field-short { width: 80px; }

/* ─── Icon picker ─── */
.icon-picker {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.icon-preview {
  width: 48px; height: 48px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  overflow: hidden;
}
.icon-preview img {
  width: 100%; height: 100%;
  object-fit: contain;
}
.icon-picker-right {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}
.icon-upload-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.icon-or {
  font-size: 0.72rem;
  color: var(--muted-2);
  font-weight: 500;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}
