/* ETL Design System
 * One file. Loaded before home.css.
 * Section 1: tokens. Section 2+: components (added in later tasks).
 */

:root {
  /* === BRAND === */
  --brand-50:  #eef2ff;
  --brand-100: #dbe6ff;
  --brand-200: #b6c8ff;
  --brand-500: #1f4fd6;   /* primary */
  --brand-600: #1438a8;   /* hover */
  --brand-700: #102b85;   /* press */

  /* === NEUTRALS === */
  --ink-900: #1a1f36;
  --ink-700: #425466;
  --ink-500: #5f7189;   /* darkened from #6b7c93 for WCAG AA (4.7:1 on --surface-2) */
  --ink-300: #aab7c4;

  /* Legacy semantic aliases used across the ETL CSS (Connect panel, my-data,
     insights, ask-card). These were referenced but never DEFINED, so every use
     silently fell back to a hardcoded light value — unreadable in dark mode
     (dark-grey text on the dark --surface). Alias them to the theme-aware ink
     scale so they flip automatically: light stays identical (--ink-500 = #5f7189,
     --ink-700 = #425466), dark becomes readable (#8d9aac / #c2cdda). */
  --muted: var(--ink-500);
  --ink-2: var(--ink-700);

  --line:        #e3e8ee;
  --line-strong: #c1c9d2;

  --surface:   #ffffff;
  --surface-2: #f6f9fc;
  --surface-3: #fafbfc;

  /* === SEMANTIC === */
  --success: #047857;
  --warn:    #b45309;
  --error:   #b91c1c;

  /* === SPACING === */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  /* === RADIUS === */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-pill: 999px;

  /* === SHADOW === */
  --shadow-1: 0 1px 1px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-2: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-3: 0 10px 15px -3px rgba(0,0,0,0.10), 0 4px 6px -4px rgba(0,0,0,0.05);

  /* === MOTION === */
  --motion-fast: 120ms;
  --motion-base: 180ms;
  --motion-slow: 240ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* === FONT STACKS === */
  --font-ui:   "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

  /* === EXTENDED NEUTRALS / ALIASES ===
   * Historically defined ad-hoc in home.css (or only as var() fallbacks).
   * Canonical home is here now; every one of these re-points in the dark
   * block below — components must use tokens, never literal hexes. */
  --ink:       #0f172a;
  --ink-soft:  rgba(15, 23, 42, 0.6);
  --ink-faint: #e5e7eb;              /* faint dividers / hover tints */
  --surface-1: #fbfbfd;              /* near-white raised surface */
  --surface-4: #edf1f7;              /* strongest gray step (drawers) */
  --line-200:  #e2e8f0;
  --line-soft: rgba(15, 23, 42, 0.06);
  /* A card/tile that must sit visibly ABOVE another surface in both themes
     (light keeps it white; dark lifts it a step). */
  --surface-raised: #ffffff;
  --hairline:        rgba(15, 23, 42, 0.08);
  --hairline-strong: rgba(15, 23, 42, 0.12);

  /* === ACCENT === */
  --accent:        #1f4fd6;          /* alias of --brand-500 */
  --accent-strong: #1438a8;          /* alias of --brand-600 */
  --accent-tint:        rgba(31, 79, 214, 0.12);
  --accent-tint-strong: rgba(31, 79, 214, 0.25);
  --brand-300: #8aa6f6;
  --brand-400: #6b7cff;
  /* Accent used as TEXT/icon color. Unlike --brand-500/--accent (also solid
   * button fills under white text), these are safe to lighten in dark. */
  --accent-text:        #1f4fd6;
  --accent-text-strong: #1438a8;

  /* === STATE (text / bg / border trios) === */
  --ok-text:   #166534;
  --ok-bg:     #dcfce7;
  --ok-border: rgba(22, 101, 52, 0.18);
  --warn-text:   #b45309;
  --warn-bg:     #fff7ed;
  --warn-border: rgba(180, 83, 9, 0.30);
  --error-text:   #b91c1c;
  --error-bg:     #fef2f2;
  --error-border: #fca5a5;
  --info-text:   #1e40af;
  --info-bg:     #dbeafe;
  --info-border: rgba(30, 64, 175, 0.18);

  /* Curated / built-in shared folders — neutral grey tint, kept distinct from
     the blue selection accent so "provided by admin" reads at a glance. */
  --curated-bg:     rgba(71, 85, 105, 0.10);
  --curated-border: rgba(71, 85, 105, 0.28);
  --curated-text:   #475569;

  /* === STATE / CATEGORY SCALES === */
  --warn-50:  #fff7ed;
  --warn-200: #fed7aa;
  --warn-300: #fcd9a6;
  --warn-600: #b45309;
  --warn-700: #b45309;
  /* dataflow-canvas category accents (transform slate; others use brand/state) */
  --cat-transform-text: #425466;
  --cat-transform-tint: rgba(66, 84, 102, 0.10);
  --violet-50:  #f5f0ff;
  --violet-100: #ede9fe;
  --violet-200: #ddd6fe;
  --violet-300: #c4b5fd;
  --violet-400: #a78bfa;
  --violet-600: #7c3aed;
  --violet-700: #6d28d9;
  --rose-50:  #fef2f2;
  --rose-300: #fca5a5;
  --rose-400: #fb7185;
  --rose-500: #ef4444;
  --rose-600: #dc2626;
  --amber-50:  #fffbeb;
  --amber-400: #f59e0b;
  --amber-700: #b45309;

  /* === APP BACKDROPS === */
  --app-bg: radial-gradient(circle at 20% 20%, #ffffff 0%, #f3f5f9 45%, #e8edf4 100%);
  --canvas-bg: radial-gradient(circle at 1px 1px, rgba(15,23,42,0.07) 1px, transparent 0) 0 0 / 22px 22px, var(--surface-2, #f6f9fc);
}

/* ════════════════ DARK THEME ════════════════
 * The one canonical dark block: re-points every token above to its dark
 * value. Toggled by data-theme="dark" on <html> (see home.html).
 * Per-component `html[data-theme="dark"] .foo` overrides are a bug class
 * (the "white card in dark mode" family) — fix the component's light rule
 * to use tokens instead of adding one. */
html[data-theme="dark"] {
  --surface:    #121821;   /* cards / panels */
  --surface-2:  #0c111a;   /* workspace background */
  --surface-3:  #1a212c;   /* hover surfaces */
  --surface-4:  #222b38;
  --surface-1:  #121821;   /* alias of --surface (card) */
  --ink-900: #e8edf4;      /* headings / primary text */
  --ink-800: #d7e0ea;      /* strong body — was undefined in dark → fell back to a
                              near-black light-mode value, making text on dark
                              surfaces (e.g. the Data tools dropdown) invisible */
  --ink-700: #c2cdda;      /* body */
  --ink-600: #a7b4c4;      /* secondary */
  --ink-500: #8d9aac;      /* muted */
  --ink-400: #7c899b;      /* faint / captions */
  --ink-300: #78859a;      /* placeholders — raised from #5e6b7b (3.28:1, FAILS
                              WCAG 1.4.3) to 4.77:1 on --surface #121821 so
                              placeholder text is legible; still faintest in the
                              dark ink ramp. */
  --ink:      #e8edf4;
  --ink-soft: rgba(232, 237, 244, 0.62);
  --ink-faint: #2a3340;    /* faint dividers / hover tints */
  --line:        #283243;
  --line-strong: #3a4658;
  --line-200:    #2a3340;
  --line-soft:   rgba(255, 255, 255, 0.05);
  --hairline:        rgba(255, 255, 255, 0.09);
  --hairline-strong: rgba(255, 255, 255, 0.15);
  --brand-50:  rgba(56, 110, 232, 0.18);   /* active pill / tint on dark */
  --brand-100: rgba(56, 110, 232, 0.26);
  --brand-200: #34508f;
  --brand-300: #44609e;
  --brand-400: #4f7bf0;
  --accent-strong: #1438a8;
  --accent-tint:        rgba(56, 110, 232, 0.22);
  --accent-tint-strong: rgba(56, 110, 232, 0.34);
  /* Lightened brand for ACCENT TEXT / icons on dark surfaces. The base
     --brand-500/--accent stay dark because they are also used as solid
     button fills with white text; these tokens are for `color:` only. */
  --accent-text:        #8fb3ff;
  --accent-text-strong: #8fb3ff;
  /* Semantic text colors lighten so they hold AA on dark surfaces. */
  --success: #34d399;
  --warn:    #fbbf24;
  --error:   #f87171;
  --ok-text:   #4ade80;
  --ok-bg:     rgba(34, 197, 94, 0.18);
  --ok-border: rgba(34, 197, 94, 0.34);
  --warn-text:   #f0b866;
  --warn-bg:     rgba(245, 158, 11, 0.14);
  --warn-border: rgba(245, 158, 11, 0.34);
  --error-text:   #f87171;
  --error-bg:     rgba(244, 63, 94, 0.14);
  --error-border: rgba(244, 63, 94, 0.40);
  --info-text:   #93b4ff;
  --info-bg:     rgba(56, 110, 232, 0.18);
  --info-border: rgba(56, 110, 232, 0.34);
  --curated-bg:     rgba(148, 163, 184, 0.16);
  --curated-border: rgba(148, 163, 184, 0.34);
  --curated-text:   #cbd5e1;
  /* status/category tints — dark translucent versions of the light pastels */
  --warn-50:  rgba(180, 83, 9, 0.16);
  --warn-200: rgba(245, 158, 11, 0.35);
  --warn-300: rgba(245, 158, 11, 0.50);
  --warn-600: #f0b866;
  --warn-700: #f0b866;
  --surface-raised: #1a212c;
  --cat-transform-text: #93a4b8;
  --cat-transform-tint: rgba(147, 164, 184, 0.16);
  --violet-50:  rgba(139, 92, 246, 0.16);
  --violet-100: rgba(139, 92, 246, 0.24);
  --violet-200: rgba(139, 92, 246, 0.32);
  --violet-300: #c4b5fd;
  --violet-400: #a78bfa;
  --violet-600: #b9a5fd;
  --violet-700: #c4b5fd;
  --rose-50:  rgba(244, 63, 94, 0.16);
  --rose-300: #f5a3ad;
  --rose-400: #f87171;
  --rose-500: #f87171;
  --rose-600: #f87171;
  --amber-50:  rgba(245, 158, 11, 0.16);
  --amber-400: #fbbf24;
  --amber-700: #f0b866;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.40);
  --shadow-2: 0 4px 10px rgba(0,0,0,0.45);
  --shadow-3: 0 12px 28px rgba(0,0,0,0.55);
  --app-bg: #0c111a;
  --canvas-bg: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.05) 1px, transparent 0) 0 0 / 22px 22px, #0c111a;
  color-scheme: dark;
}

