/* ═══════════════════════════════════════════════
   Beast Builder — "Forge" Design System
   Industrial Command Center aesthetic
   Dark-first · Amber accents · Technical typography
   ═══════════════════════════════════════════════ */

/* ── Fonts ──────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

/* ── Design Tokens ──────────────────────────── */
:root {
  color-scheme: dark;
  /* Surfaces */
  --bb-bg: #0c0c0e;
  --bb-bg-elevated: #111114;
  --bb-topbar-bg: rgba(12, 12, 14, 0.88);
  --bb-sidebar-bg: rgba(16, 16, 20, 0.92);
  --bb-surface: rgba(22, 22, 28, 0.88);
  --bb-surface-solid: #161620;
  --bb-surface-muted: #1a1a22;
  --bb-surface-2: rgba(30, 30, 38, 0.92);
  /* Borders */
  --bb-border: rgba(255, 255, 255, 0.08);
  --bb-border-glow: rgba(255, 180, 50, 0.12);
  --bb-separator: rgba(255, 255, 255, 0.06);
  /* Text */
  --bb-text: rgba(240, 238, 232, 0.94);
  --bb-muted: rgba(200, 196, 186, 0.62);
  --bb-faint: rgba(180, 176, 168, 0.38);
  /* Accent — Amber/Gold (Forge fire) */
  --bb-primary: #e8a020;
  --bb-primary-strong: #f0b030;
  --bb-primary-soft: rgba(232, 160, 32, 0.14);
  --bb-primary-glow: rgba(232, 160, 32, 0.25);
  /* Status */
  --bb-danger: #ef4444;
  --bb-danger-soft: rgba(239, 68, 68, 0.16);
  --bb-ok: #22c55e;
  --bb-ok-soft: rgba(34, 197, 94, 0.14);
  --bb-warn: #f59e0b;
  --bb-warn-soft: rgba(245, 158, 11, 0.16);
  /* Shadows */
  --bb-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  --bb-shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
  --bb-shadow-hover: 0 16px 40px rgba(0, 0, 0, 0.45);
  --bb-shadow-pop: 0 16px 40px rgba(232, 160, 32, 0.12);
  --bb-shadow-glow: 0 0 20px rgba(232, 160, 32, 0.08);
  /* Radii */
  --bb-radius-xl: 14px;
  --bb-radius-lg: 10px;
  --bb-radius-md: 8px;
  --bb-radius-sm: 6px;
  --bb-pill: 999px;
  /* Layout */
  --bb-max-width: 1260px;
  --bb-scroll-margin-top: 140px;
  /* Washes */
  --bb-accent-wash-a: rgba(232, 160, 32, 0.08);
  --bb-accent-wash-b: rgba(232, 120, 20, 0.06);
  /* Grid pattern */
  --bb-grid-color: rgba(255, 255, 255, 0.025);
  --bb-grid-size: 60px;
}

/* Light theme override */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bb-bg: #f0ede8;
    --bb-bg-elevated: #f7f5f0;
    --bb-topbar-bg: rgba(247, 245, 240, 0.90);
    --bb-sidebar-bg: rgba(240, 237, 232, 0.92);
    --bb-surface: rgba(255, 253, 248, 0.90);
    --bb-surface-solid: #fdfcf8;
    --bb-surface-muted: #f2efe8;
    --bb-surface-2: rgba(235, 232, 224, 0.92);
    --bb-border: rgba(0, 0, 0, 0.10);
    --bb-border-glow: rgba(200, 140, 20, 0.18);
    --bb-separator: rgba(0, 0, 0, 0.07);
    --bb-text: #1a1816;
    --bb-muted: #6b6560;
    --bb-faint: rgba(60, 56, 50, 0.45);
    --bb-primary: #c07810;
    --bb-primary-strong: #a86808;
    --bb-primary-soft: rgba(192, 120, 16, 0.12);
    --bb-primary-glow: rgba(192, 120, 16, 0.18);
    --bb-shadow: 0 18px 44px rgba(0, 0, 0, 0.12);
    --bb-shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.08);
    --bb-shadow-hover: 0 14px 32px rgba(0, 0, 0, 0.12);
    --bb-shadow-pop: 0 14px 32px rgba(192, 120, 16, 0.14);
    --bb-shadow-glow: 0 0 16px rgba(192, 120, 16, 0.06);
    --bb-grid-color: rgba(0, 0, 0, 0.025);
  }
}

