:root {
  color-scheme: light;
  --muted: #676d63;
  --accent: #bf4624;
  --focus: #d88b60;
  --input-bg: #f6f6f0;
  --input-border: #d8dbd0;
  --button-bg: #fff;
  --on-accent: #fff;
  --accent-hover: #a93b1c;
  --track: #eeeee5;
  --badge: #eaece3;
  --empty-bg: #edf0e7;
  --empty-text: #5d6d52;
  --savebar-bg: #fffffcf5;
  --success-bg: #e9eee4;
  --success-text: #45604b;
  --error-bg: #fae9e3;
  --error-text: #a03927;
  --backdrop: #26312560;
  --menu-shadow: #28352518;
  --summary-shadow: #35412d04;
  --savebar-shadow: #29342910;
  --dialog-shadow: #222c2730;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14181d; --panel: #1d242b; --text: #edf1f5; --muted: #a7b1bb;
  --line: #35404c; --accent: #ff9e6b; --soft: #382a24; --green: #a1cfb3; --danger: #ffaba1;
  --focus: #ffc093; --input-bg: #171e25; --input-border: #485460; --button-bg: #252e37;
  --on-accent: #23170e; --accent-hover: #ffb68e; --track: #35404b; --badge: #303a44;
  --empty-bg: #25342d; --empty-text: #b2c9b7; --savebar-bg: #1d242bf5;
  --success-bg: #203b2d; --success-text: #b2dfbe; --error-bg: #442925; --error-text: #ffc0b4;
  --backdrop: #080b10bb; --menu-shadow: #00000055; --summary-shadow: #00000022;
  --savebar-shadow: #00000055; --dialog-shadow: #00000088;
}

:root[data-theme="cosmic"] {
  color-scheme: dark;
  --bg: #100c24; --panel: #1d1735; --text: #f3edff; --muted: #b9abd4;
  --line: #42365d; --accent: #bc9cff; --soft: #34254e; --green: #b8d9ca; --danger: #ffadbd;
  --focus: #d1b7ff; --input-bg: #17112d; --input-border: #665280; --button-bg: #2a2043;
  --on-accent: #170d2a; --accent-hover: #d0b7ff; --track: #403153; --badge: #36274e;
  --empty-bg: #302443; --empty-text: #c3b3d8; --savebar-bg: #1d1735f5;
  --success-bg: #213b36; --success-text: #b3e2d3; --error-bg: #45273e; --error-text: #ffc2d5;
  --backdrop: #080515cc; --menu-shadow: #05010c88; --summary-shadow: #a775ff16;
  --savebar-shadow: #05010c66; --dialog-shadow: #05010caa;
  background-image:
    radial-gradient(ellipse at 15% 5%, #9e53e52c, transparent 45%),
    radial-gradient(ellipse at 90% 65%, #546ee820, transparent 50%),
    radial-gradient(circle at 35px 55px, #dbc7ff55 1px, transparent 1.5px),
    radial-gradient(circle at 130px 170px, #b3ceff33 1px, transparent 1.5px);
  background-size: auto, auto, 230px 290px, 310px 370px;
  background-attachment: fixed;
}

:root[data-theme="forest"] {
  color-scheme: dark;
  --bg: #0e1b17; --panel: #172c24; --text: #ecf5ec; --muted: #a4bcae;
  --line: #345344; --accent: #9ad7a0; --soft: #243f30; --green: #b0ddbd; --danger: #ffb0a2;
  --focus: #b3e4bb; --input-bg: #10221a; --input-border: #4d715b; --button-bg: #213b2d;
  --on-accent: #0d2117; --accent-hover: #b5e5b9; --track: #304b3c; --badge: #294535;
  --empty-bg: #213e2d; --empty-text: #bad7be; --savebar-bg: #172c24f5;
  --success-bg: #244330; --success-text: #c0e6c1; --error-bg: #462e24; --error-text: #ffccaf;
  --backdrop: #030d08bb; --menu-shadow: #020e0866; --summary-shadow: #00000022;
  --savebar-shadow: #020e0866; --dialog-shadow: #020e0899;
}

:root[data-theme="lemon"] {
  color-scheme: light;
  --bg: #f8f8e9; --panel: #fffff4; --text: #30351d; --muted: #686e4e;
  --line: #dedfc2; --accent: #d5df4f; --soft: #f0f3cf; --green: #587344; --danger: #aa3f30;
  --focus: #89962a; --input-bg: #f8f9e6; --input-border: #cbd09f; --button-bg: #fffff8;
  --on-accent: #283011; --accent-hover: #e0e873; --track: #e7ebc9; --badge: #eef0cf;
  --empty-bg: #edf1d2; --empty-text: #626c3e; --savebar-bg: #fffff4f5;
  --success-bg: #e8efd3; --success-text: #455d2b; --error-bg: #fae7d8; --error-text: #963b26;
  --backdrop: #343a1b70;
}

/* Keep accent text readable on the pale lemon surfaces. */
:root[data-theme="lemon"] .brand-dot,
:root[data-theme="lemon"] .accent,
:root[data-theme="lemon"] .text-button,
:root[data-theme="lemon"] .result-plus,
:root[data-theme="lemon"] .user-card summary::after { color: #647010; }

.header-actions { position: relative; display: flex; align-items: center; gap: 4px; }
.theme-menu { position: static; }
.theme-menu > summary { display: flex; align-items: center; gap: 7px; min-height: 44px; padding: 10px; list-style: none; font-size: 13px; border-radius: 10px; }
.theme-menu > summary::-webkit-details-marker { display: none; }
.theme-menu > summary:hover { background: var(--soft); }
.theme-menu > summary > span { font-size: 20px; }
.theme-options { position: absolute; right: 0; top: 48px; z-index: 30; width: 258px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 14px 40px var(--menu-shadow); }
.theme-choice { display: grid; grid-template-columns: 28px 1fr 18px; align-items: center; gap: 10px; width: 100%; min-height: 49px; padding: 9px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text); text-align: left; font-size: 13px; }
.theme-choice:hover, .theme-choice[aria-pressed="true"] { background: var(--soft); border-color: var(--line); }
.theme-choice::after { content: ""; color: var(--text); }
.theme-choice[aria-pressed="true"]::after { content: "✓"; }
.theme-swatch { width: 27px; height: 27px; border-radius: 9px; border: 1px solid #8885; }
[data-theme-choice="orange"] .theme-swatch { background: linear-gradient(135deg, #f6f4ef 50%, #bf4624 50%); }
[data-theme-choice="dark"] .theme-swatch { background: linear-gradient(135deg, #1d242b 50%, #ff9e6b 50%); }
[data-theme-choice="cosmic"] .theme-swatch { background: linear-gradient(135deg, #1d1735 50%, #bc9cff 50%); }
[data-theme-choice="forest"] .theme-swatch { background: linear-gradient(135deg, #172c24 50%, #9ad7a0 50%); }
[data-theme-choice="lemon"] .theme-swatch { background: linear-gradient(135deg, #fffff4 50%, #d5df4f 50%); }
@media (max-width: 430px) { .header-actions > .eyebrow { display: none; } }
