/* ==========================================================================
   be—os Theme System  —  WORKSPACE + REVEAL
   Shared across all engines (BAE, BSE, BGE, PM)

   Default: Light workspace (off-white canvas, Ateneo blue accents)
   User toggle: data-theme="dark" for dark workspace preference
   Reveal mode: .beos-mode-reveal for loading screens, score reveals, drama

   Three tonal states:
   1. Workspace (light, default) — where users spend 90% of their time
   2. Dark workspace (user preference toggle) — same layout, dark canvas
   3. Reveal (dark + Volt) — dramatic moments, score reveals, loading

   Four layers:
   1. Canonical --beos-* tokens (per theme/mode)
   2. Tonal mode overrides (workspace = calm, reveal = Volt energy)
   3. Legacy aliases (--ink, --paper, --carbon, etc.) mapped to canonical
   4. Component styles
   ========================================================================== */


/* ==========================================================================
   WORKSPACE — LIGHT (default)
   Off-white canvas, navy text, Ateneo blue accents.
   Where users spend 90% of their time.
   ========================================================================== */

:root {
  /* ---- Foundation colours (Workspace palette) ---- */
  --beos-void:          #F0EEEB;        /* warm off-white canvas */
  --beos-carbon:        #E5E2DE;        /* card surface */
  --beos-signal:        #13181B;        /* deep navy text */
  --beos-dim:           #5C6169;        /* secondary text — 5.3:1 on off-white */

  /* ---- Accent identity: Ateneo blue ---- */
  --beos-volt:          #003A6C;        /* legacy token → workspace accent */
  --beos-charged:       #004D8F;        /* legacy token → workspace hover */

  /* ---- Legacy foundation names (map to workspace equivalents) ---- */
  --beos-frost:         var(--beos-signal);
  --beos-violet:        var(--beos-volt);
  --beos-violet-glow:   var(--beos-charged);
  --beos-deep-mauve:    var(--beos-dim);
  --beos-haze:          var(--beos-dim);

  /* ---- Semantic aliases ---- */
  --beos-bg:            var(--beos-void);
  --beos-text:          var(--beos-signal);
  --beos-text-dim:      var(--beos-dim);
  --beos-text-muted:    #7D8189;        /* decorative — large text only */
  --beos-accent:        #003A6C;        /* Ateneo Deep — 9.4:1 on off-white */
  --beos-accent-hover:  #004D8F;        /* Ateneo Mid — 7.0:1 on off-white */
  --beos-accent-muted:  rgba(0, 58, 108, 0.12);
  --beos-highlight:     #B07820;        /* Burnt Amber — key metrics — 4.6:1 */
  --beos-warm:          #C45A47;        /* Deep Coral — data secondary — 4.8:1 */
  --beos-border:        rgba(19, 24, 27, 0.15);
  --beos-border-strong: rgba(19, 24, 27, 0.28);
  --beos-surface:       rgba(19, 24, 27, 0.04);
  --beos-surface-hover: rgba(19, 24, 27, 0.07);

  /* ---- Status colours — WCAG AA on off-white and card ---- */
  --beos-success:       #217542;
  --beos-warning:       #B07820;        /* Burnt Amber */
  --beos-error:         #C45A47;        /* Deep Coral */
  --beos-info:          var(--beos-accent);

  /* ---- Typography ---- */
  --beos-font-display:  'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --beos-font-body:     'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --beos-font-mono:     'JetBrains Mono', 'Courier New', monospace;

  /* ---- Shadows (light canvas = soft, diffuse) ---- */
  --beos-shadow-sm:     0 1px 3px rgba(19, 24, 27, 0.08);
  --beos-shadow-md:     0 4px 12px rgba(19, 24, 27, 0.1);
  --beos-shadow-lg:     0 8px 24px rgba(19, 24, 27, 0.12);
  --beos-shadow-glow:   none;

  /* ---- Overlay ---- */
  --beos-overlay:       rgba(240, 238, 235, 0.88);

  /* ---- Scrollbar ---- */
  --beos-scrollbar:     rgba(19, 24, 27, 0.15);
  --beos-scrollbar-hover: rgba(19, 24, 27, 0.25);

  /* ---- Archetype wheel tokens (WHEEL-DARK-1) ---- */
  /* Consumed by system/shared/js/archetype-wheel.js via readPalette(). */
  --beos-wheel-primary:       #13181B;  /* filled primary dot */
  --beos-wheel-supportive:    #3A3F45;  /* filled supportive dot + halo */
  --beos-wheel-inactive:      #E5E2DE;  /* empty archetype node fill */
  --beos-wheel-node-stroke:   #5C6169;  /* hairline around node */
  --beos-wheel-grid:          #D5D2CE;  /* concentric rings */
  --beos-wheel-spoke:         #DDD9D5;  /* radial spokes */
  --beos-wheel-center-bg:     #F0EEEB;  /* center puck — matches canvas */
  --beos-wheel-cluster-label: #9A9EA4;  /* quadrant cluster names */
  --beos-wheel-sub-dot:       #9A9EA4;  /* sub-archetype dots on spokes */
  --beos-wheel-inactive-text: #7D8189;  /* archetype labels (non-diagnosed) */

  /* ---- Wheel tooltip + role-badge tokens (WHEEL-DARK-2) ---- */
  --beos-wheel-perceived:        #4A90C4;  /* PERCEIVED badge fill — Ateneo Blue */
  --beos-wheel-tooltip-bg:       #FFFFFF;  /* tooltip body */
  --beos-wheel-tooltip-divider:  #E6E3DE;  /* tooltip section rule + sticky-header underline */
  --beos-wheel-tooltip-row-hover:#FDFCFA;  /* sub-archetype row hover */
}