/* ── Reset ──────────────────────────────────── */
* {
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bb-bg);
  color: var(--bb-text);
  font-family: 'Outfit', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Subtle grid background */
  background-image:
    linear-gradient(var(--bb-grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--bb-grid-color) 1px, transparent 1px);
  background-size: var(--bb-grid-size) var(--bb-grid-size);
  background-attachment: fixed;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
}

img {
  max-width: 100%;
}

/* ── Shell Layout ───────────────────────────── */
.bb-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

/* ── Sidebar ────────────────────────────────── */
.bb-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding:
    max(14px, env(safe-area-inset-top))
    10px
    14px
    max(10px, env(safe-area-inset-left));
}

.bb-sidebar-inner {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--bb-border);
  border-radius: var(--bb-radius-xl);
  background: var(--bb-sidebar-bg);
  box-shadow: var(--bb-shadow-soft);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
}

/* Brand block */
.bb-brand {
  display: block;
  padding: 16px;
  border-radius: var(--bb-radius-lg);
  background: linear-gradient(135deg, var(--bb-surface-solid), var(--bb-surface-muted));
  border: 1px solid var(--bb-border-glow);
  position: relative;
  overflow: hidden;
}

.bb-brand::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--bb-primary), transparent);
  opacity: 0.6;
}

.bb-brand-kicker {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bb-primary);
}

.bb-brand-title {
  margin-top: 6px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--bb-text), var(--bb-primary-strong));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.bb-brand-sub {
  margin-top: 8px;
  color: var(--bb-muted);
  font-size: 0.82rem;
}

.bb-sidebar-note {
  align-self: end;
  padding: 12px 14px;
  border-radius: var(--bb-radius-md);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-muted);
  color: var(--bb-faint);
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* ── Navigation ─────────────────────────────── */
.bb-nav {
  display: grid;
  gap: 4px;
  align-content: start;
}

.bb-nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-radius: var(--bb-radius-md);
  border: 1px solid transparent;
  color: var(--bb-muted);
  background: transparent;
  font-weight: 500;
  font-size: 0.92rem;
  transition: all 180ms ease;
  position: relative;
}

.bb-nav-left {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.bb-nav-badge {
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: var(--bb-pill);
  background: var(--bb-warn);
  color: #0c0c0e;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  animation: bb-badge-pulse 2s ease-in-out infinite;
}

@keyframes bb-badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.bb-nav-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.bb-nav-label {
  min-width: 0;
}

.bb-nav a:hover {
  background: var(--bb-surface);
  border-color: var(--bb-border);
  color: var(--bb-text);
}

.bb-nav a.bb-active {
  background: var(--bb-primary-soft);
  border-color: var(--bb-border-glow);
  color: var(--bb-primary-strong);
  box-shadow: var(--bb-shadow-glow);
}

.bb-nav a.bb-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--bb-primary);
}

/* ── Main Content Area ──────────────────────── */
.bb-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ─────────────────────────────────── */
.bb-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding:
    max(18px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    14px
    max(24px, env(safe-area-inset-left));
  background: var(--bb-topbar-bg);
  border-bottom: 1px solid var(--bb-border);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}

