/* Shared Fruitbowl visual language. Load after page styles.
   Keep layout/geometry in feature CSS and semantic risk colours distinct. */
:root {
    --fb-canvas: #f3f5ef;
    --fb-paper: #fffef9;
    --fb-surface: #e9eee5;
    --fb-line: #d7e2dc;
    --fb-ink: #193c36;
    --fb-secondary: #546861;
    --fb-green: #236348;
    --fb-tint: #e7edde;
    --fb-focus: #5b782f;
    --fb-radius: 14px;
    --fb-shadow: 0 5px 20px rgba(25,60,54,.045);
}
html, body { background: var(--fb-canvas); color: var(--fb-ink); }
body:has(.shell:not(.theme-light)) { background: #08100e; color: #e9f3ec; }
.shell.theme-light {
    color-scheme: light;
    --fb-bg: var(--fb-canvas);
    --fb-panel: var(--fb-paper);
    --fb-panel-strong: var(--fb-paper);
    --fb-border: var(--fb-line);
    --fb-text: var(--fb-ink);
    --fb-muted: var(--fb-secondary);
    --fb-accent: var(--fb-green);
    --fb-warn: #8a5815;
    background: var(--fb-canvas);
    color: var(--fb-ink);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}
.shell.theme-light * { scrollbar-color: #abbcaf var(--fb-canvas); }
.shell.theme-light ::-webkit-scrollbar-track,
.shell.theme-light ::-webkit-scrollbar-corner { background: var(--fb-canvas); }
.shell.theme-light ::-webkit-scrollbar-thumb { background: #abbcaf; border-color: var(--fb-canvas); }
.shell.theme-light ::-webkit-scrollbar-thumb:hover { background: #819c8a; }
/* Keep heading typography in shared/page styles so both themes use the same scale. */
.shell.theme-light :is(h1,h2,h3,h4) { color: var(--fb-ink); }
.shell.theme-light h1:focus { outline: none; }
.shell.theme-light p { color: var(--fb-secondary); line-height: 1.7; }
.shell.theme-light .eyebrow { color: var(--fb-green); font-size: 11px; letter-spacing: .14em; }
.shell.theme-light :is(.page-intro,.context-note,.panel-title>span,.brand-subtitle) { color: var(--fb-secondary); }
.shell.theme-light :is(.page-header,.workspace-header) { margin-bottom: 26px; gap: 22px; }
.shell.theme-light .header-actions { flex-wrap: wrap; align-items: center; }

/* Shared surfaces: flat, readable cards rather than translucent dark panels. */
.shell.theme-light :is(.panel,.metric-card,.sidebar-card,.api-config-card,.market-alert-card,
    .project-card,.project-site-card,.company-result-card,.company-result,.agent-card,
    .owned-asset-card,.context-card,.crm-context-panel,.commercial-anchor-card,
    .strategic-anchor-card,.council-index-card,.council-action-card) {
    background: var(--fb-paper); color: var(--fb-ink); border-color: var(--fb-line);
    border-radius: var(--fb-radius); box-shadow: var(--fb-shadow); backdrop-filter: none;
}
.shell.theme-light .panel { padding: 22px; }
.shell.theme-light .metric-card { padding: 20px; }
.shell.theme-light .metric-card strong { color: var(--fb-ink); font-weight: 700; letter-spacing: -.03em; }
.shell.theme-light :is(.metric-card span,.metric-card small,.market-alert-card span,
    .market-alert-card small,.project-card p,.project-site-card p) { color: var(--fb-secondary); }
.shell.theme-light :is(.project-stat-row article,.project-summary-list div,.site-profile-evidence-strip div,
    .site-profile-evidence-list article,.council-coverage-grid>article,.council-summary-grid article) {
    background: var(--fb-paper); border-color: var(--fb-line); box-shadow: none; border-radius: 10px;
}
.shell.theme-light :is(.view-toggle,.site-profile-tab-rail,.project-filter-bar,.filter-bar) {
    background: var(--fb-surface); border-color: var(--fb-line); box-shadow: none;
}

/* Inputs and actions share the source library's solid green / quiet outline hierarchy. */
.shell.theme-light :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=hidden]),
    select,textarea,.input) {
    background: var(--fb-paper); color: var(--fb-ink); border: 1px solid #bdcdc3;
    border-radius: 8px; box-shadow: none; font: inherit; font-size: 14px;
}
.shell.theme-light :is(input,textarea)::placeholder { color: #677b70; opacity: 1; }
.shell.theme-light :is(label,label>span,.field-label,.stacked-form label) { color: var(--fb-secondary); }
.shell.theme-light :is(input,textarea,select) { font-weight: 400; }
.shell.theme-light .project-filter-bar { padding: 16px; border-radius: 10px; }
.shell.theme-light .workspace-tab-bar { background: var(--fb-surface); border-color: var(--fb-line); border-radius: 10px; }
.shell.theme-light .workspace-tab-bar button { background: transparent; color: var(--fb-ink); border-color: transparent; box-shadow: none; }
.shell.theme-light .workspace-tab-bar button.active { background: var(--fb-ink); color: var(--fb-paper); border-color: var(--fb-ink); }
.shell.theme-light .workspace-tab-bar button small { background: var(--fb-tint); color: var(--fb-ink); }
.shell.theme-light :is(select option,select optgroup) { background: var(--fb-paper); color: var(--fb-ink); }
.shell.theme-light :is(input[type=checkbox],input[type=radio],input[type=range]) { accent-color: var(--fb-green); }
.shell.theme-light :is(.primary-action,.primary-button,.run-button,.auth-submit) {
    background: var(--fb-ink); color: #fffef9; border: 1px solid var(--fb-ink);
    border-radius: 9px; box-shadow: none; font-weight: 650; text-decoration: none;
}
.shell.theme-light :is(.primary-action,.primary-button):hover:not(:disabled) { background: #28574c; border-color: #28574c; }
.shell.theme-light :is(.secondary-action,.ghost-button,.ghost-link-button,.mini-button,.theme-toggle) {
    background: var(--fb-paper); color: var(--fb-ink); border-color: #bdcdc3;
    border-radius: 8px; box-shadow: none; font-weight: 600;
}
.shell.theme-light :is(.secondary-action,.ghost-button,.ghost-link-button,.mini-button):hover:not(:disabled) {
    background: var(--fb-tint); border-color: #93ac99;
}
.shell.theme-light :is(button:disabled,input:disabled,select:disabled) { opacity: .6; cursor: not-allowed; }
.shell.theme-light :is(a,button,input,select,textarea,summary):focus-visible {
    outline: 3px solid var(--fb-focus); outline-offset: 3px;
}
.shell.theme-light :is(.view-toggle button.active,.site-profile-tab-button.active) {
    background: var(--fb-ink); color: white; border-color: var(--fb-ink);
}

.shell.theme-light :is(.catalogue-category-card,.catalogue-dataset-row) { background: var(--fb-paper); border-color: var(--fb-line); border-radius: 10px; box-shadow: none; }
.shell.theme-light .catalogue-category-header span { color: var(--fb-green); }
.shell.theme-light .catalogue-dataset-row strong { color: var(--fb-ink); }
.shell.theme-light .catalogue-dataset-row small { color: var(--fb-secondary); }
.shell.theme-light .catalogue-dataset-row:hover { background: var(--fb-tint); }
.shell.theme-light :is(.catalogue-check,.catalogue-category-icon) { background: var(--fb-tint); color: var(--fb-green); border-color: var(--fb-line); }
.shell.theme-light :is(.map-context-header,.map-control-console,.map-outcome-note,.map-load-strip>div,.map-settings-panel) { background: var(--fb-surface); color: var(--fb-ink); border-color: var(--fb-line); box-shadow: none; }
.shell.theme-light :is(.map-shell,.map-toolbar,.map-layer-rail,.feature-toggle-console,
    .map-style-switcher,.boundary-mode-toggle,.feature-toggle-card) { background: var(--fb-paper); border-color: var(--fb-line); color: var(--fb-ink); box-shadow: none; }
.shell.theme-light :is(.map-outcome-note strong,.map-style-switcher strong,.boundary-mode-toggle strong,
    .feature-toggle-card strong,.legend-label) { color: var(--fb-ink); }
.shell.theme-light :is(.map-outcome-note span,.map-style-switcher span,.boundary-mode-toggle span,
    .feature-toggle-card small,.map-load-strip small,.feature-toggle-heading small,.feature-toggle-heading span) { color: var(--fb-secondary); }
/* Legacy map labels declare important colours; override only these labels. */
.shell.theme-light .map-chip { background: #f5ecd8; color: #785112 !important; border-color: #dac693; }
.shell.theme-light .legend-label { color: var(--fb-ink) !important; }
.shell.theme-light .range-value { color: #785112; }
.shell.theme-light .market-alert-card b { background: #f5ecd8; color: #785112; border-color: #dac693; }
.shell.theme-light .feature-toggle-card b { background: var(--fb-tint); color: var(--fb-green); }

/* Tables and evidence retain their structure and status information. */
.shell.theme-light th {
    background: var(--fb-tint); color: var(--fb-ink); border-color: var(--fb-line);
    text-transform: none; letter-spacing: normal; font-weight: 650;
}
.shell.theme-light td { color: var(--fb-ink); border-color: var(--fb-line); }
.shell.theme-light :is(tr.clickable:hover,tr.selected-row) { background: #e4edde; }
.shell.theme-light :is(.score-pill,.site-tag-chip,.status-chip,.tag-chip) {
    border-radius: 20px; box-shadow: none;
}
.shell.theme-light :is(.status-message,.notice,.context-note-box) {
    background: var(--fb-tint); color: #344e3c; border-color: #b9cbb0;
}
.shell.theme-light :is(.status-message.warning,.status-message.error,.validation-message) {
    background: #fae9df; color: #843919; border-color: #deb29a;
}
.shell.theme-light :is(.status-message.success,.status-message.ok) { background: #e2edde; color: #285330; }

/* Navigation and overlays remain opaque and legible over maps. */
.shell.theme-light :is(.floating-brand-button,.floating-account-card,.floating-nav-panel,.account-popover,
    .row-action-menu>div,.project-site-action-menu-list,.floating-agent-panel,.filter-drawer,
    .alert-composer-modal,.project-modal,.modal-panel,.dialog-panel) {
    background: var(--fb-paper); border-color: var(--fb-line); color: var(--fb-ink);
    box-shadow: 0 12px 36px rgba(25,60,54,.12); backdrop-filter: none;
}
.shell.theme-light .brand-mark {
    background: var(--fb-ink); color: #f0f4d7; border: 0; box-shadow: none;
}
.shell.theme-light .account-avatar { background: var(--fb-tint); color: var(--fb-ink); }
.shell.theme-light :is(.account-copy strong,.brand-title,.account-popover a,.floating-agent-header strong) { color: var(--fb-ink); }
.shell.theme-light :is(.account-copy span,.brand-subtitle) { color: var(--fb-secondary); }
.shell.theme-light .floating-nav-panel .nav-section {
    background: transparent; border: 0; border-bottom: 1px solid var(--fb-line); border-radius: 0; padding: 12px 0;
}
.shell.theme-light .floating-nav-panel .nav-section>span { color: var(--fb-secondary); letter-spacing: .12em; font-size: 10px; text-transform: uppercase; }
.shell.theme-light .nav a { color: var(--fb-ink); font-weight: 550; padding: 10px 12px; }
.shell.theme-light :is(.nav a.active,.nav a:hover) { background: var(--fb-tint); color: var(--fb-ink); border-color: transparent; box-shadow: none; }
.shell.theme-light .nav a.active { box-shadow: inset 3px 0 0 var(--fb-green); font-weight: 700; }
.shell.theme-light .account-theme-button { background: var(--fb-surface); color: var(--fb-ink); border-color: var(--fb-line); }
.shell.theme-light :is(.floating-nav-scrim,.drawer-scrim,.alert-modal-scrim) { background: rgba(25,45,35,.3); }
.shell.theme-light :is(.leaflet-popup-content-wrapper,.leaflet-popup-tip) {
    background: var(--fb-paper); color: var(--fb-ink); border-color: var(--fb-line);
}
.shell.theme-light :is(.map-loading-overlay,.preview-loading-overlay) { background: rgba(243,245,239,.92); color: var(--fb-ink); }
.shell.theme-light :is(.filter-drawer h3,.drawer-subtitle) { color: var(--fb-green); }
.shell.theme-light .floating-agent-button { background: #e6efdc; color: #254b36; border-color: #73916b; box-shadow: 0 6px 18px #193c3620; }
.shell.theme-light :is(.floating-agent-status,.floating-agent-message.agent) { background: var(--fb-tint); color: var(--fb-ink); }

/* Knowledge is an application area, with a dashboard entry and a shared palette. */
.knowledge-entry { display: flex; justify-content: space-between; align-items: center; gap: 28px; margin-bottom: 24px; }
.knowledge-entry h2 { margin: 8px 0; }
.knowledge-entry p { margin-bottom: 0; max-width: 680px; }
.knowledge-entry .header-actions { flex-shrink: 0; }
.knowledge-entry .primary-action { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 10px 16px; }
.shell.theme-light .source-library {
    --ink: var(--fb-ink); --muted: var(--fb-secondary); --line: var(--fb-line); --paper: var(--fb-paper);
    background: var(--fb-canvas);
}
.shell.theme-light .source-library .library-overview { color: var(--fb-ink); }
.shell.theme-light .source-library .library-overview span { color: var(--fb-secondary); }

/* Source guides follow the account theme, including rendered Markdown content. */
.shell:not(.theme-light) .source-library {
    color-scheme: dark;
    --ink: #e3eee6; --muted: #b0c2b7; --line: #395348; --paper: #172b24;
    background: #102019; color: var(--ink);
}
.shell:not(.theme-light) .source-library :is(.draft-label,.library-filters,.library-notice,.facts-strip) {
    background: #22392c; color: var(--ink);
}
.shell:not(.theme-light) .source-library .source-category>h2 span { background: #2c4535; }
.shell:not(.theme-light) .source-library :is(.library-filters input,.library-filters select,.library-filters button,.detail-actions a,.guide-links a) {
    background: var(--paper); color: var(--ink); border-color: #587263;
}
.shell:not(.theme-light) .source-library input::placeholder { color: #a5baad; opacity: 1; }
.shell:not(.theme-light) .source-library :is(.detail-actions a,.guide-links a,.library-filters button):hover {
    background: #2c4535; border-color: #96ba93;
}
.shell:not(.theme-light) .source-library .brief-button { background: #315740; color: #f1f7eb !important; }
.shell:not(.theme-light) .source-library .brief-button:hover { background: #3c684d; }
.shell:not(.theme-light) .source-library .brief-button small { color: #d5e9bd; }
.shell:not(.theme-light) .source-library .source-card:hover { border-color: #96ba93; box-shadow: 0 8px 24px #0003; }
.shell:not(.theme-light) .source-library .card-tags span { background: #304037; color: #c6d4ca; }
.shell:not(.theme-light) .source-library .card-tags .delivery { background: #294c3a; color: #c2ecd0; }
.shell:not(.theme-light) .source-library .card-tags .legal-restricted { background: #543526; color: #ffd2b5; }
.shell:not(.theme-light) .source-library .card-tags .legal-conditional { background: #384a28; color: #d5e9ad; }
.shell:not(.theme-light) .source-library .library-notice { border-left-color: #a2bb75; }
.shell:not(.theme-light) .source-library .source-prose :is(h1,h2,h3,h4,th,td) { color: var(--ink); }
.shell:not(.theme-light) .source-library .source-prose :is(p,li) { color: #c5d4cb; }
.shell:not(.theme-light) .source-library .source-prose a { color: #b9dfa1; }
.shell:not(.theme-light) .source-library .source-prose blockquote { background: #22392c; border-left-color: #a2bb75; }
.shell:not(.theme-light) .source-library .source-prose pre { background: #0b1913; color: #dceccf; border: 1px solid var(--line); }
.shell:not(.theme-light) .source-library .source-prose :is(p,td,li) code { background: #2b4231; color: #d5e9bd; }
.shell:not(.theme-light) .source-library .source-prose th { background: #2b4231; }
.shell:not(.theme-light) .source-library .source-prose tr:nth-child(even) { background: #1d3228; }
.shell:not(.theme-light) .source-library :is(a,button,input,select):focus-visible { outline: 3px solid #bddb88; outline-offset: 4px; }

/* Readable source-library type scale, shared by light and dark themes. */
.shell .source-library { font-size: 17px; }
.shell .source-library .library-hero h1 { font-size: clamp(36px,4.5vw,60px); }
.shell .source-library .library-hero p { font-size: 19px; }
.shell .source-library :is(.library-brand,.draft-label,.card-tags span,.facts-strip dt,.contents>strong,.source-category>h2 span) { font-size: 14px; }
.shell .source-library :is(.library-overview span,.library-filters label,.result-count,.source-card dl div,.card-footer,.contents a,.source-prose footer,.brief-button small) { font-size: 16px; }
.shell .source-library :is(.detail-actions a,.guide-links a,.guide-theme-toggle,.library-filters input,.library-filters select,.library-filters button) { font-size: 16px; }
.shell .source-library :is(.source-card p,.library-notice p,.facts-strip dd,.source-prose p,.source-prose li) { font-size: 17px; line-height: 1.75; }
.shell .source-library :is(.source-card h3,.source-prose h3,.library-notice h2,.overview-note strong) { font-size: 22px; }
.shell .source-library :is(.source-category>h2,.source-prose h2) { font-size: 28px; }
.shell .source-library .library-overview>div>strong { font-size: 38px; }
.shell .source-library .library-overview .overview-note strong { font-size: 22px; }
.shell .source-library .source-prose table { font-size: 16px; }
.shell .source-library .source-prose pre { font-size: 16px; }
.shell .source-library .source-prose pre code { font-size: 1em; }
.shell .source-library .library-hero>div,
.shell .source-library .source-card { min-width: 0; overflow-wrap: anywhere; }
.shell .source-library .card-footer { flex-wrap: wrap; }
@media(max-width:750px) {
    .shell .source-library .library-hero h1 { font-size: 36px; }
    .shell .source-library .facts-strip { grid-template-columns: 1fr; }
    .shell .source-library .guide-theme-toggle { margin-top: 12px; }
}

@media(max-width:800px) {
    .knowledge-entry { align-items: flex-start; flex-direction: column; gap: 16px; }
    .knowledge-entry .header-actions { flex-wrap: wrap; width: 100%; }
    .shell.theme-light .panel { padding: 18px; }
    .shell.theme-light .page-header { flex-wrap: wrap; }
}
@media(prefers-reduced-motion:reduce) {
    .shell.theme-light :is(button,a,.filter-drawer) { transition: none; }
}


/* The reconnect dialog lives outside the interactive shell so its controls survive a disconnect. */
body:has(.shell.theme-light) #components-reconnect-modal {
    --reconnect-surface: #fffef9;
    --reconnect-text: #193c36;
    --reconnect-line: #bdcdc3;
    --reconnect-action: #236348;
    --reconnect-action-text: #fffef9;
    --reconnect-hover: #28574c;
    --reconnect-scheme: light;
}
