/* Theme palettes — Termius-inspired. Default (no data-theme) = Termius Dark from tokens.css.
   Each theme overrides the core variables; switch live via the header theme picker (themes.js). */

:root[data-theme="midnight"] {
  --bg: #0a0e1a; --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(91,141,239,0.07), transparent 60%), #0a0e1a;
  --surface-1: #121829; --surface-2: #18203a; --surface-3: #233052;
  --color-text-primary: #e6ecf7; --color-text-secondary: #a3b0cc; --color-text-tertiary: #6b7a9c;
  --color-border-secondary: rgba(120,150,220,0.15); --color-border-tertiary: rgba(120,150,220,0.08);
  --accent: #5b8def; --accent-text: #06122e; --accent-dim: rgba(91,141,239,0.17);
  --st-done: #4dd4a8; --st-next: #5b8def;
}
:root[data-theme="carbon"] {
  --bg: #101113; --bg-grad: #101113; --surface-1: #1a1c1f; --surface-2: #212429; --surface-3: #2b2f35;
  --color-text-primary: #e8eaed; --color-text-secondary: #a8acb3; --color-text-tertiary: #71757c;
  --color-border-secondary: rgba(255,255,255,0.1); --color-border-tertiary: rgba(255,255,255,0.05);
  --accent: #2ab8cc; --accent-text: #04181c; --accent-dim: rgba(42,184,204,0.16); --st-done: #2ab8cc;
}
:root[data-theme="dracula"] {
  --bg: #1e1f29; --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(189,147,249,0.09), transparent 60%), #1e1f29;
  --surface-1: #282a36; --surface-2: #343746; --surface-3: #424559;
  --color-text-primary: #f8f8f2; --color-text-secondary: #bcc0d0; --color-text-tertiary: #8a8fa3;
  --color-border-secondary: rgba(189,147,249,0.2); --color-border-tertiary: rgba(255,255,255,0.06);
  --accent: #bd93f9; --accent-text: #1e1f29; --accent-dim: rgba(189,147,249,0.2);
  --st-done: #50fa7b; --st-active: #ffb86c; --st-next: #8be9fd; --st-blocked: #ff5555; --st-planned: #6272a4;
  --st-done-bg: rgba(80,250,123,0.14); --st-active-bg: rgba(255,184,108,0.14); --st-next-bg: rgba(139,233,253,0.14); --st-blocked-bg: rgba(255,85,85,0.15);
}
:root[data-theme="nord"] {
  --bg: #242933; --bg-grad: #242933; --surface-1: #2e3440; --surface-2: #3b4252; --surface-3: #434c5e;
  --color-text-primary: #eceff4; --color-text-secondary: #c0c8d6; --color-text-tertiary: #8a93a5;
  --color-border-secondary: rgba(136,192,208,0.2); --color-border-tertiary: rgba(255,255,255,0.06);
  --accent: #88c0d0; --accent-text: #1c2128; --accent-dim: rgba(136,192,208,0.17);
  --st-done: #a3be8c; --st-active: #ebcb8b; --st-next: #81a1c1; --st-blocked: #bf616a; --st-planned: #6c7689;
  --st-done-bg: rgba(163,190,140,0.15); --st-active-bg: rgba(235,203,139,0.15); --st-next-bg: rgba(129,161,193,0.15); --st-blocked-bg: rgba(191,97,106,0.16);
}
:root[data-theme="solarized"] {
  --bg: #002b36; --bg-grad: #002b36; --surface-1: #073642; --surface-2: #0a4250; --surface-3: #0f4d5e;
  --color-text-primary: #eee8d5; --color-text-secondary: #93a1a1; --color-text-tertiary: #657b83;
  --color-border-secondary: rgba(147,161,161,0.22); --color-border-tertiary: rgba(147,161,161,0.1);
  --accent: #268bd2; --accent-text: #002b36; --accent-dim: rgba(38,139,210,0.18);
  --st-done: #859900; --st-active: #b58900; --st-next: #268bd2; --st-blocked: #dc322f; --st-planned: #657b83;
  --st-done-bg: rgba(133,153,0,0.16); --st-active-bg: rgba(181,137,0,0.16); --st-next-bg: rgba(38,139,210,0.16); --st-blocked-bg: rgba(220,50,47,0.16);
}
:root[data-theme="matrix"] {
  --bg: #020402; --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(51,255,102,0.06), transparent 60%), #020402;
  --surface-1: #0a140c; --surface-2: #0f1f12; --surface-3: #16301a;
  --color-text-primary: #b8ffc4; --color-text-secondary: #5fd97a; --color-text-tertiary: #3a8a4d;
  --color-border-secondary: rgba(51,255,102,0.2); --color-border-tertiary: rgba(51,255,102,0.08);
  --accent: #33ff66; --accent-text: #021008; --accent-dim: rgba(51,255,102,0.14);
  --st-done: #33ff66; --st-active: #9bff33; --st-next: #33ffcc; --st-blocked: #ff5544; --st-planned: #3a8a4d;
}
:root[data-theme="amber"] {
  --bg: #140e00; --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(255,176,0,0.06), transparent 60%), #140e00;
  --surface-1: #231900; --surface-2: #2e2100; --surface-3: #3d2c00;
  --color-text-primary: #ffd591; --color-text-secondary: #d9a441; --color-text-tertiary: #9c7320;
  --color-border-secondary: rgba(255,176,0,0.22); --color-border-tertiary: rgba(255,176,0,0.09);
  --accent: #ffb000; --accent-text: #140e00; --accent-dim: rgba(255,176,0,0.15);
  --st-done: #ffb000; --st-active: #ff8c00; --st-next: #ffd591; --st-blocked: #ff5544; --st-planned: #9c7320;
}
:root[data-theme="light"] {
  --bg: #f6f7f9; --bg-grad: #f6f7f9; --surface-1: #ffffff; --surface-2: #f0f2f5; --surface-3: #e6e9ee;
  --color-text-primary: #1a1d23; --color-text-secondary: #4a5161; --color-text-tertiary: #8a909c;
  --color-border-secondary: rgba(0,0,0,0.13); --color-border-tertiary: rgba(0,0,0,0.07);
  --color-background-secondary: #eef0f3;
  --accent: #0a7d5a; --accent-text: #ffffff; --accent-dim: rgba(10,125,90,0.12);
  --st-done: #0a7d5a; --st-active: #b06d14; --st-next: #2563eb; --st-blocked: #d6453f; --st-planned: #8a909c;
  --st-done-bg: rgba(10,125,90,0.1); --st-active-bg: rgba(176,109,20,0.12); --st-next-bg: rgba(37,99,235,0.1); --st-blocked-bg: rgba(214,69,63,0.1); --st-planned-bg: rgba(138,144,156,0.12);
  --shadow-1: 0 1px 2px rgba(0,0,0,0.06); --shadow-2: 0 8px 28px rgba(0,0,0,0.12);
}
:root[data-theme="paper"] {
  --bg: #f3efe6; --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(20,140,100,0.05), transparent 60%), #f3efe6;
  --surface-1: #fbf9f3; --surface-2: #efeadd; --surface-3: #e4ddcb;
  --color-text-primary: #2a2620; --color-text-secondary: #5a5346; --color-text-tertiary: #8a8170;
  --color-border-secondary: rgba(60,50,30,0.16); --color-border-tertiary: rgba(60,50,30,0.08);
  --color-background-secondary: #efeadd;
  --accent: #1a936f; --accent-text: #ffffff; --accent-dim: rgba(26,147,111,0.13);
  --st-done: #1a936f; --st-active: #b9770e; --st-next: #2b6cb0; --st-blocked: #c53030; --st-planned: #8a8170;
  --st-done-bg: rgba(26,147,111,0.12); --st-active-bg: rgba(185,119,14,0.13); --st-next-bg: rgba(43,108,176,0.12); --st-blocked-bg: rgba(197,48,48,0.11); --st-planned-bg: rgba(138,129,112,0.13);
  --shadow-1: 0 1px 2px rgba(60,50,30,0.08); --shadow-2: 0 8px 28px rgba(60,50,30,0.12);
}
:root[data-theme="solar-light"] {
  --bg: #fdf6e3; --bg-grad: #fdf6e3; --surface-1: #fbf1d8; --surface-2: #eee8d5; --surface-3: #e3dcc4;
  --color-text-primary: #073642; --color-text-secondary: #586e75; --color-text-tertiary: #93a1a1;
  --color-border-secondary: rgba(88,110,117,0.22); --color-border-tertiary: rgba(88,110,117,0.12);
  --color-background-secondary: #eee8d5;
  --accent: #268bd2; --accent-text: #ffffff; --accent-dim: rgba(38,139,210,0.14);
  --st-done: #859900; --st-active: #b58900; --st-next: #268bd2; --st-blocked: #dc322f; --st-planned: #93a1a1;
  --st-done-bg: rgba(133,153,0,0.14); --st-active-bg: rgba(181,137,0,0.14); --st-next-bg: rgba(38,139,210,0.14); --st-blocked-bg: rgba(220,50,47,0.13); --st-planned-bg: rgba(147,161,161,0.16);
  --shadow-1: 0 1px 2px rgba(7,54,66,0.08); --shadow-2: 0 8px 28px rgba(7,54,66,0.12);
}
:root[data-theme="nord-light"] {
  --bg: #eceff4; --bg-grad: #eceff4; --surface-1: #ffffff; --surface-2: #e5e9f0; --surface-3: #d8dee9;
  --color-text-primary: #2e3440; --color-text-secondary: #434c5e; --color-text-tertiary: #7b8494;
  --color-border-secondary: rgba(46,52,64,0.15); --color-border-tertiary: rgba(46,52,64,0.08);
  --color-background-secondary: #e5e9f0;
  --accent: #5e81ac; --accent-text: #ffffff; --accent-dim: rgba(94,129,172,0.14);
  --st-done: #5e8a6a; --st-active: #b58a3c; --st-next: #5e81ac; --st-blocked: #bf616a; --st-planned: #7b8494;
  --st-done-bg: rgba(94,138,106,0.14); --st-active-bg: rgba(181,138,60,0.14); --st-next-bg: rgba(94,129,172,0.14); --st-blocked-bg: rgba(191,97,106,0.13); --st-planned-bg: rgba(123,132,148,0.15);
  --shadow-1: 0 1px 2px rgba(46,52,64,0.08); --shadow-2: 0 8px 28px rgba(46,52,64,0.12);
}
:root[data-theme="daylight"] {
  --bg: #f4f7fb; --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(37,99,235,0.05), transparent 60%), #f4f7fb;
  --surface-1: #ffffff; --surface-2: #eef2f8; --surface-3: #e1e8f2;
  --color-text-primary: #16202e; --color-text-secondary: #46566b; --color-text-tertiary: #7e8a9d;
  --color-border-secondary: rgba(20,40,70,0.13); --color-border-tertiary: rgba(20,40,70,0.07);
  --color-background-secondary: #eef2f8;
  --accent: #2563eb; --accent-text: #ffffff; --accent-dim: rgba(37,99,235,0.12);
  --st-done: #0a7d5a; --st-active: #b06d14; --st-next: #2563eb; --st-blocked: #d6453f; --st-planned: #7e8a9d;
  --st-done-bg: rgba(10,125,90,0.11); --st-active-bg: rgba(176,109,20,0.12); --st-next-bg: rgba(37,99,235,0.11); --st-blocked-bg: rgba(214,69,63,0.1); --st-planned-bg: rgba(126,138,157,0.14);
  --shadow-1: 0 1px 2px rgba(20,40,70,0.07); --shadow-2: 0 8px 28px rgba(20,40,70,0.1);
}
:root[data-theme="sand"] {
  --bg: #efe9df; --bg-grad: #efe9df; --surface-1: #f8f4ec; --surface-2: #e8e0d2; --surface-3: #dcd2bf;
  --color-text-primary: #3a3226; --color-text-secondary: #665c4a; --color-text-tertiary: #998b72;
  --color-border-secondary: rgba(90,70,40,0.16); --color-border-tertiary: rgba(90,70,40,0.08);
  --color-background-secondary: #e8e0d2;
  --accent: #c2683a; --accent-text: #ffffff; --accent-dim: rgba(194,104,58,0.14);
  --st-done: #6b8e23; --st-active: #c2683a; --st-next: #3a7ca5; --st-blocked: #b3433a; --st-planned: #998b72;
  --st-done-bg: rgba(107,142,35,0.13); --st-active-bg: rgba(194,104,58,0.13); --st-next-bg: rgba(58,124,165,0.13); --st-blocked-bg: rgba(179,67,58,0.12); --st-planned-bg: rgba(153,139,114,0.15);
  --shadow-1: 0 1px 2px rgba(90,70,40,0.08); --shadow-2: 0 8px 28px rgba(90,70,40,0.12);
}