.bb-topbar-inner {
  width: 100%;
  max-width: var(--bb-max-width);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

/* ── Page Header ────────────────────────────── */
.bb-page-head {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.bb-page-kicker {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bb-primary);
}

.bb-page-kicker:empty,
.bb-page-subtitle:empty {
  display: none;
}

.bb-page-title {
  margin: 0;
  font-size: clamp(1.8rem, 2.4vw, 2.5rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.bb-page-subtitle {
  margin: 0;
  max-width: 64ch;
  color: var(--bb-muted);
  font-size: clamp(0.9rem, 1vw, 0.96rem);
  line-height: 1.5;
}

.bb-top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Content Area ───────────────────────────── */
.bb-content {
  width: 100%;
  max-width: var(--bb-max-width);
  margin: 0 auto;
  padding:
    24px
    max(24px, env(safe-area-inset-right))
    calc(40px + env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  /* Page entrance animation */
  animation: bb-page-in 400ms ease-out;
}

@keyframes bb-page-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bb-content [id] {
  scroll-margin-top: calc(env(safe-area-inset-top) + var(--bb-scroll-margin-top));
}

/* ── Mobile Tab Bar (hidden on desktop) ─────── */
.bb-tabbar {
  display: none;
}

/* ── Typography Utilities ───────────────────── */
.bb-muted { color: var(--bb-muted); }
.bb-faint { color: var(--bb-faint); }
.bb-small { font-size: 0.88rem; }

.bb-mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

.bb-strong { font-weight: 700; }
.bb-stronger { font-weight: 800; }

/* ── Stack / Grid Layout ────────────────────── */
.bb-stack, .bb-stack-sm, .bb-stack-lg { display: grid; }
.bb-stack { gap: 14px; }
.bb-stack-sm { gap: 10px; }
.bb-stack-lg { gap: 20px; }

.bb-grid-2, .bb-grid-3 { display: grid; gap: 16px; }
.bb-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bb-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.bb-split {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(300px, 0.82fr);
  gap: 18px;
}

/* ── Cards ──────────────────────────────────── */
.bb-card {
  min-width: 0;
  border-radius: var(--bb-radius-xl);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-solid);
  box-shadow: var(--bb-shadow-soft);
  padding: 20px;
  transition: box-shadow 220ms ease, border-color 220ms ease, transform 220ms ease;
  position: relative;
}

.bb-card-tonal {
  background: var(--bb-surface);
}

.bb-card-muted {
  background: var(--bb-surface-muted);
  box-shadow: none;
}

/* ── Hero Section ───────────────────────────── */
.bb-hero {
  padding: 24px;
  background: linear-gradient(135deg, var(--bb-surface-muted), var(--bb-surface-solid));
  border-color: var(--bb-border-glow);
  position: relative;
  overflow: hidden;
}

.bb-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--bb-primary), var(--bb-primary-strong), transparent);
  opacity: 0.7;
}

.bb-hero::after {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--bb-primary-glow), transparent 70%);
  pointer-events: none;
}

.bb-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 20px;
  align-items: start;
  position: relative;
  z-index: 1;
}

/* ── Section Headers ────────────────────────── */
.bb-section-kicker,
.bb-section-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--bb-primary);
}

.bb-section-title {
  margin: 6px 0 0 0;
  font-size: clamp(1.15rem, 1.3vw, 1.32rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.18;
}

.bb-section-note {
  margin: 10px 0 0 0;
  color: var(--bb-muted);
  line-height: 1.55;
}

.bb-card h2,
.bb-card h3 {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.bb-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.bb-section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Dividers ───────────────────────────────── */
.bb-divider {
  height: 1px;
  margin: 8px 0;
  background: var(--bb-separator);
}

/* ── Row / Meta ─────────────────────────────── */
.bb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bb-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── KPI Cards ──────────────────────────────── */
.bb-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.bb-kpi {
  padding: 16px;
  border-radius: var(--bb-radius-lg);
  border: 1px solid var(--bb-border);
  background: linear-gradient(145deg, var(--bb-surface-solid), var(--bb-surface-muted));
  position: relative;
  overflow: hidden;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.bb-kpi:hover {
  border-color: var(--bb-border-glow);
  box-shadow: var(--bb-shadow-glow);
}

.bb-kpi::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--bb-primary-soft), transparent);
}

.bb-kpi .bb-kpi-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--bb-muted);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bb-kpi .bb-kpi-value {
  margin-top: 8px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--bb-text), var(--bb-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── List Component ─────────────────────────── */
.bb-list {
  border-radius: var(--bb-radius-lg);
  border: 1px solid var(--bb-border);
  overflow: hidden;
  background: var(--bb-surface-solid);
}

.bb-list-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 16px;
  transition: background 180ms ease;
}

.bb-list-row + .bb-list-row {
  border-top: 1px solid var(--bb-separator);
}

a.bb-list-row:hover {
  background: var(--bb-primary-soft);
}

.bb-list-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--bb-faint);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bb-list-title {
  margin-top: 3px;
  font-weight: 600;
  font-size: 0.94rem;
}

