/* Shared surfaces and compatibility aliases for component styles. */
:root {
    color-scheme: light;
    --panel: #fff;
    --panel-soft: #f4f0fb;
    --theme-panel: var(--panel);
    --theme-panel-soft: var(--panel-soft);
    --accent-solid: #7940c7;
}

.icon-dark { display: none; }
:root[data-theme="dark"] .icon-light { display: none; }
:root[data-theme="dark"] .icon-dark { display: inline; }

:root[data-theme="dark"] {
    color-scheme: dark;
    --ink: #edf1f8;
    --muted: #b1bfd4;
    --purple: #c6a0ff;
    --border: #3b4860;
    --surface: #101725;
    --panel: #192335;
    --panel-soft: #222c40;
    --banner-background: linear-gradient(115deg, #18223b, #29213d 70%, #202c46);
    --banner-copy: #cbd4e5;
    --banner-accent: #d5b5ff;
    --theme-border: var(--border);
    --theme-ink: var(--ink);
    --theme-muted: var(--muted);
    --theme-accent: var(--purple);
    --theme-blue: #9dbaff;
    --theme-accent-soft: #302543;
    --theme-success: #88dfc2;
    --theme-success-soft: #173b35;
    --theme-danger: #ffb1bb;
    --theme-danger-soft: #422831;
    --theme-warning: #f3d28c;
    --theme-warning-soft: #3d3322;
    background: var(--surface);
    color: var(--ink);
}

body { background: var(--surface); color: var(--ink); }
/* The published figure controls its own background; transparent iframe canvases stay transparent. */
:root:has([data-analysis-embed]), body:has([data-analysis-embed]) { background:transparent; color-scheme:normal; }
dialog { background: var(--panel); color: var(--ink); }
input, textarea, select { accent-color: var(--accent-solid); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
:root[data-theme="dark"] :is(input, textarea, select) { color: var(--ink); }
:root[data-theme="dark"] :is(input, textarea):autofill { box-shadow: 0 0 0 1000px var(--panel-soft) inset; -webkit-text-fill-color: var(--ink); }
:root[data-theme="dark"] :is(a, button, input, select, textarea, summary):focus-visible { outline-color: #c6a0ff; }
:root[data-theme="dark"] ::selection { background: #65438c; color: #fff; }

.theme-switch { display: inline-grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--panel); color: var(--ink); cursor: pointer; }
.theme-switch[hidden] { display: none; }
.theme-switch:hover { background: var(--panel-soft); border-color: var(--purple); }
.theme-switch > span { display: flex; }
.theme-switch .theme-moon { display: none; }
:root[data-theme="dark"] .theme-switch .theme-moon { display: flex; }
:root[data-theme="dark"] .theme-switch .theme-sun { display: none; }

@media (forced-colors: active) { .theme-switch { border: 1px solid ButtonText; } }
@media print {
    :root[data-theme] { color-scheme: light; --ink: #142039; --muted: #526680; --purple: #6831ac; --surface: white; --border: #ccd4df; --panel: white; --panel-soft: #f5f5f5; --theme-panel: white; --theme-panel-soft: #f5f5f5; --theme-border: #ccd4df; --theme-ink: #142039; --theme-muted: #526680; --theme-accent: #6831ac; --theme-accent-soft: #f4eefb; --theme-success: #146a50; --theme-success-soft: #edf8f3; --theme-danger: #992e40; --theme-danger-soft: #fff3f5; --theme-warning: #674513; --theme-warning-soft: #fff8e5; }
    .theme-switch, .survey-invitation { display: none; }
}