/* === BASE === */
*, *::before, *::after { box-sizing: border-box; }


/* === LAYOUT PRIMITIVES === */
.row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: var(--space-1); }

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2); height: 32px; padding: 0 14px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 600; letter-spacing: 0.005em;
  border-radius: var(--radius-md); border: 1px solid transparent;
  cursor: pointer; transition: background var(--motion-fast) var(--ease),
                                border-color var(--motion-fast) var(--ease),
                                color var(--motion-fast) var(--ease),
                                box-shadow var(--motion-fast) var(--ease);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(31,79,214,0.18); }

.btn-primary {
  background: linear-gradient(180deg, #2858e0 0%, #1f4fd6 100%);
  color: #ffffff;
  border-color: var(--brand-700);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), var(--shadow-1);
}
.btn-primary:hover  { background: linear-gradient(180deg, #1f4fd6 0%, #1438a8 100%); }
.btn-primary:active { background: var(--brand-700); box-shadow: inset 0 1px 2px rgba(0,0,0,0.18); }

.btn-secondary {
  background: var(--surface); color: var(--ink-900);
  border-color: var(--line-strong); box-shadow: var(--shadow-1);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--ink-500); }

.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: rgba(15,23,42,0.06); color: var(--ink-900); }

.btn-danger {
  background: var(--surface); color: var(--error);
  border-color: rgba(185,28,28,0.30);
}
.btn-danger:hover { background: rgba(185,28,28,0.06); border-color: var(--error); }

