/* Whole-app appearance: palette changes chrome only, never stored shift colours. */
:root[data-palette="green"][data-mode="light"] {
  --brand-ink: #0b5836;
  --brand-accent: #839e65;
  --brand-soft: #d7dfc7;
  color-scheme: light;
  --theme-page: #f3f5f3;
  --theme-surface: #ffffff;
  --theme-surface-soft: #eff3f2;
  --theme-hover: #e1eae8;
  --theme-selected: #dee8e5;
  --theme-ink: #142c32;
  --theme-muted: #485954;
  --theme-line: #70857f;
  --theme-accent: #246d61;
  --theme-primary: #142c32;
  --theme-primary-hover: #285053;
  --theme-on-primary: #ffffff;
  --theme-focus: #356e5f;
  --theme-overlay: #112c3266;
  --theme-danger-surface: #f6e9e9;
  --theme-danger-ink: #6e1c1c;
  --theme-danger-border: #9b3b3b;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #f6f1e9;
  --theme-warning-ink: #6e501c;
  --theme-warning-border: #9b783b;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #e9f6ef;
  --theme-success-ink: #1c6e42;
  --theme-success-border: #3b9b68;
  --theme-success-solid: #1f7a49;
}
:root[data-palette="green"][data-mode="dark"] {
  color-scheme: dark;
  --theme-page: #131917;
  --theme-surface: #1b2422;
  --theme-surface-soft: #25322f;
  --theme-hover: #2b3d39;
  --theme-selected: #2d433d;
  --theme-ink: #eef2f1;
  --theme-muted: #bbc8c5;
  --theme-line: #7f948e;
  --theme-accent: #b0d9ce;
  --theme-primary: #acd7cc;
  --theme-primary-hover: #c8e4dd;
  --theme-on-primary: #171c1b;
  --theme-focus: #b3dbd0;
  --theme-overlay: #050b12b3;
  --theme-danger-surface: #451c1c;
  --theme-danger-ink: #edb6b6;
  --theme-danger-border: #ce7e7e;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #45361c;
  --theme-warning-ink: #edd8b6;
  --theme-warning-border: #ceb07e;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #1c452f;
  --theme-success-ink: #b6edcf;
  --theme-success-border: #7ecea3;
  --theme-success-solid: #1f7a49;
}
:root[data-palette="blue"][data-mode="light"] {
  --brand-ink: #0b3752;
  --brand-accent: #5399c4;
  --brand-soft: #c6e0f3;
  color-scheme: light;
  --theme-page: #f1f3f6;
  --theme-surface: #fdfdfe;
  --theme-surface-soft: #eef1f4;
  --theme-hover: #dfe5ec;
  --theme-selected: #dbe3eb;
  --theme-ink: #1c2228;
  --theme-muted: #44505c;
  --theme-line: #6b7a8a;
  --theme-accent: #24466b;
  --theme-primary: #172d45;
  --theme-primary-hover: #1f3c5c;
  --theme-on-primary: #ffffff;
  --theme-focus: #29507a;
  --theme-overlay: #112c3266;
  --theme-danger-surface: #f6e9e9;
  --theme-danger-ink: #6e1c1c;
  --theme-danger-border: #9b3b3b;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #f6f1e9;
  --theme-warning-ink: #6e501c;
  --theme-warning-border: #9b783b;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #e9f6ef;
  --theme-success-ink: #1c6e42;
  --theme-success-border: #3b9b68;
  --theme-success-solid: #1f7a49;
}
:root[data-palette="blue"][data-mode="dark"] {
  color-scheme: dark;
  --theme-page: #11161a;
  --theme-surface: #1a2026;
  --theme-surface-soft: #222b35;
  --theme-hover: #273441;
  --theme-selected: #293848;
  --theme-ink: #edf0f2;
  --theme-muted: #b9c1cb;
  --theme-line: #7b8998;
  --theme-accent: #a7c3e2;
  --theme-primary: #a3c1e0;
  --theme-primary-hover: #c2d6eb;
  --theme-on-primary: #16191d;
  --theme-focus: #abc6e3;
  --theme-overlay: #050b12b3;
  --theme-danger-surface: #451c1c;
  --theme-danger-ink: #edb6b6;
  --theme-danger-border: #ce7e7e;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #45361c;
  --theme-warning-ink: #edd8b6;
  --theme-warning-border: #ceb07e;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #1c452f;
  --theme-success-ink: #b6edcf;
  --theme-success-border: #7ecea3;
  --theme-success-solid: #1f7a49;
}
:root[data-palette="coral"][data-mode="light"] {
  --brand-ink: #5f1020;
  --brand-accent: #f37061;
  --brand-soft: #fbc8bc;
  color-scheme: light;
  --theme-page: #f6f2f0;
  --theme-surface: #fefdfc;
  --theme-surface-soft: #f5eeeb;
  --theme-hover: #ece0db;
  --theme-selected: #eadcd5;
  --theme-ink: #2b201c;
  --theme-muted: #60463d;
  --theme-line: #8c7167;
  --theme-accent: #7a3625;
  --theme-primary: #4e2319;
  --theme-primary-hover: #663021;
  --theme-on-primary: #ffffff;
  --theme-focus: #8c3e2b;
  --theme-overlay: #112c3266;
  --theme-danger-surface: #f6e9e9;
  --theme-danger-ink: #6e1c1c;
  --theme-danger-border: #9b3b3b;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #f6f1e9;
  --theme-warning-ink: #6e501c;
  --theme-warning-border: #9b783b;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #e9f6ef;
  --theme-success-ink: #1c6e42;
  --theme-success-border: #3b9b68;
  --theme-success-solid: #1f7a49;
}
:root[data-palette="coral"][data-mode="dark"] {
  color-scheme: dark;
  --theme-page: #1c1411;
  --theme-surface: #291d18;
  --theme-surface-soft: #372720;
  --theme-hover: #442f26;
  --theme-selected: #49332a;
  --theme-ink: #f6efeb;
  --theme-muted: #d3c0b7;
  --theme-line: #9f8477;
  --theme-accent: #edb39d;
  --theme-primary: #ebb098;
  --theme-primary-hover: #f2d0c1;
  --theme-on-primary: #211811;
  --theme-focus: #efbba7;
  --theme-overlay: #050b12b3;
  --theme-danger-surface: #451c1c;
  --theme-danger-ink: #edb6b6;
  --theme-danger-border: #ce7e7e;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #45361c;
  --theme-warning-ink: #edd8b6;
  --theme-warning-border: #ceb07e;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #1c452f;
  --theme-success-ink: #b6edcf;
  --theme-success-border: #7ecea3;
  --theme-success-solid: #1f7a49;
}
:root[data-palette="purple"][data-mode="light"] {
  --brand-ink: #402046;
  --brand-accent: #a477b7;
  --brand-soft: #e4d1ed;
  color-scheme: light;
  --theme-page: #f4f2f5;
  --theme-surface: #fdfdfd;
  --theme-surface-soft: #f2eff3;
  --theme-hover: #e7e1ea;
  --theme-selected: #e5dde9;
  --theme-ink: #241e27;
  --theme-muted: #534759;
  --theme-line: #7e6f86;
  --theme-accent: #4f2c63;
  --theme-primary: #331c3f;
  --theme-primary-hover: #432654;
  --theme-on-primary: #ffffff;
  --theme-focus: #5a3371;
  --theme-overlay: #112c3266;
  --theme-danger-surface: #f6e9e9;
  --theme-danger-ink: #6e1c1c;
  --theme-danger-border: #9b3b3b;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #f6f1e9;
  --theme-warning-ink: #6e501c;
  --theme-warning-border: #9b783b;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #e9f6ef;
  --theme-success-ink: #1c6e42;
  --theme-success-border: #3b9b68;
  --theme-success-solid: #1f7a49;
}
:root[data-palette="purple"][data-mode="dark"] {
  color-scheme: dark;
  --theme-page: #171219;
  --theme-surface: #211b25;
  --theme-surface-soft: #2d2433;
  --theme-hover: #372a3e;
  --theme-selected: #3b2c44;
  --theme-ink: #f0eef2;
  --theme-muted: #c4bbc9;
  --theme-line: #8d7f95;
  --theme-accent: #caaedb;
  --theme-primary: #c8abd9;
  --theme-primary-hover: #dac7e6;
  --theme-on-primary: #1a171c;
  --theme-focus: #cdb2dc;
  --theme-overlay: #050b12b3;
  --theme-danger-surface: #451c1c;
  --theme-danger-ink: #edb6b6;
  --theme-danger-border: #ce7e7e;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #45361c;
  --theme-warning-ink: #edd8b6;
  --theme-warning-border: #ceb07e;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #1c452f;
  --theme-success-ink: #b6edcf;
  --theme-success-border: #7ecea3;
  --theme-success-solid: #1f7a49;
}
:root, :root[data-palette="teal"][data-mode="light"] {
  --brand-ink: #292f31;
  --brand-accent: #4c9e9b;
  --brand-soft: #c2e0dc;
  color-scheme: light;
  --theme-page: #f1f5f6;
  --theme-surface: #fdfdfe;
  --theme-surface-soft: #eef3f4;
  --theme-hover: #e0eaeb;
  --theme-selected: #dce9ea;
  --theme-ink: #1d2728;
  --theme-muted: #455a5b;
  --theme-line: #6d8688;
  --theme-accent: #276368;
  --theme-primary: #194043;
  --theme-primary-hover: #225559;
  --theme-on-primary: #ffffff;
  --theme-focus: #2d7176;
  --theme-overlay: #112c3266;
  --theme-danger-surface: #f6e9e9;
  --theme-danger-ink: #6e1c1c;
  --theme-danger-border: #9b3b3b;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #f6f1e9;
  --theme-warning-ink: #6e501c;
  --theme-warning-border: #9b783b;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #e9f6ef;
  --theme-success-ink: #1c6e42;
  --theme-success-border: #3b9b68;
  --theme-success-solid: #1f7a49;
}
:root[data-palette="teal"][data-mode="dark"] {
  color-scheme: dark;
  --theme-page: #12191a;
  --theme-surface: #1a2526;
  --theme-surface-soft: #233334;
  --theme-hover: #293e40;
  --theme-selected: #2a4446;
  --theme-ink: #edf2f2;
  --theme-muted: #bac9ca;
  --theme-line: #7d9597;
  --theme-accent: #aadbdf;
  --theme-primary: #a6dadd;
  --theme-primary-hover: #c4e6e9;
  --theme-on-primary: #161c1d;
  --theme-focus: #aedde0;
  --theme-overlay: #050b12b3;
  --theme-danger-surface: #451c1c;
  --theme-danger-ink: #edb6b6;
  --theme-danger-border: #ce7e7e;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #45361c;
  --theme-warning-ink: #edd8b6;
  --theme-warning-border: #ceb07e;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #1c452f;
  --theme-success-ink: #b6edcf;
  --theme-success-border: #7ecea3;
  --theme-success-solid: #1f7a49;
}
:root[data-palette="amber"][data-mode="light"] {
  --brand-ink: #08334b;
  --brand-accent: #df9c32;
  --brand-soft: #f7dfb6;
  color-scheme: light;
  --theme-page: #f6f4f1;
  --theme-surface: #fefdfc;
  --theme-surface-soft: #f4f2ee;
  --theme-hover: #ece7df;
  --theme-selected: #eae5dc;
  --theme-ink: #28241d;
  --theme-muted: #5c5345;
  --theme-line: #897e6c;
  --theme-accent: #6a5125;
  --theme-primary: #443418;
  --theme-primary-hover: #5b4520;
  --theme-on-primary: #ffffff;
  --theme-focus: #795c2a;
  --theme-overlay: #112c3266;
  --theme-danger-surface: #f6e9e9;
  --theme-danger-ink: #6e1c1c;
  --theme-danger-border: #9b3b3b;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #f6f1e9;
  --theme-warning-ink: #6e501c;
  --theme-warning-border: #9b783b;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #e9f6ef;
  --theme-success-ink: #1c6e42;
  --theme-success-border: #3b9b68;
  --theme-success-solid: #1f7a49;
}
:root[data-palette="amber"][data-mode="dark"] {
  color-scheme: dark;
  --theme-page: #1a1712;
  --theme-surface: #26221a;
  --theme-surface-soft: #352e22;
  --theme-hover: #413828;
  --theme-selected: #473c29;
  --theme-ink: #f2f0ed;
  --theme-muted: #cbc4b9;
  --theme-line: #988d7c;
  --theme-accent: #e1cca8;
  --theme-primary: #dfcaa4;
  --theme-primary-hover: #eadbc3;
  --theme-on-primary: #1d1a16;
  --theme-focus: #e2ceac;
  --theme-overlay: #050b12b3;
  --theme-danger-surface: #451c1c;
  --theme-danger-ink: #edb6b6;
  --theme-danger-border: #ce7e7e;
  --theme-danger-solid: #7a1f1f;
  --theme-warning-surface: #45361c;
  --theme-warning-ink: #edd8b6;
  --theme-warning-border: #ceb07e;
  --theme-warning-solid: #7a591f;
  --theme-success-surface: #1c452f;
  --theme-success-ink: #b6edcf;
  --theme-success-border: #7ecea3;
  --theme-success-solid: #1f7a49;
}