/* ==========================================================================
   DARK WORKSPACE (user preference toggle)
   Same layout, dark canvas. Ateneo Bright blue accents (not Volt).
   Toggle via data-theme="dark" on <html>
   ========================================================================== */

[data-theme="dark"] {
  /* ---- Foundation colours ---- */
  --beos-void:          #13181B;        /* deep navy canvas */
  --beos-carbon:        #1C2127;        /* card/lifted surface */
  --beos-signal:        #F0EEEB;        /* warm white text */
  --beos-dim:           #A0ABB2;        /* Polar Drift — 7.2:1 on navy */

  /* ---- Accent identity: Ateneo Bright (lighter blue for dark bg) ---- */
  --beos-volt:          #4A90C4;        /* legacy token → dark accent */
  --beos-charged:       #6BAAD8;        /* legacy token → dark hover */

  /* ---- Semantic aliases ---- */
  --beos-bg:            var(--beos-void);
  --beos-text:          var(--beos-signal);
  --beos-text-dim:      var(--beos-dim);
  --beos-text-muted:    #6B7A85;        /* decorative — large text only */
  --beos-accent:        #4A90C4;        /* Ateneo Bright — 5.5:1 on navy */
  --beos-accent-hover:  #6BAAD8;        /* Ateneo Light — 7.4:1 on navy */
  --beos-accent-muted:  rgba(74, 144, 196, 0.2);
  --beos-highlight:     #FFBF65;        /* Sea Buckthorn — 9.5:1 on navy */
  --beos-warm:          #FD8973;        /* Miami Coral — 5.8:1 on navy */
  --beos-border:        rgba(160, 171, 178, 0.18);
  --beos-border-strong: rgba(160, 171, 178, 0.32);
  --beos-surface:       rgba(240, 238, 235, 0.04);
  --beos-surface-hover: rgba(240, 238, 235, 0.07);

  /* ---- Status colours ---- */
  --beos-success:       #7ADB9B;
  --beos-warning:       #DBB07A;
  --beos-error:         #DB7A8A;
  --beos-info:          var(--beos-accent);

  /* ---- Shadows (dark canvas = heavier) ---- */
  --beos-shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.4);
  --beos-shadow-md:     0 4px 12px rgba(0, 0, 0, 0.5);
  --beos-shadow-lg:     0 8px 24px rgba(0, 0, 0, 0.6);
  --beos-shadow-glow:   none;

  /* ---- Overlay ---- */
  --beos-overlay:       rgba(19, 24, 27, 0.85);

  /* ---- Scrollbar ---- */
  --beos-scrollbar:     rgba(160, 171, 178, 0.2);
  --beos-scrollbar-hover: var(--beos-dim);

  /* ---- Archetype wheel tokens (WHEEL-DARK-1, Option A — signal inversion) ---- */
  /* Primary inverts to warm-white so the diagnosis reads as signal text does. */
  --beos-wheel-primary:       #F0EEEB;  /* warm-white primary dot */
  --beos-wheel-supportive:    #A0ABB2;  /* polar-drift gray — one step back */
  --beos-wheel-inactive:      #2A2F36;  /* subtle lifted node on navy */
  --beos-wheel-node-stroke:   #5C6169;  /* hairline stays mid-gray both ways */
  --beos-wheel-grid:          #242A31;  /* faint rings on navy */
  --beos-wheel-spoke:         #1C2127;  /* even fainter spokes */
  --beos-wheel-center-bg:     #13181B;  /* center puck matches dark canvas */
  --beos-wheel-cluster-label: #6B7A85;  /* muted cluster names */
  --beos-wheel-sub-dot:       #6B7A85;
  --beos-wheel-inactive-text: #6B7A85;

  /* ---- Wheel tooltip + role-badge tokens (WHEEL-DARK-2) ---- */
  --beos-wheel-perceived:        #6BAAD8;  /* PERCEIVED badge fill — Ateneo Light on navy */
  --beos-wheel-tooltip-bg:       #1C2127;  /* tooltip body — Carbon (lifted surface) */
  --beos-wheel-tooltip-divider:  #2A2F36;  /* matches inactive node fill — same family */
  --beos-wheel-tooltip-row-hover:rgba(240, 238, 235, 0.04);  /* very subtle warm wash */
}


