/* Theme changes color and elevation, never component geometry. */
body.dark-mode {
  color-scheme: dark;
  --primary-color: inherit;
  --primary-hover-color: inherit;
  --primary-light: inherit;
  --text-color: #f5f5f5;
  --text-light-color: #e5e5e5;
  --border-color: #484848;
  --background-color: #080808;
  --card-background-color: #181818;
  --submission-color: #ffd79a;
  --submission-bg: #3b2b19;
  --school-submission-color: #b3dcff;
  --school-submission-bg: #203b52;
  --surface-raised: #2b2b2b;
  --surface-input: #101010;
}
body.dark-mode::before { background: none; }
body.dark-mode .modal-overlay { background: rgba(0, 0, 0, .65); }
body.dark-mode .header { background: #101010f5; border-color: #383838; }
body.dark-mode .header-identity { background: #173c30; border-color: #347b61; color: #b1f5d8; }
body.dark-mode .header-clock { color: #e5e5e5; }
body.dark-mode .header-update { color: #d1d5db; }
body.dark-mode .logo { background: none; -webkit-text-fill-color: var(--primary-color); color: var(--primary-color); animation: logoPopIn var(--duration-slower) var(--ease-out-back); text-shadow: 0 0 22px #10b98122; }
body.dark-mode :is(.modal, .editor-modal, .settings-modal, .subject-create-modal) { background: #181818; border-color: #484848; box-shadow: 0 24px 80px #0009, 0 0 0 1px #ffffff08; }
body.dark-mode .subject-column { background: #181818; border-color: #484848; }
body.dark-mode .subject-header { background: #222222; border-color: #484848; }
body.dark-mode .subject-column:hover { border-color: var(--primary-color); box-shadow: 0 14px 36px #0008; }
body.dark-mode .homework-item:not(.needs-submission):not(.school-submission):not(.online-submission) { background: #2b2b2b; border-color: #454545; color: var(--text-color); }
body.dark-mode .homework-item.needs-submission { background: var(--submission-bg); border-color: #9c7440; color: var(--submission-color); border-radius: 14px; }
body.dark-mode .homework-item.school-submission { background: var(--school-submission-bg); border-color: #709abf; color: var(--school-submission-color); }
body.dark-mode .homework-item:hover { background-color: #343434; }
body.dark-mode .homework-item.needs-submission::before { background: none; }
body.dark-mode :is(.subject-count, .editor-title-meta span, .date-status) { background: #164536; color: #9aefd0; }
body.dark-mode .date-status.historical { background: #49321b; color: #ffe0ab; border-color: #bc915b; }
body.dark-mode :is(.subject-monogram, .subject-choice-icon, .editor-subject-icon) { background: #164536; color: #9aefd0; }

body.dark-mode .button:not(.secondary),
body.dark-mode .button.secondary,
body.dark-mode :is(.theme-option, .editor-mode-btn, .quick-tools-toggle, .hex-key, .identity-choice, .subject-choice) {
  background: #2b2b2b; color: var(--text-color); border-color: #686868;
  text-shadow: none; animation: none; box-shadow: inset 0 0 0 1px #686868, 0 3px 8px #0003;
}
body.dark-mode .button:not(.secondary):not(.quick-btn):not(.date-nav) { background: #164536; color: #edfff6; box-shadow: inset 0 0 0 1px var(--primary-color), 0 0 14px #10b98114; }
/* One raised capsule, not two glowing rings. Keep the primary action distinct. */
body.dark-mode .board-actions { background: #222222; border-color: #ffffff1a; box-shadow: 0 8px 24px #0006; }
body.dark-mode .board-action { background: transparent; color: #e5e7eb; box-shadow: none; }
body.dark-mode .board-action.add-homework-button { background: var(--primary-color); color: #062e24; box-shadow: none; }
body.dark-mode .board-action:hover:not(:disabled) { background: #ffffff12; color: #fff; }
body.dark-mode .board-action.add-homework-button:hover:not(:disabled) { background: #34d399; color: #062e24; }
body.dark-mode .presentation-tools { background: #222; border-color: #414141; box-shadow: 0 12px 40px #0008; }
body.dark-mode .presentation-options { background: #151515; }
body.dark-mode .presentation-options button { color: #e5e7eb; }
body.dark-mode .presentation-options button[aria-pressed="true"] { background: #244b3c; border-color: #477962; color: #d5ffea; box-shadow: none; }
body.dark-mode .presentation-tool-icon:hover { background: #353535; }
body.dark-mode .button:not(.secondary)::before { display: none; }
body.dark-mode .button:not(.secondary):hover,
body.dark-mode .button.secondary:hover,
body.dark-mode :is(.theme-option, .hex-key, .identity-choice, .subject-choice, .quick-tools-toggle):hover {
  background: #353535; color: #f5f5f5; border-color: var(--primary-color); box-shadow: inset 0 0 0 1px var(--primary-color), 0 5px 16px #0005;
}
body.dark-mode .theme-option.active,
body.dark-mode .editor-mode-btn.active,
body.dark-mode .quick-tools-toggle[aria-expanded="true"],
body.dark-mode .editor-template-toggle[aria-expanded="true"] { background: #1c5240; color: #edfff6; border-color: var(--primary-color); box-shadow: inset 0 0 0 1px var(--primary-color); }
body.dark-mode .editor-mode-switch { background: #101010; }
body.dark-mode .button:disabled { opacity: 1; background: #181818; color: #d8d8d8; border-color: #484848; box-shadow: inset 0 0 0 1px #484848 !important; }
body.dark-mode .settings-btn { color: #f5f5f5; }
body.dark-mode .settings-btn:hover { color: var(--primary-color); background: #343434; }
body.dark-mode button:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 3px; }
/* Switch text and surface together; interpolating the old light surface flashes white-on-white. */
body.dark-mode button { transition: transform var(--duration-normal) var(--ease-out-back), box-shadow var(--duration-normal) var(--ease-smooth), border-color var(--duration-normal) var(--ease-smooth); }
body.dark-mode .toggle-switch { background: #4a4a4a; }
body.dark-mode .toggle-switch.active { background: var(--primary-color); }
body.dark-mode .toggle-knob { background: #f5f5f5; box-shadow: 0 0 0 1px #151515; }
body.dark-mode input[type="checkbox"] { accent-color: var(--primary-color); }
body.dark-mode .school-check input { accent-color: var(--school-submission-color); }
body.dark-mode .font-size-slider { background: #4a4a4a; }

body.dark-mode :is(.editor-panel, .visual-editor-card, .quick-insert-panel, .editor-template-picker, .visual-editor-empty, .empty-add-subject) { background: #222222; border-color: #484848; }
body.dark-mode .quick-insert-bar { background: transparent; border-color: #484848; }
body.dark-mode .quick-insert-panel::before { background: var(--primary-color); }
body.dark-mode :is(.text-editor-shell, .editor-template-groups, .editor-line-numbers) { background: #141414; border-color: #484848; }
body.dark-mode :is(.editor-template-picker button:hover, .editor-template-picker button.active) { background: #1c5240; color: #edfff6; }
body.dark-mode :is(.modal-input, .editor-textarea, .editor-item-input) { background: #101010; color: #f5f5f5; border-color: #686868; caret-color: var(--primary-color); }
body.dark-mode :is(.modal-input, .editor-textarea, .editor-item-input):focus { background: #101010; border-color: var(--primary-color); box-shadow: 0 0 0 3px #10b98130; }
body.dark-mode :is(input, textarea)::placeholder { color: #e5e5e5; opacity: 1; }
body.dark-mode :is(.today-info, .editor-titlebar p, .editor-toolbar-label, .editor-panel-tip, .editor-item-check, .editor-line-numbers, .quick-insert-label, .editor-template-options p, .settings-group h3, .toggle-desc, .subject-create-header p, .subject-choice-copy small, .subject-edit-hint, .empty-add-subject small, .footer, .footer-authors) { color: #e5e5e5; }
body.dark-mode .subject-choice.has-homework .subject-choice-copy small { color: #9aefd0; }
body.dark-mode .subject-choice-arrow { color: #e5e5e5; }
body.dark-mode .editor-item-tags .school-check { color: #b3dcff; }
body.dark-mode .editor-item-tags .online-check { color: var(--online-submission-color); }
body.dark-mode .editor-item-order .order-handle { background: #363636; color: #f5f5f5; }
body.dark-mode .editor-item-delete { background: #542d35; color: #ffd0d8; }
body.dark-mode .editor-item-delete:hover { background: #6a3541; color: #fff0f3; }
body.dark-mode .editor-homework-item.is-dragging { opacity: .38; border-color: var(--primary-color); }
body.dark-mode .editor-homework-item.drag-target { outline-color: var(--primary-color); }
body.dark-mode :is(.settings-group, .editor-titlebar) { border-color: #484848; }
body.dark-mode .footer { background: #101010; border-color: #383838; }
body.dark-mode .global-loader { background: #080808ed; }
body.dark-mode .spinner { border-color: #353535; border-top-color: var(--primary-color); }
/* Keep the notebook's shared geometry, ruled background and intentional lack of cards. */
body.dark-mode #export-area.notebook-view { background: #181818; --notebook-rule: #484848; }
body.dark-mode #export-area.notebook-view :is(.subject-column, .subject-header) { background: transparent; box-shadow: none; }
body.dark-mode #export-area.notebook-view .homework-item { background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--notebook-line) - 1px), var(--notebook-rule) calc(var(--notebook-line) - 1px), var(--notebook-rule) var(--notebook-line)); border-radius: 0; border: 0; }

/* Shared action hierarchy; semantic colors have equivalent light/dark surfaces. */
body button[class] { transition: transform var(--duration-normal) var(--ease-out-back), box-shadow var(--duration-normal) var(--ease-smooth), border-color var(--duration-normal) var(--ease-smooth); }
body { --action-ink: #425c52; --action-fill: #f3f7f5; --action-border: #ceddd5; --action-hover: #e5eee9; }
body.dark-mode { --action-ink: #eeeeee; --action-fill: #262626; --action-border: #626262; --action-hover: #363636; }
.action-add { --action-ink: #065f46; --action-fill: #e5f8ee; --action-border: #94d9b7; --action-hover: #cef1df; }
.action-edit { --action-ink: #1e4e95; --action-fill: #edf5ff; --action-border: #aecbee; --action-hover: #dcecff; }
.action-structure { --action-ink: #633899; --action-fill: #f4edff; --action-border: #d4b9f1; --action-hover: #eadbfc; }
.action-warning { --action-ink: #84500b; --action-fill: #fff5df; --action-border: #e9c982; --action-hover: #ffebc2; }
.action-danger { --action-ink: #a62b43; --action-fill: #fff0f2; --action-border: #efb2be; --action-hover: #ffdee5; }
body.dark-mode .action-add { --action-ink: #b6f5d5; --action-fill: #194631; --action-border: #4f9574; --action-hover: #245b42; }
body.dark-mode .action-edit { --action-ink: #cee4ff; --action-fill: #1e3859; --action-border: #577fae; --action-hover: #2b4c72; }
body.dark-mode .action-structure { --action-ink: #eedbff; --action-fill: #3e2c55; --action-border: #9875b8; --action-hover: #52396d; }
body.dark-mode .action-warning { --action-ink: #ffe2ac; --action-fill: #4b361b; --action-border: #af874b; --action-hover: #634922; }
body.dark-mode .action-danger { --action-ink: #ffd5de; --action-fill: #542c38; --action-border: #b16b7c; --action-hover: #6e3949; }
body .button.secondary, body.dark-mode .button.secondary {
  color: var(--action-ink); background: var(--action-fill); border: 1px solid var(--action-border);
  box-shadow: 0 2px 5px #152d2010; text-shadow: none;
}
body .button.secondary::before, body.dark-mode .button.secondary::before { display: none; }
body .button.secondary:hover, body.dark-mode .button.secondary:hover {
  color: var(--action-ink); background: var(--action-hover); border-color: var(--action-border); box-shadow: 0 4px 10px #152d201a;
}
body .button.secondary:disabled, body.dark-mode .button.secondary:disabled {
  color: var(--text-light-color); background: transparent; border-color: var(--border-color); box-shadow: none !important; opacity: .5; transform: none;
}
.settings-modal .theme-option { border: 1px solid var(--border-color); background: #f7faf9; color: #385447; box-shadow: none; }
.settings-modal .theme-option.active { color: #065f46; background: #e1f6ea; border-color: #64bd90; box-shadow: inset 0 0 0 1px #64bd90, 0 3px 9px #10b98112; }
.settings-modal .theme-option:hover { border-color: var(--primary-color); }
.settings-modal .theme-options button:first-child .theme-icon { color: #b5740c; }
.settings-modal .theme-options button:last-child .theme-icon { color: #7162b1; }
.settings-modal .settings-group h3 { display: flex; align-items: center; gap: 8px; }
.settings-modal .settings-group h3::before { content: ''; width: 4px; height: 12px; border-radius: 4px; background: var(--primary-color); }
.settings-modal .identity-settings h3::before { background: #9b7ac4; }
body.dark-mode .settings-modal .theme-option { color: #eeeeee; background: #262626; border-color: #626262; box-shadow: none; }
body.dark-mode .settings-modal .theme-option.active { color: #c5ffe2; background: #194631; border-color: #60c792; box-shadow: inset 0 0 0 1px #60c792; }
body.dark-mode .settings-modal .theme-options button:first-child .theme-icon { color: #ffda94; }
body.dark-mode .settings-modal .theme-options button:last-child .theme-icon { color: #dcc5ff; }
body.dark-mode .dialog-kicker { color: #8fe4b6; }
body.dark-mode .identity-modal .identity-choice { background: #222; border-color: #424242; box-shadow: 0 2px 4px #0003; }
body.dark-mode .identity-modal .identity-choice:hover { background: #2c2c2c; border-color: #719783; box-shadow: 0 7px 18px #0004; }
body.dark-mode .identity-choice .identity-icon { color: #c3dfff; background: #243d59; }
body.dark-mode .identity-teacher .identity-icon { color: #b4f0cf; background: #214735; }
body.dark-mode .identity-screen .identity-icon { color: #e3ceff; background: #42315a; }
body.dark-mode .identity-copy small { color: #e5e5e5; background: #353535; }
body.dark-mode .identity-choice .identity-chevron { color: #dedede; }
body.dark-mode .confirm-date-panel { background: #242424; border-color: #464646; }
body.dark-mode .confirm-calendar { color: #b4f0cf; background: #214735; }
