:root { color-scheme: light; }
:root[data-theme="dark"] {
    color-scheme: dark;
    --ink: #edf0f7;
    --muted: #a5adbf;
    --surface: #1a2030;
    --background: #111522;
    --line: #333c50;
    --lavender: #302644;
    --purple: #b49af3;
    --purple-dark: #c5b0fb;
    --green: #73d6aa;
    --blue: #8db8f4;
    --orange: #f0bb70;
    --shadow: 0 3px 16px #00000024;
    background: var(--background);
    color: var(--ink);
}
html[data-theme="dark"] body { background-color: var(--background); color: var(--ink); }
html[data-theme="dark"] dialog { background-color: var(--surface); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] .button.primary { background: #7955d8; color: #fff; }
html[data-theme="dark"] .button.primary:hover { background: #6841c3; }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #9aa4b9; opacity: 1; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { accent-color: #9875eb; }
html[data-theme="dark"] .history-chart text { fill: var(--muted); }
html[data-theme="dark"] .history-chart>path { stroke: var(--line); }
/* Rich text content follows the editor's theme; exported documents retain their own colors. */
html[data-theme="dark"] .ql-toolbar,
html[data-theme="dark"] .ql-container { border-color: var(--line); }
html[data-theme="dark"] .ql-toolbar,
html[data-theme="dark"] .ql-editor,
html[data-theme="dark"] .ql-tooltip { background: var(--surface); color: var(--ink); }
html[data-theme="dark"] .ql-snow .ql-stroke { stroke: var(--ink); }
html[data-theme="dark"] .ql-snow .ql-fill { fill: var(--ink); }
html[data-theme="dark"] .ql-snow .ql-picker { color: var(--ink); }
html[data-theme="dark"] .ql-snow .ql-picker-options { background: var(--surface); border-color: var(--line); }
.theme-switch { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0; color: var(--muted, #746f80); }
.theme-trigger { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; }
.theme-trigger:hover, .theme-trigger[aria-expanded="true"] { color: var(--purple, #7955d8); background: var(--lavender, #f3eefc); }
.theme-trigger:focus-visible { outline: 2px solid var(--purple, #7955d8); outline-offset: 3px; }
.theme-icon { display: none; width: 20px; height: 20px; pointer-events: none; }
:root:not([data-theme-preference]) .theme-icon-system,
:root[data-theme-preference="system"] .theme-icon-system,
:root[data-theme-preference="light"] .theme-icon-light,
:root[data-theme-preference="dark"] .theme-icon-dark { display: block; }
.theme-menu { position: absolute; top: calc(100% + 10px); right: 0; z-index: 50; width: 216px; max-width: calc(100vw - 32px); padding: 8px; border: 0; border-radius: 16px; background: var(--surface, #fff); color: var(--ink, #272432); box-shadow: 0 12px 40px #21133320, 0 2px 8px #2113330a; text-align: left; }
.theme-menu-title { margin: 0; padding: 7px 12px 9px; color: var(--muted, #746f80); font-size: 11px; font-weight: 600; line-height: 1.5; letter-spacing: .2px; }
.theme-option { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 9px; background: transparent; color: inherit; font: inherit; font-size: 13px; line-height: 1.5; text-align: left; cursor: pointer; }
.theme-option + .theme-option { margin-top: 3px; }
.theme-option:hover, .theme-option:focus-visible { background: var(--lavender, #f3eefc); outline: none; }
.theme-option[aria-checked="true"] { color: var(--purple, #7955d8); background: var(--lavender, #f3eefc); font-weight: 600; }
.theme-option:focus-visible { outline: 2px solid var(--purple, #7955d8); outline-offset: -2px; }
.theme-option-icon { width: 19px; height: 19px; flex-shrink: 0; }
.theme-option-check { width: 16px; height: 16px; margin-left: auto; flex-shrink: 0; visibility: hidden; }
.theme-option[aria-checked="true"] .theme-option-check { visibility: visible; }
html[data-theme="dark"] .theme-menu { box-shadow: 0 12px 40px #0006, 0 2px 8px #0003; }
.account-theme { display: flex; justify-content: flex-end; margin-bottom: 20px; }
@media(max-width:600px) {
    .top-actions { gap: 8px; }
    .header-actions { gap: 8px; }
}
@media(max-width:360px) {
    .topbar .breadcrumb strong { display: none; }
}
@media print {
    [data-theme-switch] { display: none !important; }
}