.bb-list-value {
  max-width: 56%;
  text-align: right;
  color: var(--bb-text);
  font-size: 0.92rem;
}

/* ── Project Cards ──────────────────────────── */
.bb-project-list {
  display: grid;
  gap: 12px;
}

.bb-project-card {
  padding: 18px;
  border-radius: var(--bb-radius-xl);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-solid);
  box-shadow: var(--bb-shadow-soft);
  transition: all 220ms ease;
  position: relative;
  overflow: hidden;
}

.bb-project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--bb-primary), transparent);
  opacity: 0;
  transition: opacity 220ms ease;
}

.bb-project-card:hover {
  box-shadow: var(--bb-shadow-hover);
  border-color: var(--bb-border-glow);
  transform: translateY(-1px);
}

.bb-project-card:hover::before {
  opacity: 1;
}

.bb-project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.bb-project-title {
  font-size: 1.1rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.bb-project-subtitle {
  margin-top: 3px;
  color: var(--bb-muted);
  font-size: 0.88rem;
}

.bb-project-summary {
  margin-top: 12px;
  color: var(--bb-muted);
  font-size: 0.92rem;
}

.bb-project-links {
  margin-top: 14px;
}

.bb-project-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Sticky Elements ────────────────────────── */
/* NOTE: Large summary cards should NOT be sticky — they block
   content on scroll when taller than the viewport gap.
   Only truly compact single-line headers should be sticky.       */
.bb-job-sticky-runner,
.bb-page-sticky-summary,
.bb-project-sticky-header,
.bb-research-sticky-header,
.bb-jobs-sticky-summary {
  position: static;
}

.bb-project-secondary {
  margin-top: 12px;
}

.bb-inline-select {
  width: auto;
  min-width: 220px;
}

/* ── Rich Text ──────────────────────────────── */
.bb-richtext { display: grid; gap: 12px; }
.bb-richtext > :first-child { margin-top: 0; }
.bb-richtext > :last-child { margin-bottom: 0; }
.bb-richtext h1, .bb-richtext h2, .bb-richtext h3, .bb-richtext h4 {
  margin: 0; line-height: 1.2; letter-spacing: -0.02em;
}
.bb-richtext p, .bb-richtext ul, .bb-richtext ol, .bb-richtext blockquote { margin: 0; }
.bb-richtext ul, .bb-richtext ol { padding-left: 20px; }
.bb-richtext blockquote {
  padding-left: 14px;
  border-left: 3px solid var(--bb-primary-soft);
  color: var(--bb-muted);
}

/* ── Page Links ─────────────────────────────── */
.bb-page-links { margin-bottom: 18px; }

/* ── Spacing Utilities ──────────────────────── */
.bb-m0 { margin: 0; }
.bb-mt-4 { margin-top: 4px; }
.bb-mt-6 { margin-top: 6px; }
.bb-mt-8 { margin-top: 8px; }
.bb-mt-10 { margin-top: 10px; }
.bb-mt-12 { margin-top: 12px; }
.bb-mt-14 { margin-top: 14px; }
.bb-mt-16 { margin-top: 16px; }

/* ── Flex Utilities ─────────────────────────── */
.bb-row-start { align-items: flex-start; }
.bb-row-between { justify-content: space-between; }
.bb-row-end { justify-content: flex-end; }
.bb-gap-10 { gap: 10px; }

/* ── List Utilities ─────────────────────────── */
.bb-list-reset { margin: 0; padding-left: 18px; }
.bb-list-offset { margin: 6px 0 0 18px; }
.bb-li-gap-6 > li { margin: 6px 0; }
.bb-li-gap-8 > li { margin: 8px 0; }
.bb-li-gap-10 > li { margin: 10px 0; }

/* ── Pre Height Utilities ───────────────────── */
.bb-pre-h-140 { max-height: 140px; }
.bb-pre-h-220 { max-height: 220px; }
.bb-pre-h-240 { max-height: 240px; }
.bb-pre-h-260 { max-height: 260px; }
.bb-pre-h-300 { max-height: 300px; }
.bb-pre-h-360 { max-height: 360px; }

/* ── Buttons ────────────────────────────────── */
.bb-btn, .bb-chip, .bb-input, .bb-select, .bb-textarea, .bb-nav a, .bb-tabbar a {
  -webkit-tap-highlight-color: transparent;
}

.bb-btn {
  min-height: 40px;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: var(--bb-radius-md);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-2);
  color: var(--bb-text);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: none;
  transition: all 180ms ease;
}