.btn-icon { width: 32px; padding: 0; }
.btn-icon svg { width: 14px; height: 14px; }

/* === FORM CONTROLS === */
.input, .select, .textarea {
  height: 32px; padding: 0 10px;
  font-family: var(--font-ui); font-size: 13px; color: var(--ink-900);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.04);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-500); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(31,79,214,0.15);
}
.textarea {
  height: auto; min-height: 64px; padding: 8px 10px; resize: vertical;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
}
.label { font-size: 12px; font-weight: 600; color: var(--ink-700); }
.help  { font-size: 11px; color: var(--ink-500); }

/* === TABS === */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--line);
  padding: 0 var(--space-2);
  overflow-x: auto;
  background: var(--surface);
}
.tab {
  padding: 8px 14px; font-size: 12.5px; font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--ink-500); border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-top-left-radius: var(--radius-sm);
  border-top-right-radius: var(--radius-sm);
  margin-bottom: -1px; cursor: pointer; white-space: nowrap;
  transition: color var(--motion-fast), background var(--motion-fast), border-color var(--motion-fast);
}
.tab:hover { color: var(--ink-900); background: var(--surface-2); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent-text); font-weight: 600; background: transparent; }


/* === STATUS PILLS === */
.pill {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 1px 8px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600; line-height: 1.6; letter-spacing: 0.01em;
}
.pill-success { background: rgba(4,120,87,0.10);  color: var(--success); }
.pill-warn    { background: rgba(180,83,9,0.10);  color: var(--warn); }
.pill-error   { background: rgba(185,28,28,0.10); color: var(--error); }
.pill-neutral { background: rgba(107,124,147,0.10); color: var(--ink-500); }
.pill-running { background: rgba(31,79,214,0.10); color: var(--brand-500); }
.pill-running .dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(31,79,214,0.18);
  animation: ds-pulse 1.4s ease-in-out infinite;
}
@keyframes ds-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

