/* The light defaults come from styles.css, components.css and navigation.css. */
:root {
  --theme-chrome: #0f6b8f;
}

:root:is([data-theme="dark"], [data-theme="night"]) {
  color-scheme: dark;
  --theme-chrome: var(--bg);
  --theme-canvas: var(--bg);
  --panel-soft: var(--theme-tint);
  --soft: var(--theme-raised);
  --theme-surface: var(--panel);
  --theme-ink: var(--text);
  --theme-muted: var(--muted);
  --theme-line: var(--border);
  --theme-on-accent: var(--text);
  --theme-shadow: 0 12px 28px rgb(0 0 0 / 34%);
  --primary: var(--theme-link);
  --primary-dark: var(--theme-link);
  --accent: var(--theme-link);
  --sun: var(--sp-warning-ink);
  --sand: var(--sp-pending-bg);
  --coral: var(--sp-error-ink);
  --danger: var(--sp-error-ink);
  --shadow: var(--theme-shadow);
  --shadow-soft: var(--theme-shadow);

  --sp-surface: var(--theme-surface);
  --sp-surface-subtle: var(--theme-raised);
  --sp-ink: var(--theme-ink);
  --sp-ink-muted: var(--theme-muted);
  --sp-line: var(--theme-line);
  --sp-action: var(--theme-emphasis);
  --sp-action-ink: var(--theme-link);
  --sp-action-hover: var(--theme-hover);
  --sp-action-on: var(--theme-ink);
  --sp-secondary: var(--theme-tint);
  --sp-secondary-hover: var(--theme-hover);
  --sp-overlay: rgb(0 0 0 / 72%);

  --navigation-surface: var(--theme-surface);
  --navigation-divider: var(--theme-line);
  --navigation-ink: var(--theme-ink);
  --navigation-hover: var(--theme-tint);
  --navigation-selected-surface: var(--theme-emphasis);
  --navigation-selected-ink: var(--theme-ink);
  --navigation-selected-border: var(--sp-line-control);
  --navigation-focus: var(--sp-focus);
}

:root[data-theme="dark"] {
  --bg: #0d171d;
  --panel: #15232c;
  --theme-raised: #1b2c37;
  --theme-tint: #203744;
  --theme-emphasis: #285065;
  --theme-hover: #305d71;
  --text: #e3eef2;
  --muted: #bfd2d9;
  --border: #3d5966;
  --theme-link: #a4dbec;
  --sp-line-control: #7897a4;
  --sp-focus: #ffc985;
  --sp-info-bg: #173743;
  --sp-info-ink: #b0e1f0;
  --sp-info-line: #568699;
  --sp-success-bg: #1a382a;
  --sp-success-ink: #ade5bf;
  --sp-success-line: #5b9c75;
  --sp-pending-bg: #3d321b;
  --sp-pending-ink: #f4dc9e;
  --sp-pending-line: #a28751;
  --sp-warning-bg: #482d19;
  --sp-warning-ink: #ffd0a0;
  --sp-warning-line: #b27e50;
  --sp-error-bg: #442428;
  --sp-error-ink: #ffbdba;
  --sp-error-line: #ae6669;
  --sp-critical-bg: #641f29;
  --sp-critical-ink: #ffe0d9;
  --sp-critical-line: #e08080;
  --sp-disabled-bg: #25343c;
  --sp-disabled-ink: #b1c1c7;
  --sp-disabled-line: #667b86;
}

:root[data-theme="night"] {
  --bg: #0d0606;
  --panel: #170909;
  --theme-raised: #200d0c;
  --theme-tint: #29100f;
  --theme-emphasis: #351311;
  --theme-hover: #3b1513;
  --text: #ed847a;
  --muted: #cb8178;
  --border: #642b28;
  --theme-link: #f4867c;
  --sp-line-control: #ae5d56;
  --sp-focus: #ff746a;
  --sp-info-bg: #2d1211;
  --sp-info-ink: #e88e84;
  --sp-info-line: #9b554e;
  --sp-success-bg: #281411;
  --sp-success-ink: #d89487;
  --sp-success-line: #926059;
  --sp-pending-bg: #301413;
  --sp-pending-ink: #ea9388;
  --sp-pending-line: #a55a53;
  --sp-warning-bg: #411614;
  --sp-warning-ink: #fda49a;
  --sp-warning-line: #ca7168;
  --sp-error-bg: #471715;
  --sp-error-ink: #fda098;
  --sp-error-line: #c86a63;
  --sp-critical-bg: #581817;
  --sp-critical-ink: #ffb6ad;
  --sp-critical-line: #f17c72;
  --sp-disabled-bg: #291715;
  --sp-disabled-ink: #cb9791;
  --sp-disabled-line: #805752;
}