.bb-btn:hover {
  background: var(--bb-surface);
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
  box-shadow: var(--bb-shadow-soft);
}

.bb-btn:active {
  transform: translateY(0) scale(0.98);
}

.bb-btn:disabled,
.bb-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.bb-btn-primary {
  border-color: rgba(232, 160, 32, 0.3);
  background: linear-gradient(135deg, var(--bb-primary), var(--bb-primary-strong));
  color: #0c0c0e;
  font-weight: 700;
  box-shadow: 0 2px 12px rgba(232, 160, 32, 0.2);
}

.bb-btn-primary:hover {
  background: linear-gradient(135deg, var(--bb-primary-strong), var(--bb-primary));
  box-shadow: 0 4px 20px rgba(232, 160, 32, 0.3);
  border-color: rgba(232, 160, 32, 0.5);
}

.bb-btn-secondary {
  background: var(--bb-surface-2);
}

.bb-btn-danger {
  border-color: rgba(239, 68, 68, 0.25);
  background: var(--bb-danger-soft);
  color: var(--bb-danger);
}

.bb-btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.4);
}

.bb-btn-link {
  min-height: 40px;
  padding: 0 6px;
  border-color: transparent;
  background: transparent;
  color: var(--bb-primary);
  box-shadow: none;
}

.bb-btn-link:hover {
  background: var(--bb-primary-soft);
  border-color: transparent;
  transform: none;
}

/* External link arrow */
.bb-btn[target="_blank"]::after,
.bb-chip[target="_blank"]::after,
.bb-badge[target="_blank"]::after {
  content: "↗";
  margin-left: 0.35em;
  font-size: 0.88em;
  opacity: 0.65;
}

.bb-btn[target="_blank"]::after {
  margin-left: 0.4em;
  transform: translateY(-0.5px);
}

/* ── Badges ─────────────────────────────────── */
.bb-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  min-height: 24px;
  border-radius: var(--bb-pill);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-2);
  color: var(--bb-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
}

.bb-badge-ok {
  border-color: rgba(34, 197, 94, 0.2);
  background: var(--bb-ok-soft);
  color: var(--bb-ok);
}

.bb-badge-warn {
  border-color: rgba(245, 158, 11, 0.2);
  background: var(--bb-warn-soft);
  color: var(--bb-warn);
}

.bb-badge-danger {
  border-color: rgba(239, 68, 68, 0.2);
  background: var(--bb-danger-soft);
  color: var(--bb-danger);
}

.bb-badge-neutral {
  background: var(--bb-surface-2);
}

/* ── Chips ──────────────────────────────────── */
.bb-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bb-chip {
  min-height: 34px;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: var(--bb-pill);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-2);
  color: var(--bb-muted);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 180ms ease;
}

.bb-chip:hover {
  color: var(--bb-text);
  background: var(--bb-surface);
  box-shadow: var(--bb-shadow-glow);
  border-color: var(--bb-border-glow);
}

.bb-chip.bb-active {
  color: #0c0c0e;
  background: var(--bb-primary);
  border-color: var(--bb-primary);
  box-shadow: 0 2px 12px rgba(232, 160, 32, 0.25);
}

/* ── Decision Focus ─────────────────────────── */
.bb-decision-focus {
  border-color: var(--bb-border-glow);
  box-shadow:
    0 0 0 3px var(--bb-primary-soft),
    var(--bb-shadow-glow);
  scroll-margin-top: 180px;
}

/* ── Actions Container ──────────────────────── */
.bb-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.bb-actions form { margin: 0; }

/* ── Form Elements ──────────────────────────── */
.bb-field { display: grid; gap: 6px; }

.bb-label {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.bb-help {
  color: var(--bb-muted);
  font-size: 0.84rem;
}

.bb-input,
.bb-select,
.bb-textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: var(--bb-radius-md);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-muted);
  color: var(--bb-text);
  outline: none;
  box-shadow: none;
  font-size: 0.92rem;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.bb-input:focus,