/* === CARDS / PANELS === */
.panel, .card-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.panel { padding: var(--space-5); }
.card-shell { padding: var(--space-4) var(--space-5); }
.card-title { font-size: 15px; font-weight: 600; color: var(--ink-900); margin: 0 0 2px; }
.card-sub   { font-size: 12px; color: var(--ink-500); margin: 0 0 var(--space-3); }

/* === TABLES === */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  text-align: left; padding: 8px 12px; background: var(--surface-2);
  font-size: 11px; font-weight: 600; color: var(--ink-500);
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
}
.table th:first-child { border-top-left-radius: var(--radius-sm); }
.table th:last-child  { border-top-right-radius: var(--radius-sm); }
.table td {
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  color: var(--ink-900); font-variant-numeric: tabular-nums;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(31,79,214,0.04); }
.table td.mono { font-family: var(--font-mono); font-size: 12px; color: var(--ink-700); }

/* === SIDEBAR PRIMITIVES === */
.ds-sidebar {
  width: 300px;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  box-shadow: none;
}
.ds-sidebar-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-500);
  cursor: pointer; user-select: none;
}
.ds-sidebar-list { display: flex; flex-direction: column; }
.ds-sidebar-list-row {
  display: flex; align-items: center; gap: 10px;
  height: 44px; padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px; color: var(--ink-900);
  cursor: pointer; transition: background var(--motion-fast);
}
.ds-sidebar-list-row:last-child { border-bottom: none; }
.ds-sidebar-list-row:hover { background: rgba(31,79,214,0.04); }
.ds-sidebar-list-row.is-active {
  background: var(--brand-50); color: var(--brand-500); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--brand-500);
}
.ds-sidebar-list-row .icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--ink-500); }
.ds-sidebar-list-row.is-active .icon { color: var(--brand-500); }
.ds-sidebar-list-row .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-sidebar-list-row .meta { font-size: 11px; color: var(--ink-500); font-variant-numeric: tabular-nums; }

/* === BOTTOM-TAB STRIP === */
.ds-bottom-tab-strip {
  flex: 0 0 auto;            /* fixed chrome in the footer's flex column */
  height: 38px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden;
}
.ds-bottom-tab-content {
  background: var(--surface-2);
  /* Trimmed from --space-4/--space-5 (16/20px). The drawer spent 49.6% of its
     height on chrome before the first editable control; padding is the
     cheapest of those pixels to give back. Density is not a usability cost
     here — HHS 6:11 found higher density scans faster with no effect on
     accuracy or preference. */
  padding: var(--space-2) var(--space-4);
  overflow: auto;
  /* Fill the footer's remaining height and let the INNER settings list own the
     scrolling, instead of overflowing the pane. */
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* An author `display: flex` BEATS the user-agent rule that [hidden] relies on,
   so adding it above un-hid every hidden pane — the SQL panel's "Run a query to
   see results." started showing under the dataflow canvas. Restore the
   attribute's meaning explicitly; class+attribute outranks the class alone, so
   no !important is needed. */
.ds-bottom-tab-content[hidden] {
  display: none;
}

/* === RESIZE HANDLE === */
.ds-resize-handle {
  height: 6px; cursor: ns-resize; background: transparent;
  position: relative; transition: background var(--motion-fast);
}
.ds-resize-handle::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 32px; height: 1px; background: var(--line);
  transform: translate(-50%, -50%);
  transition: background var(--motion-fast), width var(--motion-fast);
}
.ds-resize-handle:hover { background: rgba(31,79,214,0.04); }
.ds-resize-handle:hover::after { background: var(--brand-500); width: 64px; }

/* === HOME (SaaS-style landing) === */
.sidebar-brand-row {
  display: flex; align-items: stretch; gap: 6px; margin: 0 0 12px;
}
.sidebar-home {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0; padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-ui);
  text-align: left;
  box-shadow: var(--shadow-1);
  transition: border-color var(--motion-fast), background var(--motion-fast);
}
.sidebar-home:hover { border-color: var(--brand-500); background: var(--brand-50); }
.sidebar-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink-700);
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: border-color var(--motion-fast), background var(--motion-fast),
              color var(--motion-fast);
}
.sidebar-icon-btn:hover {
  border-color: var(--brand-500);
  background: var(--brand-50);
  color: var(--brand-500);
}
.sidebar-home-icon {
  display: inline-flex; width: 28px; height: 28px;
  align-items: center; justify-content: center;
  background: var(--brand-500); color: #fff;
  border-radius: var(--radius-sm); flex-shrink: 0;
}
.sidebar-home-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sidebar-home-text strong { font-size: 13px; font-weight: 600; color: var(--ink-900); }
.sidebar-home-text > span { font-size: 11px; color: var(--ink-500); }

body.home-mode .pipeline-run,
body.home-mode #chart_container,
body.home-mode #notebook_workspace,
body.home-mode #settings_workspace,
body.home-mode .footer,
body.home-mode .zoom-controls { display: none !important; }
body.home-mode .content { padding: 0; }