/* ==========================================================================
   TONAL MODES
   Workspace: calm, understated — the default working state.
   Reveal: Volt energy — loading screens, score reveals, dramatic moments.

   .beos-mode-workspace  — explicit calm (optional, matches :root default)
   .beos-mode-reveal     — dark + Volt yellow accent
   ========================================================================== */

/* Workspace mode — dims accent for calm feel, removes glow */
.beos-mode-workspace {
  --beos-accent:        var(--beos-dim);
  --beos-accent-hover:  var(--beos-charged);
  --beos-accent-muted:  rgba(92, 97, 105, 0.12);
  --beos-shadow-glow:   none;
}

/* Workspace: CTAs still get accent colour for wayfinding */
.beos-mode-workspace .beos-cta,
.beos-mode-workspace [data-role="cta"],
.beos-mode-workspace .btn-cta,
.beos-mode-workspace .btn-primary,
.beos-mode-workspace .btn-save,
.beos-mode-workspace .btn-new,
.beos-mode-workspace .nav-tab.active {
  --beos-accent:        #003A6C;
}

/* ── Reveal mode — dark + Volt yellow ── */
.beos-mode-reveal {
  /* ---- Foundation: dark navy canvas ---- */
  --beos-void:          #13181B;
  --beos-carbon:        #1C2127;
  --beos-signal:        #F0EEEB;
  --beos-dim:           #C8C8C0;        /* bright secondary — ~10.8:1 on navy */

  /* ---- Volt accent identity ---- */
  --beos-volt:          #D4FF00;
  --beos-charged:       #A8CC00;

  /* ---- Semantic aliases ---- */
  --beos-bg:            var(--beos-void);
  --beos-text:          var(--beos-signal);
  --beos-text-dim:      var(--beos-dim);
  --beos-text-muted:    #6B7A85;
  --beos-accent:        #D4FF00;        /* Volt yellow — 13.1:1 on navy */
  --beos-accent-hover:  #A8CC00;        /* Charged — 8.8:1 on navy */
  --beos-accent-muted:  rgba(212, 255, 0, 0.25);
  --beos-highlight:     #FFBF65;        /* Sea Buckthorn scores */
  --beos-warm:          #FD8973;        /* Miami Coral */
  --beos-border:        rgba(200, 200, 192, 0.15);
  --beos-border-strong: rgba(200, 200, 192, 0.28);
  --beos-surface:       rgba(240, 238, 235, 0.04);
  --beos-surface-hover: rgba(240, 238, 235, 0.07);

  /* ---- Status colours ---- */
  --beos-success:       #7ADB9B;
  --beos-warning:       #DBB07A;
  --beos-error:         #DB7A8A;
  --beos-info:          var(--beos-charged);

  /* ---- Shadows (dark + glow) ---- */
  --beos-shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.4);
  --beos-shadow-md:     0 4px 12px rgba(0, 0, 0, 0.5);
  --beos-shadow-lg:     0 8px 24px rgba(0, 0, 0, 0.6);
  --beos-shadow-glow:   0 0 24px rgba(212, 255, 0, 0.15);

  /* ---- Overlay ---- */
  --beos-overlay:       rgba(19, 24, 27, 0.85);

  /* ---- Scrollbar ---- */
  --beos-scrollbar:     rgba(200, 200, 192, 0.2);
  --beos-scrollbar-hover: var(--beos-dim);

  /* ---- Archetype wheel tokens (WHEEL-DARK-1, reveal — Volt drama) ---- */
  /* Primary takes Volt yellow so it reads as the reveal moment's signal. */
  --beos-wheel-primary:       #D4FF00;  /* Volt — reveal accent */
  --beos-wheel-supportive:    #F0EEEB;  /* warm-white — stays legible */
  --beos-wheel-inactive:      #242A31;
  --beos-wheel-node-stroke:   #5C6169;
  --beos-wheel-grid:          #1C2127;
  --beos-wheel-spoke:         #13181B;
  --beos-wheel-center-bg:     #13181B;
  --beos-wheel-cluster-label: #C8C8C0;
  --beos-wheel-sub-dot:       #C8C8C0;
  --beos-wheel-inactive-text: #8B8B85;
}