.bb-select:focus,
.bb-textarea:focus {
  border-color: var(--bb-primary);
  box-shadow: 0 0 0 3px var(--bb-primary-soft), var(--bb-shadow-glow);
}

.bb-btn:focus-visible,
.bb-chip:focus-visible,
.bb-nav a:focus-visible,
.bb-tabbar a:focus-visible,
a.bb-list-row:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bb-primary-soft);
}

.bb-textarea {
  min-height: 100px;
  resize: vertical;
}

/* ── Dropzone ───────────────────────────────── */
.bb-dropzone {
  position: relative;
  display: grid;
  min-height: 88px;
  padding: 14px 16px;
  border-radius: var(--bb-radius-lg);
  border: 1.5px dashed var(--bb-border);
  background: linear-gradient(180deg, var(--bb-surface), var(--bb-surface-muted));
  cursor: pointer;
  transition: all 200ms ease;
}

.bb-dropzone:hover {
  border-color: var(--bb-border-glow);
  box-shadow: var(--bb-shadow-glow);
}

.bb-dropzone.bb-dropzone-active {
  border-color: var(--bb-primary);
  background: linear-gradient(180deg, var(--bb-surface), var(--bb-accent-wash-a));
  box-shadow: 0 0 0 3px var(--bb-primary-soft), var(--bb-shadow-glow);
}

.bb-dropzone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.bb-dropzone-body {
  pointer-events: none;
  display: grid;
  gap: 4px;
}

.bb-dropzone-title {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.bb-dropzone-subtitle {
  color: var(--bb-muted);
  font-size: 0.88rem;
}

.bb-dropzone-filename {
  margin-top: 10px;
  color: var(--bb-faint);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.82rem;
}

/* ── Tables ─────────────────────────────────── */
.bb-table-wrap { overflow: auto; }

.bb-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--bb-radius-lg);
  overflow: hidden;
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-solid);
}

.bb-table th,
.bb-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--bb-separator);
  vertical-align: top;
}

.bb-table th {
  text-align: left;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--bb-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--bb-surface-muted);
  position: sticky;
  top: 0;
  z-index: 1;
}

.bb-table tr:last-child td { border-bottom: none; }
.bb-table td:last-child { white-space: nowrap; }
.bb-table tbody tr { transition: background 160ms ease; }

.bb-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}

.bb-table tr:hover td {
  background: var(--bb-primary-soft);
}

/* ── Code / Pre ─────────────────────────────── */
.bb-pre {
  margin: 0;
  padding: 14px;
  max-height: 520px;
  overflow: auto;
  border-radius: var(--bb-radius-lg);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-muted);
  white-space: pre-wrap;
  line-height: 1.55;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.82rem;
}

/* ── Alerts ─────────────────────────────────── */
.bb-alert {
  padding: 14px 16px;
  border-radius: var(--bb-radius-lg);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-muted);
}

.bb-alert-danger {
  border-color: rgba(239, 68, 68, 0.2);
  background: var(--bb-danger-soft);
}

.bb-alert-ok {
  border-color: rgba(34, 197, 94, 0.2);
  background: var(--bb-ok-soft);
}

.bb-alert-warn {
  border-color: rgba(245, 158, 11, 0.2);
  background: var(--bb-warn-soft);
}

/* ── Feedback Notice ────────────────────────── */
.bb-feedback-note {
  display: grid;
  gap: 10px;
}

.bb-feedback-head {
  display: grid;
  gap: 4px;
}

.bb-feedback-body {
  line-height: 1.55;
}

.bb-feedback-actions,
.bb-empty-state-actions {
  align-items: flex-start;
}

/* ── Empty State ────────────────────────────── */
.bb-empty-state {
  display: grid;
  gap: 12px;
  border-style: dashed;
}

.bb-empty-state .bb-section-label { margin-bottom: 2px; }
.bb-empty-state h3 { font-size: 1.02rem; }

.bb-empty-state-body {
  line-height: 1.6;
  max-width: 62ch;
}

.bb-empty-state-ok {
  border-color: rgba(34, 197, 94, 0.2);
  background: var(--bb-surface-muted);
}

.bb-empty-state-warn {
  border-color: rgba(245, 158, 11, 0.2);
  background: var(--bb-surface-muted);
}

