:root {
  color-scheme: light;
  --theme-surface-soft: #fafafa;
  --theme-surface-blue: #f5f8ff;
  --theme-surface-green: #effbf6;
  --theme-surface-result: #fbfbfa;
  --theme-focus: rgba(24, 60, 221, 0.25);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --ink: #f5f7fb;
  --muted: #a8b0bd;
  --line: #2d3440;
  --paper: #0b0e14;
  --white: #141922;
  --accent: #ff644f;
  --mint: #69e0b3;
  --blue: #8298ff;
  --theme-surface-soft: #181d26;
  --theme-surface-blue: #171d31;
  --theme-surface-green: #10251f;
  --theme-surface-result: #111720;
  --theme-focus: rgba(130, 152, 255, 0.38);
}

body,
.calculator,
.result-card,
.rules-table,
.segmented button,
.control select,
.control > input,
.money-input,
.check-row,
.waiver-row,
.date-helper,
.result-warning,
.result-actions button,
.rule-explainer {
  transition: background-color .22s ease, color .22s ease, border-color .22s ease, box-shadow .22s ease;
}

.theme-toggle {
  order: 3;
  flex: 0 0 2.55rem;
  width: 2.55rem;
  height: 2.55rem;
  margin-left: 12px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px rgba(255,255,255,.12), 0 8px 24px rgba(10,14,21,.08);
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-1px); }
.theme-toggle:focus-visible { outline: 3px solid var(--theme-focus); outline-offset: 3px; }
.theme-toggle span { font-size: 1rem; line-height: 1; }
.privacy-pill { margin-left: auto; }

:root[data-theme='dark'] body {
  background:
    radial-gradient(circle at 92% 8%, rgba(24,60,221,.16), transparent 32rem),
    radial-gradient(circle at 8% 32%, rgba(255,100,79,.08), transparent 28rem),
    var(--paper);
}
:root[data-theme='dark'] .topbar { border-color: var(--line); }
:root[data-theme='dark'] .law-card,
:root[data-theme='dark'] .result-topline,
:root[data-theme='dark'] .result-total,
:root[data-theme='dark'] .rules-table .rules-head { background: #070a10; }
:root[data-theme='dark'] .calculator,
:root[data-theme='dark'] .result-card,
:root[data-theme='dark'] .rules-table { background: var(--white); box-shadow: 0 20px 56px rgba(0,0,0,.28); }
:root[data-theme='dark'] .segmented button,
:root[data-theme='dark'] .check-row { background: var(--theme-surface-soft); color: var(--ink); }
:root[data-theme='dark'] .segmented button.active { background: #05080d; border-color: var(--mint); }
:root[data-theme='dark'] .control select,
:root[data-theme='dark'] .control > input,
:root[data-theme='dark'] .money-input,
:root[data-theme='dark'] .money-input input,
:root[data-theme='dark'] .result-actions button + button { background: #0d121a; color: var(--ink); }
:root[data-theme='dark'] .equipment-row,
:root[data-theme='dark'] .date-helper { background: var(--theme-surface-blue); border-color: #344271; }
:root[data-theme='dark'] .waiver-row { background: var(--theme-surface-green); border-color: #285c4b; }
:root[data-theme='dark'] .date-result { background: #153b30; color: #8ce4c0; }
:root[data-theme='dark'] .rule-explainer { background: #19203a; }
:root[data-theme='dark'] .rule-explainer p { color: #c8d1ef; }
:root[data-theme='dark'] .result-warning,
:root[data-theme='dark'] .result-pending { background: var(--theme-surface-result); }
:root[data-theme='dark'] .breakdown > div strong,
:root[data-theme='dark'] .breakdown .subtotal,
:root[data-theme='dark'] .rules-table strong { color: var(--ink); }
:root[data-theme='dark'] footer { border-color: var(--line); }
:root[data-theme='dark'] footer a { color: #c0c7d2; }

@media (max-width: 620px) {
  .theme-toggle { width: 2.3rem; height: 2.3rem; margin-left: 8px; }
}

@media print {
  .theme-toggle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