/* ==========================================================================
   READABILITY SYSTEM
   Tokens and utility classes for comfortable reading of analysis results.
   MEWS-inspired: bigger text, generous line-height, constrained width,
   lifted backgrounds for content areas, alternating section rhythm.
   ========================================================================== */

:root,
[data-theme="dark"] {
  /* ---- Reading scale ---- */
  --beos-read-body:       1rem;            /* 16px — up from 14px */
  --beos-read-body-lg:    1.0625rem;       /* 17px — for narrative paragraphs */
  --beos-read-leading:    1.65;            /* comfortable line-height for body */
  --beos-read-leading-lg: 1.7;            /* extra generous for long text */
  --beos-read-max-width:  660px;           /* ~65-75 chars per line */
  --beos-read-gap:        1.25em;          /* paragraph spacing */

  /* ---- Heading scale (results) ---- */
  --beos-read-h2:         1.5rem;          /* 24px — section headings */
  --beos-read-h3:         1.2rem;          /* ~19px — sub-headings */
  --beos-read-h2-weight:  700;
}

/* Result content wrapper — lifted background for reading comfort */
.beos-result-content {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 28px 32px;
  margin-bottom: 16px;
}

/* Readable text block — constrained width + generous spacing */
.beos-readable {
  font-family: var(--beos-font-body);
  font-size: var(--beos-read-body);
  line-height: var(--beos-read-leading);
  color: var(--beos-text);
  max-width: var(--beos-read-max-width);
}

.beos-readable p {
  margin-bottom: var(--beos-read-gap);
}

.beos-readable p:last-child {
  margin-bottom: 0;
}

/* Narrative text — slightly larger for long-form analysis content */
.beos-narrative {
  font-size: var(--beos-read-body-lg);
  line-height: var(--beos-read-leading-lg);
}

/* Result section heading */
.beos-result-content h2,
.beos-read-heading {
  font-family: var(--beos-font-display);
  font-size: var(--beos-read-h2);
  font-weight: var(--beos-read-h2-weight);
  color: var(--beos-text);
  margin-bottom: 16px;
  line-height: 1.3;
}

.beos-result-content h3 {
  font-family: var(--beos-font-display);
  font-size: var(--beos-read-h3);
  font-weight: 600;
  color: var(--beos-text);
  margin-bottom: 12px;
  line-height: 1.35;
}

/* Alternating section backgrounds for visual rhythm */
.beos-section-alt {
  background: var(--beos-void);
}

/* Body text color — uses semantic token */
.beos-result-content,
.beos-readable {
  color: var(--beos-text);
}

.beos-result-content h2,
.beos-result-content h3,
.beos-result-content strong {
  color: var(--beos-text);
}

/* ── Dark workspace overrides ── */
[data-theme="dark"] .beos-result-content {
  background: #1C2127;
  color: #D8D8D0;
}

[data-theme="dark"] .beos-section-alt {
  background: #13181B;
}

[data-theme="dark"] .beos-readable {
  color: #D8D8D0;
}

[data-theme="dark"] .beos-result-content h2,
[data-theme="dark"] .beos-result-content h3,
[data-theme="dark"] .beos-result-content strong {
  color: var(--beos-text);
}

/* ── Reveal mode overrides ── */
.beos-mode-reveal .beos-result-content {
  background: #1C2127;
  color: #C8C8C0;
}

.beos-mode-reveal .beos-section-alt {
  background: #13181B;
}

.beos-mode-reveal .beos-readable {
  color: #C8C8C0;
}

.beos-mode-reveal .beos-result-content h2,
.beos-mode-reveal .beos-result-content h3,
.beos-mode-reveal .beos-result-content strong {
  color: var(--beos-text);
}


/* --------------------------------------------------------------------------
   AUTO-APPLY: Results View Readability
   Wrap any engine's results container with .beos-results-view to activate.
   Targets .report-section (BAE/BSE) and .section (BGE) child elements.
   -------------------------------------------------------------------------- */

/* Lifted background for each result section */
.beos-results-view .report-section,
.beos-results-view > .section {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 28px 32px;
  margin-bottom: 16px;
  color: var(--beos-text);
}

/* Alternating rhythm — every other section gets canvas bg */
.beos-results-view .report-section:nth-child(even),
.beos-results-view > .section:nth-child(even) {
  background: var(--beos-void);
}

/* Reading scale for body text inside result sections */
.beos-results-view .report-section p,
.beos-results-view .report-section li,
.beos-results-view .report-section .verdict-text,
.beos-results-view .report-section .ec-text,
.beos-results-view .report-section .ec-sub,
.beos-results-view .report-section .nm-reason,
.beos-results-view .report-section .cons-text,
.beos-results-view .report-section .cons-reasoning,
.beos-results-view .report-section .insight-pull,
.beos-results-view .report-section .reframe-rationale,
.beos-results-view .report-section .reframe-shift,
.beos-results-view > .section p,
.beos-results-view > .section li,
.beos-results-view > .section .context-interpretation,
.beos-results-view > .section .trajectory-box {
  font-size: var(--beos-read-body);
  line-height: var(--beos-read-leading);
}