/* Storage Library docs page — full-screen, hides the canvas like home. */
body.docs-mode .pipeline-run,
body.docs-mode #chart_container,
body.docs-mode #home_workspace,
body.docs-mode #notebook_workspace,
body.docs-mode #settings_workspace,
body.docs-mode #sql_workspace,
body.docs-mode .footer,
body.docs-mode .zoom-controls { display: none !important; }
body.docs-mode .content { padding: 0; }

/* Pre-boot home view — set by the inline <head> script before JS runs,
   so a refresh with no open pipeline shows only the ETL Studio with no
   flash of the canvas. Mirrors body.home-mode. Cleared by JS once
   showHomeView()/hideHomeView() owns the view. */
html[data-boot="home"] .pipeline-run,
html[data-boot="home"] #chart_container,
html[data-boot="home"] #notebook_workspace,
html[data-boot="home"] #settings_workspace,
html[data-boot="home"] .footer,
html[data-boot="home"] .zoom-controls { display: none !important; }
html[data-boot="home"] .content { padding: 0; }
html[data-boot="home"] #home_workspace { display: block !important; }

body.settings-mode .pipeline-run,
body.settings-mode #chart_container,
body.settings-mode #notebook_workspace,
body.settings-mode #home_workspace,
body.settings-mode .footer,
body.settings-mode .zoom-controls { display: none !important; }
body.settings-mode .content { padding: 0; }

.settings-workspace {
  width: 100%; height: 100%; overflow-y: auto;
  background: var(--surface-2);
  padding: 32px 40px 48px;
  font-family: var(--font-ui);
}
.settings-card {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.settings-card-row {
  display: flex; align-items: flex-end; gap: 12px;
  flex-wrap: wrap;
}
.settings-card-row--col {
  flex-direction: column; align-items: stretch; gap: 6px;
}
.settings-row-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.settings-card .nb-spark-log {
  max-height: 280px;
  font-size: 12px;
}
.settings-card .nb-spark-status {
  font-size: 13px;
  color: var(--ink-700);
}

.home-workspace {
  width: 100%; height: 100%; overflow-y: auto;
  background: var(--surface-2);
  padding: 32px 40px 48px;
  font-family: var(--font-ui);
}
.home-hero {
  margin-bottom: 28px;
  padding: 32px 32px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--brand-50) 0%, var(--surface) 70%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.home-hero-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent-text); margin-bottom: 8px;
}
.home-hero-title { margin: 0 0 6px; font-size: 26px; font-weight: 600; color: var(--ink-900); }
.home-hero-sub { margin: 0; font-size: 13.5px; color: var(--ink-700); max-width: 640px; }