/* The application marks can be softened without altering any document or media. */
:root[data-theme="night"] :is(.brand-mark img, .home-welcome-mark) {
  filter: grayscale(1) brightness(0.82);
}

:root:is([data-theme="dark"], [data-theme="night"]) {
  background: var(--bg);
  color: var(--text);
}

:root:is([data-theme="dark"], [data-theme="night"]) :is(input, textarea)::placeholder {
  color: var(--sp-ink-muted);
  opacity: 1;
}

.theme-preferences {
  display: grid;
  gap: var(--sp-space-md);
}

.theme-choices,
.theme-schedule,
.theme-conflict-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-space-sm) var(--sp-space-lg);
}

.theme-choices label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-space-sm);
}

.theme-schedule label {
  flex: 1 1 7rem;
}

.theme-schedule button {
  align-self: end;
}

.theme-conflict-actions {
  padding: var(--sp-space-sm);
  border: 1px solid var(--sp-warning-line);
  border-radius: var(--sp-control-radius);
}

.theme-bright-reveal {
  min-block-size: var(--sp-control-height, 44px);
  margin-block: var(--sp-space-sm, 0.5rem);
}

@media (forced-colors: active) {
  .theme-choices input { accent-color: auto; }
  .theme-conflict-actions { border-color: CanvasText; }
}

[data-bright-preview][hidden],
[data-theme-source][hidden],
.theme-bright-reveal[hidden] {
  display: none !important;
}

@media screen {
  .theme-print-preview :is(body, main, th, td, .summary div, .print-header, .dossier-header) {
    color: var(--theme-ink);
    border-color: var(--theme-line);
  }

  .theme-print-preview body { background: var(--theme-canvas); }
  .theme-print-preview main { background: var(--theme-surface); }
  .theme-print-preview :is(th, .privacy) { background: var(--theme-raised); }
  .theme-print-preview :is(h1, h2, .brand, .privacy) { color: var(--theme-ink); }
  .theme-print-preview :is(.muted, .summary strong) { color: var(--theme-muted); }
  .theme-print-preview a { color: var(--theme-link); }
  .theme-print-preview button {
    background: var(--theme-emphasis);
    color: var(--theme-ink);
    min-height: 44px;
  }
}


.preferences-layout {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 0.75rem;
}
.preferences-layout > * { min-width: 0; }
.preferences-card {
  display: grid;
  align-content: start;
  gap: 0.65rem;
  padding: 0.85rem;
  border: 1px solid var(--sp-line);
  border-radius: var(--sp-control-radius);
  background: var(--sp-surface-subtle);
}
.preferences-card h3 { font-size: 1rem; }
.preferences-card .form-message { min-height: 0; margin: 0; }
.preferences-card .form-message:empty { display: none; }
.preferences-layout .theme-preferences { grid-row: span 2; }
.preferences-layout .theme-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(6.7rem, 100%), 1fr));
  gap: 0.35rem;
  padding: 0;
  margin: 0;
  border: 0;
}
.preferences-layout .theme-choices legend { padding: 0 0 0.3rem; }
.preferences-layout .theme-choices label {
  min-height: 44px;
  padding: 0.35rem;
  border: 1px solid var(--sp-line-control);
  border-radius: var(--sp-control-radius);
  background: var(--sp-surface);
}
.preferences-layout .theme-choices :is(label:has(:checked), label:hover) {
  border-color: var(--navigation-selected-border);
  background: var(--navigation-selected-surface);
}
.preferences-layout .theme-choices label:focus-within {
  outline: 2px solid var(--sp-focus);
  outline-offset: 1px;
}
.preferences-layout .mobile-shortcut-form { width: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.preferences-layout .mobile-shortcut-form button { grid-column: 1 / -1; }
.preferences-notification-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.5rem;
}
.preferences-notification-heading small { color: var(--sp-ink-muted); }
.preferences-notifications p { font-size: 0.9rem; }
.preferences-notifications .home-notification-actions { gap: 0.35rem; }
.preferences-notifications .home-notification-actions button { max-width: 100%; white-space: normal; }
@media (max-width: 720px) {
  .preferences-layout { grid-template-columns: minmax(0, 1fr); }
  .preferences-layout .theme-preferences { grid-row: auto; }
}