/* Narrative-length text gets the larger scale */
.beos-results-view .verdict-text,
.beos-results-view .ec-text,
.beos-results-view .insight-pull,
.beos-results-view .context-interpretation {
  font-size: var(--beos-read-body-lg);
  line-height: var(--beos-read-leading-lg);
}

/* Paragraph spacing */
.beos-results-view .report-section p,
.beos-results-view > .section p {
  margin-bottom: var(--beos-read-gap);
}
.beos-results-view .report-section p:last-child,
.beos-results-view > .section p:last-child {
  margin-bottom: 0;
}

/* Headings stay full brightness */
.beos-results-view .report-section h2,
.beos-results-view .report-section h3,
.beos-results-view .report-section .section-title,
.beos-results-view .report-section .phase-label,
.beos-results-view .report-section strong,
.beos-results-view > .section h2,
.beos-results-view > .section h3,
.beos-results-view > .section .section-label,
.beos-results-view > .section strong {
  color: var(--beos-text);
}

/* Section titles — MEWS-inspired scale */
.beos-results-view .section-title,
.beos-results-view .section-label {
  font-size: var(--beos-read-h2);
  font-weight: var(--beos-read-h2-weight);
}

/* Constrain max-width for pure-text sections (readability) */
.beos-results-view .verdict-text,
.beos-results-view .ec-text,
.beos-results-view .insight-pull,
.beos-results-view .context-interpretation,
.beos-results-view .trajectory-box {
  max-width: var(--beos-read-max-width);
}

/* Card surfaces inside result sections */
.beos-results-view .arch-card,
.beos-results-view .comp-card,
.beos-results-view .cluster-card,
.beos-results-view .consequence-card,
.beos-results-view .reframe-card,
.beos-results-view .near-miss-item,
.beos-results-view .gap-item,
.beos-results-view .impl-card,
.beos-results-view .brief-field {
  background: var(--beos-surface);
}

/* ── Dark workspace overrides for auto-apply ── */
[data-theme="dark"] .beos-results-view .report-section,
[data-theme="dark"] .beos-results-view > .section {
  background: #1C2127;
  color: #D8D8D0;
}

[data-theme="dark"] .beos-results-view .report-section:nth-child(even),
[data-theme="dark"] .beos-results-view > .section:nth-child(even) {
  background: #13181B;
}

[data-theme="dark"] .beos-results-view .arch-card,
[data-theme="dark"] .beos-results-view .comp-card,
[data-theme="dark"] .beos-results-view .cluster-card,
[data-theme="dark"] .beos-results-view .consequence-card,
[data-theme="dark"] .beos-results-view .reframe-card,
[data-theme="dark"] .beos-results-view .near-miss-item,
[data-theme="dark"] .beos-results-view .gap-item,
[data-theme="dark"] .beos-results-view .impl-card,
[data-theme="dark"] .beos-results-view .brief-field {
  background: #13181B;
}

/* ── Reveal mode overrides for auto-apply ── */
.beos-mode-reveal .beos-results-view .report-section,
.beos-mode-reveal .beos-results-view > .section {
  background: #1C2127;
  color: #C8C8C0;
}

.beos-mode-reveal .beos-results-view .report-section:nth-child(even),
.beos-mode-reveal .beos-results-view > .section:nth-child(even) {
  background: #13181B;
}

.beos-mode-reveal .beos-results-view .arch-card,
.beos-mode-reveal .beos-results-view .comp-card,
.beos-mode-reveal .beos-results-view .cluster-card,
.beos-mode-reveal .beos-results-view .consequence-card,
.beos-mode-reveal .beos-results-view .reframe-card,
.beos-mode-reveal .beos-results-view .near-miss-item,
.beos-mode-reveal .beos-results-view .gap-item,
.beos-mode-reveal .beos-results-view .impl-card,
.beos-mode-reveal .beos-results-view .brief-field {
  background: #13181B;
}


/* ==========================================================================
   LEGACY ALIASES
   Maps old variable names (--ink, --paper, etc.) to canonical --beos-* tokens.
   Keeps BAE, BSE, PM working without rewriting every CSS rule.
   ========================================================================== */