.home-section { margin-bottom: 24px; }
.home-section-header {
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px;
}
.home-section-header h2 {
  margin: 0; font-size: 11px; font-weight: 700; color: var(--ink-700);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.home-section-header .help { color: var(--ink-500); font-size: 12px; }

.home-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.home-action {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-md);
  cursor: pointer; box-shadow: var(--shadow-1);
  font-family: var(--font-ui); color: var(--ink-900);
  transition: border-color var(--motion-fast), background var(--motion-fast),
              box-shadow var(--motion-fast);
}
.home-action:hover {
  border-color: var(--brand-500);
  background: var(--brand-50);
  box-shadow: var(--shadow-2);
}
.home-action-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-md);
  background: var(--brand-50); color: var(--brand-500);
  flex-shrink: 0;
}
.home-action-text { display: flex; flex-direction: column; line-height: 1.25; }
.home-action-text strong { font-size: 13px; font-weight: 600; color: var(--ink-900); }
.home-action-text .help { font-size: 11px; color: var(--ink-500); margin-top: 2px; }

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.home-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 18px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.home-card-head { display: flex; align-items: center; gap: 10px; }
.home-card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: var(--brand-50); color: var(--brand-500);
}
.home-card h3 {
  margin: 0; font-size: 11px; font-weight: 700; color: var(--ink-700);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.home-card-count {
  font-size: 30px; font-weight: 700; color: var(--ink-900); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.home-card-desc { margin: 0; font-size: 12px; color: var(--ink-500); flex: 1; }
.home-card-cta { align-self: flex-start; margin-top: 4px; height: 28px; padding: 0 10px; font-size: 12px; }

/* === CANVAS GRID === */
.ds-canvas-grid {
  background:
    radial-gradient(circle at center, rgba(15,23,42,0.05) 1px, transparent 1px) 0 0 / 16px 16px,
    var(--surface-2);
}


/* === SIDEBAR (PHASE 1 — promotion alias) ===
 * Added to sidebar element to override legacy gradient background.
 * After Phase 1 completes, the legacy .sidebar visual rules are deleted
 * and this can be folded back into a plain .sidebar selector.
 */
.sidebar-v2 {
  background: var(--surface-2) !important;
  box-shadow: none !important;
  border-right: 1px solid var(--line);
}

/* Headers/search inside the new sidebar */
.sidebar-v2 .sidebar-header h3 {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-900);
  margin: 0;
}
.sidebar-v2 .sidebar-subtitle {
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 500;
}
.sidebar-v2 .sidebar-search {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.04);
}
.sidebar-v2 .sidebar-search input {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-900);
  background: transparent;
  border: none;
}
.sidebar-v2 .sidebar-search input::placeholder { color: var(--ink-500); }
.sidebar-v2 .sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink-700);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  white-space: nowrap;
  transition: background var(--motion-fast), color var(--motion-fast),
              border-color var(--motion-fast);
}
.sidebar-v2 .sidebar-toggle:hover {
  background: var(--surface-3);
  border-color: var(--ink-500);
  color: var(--ink-900);
  transform: none;
}
.sidebar-v2 .sidebar-toggle:active {
  background: var(--surface-2);
}
.sidebar-v2 .sidebar-toggle--floating {
  height: 32px;
  padding: 0 14px;
  font-size: 12.5px;
  color: #ffffff;
  background: linear-gradient(180deg, #2858e0 0%, #1f4fd6 100%);
  border-color: var(--brand-700);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), var(--shadow-2);
}
.sidebar-v2 .sidebar-toggle--floating:hover {
  background: linear-gradient(180deg, #1f4fd6 0%, #1438a8 100%);
  border-color: var(--brand-700);
  color: #ffffff;
}

/* Section <details> wrapping each panel */
.sidebar-v2 .ds-sidebar-section {
  border-bottom: 1px solid var(--line);
}
.sidebar-v2 .ds-sidebar-section:last-child { border-bottom: none; }
.sidebar-v2 .ds-sidebar-section > summary {
  list-style: none;
  outline: none;
}
.sidebar-v2 .ds-sidebar-section > summary::-webkit-details-marker { display: none; }
.sidebar-v2 .ds-sidebar-section > summary::after {
  content: "▸";
  display: inline-block;
  margin-left: var(--space-2);
  font-size: 9px;
  color: var(--ink-500);
  transition: transform var(--motion-fast);
}
.sidebar-v2 .ds-sidebar-section[open] > summary::after { transform: rotate(90deg); }

/* "+ New" inline ghost button inside section header */
.sidebar-v2 .ds-sidebar-section-header .new-btn {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--brand-500);
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background var(--motion-fast);
}
.sidebar-v2 .ds-sidebar-section-header .new-btn:hover { background: var(--brand-50); }

/* Per-section count badge (uses .pill .pill-neutral) — extra spacing */
.sidebar-v2 .ds-sidebar-section-header .count {
  font-size: 10px;
  letter-spacing: 0;
}

/* One-line "when to use this" helper under a section header.
 * Plain sentence case (not the uppercase header treatment), muted, tight. */
.sidebar-v2 .ds-section-hint {
  margin: -2px 0 8px;
  padding: 0 14px;
  font-size: 11.5px;
  line-height: 1.4;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-500);
}
/* Hide the hint when its section is collapsed. */
.sidebar-v2 .ds-sidebar-section:not([open]) > .ds-section-hint { display: none; }


/* === Ingest section list rows (buttons that act like rows) ===
 * The Ingest section uses <button id="import_activity" class="create_operator ds-sidebar-list-row">.
 * Reset button defaults so they render the same as <div> rows.
 */
.sidebar-v2 .ds-sidebar-list-row.create_operator {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--ink-900);
  margin: 0;
}
.sidebar-v2 .ds-sidebar-list-row.create_operator:last-child { border-bottom: none; }
.sidebar-v2 .ds-sidebar-list-row.create_operator:hover { background: rgba(31,79,214,0.04); }
.sidebar-v2 .ds-sidebar-list-row.create_operator .icon {
  width: 18px; height: 18px;
}
.sidebar-v2 .ds-sidebar-list-row.create_operator .icon svg {
  width: 100%; height: 100%;
}

/* === Larger tap targets for "+ New" + section header === */
.sidebar-v2 .ds-sidebar-section-header {
  padding: 12px 14px;
  min-height: 40px;
}
.sidebar-v2 .ds-sidebar-section-header .new-btn {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  background: var(--brand-50);
  color: var(--brand-500);
  border: 1px solid transparent;
}
.sidebar-v2 .ds-sidebar-section-header .new-btn:hover {
  background: var(--brand-100);
  border-color: var(--brand-200);
}

/* === Drop the legacy gradient styling on Ingest <details> chrome === */
.sidebar-v2 details.ds-sidebar-section {
  background: transparent;
  border: none;
  border-radius: 0;
  margin: 0;
  padding: 0;
  box-shadow: none;
  overflow: visible;
}
.sidebar-v2 details.ds-sidebar-section > summary {
  list-style: none;
}
.sidebar-v2 details.ds-sidebar-section > summary::-webkit-details-marker { display: none; }

