:root {
  --nav: #342942;
  --nav-selected: #554068;
  --nav-active-ink: #f9dcff;
  --banner-base: #292039;
  --banner-middle: #292039ef;
  --banner-fade: #29203938;
  --paper: #f7f3fa;
  --card: #fffcff;
  --ink: #28223b;
  --muted: #625774;
  --line: #e4d9ee;
  --accent: #a66bab;
  --theme-header: #fbf7fe;
  --theme-hover: #eee5f4;
  --theme-primary: #e6c7f0;
  --theme-primary-text: #482a59;
  --theme-focus: #744986;
  --theme-hero-start: #f4e5f2;
  --theme-hero-end: #ded9fa;
  --theme-orbit: #7e62a1;
  --theme-planet-light: #d8a8ce;
  --theme-planet-dark: #8e79be;
  --theme-spark: #73518a;
  --theme-warm: #a45b50;
  --shadow: 0 6px 20px #4d2e6310;
}

:root[data-theme="night"] {
  color-scheme: dark;
  --nav: #191d2e;
  --nav-selected: #393657;
  --nav-active-ink: #eee4ff;
  --banner-base: #20233e;
  --banner-middle: #20233eef;
  --banner-fade: #20233e38;
  --paper: #151827;
  --card: #202438;
  --ink: #f5efff;
  --muted: #c0b6d6;
  --line: #3c415b;
  --accent: #a791ec;
  --theme-header: #191d2e;
  --theme-hover: #313655;
  --theme-primary: #bba7fb;
  --theme-primary-text: #21163b;
  --theme-focus: #cfbbff;
  --theme-hero-start: #232946;
  --theme-hero-end: #353464;
  --theme-orbit: #b0a2f8;
  --theme-planet-light: #9e94ed;
  --theme-planet-dark: #594b9a;
  --theme-spark: #cab8ff;
  --theme-warm: #ffa98b;
  --shadow: 0 7px 22px #0004;
}

:root[data-theme="mars"] {
  --nav: #402b2d;
  --nav-selected: #653f40;
  --nav-active-ink: #ffe3d2;
  --banner-base: #412b30;
  --banner-middle: #412b30ef;
  --banner-fade: #412b3038;
  --paper: #fbf1e6;
  --card: #fffaf2;
  --ink: #392824;
  --muted: #72594e;
  --line: #ead4c3;
  --accent: #b97156;
  --theme-header: #fff6eb;
  --theme-hover: #f4e3d5;
  --theme-primary: #f4c5a0;
  --theme-primary-text: #512a23;
  --theme-focus: #a04f3a;
  --theme-hero-start: #fbe5ce;
  --theme-hero-end: #f1c9bb;
  --theme-orbit: #ac694f;
  --theme-planet-light: #f0bb83;
  --theme-planet-dark: #be715f;
  --theme-spark: #945143;
  --theme-warm: #945143;
  --shadow: 0 6px 20px #723f2210;
}