:root {
  --brand-ink: #292f31;
  --brand-accent: #4c9e9b;
  --brand-soft: #c2e0dc;
  --theme-on-status-solid: #fff;
  --theme-browser: var(--theme-page);
  --ink: var(--theme-ink); --muted: var(--theme-muted); --line: var(--theme-line);
  --accent: var(--theme-accent); --primary: var(--theme-primary); --border: var(--theme-line);
  --green: var(--theme-primary); --paper: var(--theme-surface); --wash: var(--theme-page);
  color: var(--theme-ink); background: var(--theme-page);
}
/* UA controls and standalone dialogs also need explicit surfaces. */
input, select, textarea, dialog { color: var(--theme-ink); background-color: var(--theme-surface); }
input::placeholder, textarea::placeholder { color: var(--theme-muted); opacity: 1; }
input[type=checkbox], input[type=radio] { accent-color: var(--theme-accent); }
a { color: var(--theme-accent); }
button.primary:hover { background: var(--theme-primary-hover); }
.app-appearance { min-width: 0; }
.app-appearance fieldset { border: 0; padding: 0; margin: 18px 0; min-width: 0; }
.app-appearance legend { font-size: 14px; font-weight: 700; padding: 0; margin-bottom: 10px; }
.theme-palette-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.theme-palette-option, .theme-mode-options label { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 12px; border: 1px solid var(--theme-line); border-radius: 10px; background: var(--theme-surface); color: var(--theme-ink); cursor: pointer; font-size: 13px; overflow-wrap: anywhere; }
.theme-palette-option:hover, .theme-mode-options label:hover { background: var(--theme-hover); }
.theme-palette-option:has(input:checked), .theme-mode-options label:has(input:checked) { background: var(--theme-selected); outline: 2px solid var(--theme-accent); outline-offset: -2px; }
.theme-palette-option:focus-within, .theme-mode-options label:focus-within { outline: 3px solid var(--theme-focus); outline-offset: 3px; }
.theme-palette-option input, .theme-mode-options input { width: 18px; height: 18px; flex: 0 0 18px; margin: 0; }
.theme-swatch { display: inline-block; width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%; border: 1px solid var(--theme-line); background: #246d61; }
.theme-palette-option[data-palette="blue"] .theme-swatch { background: #245f99; }
.theme-palette-option[data-palette="coral"] .theme-swatch { background: #ba5038; }
.theme-palette-option[data-palette="purple"] .theme-swatch { background: #784697; }
.theme-palette-option[data-palette="teal"] .theme-swatch { background: #237c82; }
.theme-palette-option[data-palette="amber"] .theme-swatch { background: #926715; }
.theme-mode-options { display: flex; flex-wrap: wrap; gap: 10px; }
.theme-mode-options label { flex: 1; }
.theme-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.theme-actions button { min-height: 44px; }
.theme-status { min-height: 1.5em; color: var(--theme-muted); font-size: 13px; line-height: 1.5; }
@media (max-width: 550px) { .theme-palette-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .theme-palette-option { padding: 10px 8px; gap: 6px; } }
/* Print is always light paper, regardless of saved/device mode. */
@media print {
  :root[data-palette][data-mode], :root {
    color-scheme: light;

    --theme-page: #f3f5f3;
    --theme-surface: #ffffff;
    --theme-surface-soft: #eff3f2;
    --theme-hover: #e1eae8;
    --theme-selected: #dee8e5;
    --theme-ink: #142c32;
    --theme-muted: #485954;
    --theme-line: #70857f;
    --theme-accent: #246d61;
    --theme-primary: #142c32;
    --theme-primary-hover: #285053;
    --theme-on-primary: #ffffff;
    --theme-focus: #356e5f;
    --theme-overlay: #112c3266;
    --theme-danger-surface: #f6e9e9;
    --theme-danger-ink: #6e1c1c;
    --theme-danger-border: #9b3b3b;
    --theme-danger-solid: #7a1f1f;
    --theme-warning-surface: #f6f1e9;
    --theme-warning-ink: #6e501c;
    --theme-warning-border: #9b783b;
    --theme-warning-solid: #7a591f;
    --theme-success-surface: #e9f6ef;
    --theme-success-ink: #1c6e42;
    --theme-success-border: #3b9b68;
    --theme-success-solid: #1f7a49;

    --theme-page: #fff; --theme-surface: #fff; --theme-surface-soft: #fff;
    --theme-hover: #fff; --theme-selected: #fff;
  }
  body { color: #142c32; background: #fff; }
  .app-appearance { display: none !important; }
}

/* Compact menu settings remain usable without changing any planner controls. */
.appearance-settings > summary { cursor: pointer; font-weight: 700; padding: 8px 0; min-height: 44px; }
.appearance-settings > h3 { margin-top: 10px; }
.planner-menu .theme-palette-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.planner-menu .theme-mode-options { gap: 6px; }
.planner-menu .theme-mode-options label { padding: 10px 6px; gap: 5px; }

.theme-status.error { color: var(--theme-danger-ink); }

/* Dedicated logo colours follow the selected concept, not text/control colours. */
:root[data-mode="dark"] {
  --brand-ink: var(--theme-ink);
  --brand-accent: var(--theme-accent);
  --brand-soft: var(--theme-selected);
}

/* Duty cards keep their semantic pastel backgrounds in both modes. */
.shift-large small, .shift-large .muted { color: inherit; }