/* Override legacy .activity-group rule that may still apply if class is present */
.sidebar-v2 .activity-group-content {
  display: block;
  gap: 0;
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}


/* === Sections as distinct white cards (clearer separation) ===
 * The sidebar-v2 background is var(--surface-2) (light gray).
 * Each <details> section sits on top as a white card with a hairline border.
 * 8px vertical gap between cards makes the separation obvious at a glance.
 */
.sidebar-v2 .sidebar-buttons {
  gap: 8px;
  padding: 8px;
}

.sidebar-v2 details.ds-sidebar-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 0;
  box-shadow: var(--shadow-1);
}

/* Header sits on the white card */
.sidebar-v2 .ds-sidebar-section-header {
  background: var(--surface);
  color: var(--ink-700);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.sidebar-v2 details.ds-sidebar-section:not([open]) .ds-sidebar-section-header {
  border-bottom-color: transparent;
}
.sidebar-v2 .ds-sidebar-section-header:hover {
  background: var(--surface-3);
}

/* List inside a card has no extra border-bottom on the last row (the card border handles it) */
.sidebar-v2 details.ds-sidebar-section .ds-sidebar-list .ds-sidebar-list-row:last-child {
  border-bottom: none;
}

/* === Stronger hover affordance on rows (clickability) === */
.sidebar-v2 .ds-sidebar-list-row {
  cursor: pointer;
  transition: background var(--motion-fast), padding-left var(--motion-fast);
}
.sidebar-v2 .ds-sidebar-list-row:hover {
  background: var(--brand-50);
  padding-left: 16px;     /* subtle 2px indent on hover */
}
.sidebar-v2 .ds-sidebar-list-row.is-active {
  background: var(--brand-50);
}

/* The "+ New" button stands out a little more inside the white card */
.sidebar-v2 .ds-sidebar-section-header .new-btn {
  background: var(--brand-500);
  color: #ffffff;
  border-color: var(--brand-500);
  font-weight: 600;
}
.sidebar-v2 .ds-sidebar-section-header .new-btn:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
}


/* === List area inside each section gets a subtle gray drawer so rows pop ===
 * Section card: --surface (white)
 *   ├── Header: --surface (white) — sits on the card
 *   └── List drawer: --surface-2 (light gray) — items live here, visually distinct
 * Hover: brightens row back to --brand-50 (light blue) — clear "you can click this"
 */
.sidebar-v2 details.ds-sidebar-section .ds-sidebar-list,
.sidebar-v2 details.ds-sidebar-section .activity-group-content {
  background: var(--surface-2);
  padding: 4px 0;
}

/* Rows inside the gray drawer — stay transparent so the drawer color shows through.
 * The hairline divider becomes lighter so it doesn't fight with the gray.
 */
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row {
  background: transparent;
  border-bottom: 1px solid rgba(15, 23, 42, 0.04);
}
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row:last-child {
  border-bottom: none;
}

/* Hover lifts the row to white-blue so it clearly stands out as the focus item */
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row:hover {
  background: var(--brand-50);
}

/* Active row stays prominent: brand-50 fill + 2px left bar */
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active {
  background: var(--brand-50);
  box-shadow: inset 3px 0 0 var(--brand-500);
}

/* Ingest buttons (which are <button>s with .ds-sidebar-list-row) need the same treatment */
.sidebar-v2 .ds-sidebar-list-row.create_operator {
  background: transparent;
  border-bottom-color: rgba(15, 23, 42, 0.04);
}


/* === MORE distinct rows: white tiles on a stronger gray drawer ===
 * Each row gets its own white background so it reads as a physical tile.
 * Rows are separated by ~3px of the gray drawer showing through (no more hairline dividers).
 */
.sidebar-v2 details.ds-sidebar-section .ds-sidebar-list,
.sidebar-v2 details.ds-sidebar-section .activity-group-content {
  background: #edf1f7;            /* stronger drawer gray */
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row,
.sidebar-v2 .ds-sidebar-list-row.create_operator {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  height: auto;
  min-height: 44px;
  box-shadow: var(--shadow-1);
}

/* Last-row hairline reset is no longer needed (rows are tiles, not bordered list rows) */
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row:last-child {
  border-bottom: 1px solid var(--line);
}

/* Hover: visibly lift to brand-tinted */
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row:hover,
.sidebar-v2 .ds-sidebar-list-row.create_operator:hover {
  background: var(--brand-50);
  border-color: var(--brand-200);
  padding-left: 12px;             /* cancel the indent we added before */
  box-shadow: var(--shadow-2);
}

/* Active tile: solid brand fill with white text */
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #ffffff;
  box-shadow: var(--shadow-2);
}
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active .icon,
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active .label,
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active .meta {
  color: #ffffff;
}
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active .pill {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}