/* ---- New high-contrast light options (added 2026-07-01; existing light themes left as-is) ---- */
:root[data-theme="daybreak"] {
  --bg: #eef1f6; --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(29,78,216,0.06), transparent 60%), #eef1f6;
  --surface-1: #ffffff; --surface-2: #e4e9f2; --surface-3: #d3dbe8;
  --color-text-primary: #0f1826; --color-text-secondary: #38445a; --color-text-tertiary: #5e6b82;
  --color-border-secondary: rgba(15,24,38,0.18); --color-border-tertiary: rgba(15,24,38,0.10);
  --color-background-secondary: #e4e9f2;
  --accent: #1d4ed8; --accent-text: #ffffff; --accent-dim: rgba(29,78,216,0.16);
  --st-done: #0a7d5a; --st-active: #b45309; --st-next: #1d4ed8; --st-blocked: #c81e2c; --st-planned: #5e6b82;
  --st-done-bg: rgba(10,125,90,0.14); --st-active-bg: rgba(180,83,9,0.15); --st-next-bg: rgba(29,78,216,0.14); --st-blocked-bg: rgba(200,30,44,0.13); --st-planned-bg: rgba(94,107,130,0.16);
  --hover-bg: rgba(15,24,38,0.06);
  --shadow-1: 0 1px 2px rgba(15,24,38,0.08); --shadow-2: 0 10px 30px rgba(15,24,38,0.14);
}
:root[data-theme="linen"] {
  --bg: #f5f1e8; --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(15,122,82,0.05), transparent 60%), #f5f1e8;
  --surface-1: #fffdf7; --surface-2: #ece5d5; --surface-3: #ded4bf;
  --color-text-primary: #241f16; --color-text-secondary: #4c4436; --color-text-tertiary: #6f6552;
  --color-border-secondary: rgba(36,31,22,0.18); --color-border-tertiary: rgba(36,31,22,0.10);
  --color-background-secondary: #ece5d5;
  --accent: #0f7a52; --accent-text: #ffffff; --accent-dim: rgba(15,122,82,0.16);
  --st-done: #0f7a52; --st-active: #9a6410; --st-next: #1f6feb; --st-blocked: #b3261e; --st-planned: #6f6552;
  --st-done-bg: rgba(15,122,82,0.14); --st-active-bg: rgba(154,100,16,0.15); --st-next-bg: rgba(31,111,235,0.13); --st-blocked-bg: rgba(179,38,30,0.12); --st-planned-bg: rgba(111,101,82,0.16);
  --hover-bg: rgba(36,31,22,0.06);
  --shadow-1: 0 1px 2px rgba(36,31,22,0.08); --shadow-2: 0 10px 30px rgba(36,31,22,0.14);
}
:root[data-theme="frost"] {
  --bg: #f4f6f8; --bg-grad: #f4f6f8; --surface-1: #ffffff; --surface-2: #e9edf1; --surface-3: #dae0e6;
  --color-text-primary: #111418; --color-text-secondary: #3a424c; --color-text-tertiary: #616a75;
  --color-border-secondary: rgba(17,20,24,0.16); --color-border-tertiary: rgba(17,20,24,0.09);
  --color-background-secondary: #e9edf1;
  --accent: #0b6bcb; --accent-text: #ffffff; --accent-dim: rgba(11,107,203,0.15);
  --st-done: #0a7d5a; --st-active: #a85b00; --st-next: #0b6bcb; --st-blocked: #c62828; --st-planned: #616a75;
  --st-done-bg: rgba(10,125,90,0.13); --st-active-bg: rgba(168,91,0,0.14); --st-next-bg: rgba(11,107,203,0.13); --st-blocked-bg: rgba(198,40,40,0.12); --st-planned-bg: rgba(97,106,117,0.15);
  --hover-bg: rgba(17,20,24,0.055);
  --shadow-1: 0 1px 2px rgba(17,20,24,0.07); --shadow-2: 0 10px 30px rgba(17,20,24,0.13);
}
/* Give the pre-existing light themes a working (dark-on-light) row hover — their palettes are
   intentionally left untouched. Selection is NOT overridden anywhere: every theme inherits
   --selected-bg = color-mix(accent 22%) from tokens.css, resolved against its own --accent. */
