/* The saved account preference is rendered on <html>, before the first paint. */
:root[data-theme="light"] { color-scheme: light; }
.appearance-setting { padding: 20px; margin-bottom: 25px; border: 1px solid var(--line); border-radius: 13px; background: var(--sage); }
.appearance-setting .eyebrow { margin-bottom: 12px; }
.theme-setting { display: flex; align-items: center; justify-content: space-between; gap: 20px; cursor: pointer; }
.theme-setting strong { display: block; font-size: 16px; font-weight: 600; }
.theme-description { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.appearance-setting .help-text { margin: 14px 0 0; }
input.theme-switch {
  appearance: none; -webkit-appearance: none; width: 52px; height: 30px;
  border: 2px solid #88718f; border-radius: 30px; background: #d6c9dc;
  flex-shrink: 0; margin: 0; position: relative; cursor: pointer;
}
input.theme-switch::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fffaf2; border-radius: 50%; box-shadow: 0 1px 3px #26143240;
}
input.theme-switch:checked { background: #80559b; border-color: #80559b; }
input.theme-switch:checked::before { transform: translateX(22px); }

/* Printouts and exported PDFs stay on white paper regardless of screen theme. */
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --ink: #f0e6f3; --muted: #c0afc9; --green: #d4abe9; --green-dark: #f0d6ff;
    --sage: #392b47; --cream: #1e1726; --line: #4b3a58; --peach: #42322f; --white: #2a2033;
    --lavender: #684779; --gold: #e3ba7b;
    --bs-body-bg: #1e1726; --bs-body-color: #f0e6f3; --bs-border-color: #4b3a58;
    --bs-secondary-color: #c0afc9; --bs-tertiary-bg: #35293e;
  }
  [data-theme="dark"] body.witchfeast {
    background-color: #1e1726;
    background-image: radial-gradient(ellipse at 4% 8%, #54376240, transparent 38%), radial-gradient(ellipse at 95% 45%, #674d3220, transparent 32%);
  }
  [data-theme="dark"] ::selection { background: #7e5596; color: #fff4ff; }
  [data-theme="dark"] :focus-visible { outline-color: #edc68b !important; }
  [data-theme="dark"] .site-header { background: #241b2ded; border-color: #44324f; }
  [data-theme="dark"] .brand,[data-theme="dark"] .brand:hover { color: #f2e2fa; }
  [data-theme="dark"] .brand-mark { background: #715086; color: #ffe5b6; }
  [data-theme="dark"] .desktop-nav a[aria-current] { background: #3b2b49; color: #e7c4fb; box-shadow: inset 0 0 0 1px #614571; }
  [data-theme="dark"] .avatar { background: #443052; border-color: #705180; color: #ecd3fa; }
  [data-theme="dark"] .btn-primary { background: #b586cd; border-color: #b586cd; color: #24152f; box-shadow: 0 3px 0 #674078; }
  [data-theme="dark"] .btn-primary:hover,[data-theme="dark"] .btn-primary:active,[data-theme="dark"] .btn-primary:focus-visible { background: #cfa3e5; border-color: #cfa3e5; color: #24152f; }
  [data-theme="dark"] .btn-secondary { background: #30243b; border-color: #70577d; color: #eeddf7; }
  [data-theme="dark"] .btn-secondary:hover { background: #473153; border-color: #a280b3; }
  [data-theme="dark"] .btn-icon { color: #e0beeF; border-color: #645071; background: #2b2134; }
  [data-theme="dark"] .site-footer { border-color: var(--line); }
  [data-theme="dark"] .eyebrow,[data-theme="dark"] .feature-number,[data-theme="dark"] .art-caption,
  [data-theme="dark"] .ritual-divider { color: #c5a4d4; }
  [data-theme="dark"] .panel,[data-theme="dark"] .auth-card,[data-theme="dark"] .import-card { background: #2a2033; border-color: #4f3a5d; box-shadow: 0 5px 18px #10091820; }
  [data-theme="dark"] .auth-card { border-top-color: #9974ad; }
  [data-theme="dark"] .auth-foot { border-color: var(--line); }
  [data-theme="dark"] .chip { background: #42304f; color: #e3c4f0; border-color: #604570; }
  [data-theme="dark"] .field input:not([type=checkbox]),[data-theme="dark"] .field select,[data-theme="dark"] .field textarea,
  [data-theme="dark"] .inline-form input:not([type=checkbox]),[data-theme="dark"] .filter-bar input,
  [data-theme="dark"] .filter-bar select,[data-theme="dark"] .export-panel select,[data-theme="dark"] .serving-form input {
    background-color: #211929; border-color: #786183; color: #f0e6f3;
  }
  [data-theme="dark"] input::placeholder,[data-theme="dark"] textarea::placeholder { color: #b4a1bf; opacity: 1; }
  [data-theme="dark"] .field select,[data-theme="dark"] .filter-bar select,[data-theme="dark"] .export-panel select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23d4abe9' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
  }
  [data-theme="dark"] .field input:focus,[data-theme="dark"] .field textarea:focus,[data-theme="dark"] .field select:focus { border-color: #bf92d5; box-shadow: 0 0 0 3px #a677bd30; }
  [data-theme="dark"] .form-check-input { background-color: #211929; border-color: #9c84a8; }
  [data-theme="dark"] .form-check-input:checked { background-color: #ae7fc5; border-color: #ae7fc5; }
  [data-theme="dark"] input[type=checkbox] { accent-color: #ae7fc5; }
  [data-theme="dark"] input.theme-switch { background: #574363; border-color: #aa8db9; }
  [data-theme="dark"] input.theme-switch:checked { background: #b586cd; border-color: #b586cd; }
  [data-theme="dark"] input.theme-switch::before { background: #24182f; }
  [data-theme="dark"] .required { color: #e4bb83; }
  [data-theme="dark"] .danger-link,[data-theme="dark"] .errorlist,[data-theme="dark"] .field-errors { color: #ffabbf !important; }
  [data-theme="dark"] .notice { background: #3c3023; border-color: #81633e; color: #f0d4a4; }
  [data-theme="dark"] .notice.success { background: #28382c; border-color: #536c4e; color: #cfdfb7; }
  [data-theme="dark"] .notice.error { background: #442635; border-color: #8c4d65; color: #ffc2d1; }
  [data-theme="dark"] .empty-state { background: #302239; border-color: #7c5c8c; }
  [data-theme="dark"] .empty-icon { background: #44304f; color: #d7b2e9; }
  [data-theme="dark"] .hero-copy h1 em { color: #c89ddf; }
  [data-theme="dark"] .hero-reassurance { color: #beacc8; }
  [data-theme="dark"] .hero-note { background: #352738; border-color: #74516e; box-shadow: 0 5px 0 #140d1b; }
  [data-theme="dark"] .hero-note strong { color: #f5e5f0; }
  [data-theme="dark"] .ritual-divider,[data-theme="dark"] .welcome-strip { border-color: var(--line); }
  [data-theme="dark"] .ritual-divider>span:last-child,[data-theme="dark"] .welcome-strip>span { color: #dfb87f; }
  [data-theme="dark"] .feature-grid article { background: #2b2234; border-color: #4b3a58; }
  [data-theme="dark"] .feature-grid article:nth-child(2) { background: #34253f; }
  [data-theme="dark"] .feature-grid article:nth-child(3) { background: #352c2b; }
  [data-theme="dark"] .feature-icon { background: #3b2c45; border-color: #755681; color: #d2a8e6; }
  [data-theme="dark"] .calendar-welcome { background: #382646; border-color: #664577; }
  [data-theme="dark"] .calendar-welcome p:last-child { color: #d0badb; }
  [data-theme="dark"] .calendar-welcome .eyebrow { color: #cfabdf; }
  [data-theme="dark"] .week-summary { border-color: var(--line); }
  [data-theme="dark"] .week-summary strong { color: #d5ace9; }
  [data-theme="dark"] .summary-dot { background: #b3c59a; }
  [data-theme="dark"] .segmented { background: #302337; border-color: #554060; }
  [data-theme="dark"] .segmented a[aria-current] { background: #654378; color: #f3e5fa; }
  [data-theme="dark"] .today-link { border-color: #886696; }
  [data-theme="dark"] .calendar-grid,[data-theme="dark"] .calendar-day,[data-theme="dark"] .calendar-agenda .calendar-day {
    background: #271e30; border-color: #513c5e;
  }
  [data-theme="dark"] .day-heading,[data-theme="dark"] .calendar-agenda .day-heading,[data-theme="dark"] .calendar-month .day-heading { background: #302238; border-color: #513c5e; }
  [data-theme="dark"] .day-heading>span,[data-theme="dark"] .slot-label { color: #c5abcd; }
  [data-theme="dark"] .is-today .day-heading { background: #503460; }
  [data-theme="dark"] .is-today .day-heading strong { background: #c197d5; color: #25182e; }
  [data-theme="dark"] .meal-card { background: #443050; border-color: #a980c0; }
  [data-theme="dark"] .meal-card h3 { color: #f1dff9; }
  [data-theme="dark"] .meal-card span { color: #d0b6dd; }
  [data-theme="dark"] .meal-breakfast { background: #433526; border-color: #be945b; }
  [data-theme="dark"] .meal-breakfast h3 { color: #f6dfba; }
  [data-theme="dark"] .meal-breakfast span { color: #dcc39e; }
  [data-theme="dark"] .meal-lunch { background: #303c2b; border-color: #95ad79; }
  [data-theme="dark"] .meal-lunch h3 { color: #e2edcc; }
  [data-theme="dark"] .meal-lunch span { color: #c4d2ad; }
  [data-theme="dark"] .meal-snack { background: #482c38; border-color: #c2869f; }
  [data-theme="dark"] .meal-snack h3 { color: #f7d7e1; }
  [data-theme="dark"] .meal-snack span { color: #e2b9c8; }
  [data-theme="dark"] .add-slot { background: #2a2033; border-color: #70527f; color: #b996ca; }
  [data-theme="dark"] .add-slot:hover { background: #443050; color: #ecd0fa; }
  [data-theme="dark"] .add-day-meal { color: #c6a0d9; }
  [data-theme="dark"] .outside-month { background: #211928; }
  [data-theme="dark"] .filter-bar { background: #33263e; border-color: #503a60; }
  [data-theme="dark"] .recipe-card { background: #2d2235; border-color: #5b406b; box-shadow: 3px 4px 0 #160d1f; }
  [data-theme="dark"] .recipe-card:hover { box-shadow: 4px 7px 0 #483052; }
  [data-theme="dark"] .recipe-placeholder { background: #433051; color: #d4b4e3; }
  [data-theme="dark"] .recipe-placeholder.color-peach { background: #49362f; color: #e2bf9e; }
  [data-theme="dark"] .recipe-card:nth-child(3n) .recipe-placeholder { background: #354031; }
  [data-theme="dark"] .recipe-meta { border-color: var(--line); color: #c7b0d2; }
  [data-theme="dark"] .recipe-meta>a { background: #493254; }
  [data-theme="dark"] .favorite-mark { background: #402735; color: #ffbdd3; }
  [data-theme="dark"] .favorite-star { color: #edc58c; }
  [data-theme="dark"] .favorite-star:hover { background: #4b3930; }
  [data-theme="dark"] .detail-art { background: #3b2949; border-color: #654474; color: #cba6dc; }
  [data-theme="dark"] .detail-image { border-color: #5b4168; box-shadow: 6px 6px 0 #32213d; }
  [data-theme="dark"] .ingredient-panel { background: #32253d; border-color: #594065; }
  [data-theme="dark"] .ingredient-list li { border-color: var(--line); }
  [data-theme="dark"] .step-list li>span { background: #412e50; border-color: #6f4b84; color: #e2b8f3; }
  [data-theme="dark"] .notes-box { background: #3a3029; border-color: #72563e; }
  [data-theme="dark"] .notes-box h3 { color: #e3bc83; }
  [data-theme="dark"] .ingredient-row { background: #241c2e; border-color: #4e395f; }
  [data-theme="dark"] .save-bar { background: #211827f5; border-color: #654671; }
  [data-theme="dark"] .list-icon { background: #49392b; border-color: #7a5c3e; color: #edc893; }
  [data-theme="dark"] .shopping-card { background: #2d2235; border-color: #5b4164; box-shadow: 0 4px 0 #170f20; }
  [data-theme="dark"] .shopping-progress { background: #392a45; border-color: #684979; }
  [data-theme="dark"] progress,[data-theme="dark"] progress::-webkit-progress-bar { background: #564063; }
  [data-theme="dark"] progress::-webkit-progress-value { background: #c197d5; }
  [data-theme="dark"] .shopping-category h2 span { background: #483152; color: #d8bae6; }
  [data-theme="dark"] .shopping-item { background: #2c2234; border-color: #513d5e; }
  [data-theme="dark"] .check-button { border-color: #a886bb; background: #251b2e; color: #ddbaed; }
  [data-theme="dark"] .check-button[aria-pressed=true] { background: #b586cd; color: #211528; border-color: #b586cd; }
  [data-theme="dark"] .is-done { background: #302737; }
  [data-theme="dark"] .export-panel { background: #362c2a; border-color: #705448; }
  [data-theme="dark"] .export-panel .list-icon { background: #493a2e; }
  [data-theme="dark"] .witchfeast .recipe-combobox .recipe-search { background: #211929; border-color: #a37fba; color: #f0e6f3; }
  [data-theme="dark"] .witchfeast .recipe-combobox .recipe-search::placeholder { color: #bfa7cc; }
  [data-theme="dark"] .witchfeast .recipe-combobox .recipe-search:focus { border-color: #d3a6ea; }
  [data-theme="dark"] .witchfeast .recipe-picker-panel { background: #2c2136; border-color: #9c75b1; box-shadow: 0 12px 30px #10071c80; }
  [data-theme="dark"] .witchfeast .recipe-picker-option.is-active,[data-theme="dark"] .witchfeast .recipe-picker-option:hover { background: #4a325c; }
  [data-theme="dark"] .mobile-nav { background: #251b2ef7; border-color: #654875; box-shadow: 0 -4px 20px #0d061d44; }
  [data-theme="dark"] .mobile-nav a[aria-current] { background: #483053; color: #e1b9f3; }
  [data-theme="dark"] .print-sheet { color: #35283e; color-scheme: light; border-color: #d8cbdc; }
  [data-theme="dark"] .print-sheet h1,[data-theme="dark"] .print-sheet h2 { color: #35283e; }
  [data-theme="dark"] .print-category h2 { border-color: #69467d; }
  [data-theme="dark"] .print-row { border-color: #ddd; }
  @media (max-width: 760px) {
    [data-theme="dark"] .calendar-grid,[data-theme="dark"] .calendar-month { background: transparent; }
    [data-theme="dark"] .calendar-day,[data-theme="dark"] .calendar-agenda .calendar-day { border-color: #513c5e !important; }
  }
}