/* === Subtle active state (override the solid brand fill from the previous pass) === */
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-700);
  box-shadow: var(--shadow-1);
}
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--brand-500);
  border-radius: 0 2px 2px 0;
}
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active {
  position: relative;
}
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active .icon { color: var(--brand-500); }
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active .label { color: var(--brand-700); font-weight: 600; }
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active .meta { color: var(--ink-500); }
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row.is-active .pill {
  background: rgba(31,79,214,0.10);
  color: var(--brand-500);
}


/* === "+ New" buttons — soft & stylish, not solid-fill harsh === */
.sidebar-v2 .ds-sidebar-section-header .new-btn {
  height: 26px;
  padding: 0 10px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-500);
  background: rgba(31, 79, 214, 0.06);
  border: 1px solid rgba(31, 79, 214, 0.14);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), transform var(--motion-fast);
}
.sidebar-v2 .ds-sidebar-section-header .new-btn:hover {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-600);
}
.sidebar-v2 .ds-sidebar-section-header .new-btn:active {
  transform: scale(0.97);
  background: var(--brand-100);
}



/* === Ingest activity buttons get a distinct, button-y outline ===
 * These are <button id="import_activity"> etc — actions that ADD a node to the canvas,
 * not existing items. Visual hint: brand-tinted border so users see them as "buttons" not "rows".
 */
.sidebar-v2 .ds-sidebar-list-row.create_operator {
  background: var(--surface) !important;
  border: 1px solid rgba(31, 79, 214, 0.22) !important;
  border-radius: var(--radius-md) !important;
  color: var(--brand-700);
  font-weight: 500;
  box-shadow: 0 1px 0 rgba(31,79,214,0.04), var(--shadow-1);
  cursor: pointer;
}
.sidebar-v2 .ds-sidebar-list-row.create_operator .icon {
  color: var(--brand-500);
}
.sidebar-v2 .ds-sidebar-list-row.create_operator .label {
  color: var(--brand-700);
}
.sidebar-v2 .ds-sidebar-list-row.create_operator:hover {
  background: var(--brand-50) !important;
  border-color: var(--brand-300) !important;
  box-shadow: var(--shadow-2);
  padding-left: 12px;            /* override the row-hover indent so buttons don't shift */
}
.sidebar-v2 .ds-sidebar-list-row.create_operator:active {
  transform: scale(0.99);
  box-shadow: inset 0 1px 2px rgba(31,79,214,0.10);
}


/* === Ingest activity buttons — hard outline + bold label === */
.sidebar-v2 .ds-sidebar-list-row.create_operator {
  background: var(--surface) !important;
  border: 1.5px solid var(--brand-500) !important;
  border-radius: var(--radius-md) !important;
  color: var(--brand-700);
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(31,79,214,0.10);
  cursor: pointer;
}
.sidebar-v2 .ds-sidebar-list-row.create_operator .label {
  color: var(--brand-700);
  font-weight: 700;
}
.sidebar-v2 .ds-sidebar-list-row.create_operator:hover {
  background: var(--brand-50) !important;
  border-color: var(--brand-600) !important;
  box-shadow: 0 4px 8px rgba(31,79,214,0.18);
}
.sidebar-v2 .ds-sidebar-list-row.create_operator:active {
  transform: scale(0.99);
  background: var(--brand-100) !important;
  box-shadow: inset 0 1px 2px rgba(31,79,214,0.18);
}


/* === Notebook / pipeline / dataflow / trigger list items — match the Ingest button outline ===
 * Same hard outline + bold label so users see every row as a distinct, clickable item.
 * Slightly less assertive than create_operator (line-strong instead of brand-500) to preserve
 * the "actions vs items" hierarchy.
 */
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row:not(.create_operator) {
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  font-weight: 600;
}
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row:not(.create_operator) .label {
  font-weight: 600;
  color: var(--ink-900);
}
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row:not(.create_operator):hover {
  background: var(--brand-50);
  border-color: var(--brand-300);
}
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row:not(.create_operator).is-active {
  background: var(--brand-50);
  border-color: var(--brand-500);
}
.sidebar-v2 .ds-sidebar-list .ds-sidebar-list-row:not(.create_operator).is-active .label {
  color: var(--brand-700);
}

/* ── Thin scrollbars, app-wide ─────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: rgba(130,140,160,0.40) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(130,140,160,0.38); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(130,140,160,0.62); background-clip: padding-box; }
html[data-theme="dark"] * { scrollbar-color: rgba(150,160,180,0.34) transparent; }
html[data-theme="dark"] *::-webkit-scrollbar-thumb { background: rgba(150,160,180,0.30); background-clip: padding-box; }
html[data-theme="dark"] *::-webkit-scrollbar-thumb:hover { background: rgba(150,160,180,0.52); background-clip: padding-box; }