.bb-empty-state-danger {
  border-color: rgba(239, 68, 68, 0.2);
  background: var(--bb-surface-muted);
}

/* ── Details / Collapsible ──────────────────── */
details.bb-details {
  border: 1px solid var(--bb-border);
  border-radius: var(--bb-radius-lg);
  background: var(--bb-surface-solid);
  overflow: hidden;
}

details.bb-details > summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  padding: 13px 18px;
  font-weight: 650;
  transition: background 180ms ease, color 180ms ease;
}

details.bb-details > summary::-webkit-details-marker { display: none; }

details.bb-details > summary::after {
  content: "›";
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bb-faint);
  font-size: 1.1em;
  transition: transform 200ms ease;
}

details.bb-details > summary:hover {
  background: var(--bb-primary-soft);
}

details.bb-details[open] > summary::after {
  transform: translateY(-50%) rotate(90deg);
}

details.bb-details[open] > summary {
  border-bottom: 1px solid var(--bb-separator);
  background: var(--bb-primary-soft);
}

details.bb-details > :not(summary) {
  margin: 0;
  padding: 14px 18px 18px 18px;
}

details.bb-details[open] > :not(summary) {
  animation: bb-details-in 220ms ease;
}

@keyframes bb-details-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Breadcrumbs ────────────────────────────── */
.bb-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  color: var(--bb-muted);
  font-size: 0.88rem;
}

.bb-breadcrumb a { color: inherit; }
.bb-breadcrumb a:hover { color: var(--bb-primary); }

.bb-sep { color: var(--bb-faint); }

/* ── Steps / Progress ───────────────────────── */
.bb-steps {
  margin: 0;
  padding-left: 20px;
}

.bb-steps li { margin: 10px 0; }

.bb-step-done {
  color: var(--bb-ok);
  font-weight: 650;
}

.bb-step-current {
  color: var(--bb-primary);
  font-weight: 700;
}

.bb-step-failed {
  color: var(--bb-danger);
  font-weight: 700;
}

.bb-step-skipped {
  color: var(--bb-warn);
  font-weight: 700;
}

.bb-step-pending {
  color: var(--bb-muted);
}

/* ── Toasts ─────────────────────────────────── */
.bb-toasts {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  width: min(400px, calc(100vw - 32px));
  z-index: 100;
}

.bb-toast {
  overflow: hidden;
  border-radius: var(--bb-radius-lg);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface);
  box-shadow: var(--bb-shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: bb-toast-in 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bb-toast-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
}

.bb-toast-msg {
  font-weight: 650;
  font-size: 0.92rem;
}

.bb-toast-x {
  min-height: 32px;
  min-width: 32px;
  appearance: none;
  border-radius: var(--bb-radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--bb-muted);
  cursor: pointer;
  transition: background 140ms ease;
}

.bb-toast-x:hover {
  background: rgba(255, 255, 255, 0.08);
}

.bb-toast-leave {
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  transition: opacity 180ms ease, transform 180ms ease;
}

.bb-toast-ok {
  border-color: rgba(34, 197, 94, 0.2);
  background: var(--bb-ok-soft);
  border-left: 3px solid var(--bb-ok);
}

.bb-toast-warn {
  border-color: rgba(245, 158, 11, 0.2);
  background: var(--bb-warn-soft);
  border-left: 3px solid var(--bb-warn);
}

.bb-toast-danger {
  border-color: rgba(239, 68, 68, 0.2);
  background: var(--bb-danger-soft);
  border-left: 3px solid var(--bb-danger);
}

