/* Keep the original light layout. Dark mode only overrides its palette. */
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] body {
  color: #f3edf9;
  background-color: #111014;
  background-image: radial-gradient(circle 420px at var(--mx) var(--my), #8563c323, transparent 72%), linear-gradient(145deg, #15111d 0%, #111014 44%, #191320 100%);
}
html[data-theme="dark"] body::before, html[data-theme="dark"] body::after { opacity: .16; }
html[data-theme="dark"] ::selection { background: #654397; color: #fff; }
html[data-theme="dark"] .subject-gate { background: linear-gradient(135deg, #16111e, #111014 42%, #20162c); }
html[data-theme="dark"] .subject-gate::before, html[data-theme="dark"] .subject-gate::after { opacity: .14; }
html[data-theme="dark"] .gate-card, html[data-theme="dark"] .panel, html[data-theme="dark"] .auth-dialog {
  color: #f3edf9;
  background: linear-gradient(145deg, #201a29f5, #19151ff5);
  border-color: #42334f;
  box-shadow: 0 20px 65px #0004;
}
html[data-theme="dark"] .gate-card::before { opacity: .07; }
html[data-theme="dark"] .muted, html[data-theme="dark"] .hint,
html[data-theme="dark"] .hero p, html[data-theme="dark"] .gate-sub,
html[data-theme="dark"] .empty, html[data-theme="dark"] .footer,
html[data-theme="dark"] .deep-option { color: #bcb2c9; }
html[data-theme="dark"] .pill { background: #241d30; border-color: #49355e; color: #d5bbff; }
html[data-theme="dark"] .grad { background-image: linear-gradient(100deg, #c5a3ff, #dfb8ff, #bda7ff, #d0acff); }
html[data-theme="dark"] .subject-card {
  color: #f3edf9;
  background: linear-gradient(145deg, #211a2b, #1b1723) padding-box,
    conic-gradient(from var(--ring-angle), #7c3aed, #c084fc, #60a5fa, #f0abfc, #7c3aed) border-box !important;
}
html[data-theme="dark"] .subject-card:hover {
  background: linear-gradient(145deg, #2b2238, #241b30) padding-box,
    conic-gradient(from var(--ring-angle), #7c3aed, #c084fc, #60a5fa, #f0abfc, #7c3aed) border-box !important;
}
html[data-theme="dark"] .subject-card::after { background: radial-gradient(circle 190px at var(--card-x,50%) var(--card-y,50%), #b79bff20, transparent 62%); }
html[data-theme="dark"] .subject-desc { color: #bcb2c9; }
html[data-theme="dark"] .change-subject, html[data-theme="dark"] .status { color: #c8a8ff; }
html[data-theme="dark"] .subject-banner { background: linear-gradient(110deg, #2a2037, #231b30); border-color: #49355e; }
html[data-theme="dark"] .subject-banner::after { opacity: .07; }
html[data-theme="dark"] .subject-current { color: #bcb2c9; }
html[data-theme="dark"] .subject-current strong, html[data-theme="dark"] .result strong,
html[data-theme="dark"] .auth-dialog h2 { color: #ddc9ff; }
html[data-theme="dark"] textarea, html[data-theme="dark"] select, html[data-theme="dark"] .auth-dialog input {
  color: #f3edf9; background: #15121c; border-color: #4a3a59;
}
html[data-theme="dark"] textarea::placeholder, html[data-theme="dark"] input::placeholder { color: #a69ab6; opacity: 1; }
html[data-theme="dark"] .upload { color: #d0c5dc; background: #1b1624; border-color: #625073; }
html[data-theme="dark"] .upload:hover { background: #251c30; border-color: #a78bfa; }
html[data-theme="dark"] .codex-empty { color: #c9b3e8; border-color: #a58cbe; }
html[data-theme="dark"] .result code, html[data-theme="dark"] .inline-code { color: #ddc9ff; background: #2a2038; border-color: #49355e; }
html[data-theme="dark"] .code-card code { color: #f7f3ff; background: transparent; border: 0; }
html[data-theme="dark"] .result mjx-container[display="true"] { background: linear-gradient(135deg, #231a30, #1b1525); border-color: #49355e; box-shadow: none; }

/* Settings use the same dialog, rounded panels and violet accent as accounts. */
.settings-dialog h2 { margin-bottom: 18px; }
.theme-options { border: 0; padding: 0; margin: 0; min-width: 0; }
.theme-options legend { font-weight: 750; font-size: 14px; padding: 0; margin-bottom: 12px; }
.theme-options-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.theme-option { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 12px; border: 1px solid #ded6ef; border-radius: 14px; cursor: pointer; background: #fcfaff; transition: border-color .2s, box-shadow .2s, transform .2s; }
.theme-option:has(input:checked) { border-color: #9b7bea; box-shadow: 0 0 0 2px #7c3aed20; }
.theme-option:has(input:focus-visible) { outline: 3px solid #a78bfa; outline-offset: 3px; }
.theme-option:hover { transform: translateY(-2px); }
.auth-dialog .theme-option input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; padding: 0; }
.theme-swatch { display: grid; place-items: center; flex: 0 0 32px; height: 32px; border: 1px solid #d4c7e8; border-radius: 10px; background: #fff; color: #7c3aed; font-size: 18px; }
.theme-swatch-dark { background: #15121c; color: #e0caff; border-color: #51405e; }
.theme-option strong { font-size: 13px; }
.settings-dialog .hint { margin-top: 14px; line-height: 1.6; }
.settings-dialog .status { min-height: 2.8em; line-height: 1.5; }
html[data-theme="dark"] .theme-option { background: #1b1624; border-color: #4a3a59; }
html[data-theme="dark"] .theme-option:has(input:checked) { border-color: #bb96f4; box-shadow: 0 0 0 2px #b892ef26; }
:where(button, a, input, select, textarea):focus-visible { outline: 3px solid #a78bfa; outline-offset: 3px; }

/* Screen zoom and circular reveal echo the motion reference without changing layout. */
.screen-switching .subject-gate, .screen-switching .solver-shell { transition: none !important; }
html.screen-switching::view-transition-old(root) { animation: screenLeave .45s cubic-bezier(.2,.75,.25,1) both; }
html.screen-switching::view-transition-new(root) { animation: screenArrive .65s cubic-bezier(.22,1,.36,1) both; }
html.theme-switching::view-transition-old(root), html.theme-switching::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.theme-switching::view-transition-old(root) { z-index: 1; }
html.theme-switching::view-transition-new(root) { z-index: 2; }
html.theme-switching::view-transition-group(root) { animation-duration: 0s; }
.auth-dialog[open] { animation: dialogArrive .32s cubic-bezier(.22,1,.36,1) both; }
.auth-dialog[open]::backdrop { animation: backdropArrive .24s ease-out both; }
@keyframes screenLeave { to { opacity: 0; transform: scale(1.04); filter: blur(4px); } }
@keyframes screenArrive { from { opacity: 0; transform: scale(.97) translateY(12px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes dialogArrive { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes backdropArrive { from { opacity: 0; } to { opacity: 1; } }
@media(prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
  .theme-option:hover { transform: none; }
}