:root[data-theme="light"], :root[data-theme="paper"], :root[data-theme="solar-light"],
:root[data-theme="nord-light"], :root[data-theme="daylight"], :root[data-theme="sand"] {
  --hover-bg: rgba(0,0,0,0.055);
}

/* ---- Island-era schemes (2026-07-12) — designed for the two-tier deck + elevated canvas.
   Balanced-contrast ramps; selection/deck/interaction all derive from these via tokens.css. ---- */
:root[data-theme="nocturne"] {
  --bg: #0d1017; --bg-grad: radial-gradient(1100px 520px at 55% -12%, rgba(46,230,166,0.08), rgba(40,200,232,0.04) 55%, transparent 75%), #0d1017;
  --surface-1: #151923; --surface-2: #1d2330; --surface-3: #29303f;
  --color-text-primary: #edf0f5; --color-text-secondary: #a8b1c2; --color-text-tertiary: #67707f;
  --color-border-secondary: rgba(165,190,235,0.15); --color-border-tertiary: rgba(165,190,235,0.08);
  --color-background-secondary: #1d2330;
  --accent: #2ee6a6; --accent-text: #06231a; --accent-dim: rgba(46,230,166,0.15);
  --st-done: #2ee6a6; --st-active: #e8b13c; --st-next: #28c8e8; --st-blocked: #e0606e; --st-planned: #67707f;
  --st-done-bg: rgba(46,230,166,0.13); --st-active-bg: rgba(232,177,60,0.13); --st-next-bg: rgba(40,200,232,0.13); --st-blocked-bg: rgba(224,96,110,0.14);
}
:root[data-theme="foundry"] {
  --bg: #16140f; --bg-grad: radial-gradient(1100px 520px at 80% -12%, rgba(255,93,64,0.06), transparent 65%), #16140f;
  --surface-1: #1d1a15; --surface-2: #26221c; --surface-3: #322d25;
  --color-text-primary: #f0eee9; --color-text-secondary: #a8a297; --color-text-tertiary: #746e63;
  --color-border-secondary: rgba(240,238,233,0.13); --color-border-tertiary: rgba(240,238,233,0.07);
  --color-background-secondary: #26221c;
  --accent: #ff6a4d; --accent-text: #2b1209; --accent-dim: rgba(255,106,77,0.14);
  --st-done: #3ecf8e; --st-active: #e0a23a; --st-next: #5aa2e8; --st-blocked: #e0606e; --st-planned: #746e63;
  --st-done-bg: rgba(62,207,142,0.13); --st-active-bg: rgba(224,162,58,0.13); --st-next-bg: rgba(90,162,232,0.13); --st-blocked-bg: rgba(224,96,110,0.14);
}
:root[data-theme="atrium"] {
  --bg: #faf9f6; --bg-grad: radial-gradient(1100px 520px at 70% -12%, rgba(37,71,244,0.05), transparent 65%), #faf9f6;
  --surface-1: #ffffff; --surface-2: #f1efe9; --surface-3: #e6e3da;
  --color-text-primary: #16181d; --color-text-secondary: #5f6672; --color-text-tertiary: #8b919c;
  --color-border-secondary: rgba(22,24,29,0.14); --color-border-tertiary: rgba(22,24,29,0.08);
  --color-background-secondary: #f1efe9;
  --accent: #2547f4; --accent-text: #ffffff; --accent-dim: rgba(37,71,244,0.10);
  --st-done: #158f60; --st-active: #b06d14; --st-next: #2547f4; --st-blocked: #cf3a46; --st-planned: #8b919c;
  --st-done-bg: rgba(21,143,96,0.11); --st-active-bg: rgba(176,109,20,0.12); --st-next-bg: rgba(37,71,244,0.10); --st-blocked-bg: rgba(207,58,70,0.11);
  --hover-bg: rgba(22,24,29,0.05);
  --shadow-1: 0 1px 2px rgba(22,24,29,0.06); --shadow-2: 0 10px 30px rgba(22,24,29,0.10);
}