@keyframes bb-toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 1100px) {
  .bb-topbar-inner,
  .bb-hero-grid {
    grid-template-columns: 1fr;
  }

  .bb-split,
  .bb-grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .bb-shell {
    grid-template-columns: 1fr;
  }

  .bb-sidebar {
    display: none;
  }

  .bb-topbar {
    padding-bottom: 12px;
  }

  /* sticky overrides already static globally — no mobile override needed */

  .bb-topbar-inner {
    gap: 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .bb-top-actions {
    justify-content: flex-start;
  }

  .bb-content {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .bb-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding:
      8px
      max(8px, env(safe-area-inset-right))
      calc(8px + env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    border-top: 1px solid var(--bb-border);
    background: var(--bb-topbar-bg);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
  }

  .bb-tabbar a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border-radius: var(--bb-radius-md);
    border: 1px solid transparent;
    color: var(--bb-muted);
    font-size: 0.8rem;
    font-weight: 600;
  }

  .bb-tabbar a.bb-active {
    background: var(--bb-primary-soft);
    color: var(--bb-primary);
    border-color: var(--bb-border-glow);
  }

  .bb-grid-2,
  .bb-kpis {
    grid-template-columns: 1fr;
  }

  .bb-list-row {
    flex-direction: column;
  }

  .bb-list-value {
    max-width: 100%;
    text-align: left;
  }
}

/* ── Workflow Progress Bar ───────────────────── */
.bb-wf-progress {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px 20px;
  margin-bottom: 16px;
  border-radius: var(--bb-radius-xl);
  border: 1px solid var(--bb-border);
  background: var(--bb-surface-solid);
}

.bb-wf-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.bb-wf-dot {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--bb-border);
  background: var(--bb-surface-muted);
  color: var(--bb-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  transition: all 250ms ease;
}

.bb-wf-done .bb-wf-dot {
  border-color: var(--bb-ok);
  background: var(--bb-ok-soft);
  color: var(--bb-ok);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.15);
}

.bb-wf-current .bb-wf-dot {
  border-color: var(--bb-primary);
  background: var(--bb-primary-soft);
  color: var(--bb-primary);
  box-shadow: 0 0 12px rgba(232, 160, 32, 0.2);
  animation: bb-badge-pulse 2s ease-in-out infinite;
}

.bb-wf-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--bb-muted);
  letter-spacing: 0.02em;
}

.bb-wf-done .bb-wf-label { color: var(--bb-ok); }
.bb-wf-current .bb-wf-label { color: var(--bb-primary); }

.bb-wf-line {
  flex: 1;
  height: 2px;
  min-width: 24px;
  background: var(--bb-border);
  margin: 0 4px;
  margin-bottom: 22px;
  transition: background 250ms ease;
}

.bb-wf-line-done {
  background: var(--bb-ok);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.15);
}

/* ── Spinner ─────────────────────────────────── */
.bb-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: bb-spin 600ms linear infinite;
  vertical-align: middle;
}

@keyframes bb-spin {
  to { transform: rotate(360deg); }
}

/* ── Stagger Animation for Cards ────────────── */
.bb-stack-lg > *:nth-child(1) { animation-delay: 0ms; }
.bb-stack-lg > *:nth-child(2) { animation-delay: 60ms; }
.bb-stack-lg > *:nth-child(3) { animation-delay: 120ms; }
.bb-stack-lg > *:nth-child(4) { animation-delay: 180ms; }
.bb-stack-lg > *:nth-child(5) { animation-delay: 240ms; }

.bb-stack-lg > * {
  animation: bb-card-in 350ms ease-out both;
}

@keyframes bb-card-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Settings Tabs ──────────────────────────── */
.bb-settings-tabs {
  margin-bottom: 16px;
  padding: 8px 0;
  position: sticky;
  top: calc(env(safe-area-inset-top) + 70px);
  z-index: 15;
  background: var(--bb-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ── Modal ───────────────────────────────────── */
.bb-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: bb-modal-fade-in 180ms ease;
}

.bb-modal {
  width: min(420px, calc(100vw - 40px));
  border-radius: var(--bb-radius-xl);
  border: 1px solid var(--bb-border-glow);
  background: var(--bb-surface-solid);
  box-shadow: var(--bb-shadow), 0 0 40px rgba(232, 160, 32, 0.08);
  overflow: hidden;
  animation: bb-modal-in 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bb-modal-body {
  padding: 24px 24px 16px;
  display: grid;
  gap: 10px;
}

.bb-modal-msg {
  font-size: 0.96rem;
  line-height: 1.55;
  font-weight: 500;
}

.bb-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 24px 20px;
}

.bb-modal-leave {
  opacity: 0;
  transition: opacity 180ms ease;
}

@keyframes bb-modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes bb-modal-in {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Scrollbar Styling ──────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.10);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ── Selection ──────────────────────────────── */
::selection {
  background: var(--bb-primary-soft);
  color: var(--bb-text);
}
