@layer theme, base, legacy, components, utilities;
@import "workspace-theme.css";
@layer legacy {
/* Each surface owns its ink, muted text, links and boundaries; nested surfaces reset them. */
:root {--surface-inset:clamp(16px,2vw,24px);--surface-radius:14px;}
/* Reference art keeps its original colors on a stable light canvas in every theme.
   Do not apply this treatment to live charts, map tiles, or map markers. */
:root :is(figure img, .instructional-image) {
 background:var(--color-neutral-white);
 border:1px solid var(--color-secondary-gray-medium);
 border-radius:8px;
 padding:12px;
 box-sizing:border-box;
 max-width:100%;
 height:auto;
 object-fit:contain;
 opacity:1;
 filter:none;
 mix-blend-mode:normal;
}
:root .instructional-image text {fill:var(--color-secondary-slate);}
/* Spacing belongs to the component, not a color preset. */
:root[data-theme-system] .library {border-color:var(--context-line);}
:root[data-theme-system] .library .local-note {border-color:var(--context-line);}
:root[data-theme-system] .experiment {padding:var(--surface-inset);border-radius:var(--surface-radius);}
:root[data-theme-system] .question-strip {padding:var(--surface-inset);border-radius:var(--surface-radius);}
:root[data-theme-system] {
 --context-bg:var(--ui-background);--context-ink:var(--ui-background-ink);--context-muted:var(--ui-background-muted);--context-link:var(--ui-background-link);--context-line:var(--ui-background-line);
 --ink:var(--ui-background-ink);--muted:var(--ui-background-muted);--paper:var(--ui-background);--line:var(--ui-background-line);--border:var(--ui-background-line);
}
:root[data-theme-system] body {background:var(--context-bg);color:var(--context-ink)}
:root[data-theme-system] :where(.feature,.detail,.summary,.lesson-reader,.library,.broker-panel,.topic-link,.device-card,.sensor-card,.steps a,.monitor-nav,article) {
 --context-bg:var(--ui-surface);--context-ink:var(--ui-surface-ink);--context-muted:var(--ui-surface-muted);--context-link:var(--ui-surface-link);--context-line:var(--ui-surface-line);
 background:var(--context-bg);color:var(--context-ink);border-color:var(--context-line);
}
:root[data-theme-system] :where(.panel,.library,body>main>section:not(.hero):not(.intro):not(.next)) {
 --context-bg:var(--ui-container);--context-ink:var(--ui-container-ink);--context-muted:var(--ui-container-muted);--context-link:var(--ui-container-link);--context-line:var(--ui-container-line);
 background:var(--context-bg);color:var(--context-ink);border-color:var(--context-line);
}
:root[data-theme-system] :where(.journey,.finish,.experiment,.reader-toolbar,.measurement,th,pre,details.student-answers,.coordinate-calculator,.coordinate-map-tools,.notice,.reading-note,.app-error,.empty,#chart-wrap,.charts,.badge,.summary>div,.question-strip) {
 --context-bg:var(--ui-panel);--context-ink:var(--ui-panel-ink);--context-muted:var(--ui-panel-muted);--context-link:var(--ui-panel-link);--context-line:var(--ui-panel-line);
 background:var(--context-bg);color:var(--context-ink);border-color:var(--context-line);
}
:root[data-theme-system] :where(.download-panel,.save-box,.device-card.selected,.sensor-card[aria-pressed=true],.measurement.temperature,.lesson-link[aria-current]) {
 --context-bg:var(--ui-support);--context-ink:var(--ui-support-ink);--context-muted:var(--ui-support-muted);--context-link:var(--ui-support-link);--context-line:var(--ui-support-line);
 background:var(--context-bg);color:var(--context-ink);border-color:var(--context-line);
}
:root[data-theme-system] :where(.site-header,.top,.topbar,body>header) {
 --context-bg:var(--ui-primary);--context-ink:var(--ui-primary-ink);--context-muted:var(--ui-primary-muted);--context-link:var(--ui-primary-ink);--context-line:var(--ui-primary-line);
 background:var(--context-bg);color:var(--context-ink);border-color:var(--ui-accent);
}
:root[data-theme-system] :where(h1,h2,h3,h4,p,li,label,strong,small,span,summary,output,td,th,.answer,.invalid,.journey-note,.eyebrow,.feature-icon,.stat-label,.course,.session,.steps b) {color:var(--context-ink)}
:root[data-theme-system] :where(.quiet,.small,.subtitle,.device-meta,.aside-note,.local-note,.site-footer,footer,.context,.hero-copy>p:not(.eyebrow),.topic-link span,.sensor-card span,td small) {color:var(--context-muted)}
:root[data-theme-system] :where(a,.secondary,.text-link,h1 em,.feature-link) {color:var(--context-link)}
:root[data-theme-system] :where(a:hover,a:active,a:visited) {color:var(--context-link)}
:root[data-theme-system] :where(h1 em,.feature-icon,.purpose) {text-decoration-color:var(--ui-accent);border-color:var(--ui-accent)}
:root[data-theme-system] :where(input,textarea,select,button,.button) {
 --context-bg:var(--ui-surface);--context-ink:var(--ui-surface-ink);--context-muted:var(--ui-surface-muted);--context-link:var(--ui-surface-link);--context-line:var(--ui-surface-line);
 background:var(--context-bg);color:var(--context-ink);border-color:var(--context-line);
}
/* Buttons that are cards retain their selected surface. */
:root[data-theme-system] :where(.device-card.selected,.sensor-card[aria-pressed=true]) {
 --context-bg:var(--ui-support);--context-ink:var(--ui-support-ink);--context-muted:var(--ui-support-muted);--context-link:var(--ui-support-link);--context-line:var(--ui-support-line);
 background:var(--context-bg);color:var(--context-ink);border-color:var(--context-line);
}
:root[data-theme-system] :where(.primary,a.button,.reader-pagination button,.step-number) {
 --context-bg:var(--ui-button);--context-ink:var(--ui-button-ink);--context-muted:var(--ui-button-muted);--context-link:var(--ui-button-ink);--context-line:var(--ui-button-line);
 background:var(--context-bg);color:var(--context-ink);border-color:var(--context-line);
}
:root[data-theme-system] :where(.primary:hover,a.button:hover,.reader-pagination button:hover) {
 --context-bg:var(--ui-primary);--context-ink:var(--ui-primary-ink);--context-muted:var(--ui-primary-muted);--context-link:var(--ui-primary-ink);--context-line:var(--ui-primary-line);
 background:var(--context-bg);color:var(--context-ink);border-color:var(--context-line);
}
/* Hover surfaces must replace the full color context, including nested labels.
   Legacy lesson hover fills otherwise retain ink from a different background. */
:root[data-theme-system] :where(.lesson-link:not([aria-current]):hover,.lesson-link:not([aria-current]):focus-visible) {
 --context-bg:var(--ui-panel);--context-ink:var(--ui-panel-ink);--context-muted:var(--ui-panel-muted);--context-link:var(--ui-panel-link);--context-line:var(--ui-panel-line);
 background:var(--context-bg);color:var(--context-ink);text-decoration:underline;text-underline-offset:3px;
}
:root[data-theme-system] :where(.lesson-link[aria-current]:hover,.lesson-link[aria-current]:focus-visible,.student-answers summary:hover,.student-answers summary:focus-visible) {
 --context-bg:var(--ui-support);--context-ink:var(--ui-support-ink);--context-muted:var(--ui-support-muted);--context-link:var(--ui-support-link);--context-line:var(--ui-support-line);
 background:var(--context-bg);color:var(--context-ink);border-color:var(--context-line);
}
:root[data-theme-system] :where(.identity-icon,.brand>span:first-child,.brand-mark,.pill) {
 --context-bg:var(--ui-accent-surface);--context-ink:var(--ui-accent-ink);--context-link:var(--ui-accent-ink);
 background:var(--context-bg);color:var(--context-ink);
}
:root[data-theme-system] :where(.site-header nav a,.top nav a) {border-bottom-color:var(--ui-primary)}
:root[data-theme-system] :where(.site-header nav a:hover,.site-header nav a[aria-current],.top nav a[aria-current]) {border-bottom-color:var(--ui-primary-ink)}
:root[data-theme-system] :where(td,th,.table-wrap,.reader-toolbar,.reader-pagination,.journey li,.journey-note,.student-answers summary) {border-color:var(--context-line)}
:root[data-theme-system] :where(input,textarea)::placeholder {color:var(--context-muted);opacity:1}
:root[data-theme-system] :where(a,button,input,select,textarea,summary):focus-visible {outline-color:var(--context-ink)}
:root[data-theme-system] :where(.hero,.intro,.next) {background:none}
:root[data-theme-system] #topic-grid .topic-link {border-left-color:var(--ui-accent)}
:root[data-theme-system] .charts {padding:12px;border-radius:8px}
:root[data-theme-system] #chart text,:root[data-theme-system] #chart .label {fill:var(--ui-panel-ink)}
:root[data-theme-system] #chart :is(.grid,.axis) {stroke:var(--ui-chart-grid)}
:root[data-theme-system] #chart .trace {stroke:var(--ui-panel-ink)}
:root[data-theme-system] #chart .c0 {fill:var(--ui-chart-blue)}
:root[data-theme-system] #chart .c1 {fill:var(--ui-chart-green)}
:root[data-theme-system] #chart .c5 {fill:var(--ui-panel-ink)}
:root[data-theme-system] .legend .c0,:root[data-theme-system] .legend.cool {background:var(--ui-chart-blue)}
:root[data-theme-system] .legend .c1,:root[data-theme-system] .legend.warm {background:var(--ui-chart-green)}
:root[data-theme-system] .legend .c5 {background:var(--ui-panel-ink)}
:root[data-theme-system] .sensor-grid {grid-auto-rows:1fr;}
/* Hierarchy and non-color selection cues. Inset focus contrasts with its own surface. */
:root[data-theme-system] :where(.sensor-card,.device-card,.topic-link) {position:relative;transition:transform .12s ease;}
:root[data-theme-system] :where(.sensor-card:hover,.device-card:hover,.topic-link:hover) {transform:translateY(-2px);box-shadow:inset 0 0 0 1px var(--context-line);}
:root[data-theme-system] :where(.sensor-card[aria-pressed=true],.device-card.selected) {box-shadow:inset 4px 0 0 var(--context-ink);padding-left:22px;}
:root[data-theme-system] .selection-label {display:block;font-size:11px;font-weight:750;letter-spacing:.06em;margin-top:10px;text-transform:uppercase;color:var(--context-ink);}
:root[data-theme-system] :where(a,button,input,select,textarea,summary):focus-visible {outline:3px solid var(--context-ink);outline-offset:-5px;}
@media(prefers-reduced-motion:reduce){:root[data-theme-system] :where(.sensor-card,.device-card,.topic-link){transition:none;transform:none}}
/* Keep the editor itself neutral and readable while experimenting. */
#theme-launcher {position:fixed;right:22px;bottom:20px;z-index:1100;background:var(--color-secondary-slate);color:var(--color-secondary-gray-light);border:2px solid var(--color-secondary-gray-medium);border-radius:30px;padding:12px 20px;cursor:pointer;font:650 14px/1.4 system-ui;}
#theme-editor {box-sizing:border-box;position:fixed;right:12px;bottom:78px;top:auto;left:auto;margin:0;z-index:1101;width:min(370px,calc(100vw - 24px));max-width:calc(100vw - 24px);max-height:calc(100dvh - 100px);overflow:auto;overscroll-behavior:contain;background:var(--color-secondary-gray-light);color:var(--color-secondary-slate);border:2px solid var(--color-secondary-gray-dark);border-radius:14px;font:14px/1.5 system-ui;letter-spacing:normal;text-align:left;}
#theme-editor .theme-editor-head {display:flex;justify-content:space-between;align-items:center;gap:14px;padding:17px;border-bottom:1px solid var(--color-secondary-gray-medium);background:var(--color-web-blue-light);position:sticky;top:0;z-index:1;}
#theme-editor .theme-editor-head strong {font-size:16px;color:var(--color-secondary-slate)}
#theme-editor .theme-editor-head p {font-size:12px;margin:2px 0 0;color:var(--color-secondary-gray-dark)}
#theme-editor .theme-editor-body {padding:18px}
#theme-editor .theme-help {font-size:12px;color:var(--color-secondary-gray-dark);margin:0 0 14px}
#theme-editor label {display:block;color:var(--color-secondary-slate);font-size:12px;font-weight:650;margin:0 0 5px}
#theme-editor select {box-sizing:border-box;width:100%;max-width:100%;margin:0;padding:9px 7px;background:var(--color-secondary-gray-light);color:var(--color-secondary-slate);border:1px solid var(--color-secondary-gray-dark);border-radius:5px;font:12px/1.4 system-ui}
#theme-editor #theme-preset {margin-bottom:12px}
#theme-editor .theme-field {margin:0 0 14px}
#theme-editor .theme-color-choice {display:grid;grid-template-columns:28px minmax(0,1fr);gap:9px;align-items:center}
#theme-editor .theme-swatch {display:block;width:28px;height:28px;border:1px solid var(--color-secondary-gray-dark);border-radius:6px}
#theme-editor button {display:inline-block;background:var(--color-secondary-gray-light);color:var(--color-secondary-slate);border:1px solid var(--color-secondary-gray-dark);border-radius:6px;padding:8px 10px;font:600 12px/1.4 system-ui;cursor:pointer;white-space:normal}
#theme-editor button:hover {background:var(--color-web-blue-light)}
#theme-editor .theme-actions {display:flex;gap:9px;flex-wrap:wrap;margin:14px 0 20px}
#theme-editor #theme-status {font-size:12px;color:var(--color-secondary-slate);background:var(--color-secondary-gold-light);padding:10px;border-left:3px solid var(--color-secondary-gold);margin:14px 0}
#theme-editor details {margin:16px 0 0;padding:0;border:0;background:var(--color-secondary-gray-light);color:var(--color-secondary-slate);font-size:12px}
#theme-editor summary {font-size:13px;font-weight:650;cursor:pointer;color:var(--color-secondary-slate);padding:8px 0}
#theme-editor .theme-table-wrap {overflow:auto}
#theme-editor table {font:11px/1.45 system-ui;display:table;border-collapse:collapse;min-width:540px;width:100%;margin:0}
#theme-editor :is(td,th) {border:1px solid var(--color-secondary-gray-medium);color:var(--color-secondary-slate);padding:8px;min-width:0;vertical-align:top;text-align:left;background:var(--color-secondary-gray-light);overflow-wrap:anywhere}
#theme-editor th {background:var(--color-web-blue-light)}
#theme-editor :is(button,select,summary):focus-visible,#theme-launcher:focus-visible {outline:3px solid var(--color-web-blue);outline-offset:3px}
#theme-editor[hidden] {display:none!important}
@media(max-width:600px){#theme-editor{right:12px;bottom:72px}#theme-launcher{right:12px;bottom:14px;padding:10px 16px}}
@media print{#theme-editor,#theme-launcher{display:none!important}}

/* SHARED NOTIFICATIONS BEGIN */
/* Shared notification component. Background and every text role travel together.
   Legacy aliases cover dynamically generated alerts as well as authored markup. */
:root body :is(.notification.notification,[role="alert"][role="alert"],.notice.notice,.app-error.app-error,.connection-result.connection-result) {
  --context-bg:var(--ui-panel,var(--color-neutral-mist));
  --context-ink:var(--ui-panel-ink,var(--color-secondary-slate));
  --context-muted:var(--ui-panel-muted,var(--color-secondary-gray-dark));
  --context-link:var(--ui-panel-link,var(--color-web-blue));
  --context-line:var(--ui-panel-line,var(--color-web-blue));
  box-sizing:border-box;min-width:0;max-width:100%;
  margin:1rem 0;padding:.85rem 1rem;
  border:1px solid var(--context-line);border-left:4px solid var(--context-line);border-radius:.6rem;
  background:var(--context-bg);color:var(--context-ink);
  font-size:.9375rem;line-height:1.55;overflow-wrap:anywhere;
}
:root[data-theme-system] body :is(.notification.notification,[role="alert"][role="alert"],.notice.notice,.app-error.app-error,.connection-result.connection-result) {
  background:var(--context-bg);color:var(--context-ink);border-color:var(--context-line);
}
:root body :is(.notification,[role="alert"],.notice,.app-error,.connection-result) :is(p,span,strong,small,h2,h3,h4,dt,dd,li) {color:var(--context-ink);}
:root body :is(.notification,[role="alert"],.notice,.app-error,.connection-result) :is(a,a:visited,a:hover) {color:var(--context-link);}
:root body :is(.notification,[role="alert"],.notice,.app-error,.connection-result) a:focus-visible {outline:2px solid var(--context-ink);outline-offset:3px;}
:root body :is(.notification,[role="alert"],.notice,.app-error,.connection-result) p:last-child {margin-bottom:0;}
:root body .notification--compact {padding:.5rem .75rem;font-size:.875rem;}
:root body :is(.notification-status,[role="status"]):not(.notification):not(.connection-result):not(#theme-status) {color:var(--context-ink,var(--ink,var(--color-secondary-slate)));overflow-wrap:anywhere;}
:root body :is(.notification,[role="alert"],.notice,.app-error,.connection-result)[hidden] {display:none!important;}
@media(max-width:520px){:root body :is(.notification,[role="alert"],.notice,.app-error,.connection-result){padding:.75rem;}}
/* SHARED NOTIFICATIONS END */
}