.topbar { background: var(--theme-header); border-color: var(--line); }
.theme-picker-icon {
  width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1px solid var(--theme-focus);
  background: conic-gradient(#c696d7 0 33%, #e9b18d 0 66%, #8c82b0 0);
}

.ghost, .icon-button, .button, .destination-list button, .sort-field select {
  background: var(--card); color: var(--ink); border-color: var(--line);
}
.ghost:hover, .icon-button:hover, .button:hover, #task-menu button:hover, #task-menu button:focus-visible,
.task-actions .icon-button:hover, .check-button:hover,
.mobile-overview .nav-entry:hover, .mobile-overview .nav-edit:hover { background: var(--theme-hover); }
.button.primary, .button.primary:hover { background: var(--theme-primary); color: var(--theme-primary-text); border-color: var(--theme-primary); }
.button.danger { background: var(--theme-hover); color: var(--theme-warm); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible,
.main .hero :focus-visible, .mobile-overview :focus-visible, .board-tools .sort-field:focus-within { outline-color: var(--theme-focus); }

.mobile-overview #navigation { box-shadow: var(--shadow); }
.task-paused { background: var(--theme-header); }
.board-head .kind { background: var(--theme-hover); color: var(--ink); }
.task-steps input[type="checkbox"] { accent-color: var(--theme-focus); }
.row-star, .menu-star, .cloud-card .cloud-error { color: var(--theme-warm); }
.drop-tray { background: var(--theme-header); border-color: var(--line); }
.drop-tray-label { color: var(--ink); }
.mobile-overview .nav-entry[aria-current], .mobile-overview .nav-entry[aria-current] .nav-count {
  background: var(--theme-hover); color: var(--ink);
}
.mobile-overview .nav-entry[aria-current]::before { background: var(--theme-focus); }
.task-row:hover, .archive { border-color: var(--line); }
.archive summary, .check-button, .task-row .drag-handle { color: var(--muted); }
.check-button .check-circle { border-color: var(--theme-focus); }
.check-button[aria-pressed="true"] .check-circle { background: var(--theme-primary); color: var(--theme-primary-text); }
.task-paused .task-title, .reviewed .task-title { color: var(--muted); }

dialog, #task-menu { background: var(--card); color: var(--ink); border-color: var(--line); }
.dialog-form input, .dialog-form textarea, .dialog-form select, .cloud-form input {
  background: var(--theme-header); color: var(--ink); border-color: var(--line);
}
.task-steps .step-title { background: transparent; border-color: transparent; }
.task-steps .step-title:focus { background: var(--theme-header); border-color: var(--line); }
#task-menu .menu-delete { color: var(--theme-warm); }
.cloud-card { background: var(--card); border-color: var(--line); }
.cloud-card h1 { color: var(--ink); }
.cloud-card p { color: var(--muted); }
.toast .ghost { color: #ffd0b5; background: #ffffff0b; border-color: #c2abbd67; }

.theme-option[aria-pressed="true"] { border-color: var(--theme-focus); }
.theme-chip {
  flex: none; width: 30px; height: 22px; border: 1px solid #81718b80;
  border-radius: 6px; background: #eee0f7;
}
.theme-chip.night { background: linear-gradient(135deg, #24283f 55%, #ad98ea 55%); }
.theme-chip.mars { background: linear-gradient(135deg, #f8e3ce 55%, #c9866c 55%); }

@media (width > 760px) {
  .sidebar .nav-entry[aria-current] { background: var(--nav-selected); color: var(--nav-active-ink); }
  .sidebar .nav-entry[aria-current] .nav-count { color: var(--nav-active-ink); }
  .sidebar .new-list { background: var(--theme-primary); color: var(--theme-primary-text); }
  .sidebar .new-list:hover { filter: brightness(1.07); }
  .sidebar .folder-lists,
  .sidebar .sidebar-foot { border-color: #fff3; }
  .hero { background-color: var(--banner-base); }
}

@media (max-width: 760px) {
  .topbar-tools { gap: 5px; }
  .theme-picker { width: 37px; padding: 0; }
  .theme-picker span { display: none; }

  .main .hero {
    background: linear-gradient(108deg, var(--theme-hero-start), var(--theme-hero-end));
    color: var(--ink); border-color: var(--line); box-shadow: none;
  }
  .main .hero .fallback-art {
    background:
      radial-gradient(circle at 71% 22%, var(--theme-orbit) 0 1px, transparent 1.6px),
      radial-gradient(circle at 77% 72%, var(--theme-orbit) 0 .8px, transparent 1.4px),
      radial-gradient(circle at 92% 24%, var(--theme-orbit) 0 .8px, transparent 1.4px),
      radial-gradient(circle at 96% 68%, var(--theme-orbit) 0 .9px, transparent 1.5px);
  }
  .main .hero .fallback-art::after {
    content: ""; position: absolute; right: 5px; top: 7px; width: 118px; height: 22px;
    border: 1px solid var(--theme-orbit); border-radius: 50%; transform: rotate(-14deg); opacity: .43;
  }
  .main .hero .ringed-planet {
    right: 8%; bottom: -11px; width: 38px; height: 38px;
    background: repeating-linear-gradient(148deg, var(--theme-planet-dark) 0 7px, var(--theme-planet-light) 7px 14px);
    box-shadow: inset 2px 1px #ffe5dc66;
  }
  .main .hero .ringed-planet::after { border-color: var(--theme-orbit); }
  .main .hero .rocket { right: 25%; top: 4px; }
  .main .hero .spark { color: var(--theme-spark); }
  .main .stat { border-color: var(--line); background: var(--card); color: var(--muted); }
  .main .stat strong { color: var(--ink); }
  .main .stat-dot { background: var(--theme-orbit); }
  .main .stat-dot.orange { background: var(--theme-warm); }
}