:root,
[data-theme="dark"] {
  /* ---- BAE / BSE shorthand ---- */
  --ink:              var(--beos-text);
  --paper:            var(--beos-bg);
  --accent:           var(--beos-accent);
  --accent-dark:      var(--beos-deep-mauve);
  --accent-glow:      var(--beos-accent-hover);
  --mid:              var(--beos-text-dim);
  --border:           var(--beos-border);
  --white:            var(--beos-frost);
  --danger:           var(--beos-error);
  --section-bg:       var(--beos-surface);
  --card-bg:          var(--beos-surface);

  /* ---- BSE colour variants ---- */
  --purple:           var(--beos-accent);
  --purple-bg:        var(--beos-surface);
  --green:            var(--beos-success);
  --green-bg:         rgba(122, 219, 155, 0.1);
  --red:              var(--beos-error);
  --red-bg:           rgba(219, 122, 138, 0.1);
  --amber:            var(--beos-warning);
  --amber-bg:         rgba(219, 176, 122, 0.1);
  --grad-from:        var(--beos-accent);
  --grad-to:          var(--beos-accent-hover);

  /* ---- PM shorthand ---- */
  --carbon:           var(--beos-carbon);
  --carbon-light:     var(--beos-surface);
  --carbon-card:      var(--beos-surface);
  --carbon-border:    var(--beos-border);
  --frost:            var(--beos-frost);
  --violet:           var(--beos-violet);
  --violet-glow:      var(--beos-violet-glow);
  --deep-mauve:       var(--beos-deep-mauve);
  --haze:             var(--beos-haze);
  --success:          var(--beos-success);
  --warning:          var(--beos-warning);
  --error:            var(--beos-error);

  /* ---- Shared font references ---- */
  --font-display:     'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --font-body:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --beos-font-heading:'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --beos-font-ui:     'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --beos-font-body:   'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}


/* ==========================================================================
   THEME TOGGLE COMPONENT
   Sun/moon icon toggle — sits in the bottom-right of every engine
   ========================================================================== */

.beos-theme-toggle {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 999;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--beos-border);
  background: var(--beos-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 200ms ease, border-color 200ms ease;
}

.beos-theme-toggle:hover {
  background: var(--beos-surface-hover);
  border-color: var(--beos-border-strong);
}

/* Moon icon (shown in light mode — click to go dark) */
.beos-theme-toggle .icon-sun {
  display: none;
}
.beos-theme-toggle .icon-moon {
  display: block;
}

/* Sun icon (shown in dark mode — click to go light) */
[data-theme="dark"] .beos-theme-toggle .icon-sun {
  display: block;
}
[data-theme="dark"] .beos-theme-toggle .icon-moon {
  display: none;
}

.beos-theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: var(--beos-text-dim);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.beos-theme-toggle:hover svg {
  stroke: var(--beos-accent);
}


/* ==========================================================================
   SMOOTH THEME TRANSITION
   Applied to body — prevents jarring flash on toggle
   ========================================================================== */

body.beos-themed {
  transition: background-color 300ms ease, color 300ms ease;
}

body.beos-themed *:not(.no-theme-transition) {
  transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease, box-shadow 300ms ease;
}


/* ==========================================================================
   NEXT ENGINE CTA
   "Continue to [Engine]" wayfinding button at the bottom of results.
   Guides users through the BAE -> BSE -> BGE pipeline.
   ========================================================================== */

.next-engine-cta {
  margin-top: 48px;
  padding: 32px 0 16px;
  text-align: center;
}

.next-engine-divider {
  width: 48px;
  height: 2px;
  background: var(--beos-border-strong);
  margin: 0 auto 24px;
}

.next-engine-label {
  font-family: var(--beos-font-body);
  font-size: 0.85rem;
  color: var(--beos-text-dim);
  margin-bottom: 16px;
  line-height: 1.5;
}

.btn-next-engine {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  font-family: var(--beos-font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--beos-void);
  background: var(--beos-accent);
  border: none;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: background 200ms ease, box-shadow 200ms ease, transform 150ms ease;
}

.btn-next-engine:hover {
  background: var(--beos-accent-hover);
  box-shadow: var(--beos-shadow-glow);
  transform: translateY(-1px);
}

.btn-next-engine:active {
  transform: translateY(0);
}

.btn-next-engine .arrow {
  font-size: 1.1em;
  transition: transform 200ms ease;
}

.btn-next-engine:hover .arrow {
  transform: translateX(3px);
}

/* Reveal mode: Volt button with dark text */
.beos-mode-reveal .btn-next-engine {
  color: #13181B;
  background: #D4FF00;
}
.beos-mode-reveal .btn-next-engine:hover {
  background: #A8CC00;
}

/* Dark workspace: light text on blue button */
[data-theme="dark"] .btn-next-engine {
  color: #F0EEEB;
}


/* ==========================================================================
   CMS SUMMARY CARD
   Compact read-only brand context shown in engine forms when launched
   from CMS (?project=). Replaces locked brand profile fields.
   ========================================================================== */