/* Theme picker (header) */
.theme-wrap { position: relative; margin-left: 8px; }
.theme-btn { background: var(--surface-1); border: 1px solid var(--color-border-secondary); color: var(--color-text-secondary); border-radius: 8px; padding: 2px 9px; cursor: pointer; font-size: 13px; line-height: 1.4; }
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }
.theme-menu { position: absolute; right: 0; top: 128%; background: var(--surface-1); border: 1px solid var(--color-border-secondary); border-radius: 11px; padding: 5px; display: none; flex-direction: column; gap: 1px; z-index: 60; box-shadow: var(--shadow-2); min-width: 156px; }
/* Custom-theme editor popover (opened from the "Custom…" theme row) */
.theme-custom-pop { position: fixed; z-index: 220; background: var(--surface-1); border: 1px solid var(--color-border-secondary); border-radius: 11px; padding: 12px 14px; box-shadow: var(--shadow-2); width: 240px; }
.theme-custom-pop .tc-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; color: var(--color-text-primary); }
.theme-custom-pop .tc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 12.5px; color: var(--color-text-secondary); }
.theme-custom-pop .tc-row input[type="color"] { width: 42px; height: 26px; padding: 1px; border: 1px solid var(--color-border-secondary); border-radius: var(--border-radius-md); background: var(--surface-2); cursor: pointer; }
.theme-custom-pop .tc-actions { margin-top: 10px; display: flex; justify-content: flex-end; gap: 6px; }
.theme-custom-pop .tc-name { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0 8px; font-size: 12.5px; color: var(--color-text-secondary); }
.theme-custom-pop .tc-name input { flex: 1; max-width: 150px; background: var(--surface-2); border: 1px solid var(--color-border-secondary); border-radius: var(--border-radius-md); color: var(--color-text-primary); padding: 5px 8px; font-size: 12.5px; }
.theme-custom-pop .tc-del { color: var(--st-blocked); border-color: var(--st-blocked); margin-right: auto; }
.theme-opt .theme-edit { margin-left: auto; color: var(--color-text-tertiary); font-size: 11px; padding: 2px 4px; border-radius: 4px; }
.theme-opt .theme-edit:hover { color: var(--color-text-primary); background: var(--surface-3); }
.theme-optname { flex: 1; text-align: left; }
.theme-sep { height: 1px; background: var(--color-border-tertiary); margin: 4px 2px; }
.theme-new .theme-sw-plus { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--color-text-secondary); font-weight: 700; }
.theme-new .theme-optname { color: var(--color-text-secondary); }
.theme-menu.open { display: flex; }
.theme-opt { display: flex; align-items: center; gap: 9px; padding: 6px 10px; background: transparent; border: 0; border-radius: 7px; color: var(--color-text-secondary); cursor: pointer; font-size: 12px; font-family: inherit; text-align: left; }
.theme-opt:hover { background: var(--surface-2); color: var(--color-text-primary); }
.theme-opt.on { color: var(--accent); font-weight: 600; }
.theme-sw { width: 13px; height: 13px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(255,255,255,0.18); }