.cms-summary-card {
  display: none;
  background: var(--beos-carbon, #E5E2DE);
  border: 1px solid var(--beos-border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 32px;
}

.cms-summary-card.visible {
  display: block;
}

.cms-summary-brand {
  font-family: var(--beos-font-display, 'Space Grotesk', sans-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--beos-signal, #13181B);
  margin-bottom: 4px;
}

.cms-summary-meta {
  font-family: var(--beos-font-body, 'Inter', sans-serif);
  font-size: 0.82rem;
  color: var(--beos-text-dim, #5C6169);
  margin-bottom: 12px;
}

.cms-summary-promise {
  font-family: var(--beos-font-body, 'Inter', sans-serif);
  font-size: 0.82rem;
  font-style: italic;
  color: var(--beos-text-dim, #5C6169);
  margin-bottom: 12px;
  line-height: 1.5;
}

.cms-summary-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.cms-summary-row {
  font-family: var(--beos-font-body, 'Inter', sans-serif);
  font-size: 0.78rem;
  line-height: 1.4;
}

.cms-summary-row .label {
  color: var(--beos-dim, #5C6169);
}

.cms-summary-row .value {
  color: var(--beos-signal, #13181B);
}

.cms-summary-edit {
  font-family: var(--beos-font-ui, 'Space Grotesk', sans-serif);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--beos-accent);
  text-decoration: none;
  transition: color 0.2s;
}

.cms-summary-edit:hover {
  color: var(--beos-accent-hover);
}


/* ==========================================================================
   ENGINE HEADER NAVIGATION
   Shared header component: logo, flow indicator, project breadcrumb,
   back-to-CMS link. Used across BAE, BSE and BGE.
   ========================================================================== */

.beos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--beos-header-height, 64px);
  padding: 0 24px;
  background: var(--beos-void, #F0EEEB);
  border-bottom: 1px solid var(--beos-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.beos-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.beos-header-logo {
  font-family: var(--beos-font-display, 'Space Grotesk', sans-serif);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--beos-accent);
  text-decoration: none;
  letter-spacing: 1px;
}

.beos-header-logo .logo-sub {
  color: var(--beos-text-dim, #5C6169);
  font-weight: 400;
  font-size: 0.7rem;
  margin-left: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline;   /* single-row header — never stack */
}

.beos-header-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--beos-font-ui, 'Space Grotesk', sans-serif);
  font-size: 0.7rem;
  color: var(--beos-text-dim, #5C6169);
  letter-spacing: 0.03em;
}

.beos-header-flow a {
  color: var(--beos-text-dim, #5C6169);
  text-decoration: none;
  transition: color 0.2s;
}

.beos-header-flow a:hover {
  color: var(--beos-accent);
}

.beos-header-flow .flow-current {
  color: var(--beos-accent);
  font-weight: 600;
}

.beos-header-flow .flow-arrow {
  color: var(--beos-border-strong, rgba(19,24,27,0.28));
  font-size: 0.6em;
}

.beos-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.beos-header-project {
  font-family: var(--beos-font-body, 'Inter', sans-serif);
  font-size: 0.75rem;
  color: var(--beos-text-dim, #5C6169);
}

.beos-header-project strong {
  color: var(--beos-signal, #13181B);
}

.beos-header-project a {
  color: var(--beos-text-dim, #5C6169);
  text-decoration: none;
}

.beos-header-project a:hover {
  color: var(--beos-accent);
}


/* ==========================================================================
   KEYBOARD FOCUS STYLES  —  :focus-visible with accent outline
   Applied globally across all engines via shared theme
   ========================================================================== */

*:focus-visible {
  outline: 2px solid var(--beos-accent, #003A6C);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Buttons and interactive elements — slightly more prominent */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[role="tab"]:focus-visible,
select:focus-visible {
  outline: 2px solid var(--beos-accent, #003A6C);
  outline-offset: 2px;
}

/* Text inputs and textareas — inset glow instead of outline */
input:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--beos-accent, #003A6C);
  box-shadow: 0 0 0 2px var(--beos-accent-muted, rgba(0, 58, 108, 0.12));
}

/* Toggle switches / chips — ring style */
[role="switch"]:focus-visible,
.chip:focus-visible,
.platform-chip:focus-visible {
  outline: 2px solid var(--beos-accent, #003A6C);
  outline-offset: 2px;
}


/* ==========================================================================
   SHARED LOADING OVERLAY  —  Unified brain-icon progress bar
   Used by BAE, BSE, BGE — always uses REVEAL palette (dark + Volt)
   ========================================================================== */

.beos-loading {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #13181B;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.beos-loading.active { display: flex; }

/* ── Title ── */
.beos-loading-label {
  font-family: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 3px;
  color: #F0EEEB;
}

/* ── Step text ── */
.beos-loading-step {
  font-size: 0.82rem;
  color: #C8C8C0;
  margin-top: 6px;
  margin-bottom: 4px;
}

/* ── Brain icon + ring ── */
.beos-loader-wrapper {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 20px auto 0;
}
.beos-loader-ring {
  width: 96px;
  height: 96px;
  border: 5px solid rgba(240, 238, 235, 0.15);
  border-top-color: #D4FF00;
  border-radius: 50%;
  animation: beos-spin 0.8s linear infinite;
}
.beos-loader-brain {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  opacity: 0.7;
  color: #F0EEEB;
}
@keyframes beos-spin { to { transform: rotate(360deg); } }

/* ── Progress bar (optional — used by BSE, BGE) ── */
.beos-loading-progress {
  width: 200px;
  height: 2px;
  background: rgba(240, 238, 235, 0.15);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 16px;
}
.beos-loading-progress-bar {
  height: 100%;
  background: #D4FF00;
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
}

/* ── Cancel button ── */
.beos-loading-cancel {
  margin-top: 28px;
  padding: 8px 24px;
  font-family: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #C8C8C0;
  background: transparent;
  border: 1px solid rgba(200, 200, 192, 0.25);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.beos-loading-cancel:hover {
  color: #F0EEEB;
  border-color: #F0EEEB;
}

/* ── Toast notification ── */
.beos-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--beos-carbon, #E5E2DE);
  border: 1px solid var(--beos-accent, #003A6C);
  color: var(--beos-signal, #13181B);
  padding: 12px 24px;
  border-radius: 8px;
  font-family: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.beos-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Dark mode toast */
[data-theme="dark"] .beos-toast {
  background: #1C2127;
  color: #F0EEEB;
}


/* ==========================================================================
   ERROR / INFO BANNER  —  Replaces alert() across all engines
   ========================================================================== */

.beos-banner {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  max-width: 480px;
  width: calc(100% - 48px);
  padding: 14px 40px 14px 18px;
  border-radius: 8px;
  font-family: var(--beos-font-body, 'Inter', sans-serif);
  font-size: 0.85rem;
  line-height: 1.45;
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.beos-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.beos-banner-dismiss {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.6;
  padding: 2px 6px;
  line-height: 1;
}
.beos-banner-dismiss:hover { opacity: 1; }

/* Error variant */
.beos-banner.error {
  background: var(--beos-carbon, #E5E2DE);
  border: 1px solid var(--beos-error, #C45A47);
  color: var(--beos-signal, #13181B);
  border-left: 3px solid var(--beos-error, #C45A47);
}

/* Warning variant */
.beos-banner.warning {
  background: var(--beos-carbon, #E5E2DE);
  border: 1px solid var(--beos-warning, #B07820);
  color: var(--beos-signal, #13181B);
  border-left: 3px solid var(--beos-warning, #B07820);
}

/* Info variant */
.beos-banner.info {
  background: var(--beos-carbon, #E5E2DE);
  border: 1px solid var(--beos-accent, #003A6C);
  color: var(--beos-signal, #13181B);
  border-left: 3px solid var(--beos-accent, #003A6C);
}

/* Dark mode banners */
[data-theme="dark"] .beos-banner.error,
[data-theme="dark"] .beos-banner.warning,
[data-theme="dark"] .beos-banner.info {
  background: #1C2127;
  color: #F0EEEB;
}


/* ==========================================================================
   CARTOGRAPHIC LAYER  —  Phase 1 elements
   Spec: beos_cartographic-layer_v1.docx (Sasan, March 2026)
   ========================================================================== */

/* ── Coordinate footer ── */
.beos-coord-footer {
  font-family: var(--beos-font-mono, 'JetBrains Mono', monospace);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--beos-dim, #5C6169);
  text-align: center;
  padding: 20px 0 16px;
  opacity: 0.6;
}
.beos-mode-reveal .beos-coord-footer {
  color: #A8CC00;
  opacity: 0.8;
}

/* ── Grid lines (faint cartographic graticule for hero sections) ── */
.beos-grid-bg {
  position: relative;
}
.beos-grid-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--beos-border, rgba(19,24,27,0.15)) 1px, transparent 1px),
    linear-gradient(to bottom, var(--beos-border, rgba(19,24,27,0.15)) 1px, transparent 1px);
  background-size: 80px 80px;
  opacity: 0.2;
  z-index: 0;
}
.beos-mode-reveal .beos-grid-bg::before {
  opacity: 0.5;
}
.beos-grid-bg > * {
  position: relative;
  z-index: 1;
}

/* ── Degree notation ── */
.beos-degree {
  font-family: var(--beos-font-mono, 'JetBrains Mono', monospace);
  letter-spacing: 0.04em;
}
.beos-degree::after {
  content: '\00B0';
}
