/* ==========================================================================
   TDMConsole WebUI — Material Design 3.
   Tonal surfaces + state layers + MD3 elevation/shape/typography. Two colour
   schemes (light / dark) selected via [data-theme] on <html>, persisted in
   localStorage; defaults to the OS preference. The accent (MD3 "primary") is
   independently themeable: everything derives from --accent-r/g/b, set at
   runtime by Settings → Theme picker. Default accent = Twitch purple.
   WCAG 2.2 AA, keyboard-first.
   ========================================================================== */
:root {
  /* ---- THEME ACCENT (overridable at runtime) --------------------------- */
  /* Only these three channels need to change to re-theme the whole UI. */
  --accent-r: 145;
  --accent-g: 70;
  --accent-b: 255;

  /* MD3 primary tonal roles, derived from the accent (scheme-independent). */
  --primary:            rgb(var(--accent-r), var(--accent-g), var(--accent-b));
  --primary-hover:      color-mix(in srgb, var(--primary) 88%, white);
  --on-primary:         #ffffff;
  /* translucent primary for MD3 "state layers" (hover/focus/press overlays) */
  --state-hover:   rgba(var(--accent-r), var(--accent-g), var(--accent-b), .08);
  --state-focus:   rgba(var(--accent-r), var(--accent-g), var(--accent-b), .12);
  --state-press:   rgba(var(--accent-r), var(--accent-g), var(--accent-b), .16);
  --primary-faint: rgba(var(--accent-r), var(--accent-g), var(--accent-b), .14);

  --text: var(--on-surface);
  --text-muted: var(--on-surface-variant);

  /* spacing 4/8/12/16/24/32 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px;
  /* type 12/14/16/20/24/32 */
  --t-xs: 12px; --t-sm: 14px; --t-md: 16px; --t-lg: 20px; --t-xl: 24px; --t-2xl: 32px;

  /* MD3 shape scale */
  --radius-xs: 8px;    /* extra-small */
  --radius-sm: 12px;   /* small */
  --radius: 16px;      /* medium / large containers */
  --radius-xl: 28px;   /* extra-large (dialogs) */

  --font: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: var(--font);
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
}

/* ---- DARK scheme (default) ---------------------------------------------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --primary-container:  color-mix(in srgb, var(--primary) 30%, #1c1b1f);
  --on-primary-container: color-mix(in srgb, var(--primary) 78%, white);

  /* status (accent-independent semantic colours) */
  --success: #4CD196;
  --success-container: #0f3d2c;
  --warning: #FFB865;
  --warning-container: #3d2f14;
  --danger: #FF8A80;
  --danger-container: #3d1512;

  /* MD3 dark neutral surfaces (tonal elevation via container tints) */
  --bg-base:            #131218;   /* app background */
  --surface:            #1a191f;   /* base surface */
  --surface-container-low:  #1f1e25;
  --surface-container:      #24232b;
  --surface-container-high: #2b2933;
  --surface-container-highest: #33313c;
  --outline:            #948f9e;   /* borders / dividers (AA) */
  --outline-variant:    #46454f;   /* subtle dividers */
  --on-surface:         #e7e1ec;   /* primary text */
  --on-surface-variant: #cac4d0;   /* secondary text */
  --screen-bg: #0f0e13;            /* console: dark terminal in dark mode */
  --screen-fg: #d8e8dc;

  /* MD3 elevation levels (key + ambient umbra), dark-tuned */
  --elev-1: 0 1px 2px rgba(0,0,0,.30), 0 1px 3px 1px rgba(0,0,0,.15);
  --elev-2: 0 1px 2px rgba(0,0,0,.30), 0 2px 6px 2px rgba(0,0,0,.15);
  --elev-3: 0 4px 8px 3px rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.30);
  --elev-4: 0 6px 10px 4px rgba(0,0,0,.15), 0 2px 3px rgba(0,0,0,.30);
  --elev-5: 0 8px 12px 6px rgba(0,0,0,.15), 0 4px 4px rgba(0,0,0,.30);
}

/* ---- LIGHT scheme ------------------------------------------------------- */
:root[data-theme="light"] {
  color-scheme: light;

  --primary-container:  color-mix(in srgb, var(--primary) 20%, white);
  --on-primary-container: color-mix(in srgb, var(--primary) 72%, black);

  /* status (accent-independent semantic colours, light-tuned) */
  --success: #1B7F52;
  --success-container: #c8f0da;
  --warning: #8A5A00;
  --warning-container: #ffe2b8;
  --danger: #BA1A1A;
  --danger-container: #ffdad6;

  /* MD3 light neutral surfaces (tonal elevation via container tints) */
  --bg-base:            #fbf8fe;   /* app background */
  --surface:            #fdfbff;   /* base surface */
  --surface-container-low:  #f5f1f9;
  --surface-container:      #efeaf3;
  --surface-container-high: #e9e3ee;
  --surface-container-highest: #e3dde8;
  --outline:            #79747e;   /* borders / dividers (AA) */
  --outline-variant:    #cac4d0;   /* subtle dividers */
  --on-surface:         #1c1b1f;   /* primary text */
  --on-surface-variant: #49454f;   /* secondary text */
  --screen-fg: #1c1b1f;
  --screen-bg: #f2eef6;            /* light console surface */

  /* MD3 elevation levels, light-tuned (softer umbra) */
  --elev-1: 0 1px 2px rgba(0,0,0,.14), 0 1px 3px 1px rgba(0,0,0,.08);
  --elev-2: 0 1px 2px rgba(0,0,0,.14), 0 2px 6px 2px rgba(0,0,0,.08);
  --elev-3: 0 4px 8px 3px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.14);
  --elev-4: 0 6px 10px 4px rgba(0,0,0,.08), 0 2px 3px rgba(0,0,0,.14);
  --elev-5: 0 8px 12px 6px rgba(0,0,0,.08), 0 4px 4px rgba(0,0,0,.14);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over component `display` rules —
   otherwise `.modal-root { display: flex }` keeps the overlay on screen and
   blocks every click. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-md);
  line-height: 1.5;
  color: var(--on-surface);
  min-height: 100vh;
  background: var(--bg-base);
}

.mono { font-family: var(--font-mono); }

/* --- top app bar --------------------------------------------------------- */
.rail {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s6);
  color: var(--on-surface);
  background: var(--surface-container);
  box-shadow: var(--elev-2);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: var(--s2); }
.pickaxe { font-size: var(--t-xl); color: var(--primary); }
.brand-name {
  font-family: var(--font-display); font-size: var(--t-xl); font-weight: 500;
  letter-spacing: .15px; color: var(--on-surface);
}
.rail-status { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); }
.rail-right { margin-left: auto; }
.plate {
  font-family: var(--font-mono); font-size: var(--t-sm);
  padding: var(--s1) var(--s3); border-radius: var(--radius-xs);
  background: var(--surface-container-highest);
  color: var(--on-surface-variant);
}

/* status LED / dot */
.led {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--_c, #999);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--_c, #999) 24%, transparent);
}
.led[data-state="watching"] { --_c: var(--success); }
.led[data-state="idle"]     { --_c: var(--primary); }
.led[data-state="error"]    { --_c: var(--danger); }
.led[data-state="offline"]  { --_c: var(--outline); box-shadow: none; }

/* --- login banner (MD3 tonal/error-ish call-to-action) ------------------- */
.login-strip {
  display: flex; align-items: center; justify-content: center; gap: var(--s4);
  padding: var(--s3);
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-weight: 500;
}

/* --- layout grid --------------------------------------------------------- */
.panel-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-areas:
    "gauges controls"
    "channels campaigns"
    "console console";
  gap: var(--s6);
  padding: var(--s6);
  max-width: 1320px; margin: 0 auto;
}
.gauges { grid-area: gauges; }
.controls { grid-area: controls; }
.channels { grid-area: channels; }
.campaigns { grid-area: campaigns; }
.console { grid-area: console; }

@media (max-width: 860px) {
  .panel-grid { grid-template-columns: 1fr; grid-template-areas: "controls" "gauges" "channels" "campaigns" "console"; }
}

/* MD3 filled card */
.panel {
  background: var(--surface-container-low);
  border-radius: var(--radius);
  padding: var(--s4);
  box-shadow: var(--elev-1);
}
.panel-title {
  font-family: var(--font-display); font-size: var(--t-lg); font-weight: 500;
  margin: 0 0 var(--s3); color: var(--on-surface); letter-spacing: .15px;
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--outline-variant);
}
.panel-heading {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  margin-bottom: var(--s3); padding-bottom: var(--s2);
  border-bottom: 1px solid var(--outline-variant);
}
.panel-heading .panel-title {
  flex: 1; margin: 0; padding: 0; border: 0;
}
.campaign-expand { flex: 0 0 auto; }

/* --- floating process runtime ------------------------------------------ */
.runtime-window {
  position: fixed; right: var(--s6); bottom: var(--s6); z-index: 30;
  width: min(360px, calc(100vw - var(--s6) - var(--s6)));
  border-radius: var(--radius); background: var(--surface-container-low);
  box-shadow: var(--elev-4); overflow: hidden;
}
.runtime-window-header {
  display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s3) var(--s3) var(--s4);
}
.runtime-window-heading { display: flex; flex: 1; min-width: 0; align-items: baseline; gap: var(--s3); }
.runtime-window-title {
  flex: 0 0 auto; margin: 0; color: var(--on-surface); font-family: var(--font-display);
  font-size: var(--t-md); font-weight: 500;
}
.runtime-summary {
  min-width: 0; overflow: hidden; color: var(--on-surface-variant); font-size: var(--t-xs);
  text-overflow: ellipsis; white-space: nowrap;
}
.runtime-body {
  max-height: 360px; padding: 0 var(--s4) var(--s4); opacity: 1;
  transition: max-height .2s ease, opacity .16s ease, padding .2s ease;
}
.runtime-details {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3);
  margin: 0;
}
.runtime-item {
  min-width: 0; padding-bottom: var(--s2);
  border-bottom: 1px solid var(--outline-variant);
}
.runtime-item dt {
  margin-bottom: 2px; color: var(--on-surface-variant); font-size: var(--t-xs);
  letter-spacing: .5px; text-transform: uppercase;
}
.runtime-item dd {
  min-width: 0; margin: 0; overflow-wrap: anywhere; color: var(--on-surface);
  font-size: var(--t-sm);
}
.runtime-item:nth-child(7) { grid-column: 1 / -1; }
.runtime-window.is-collapsed .runtime-body {
  max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; overflow: hidden;
}
@media (max-width: 500px) {
  .runtime-window { right: var(--s3); bottom: var(--s3); width: calc(100vw - var(--s3) - var(--s3)); }
  .runtime-details { grid-template-columns: 1fr; }
  .runtime-item:nth-child(7) { grid-column: auto; }
}

/* --- now mining + gauges ------------------------------------------------- */
.now-mining { display: flex; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.chip {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s2) var(--s3); border-radius: var(--radius-xs);
  background: var(--surface-container-high);
  min-width: 120px;
}
.chip-label { font-size: var(--t-xs); color: var(--on-surface-variant); text-transform: uppercase; letter-spacing: .5px; }
.chip-value { font-size: var(--t-md); font-weight: 500; color: var(--on-surface); }

.gauge { margin-bottom: var(--s4); }
.gauge-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s2); font-size: var(--t-sm); font-weight: 500; gap: var(--s2); color: var(--on-surface-variant); }
.gauge-head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--on-surface); }

/* MD3 linear progress indicator */
.meter {
  position: relative; height: 16px; border-radius: 999px;
  background: var(--surface-container-highest);
  overflow: hidden;
}
.meter-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: var(--primary);
  transition: width .4s cubic-bezier(.2,0,0,1);
}
.meter-alt .meter-fill { background: var(--primary-hover); }
.meter-pct {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: var(--t-xs); font-weight: 500; color: var(--on-surface);
}
.camp-drops { margin-top: var(--s2); font-size: var(--t-xs); color: var(--on-surface-variant); }

.ws-strip { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }
.ws-dot { display: flex; align-items: center; gap: 6px; font-size: var(--t-xs); color: var(--on-surface-variant); font-family: var(--font-mono); }
.ws-dot .led { width: 8px; height: 8px; }

/* --- buttons: MD3 filled-tonal / filled --------------------------------- */
.controls { display: flex; flex-direction: column; gap: var(--s3); }
.ico { width: 18px; height: 18px; flex: 0 0 auto; fill: currentColor; color: inherit; }
.btn {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  font-family: var(--font); font-size: var(--t-sm); font-weight: 500; letter-spacing: .1px;
  color: var(--on-surface); padding: 10px var(--s4);
  border-radius: 999px; border: none;
  background: var(--surface-container-high);
  cursor: pointer;
  transition: box-shadow .18s ease, background .18s ease;
}
/* MD3 state layer */
.btn::after {
  content: ""; position: absolute; inset: 0; background: currentColor;
  opacity: 0; transition: opacity .15s ease; pointer-events: none;
}
.btn:hover::after { opacity: .08; }
.btn:focus-visible::after { opacity: .12; }
.btn:active::after { opacity: .12; }
.btn:hover { box-shadow: var(--elev-1); }
.btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }
.btn:disabled::after { opacity: 0; }

.btn-primary {
  color: var(--on-primary);
  background: var(--primary);
  box-shadow: var(--elev-1);
}
.btn-primary:hover { box-shadow: var(--elev-2); }

/* logged-in state of the Login control (MD3 tonal success) */
.btn.btn-online {
  color: var(--success);
  background: var(--success-container);
  cursor: default;
}
.btn.btn-online::after { display: none; }
.btn.btn-online:hover { box-shadow: none; }

/* --- tables -------------------------------------------------------------- */
.table-wrap { overflow: auto; max-height: 320px; border-radius: var(--radius-sm); border: 1px solid var(--outline-variant); }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
thead th {
  position: sticky; top: 0;
  background: var(--surface-container-high);
  text-align: left; padding: var(--s3) var(--s3);
  font-size: var(--t-xs); font-weight: 500; letter-spacing: .5px; color: var(--on-surface-variant);
  border-bottom: 1px solid var(--outline-variant);
}
tbody td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--outline-variant); color: var(--on-surface); }
tbody tr:last-child td { border-bottom: none; }
tbody tr.watching { background: var(--success-container); }
tbody tr.locked { background: var(--primary-faint); }
.num { text-align: right; }
.ch-flag { width: 1.5em; text-align: center; }
.ch-act { width: 2.4em; text-align: center; }
.empty { color: var(--on-surface-variant); padding: var(--s4); text-align: center; }

/* MD3 assist/suggestion chips */
.pill { display: inline-block; padding: 2px var(--s2); border-radius: var(--radius-xs); font-size: var(--t-xs); font-weight: 500; }
.pill.online { background: var(--success-container); color: var(--success); }
.pill.pending { background: var(--warning-container); color: var(--warning); }
.pill.offline { background: var(--surface-container-highest); color: var(--on-surface-variant); }

/* per-row icon button (MD3 icon button + state layer) */
.row-btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; cursor: pointer;
  border-radius: 999px; border: none;
  background: transparent; color: var(--on-surface-variant);
  transition: background .15s ease, color .15s ease;
}
.row-btn::after {
  content: ""; position: absolute; inset: 0; background: currentColor;
  opacity: 0; transition: opacity .15s ease; pointer-events: none; border-radius: inherit;
}
.row-btn:hover::after { opacity: .08; }
.row-btn:active::after { opacity: .12; }
.row-btn .ico { width: 18px; height: 18px; }
.row-btn.switch:hover { color: var(--primary); }
.row-btn.unlock { color: var(--danger); font-size: var(--t-lg); line-height: 1; }
.row-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.row-btn:disabled { opacity: .38; cursor: not-allowed; }
.row-btn:disabled::after { opacity: 0; }

/* --- repo / version footer (under the Settings button) ------------------- */
.repo-info {
  margin-top: var(--s2); padding-top: var(--s3);
  border-top: 1px solid var(--outline-variant);
  display: flex; flex-direction: column; gap: 2px;
  font-size: var(--t-xs); text-align: center;
}
.repo-link {
  color: var(--primary); text-decoration: none; font-weight: 500;
  border-radius: var(--radius-xs); padding: 2px 4px;
}
.repo-link:hover { text-decoration: underline; }
.repo-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.repo-ver { color: var(--on-surface-variant); font-family: var(--font-mono); }

/* --- campaign cards (MD3 outlined cards) --------------------------------- */
.cards { display: flex; flex-direction: column; gap: var(--s3); max-height: 320px; overflow: auto; }
.card {
  padding: var(--s3); border-radius: var(--radius-sm);
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
}
.card-top { display: flex; justify-content: space-between; gap: var(--s2); align-items: baseline; }
.card-game { font-weight: 500; font-size: var(--t-sm); color: var(--on-surface); }
.card-name { font-size: var(--t-xs); color: var(--on-surface-variant); }
.card-meter { height: 6px; margin-top: var(--s2); border-radius: 999px; background: var(--surface-container-highest); overflow: hidden; }
.card-meter > div { height: 100%; background: var(--primary); border-radius: 999px; }
.tag { font-size: var(--t-xs); font-weight: 500; padding: 0 6px; border-radius: var(--radius-xs); }
.tag.active { color: var(--success); } .tag.upcoming { color: var(--warning); } .tag.expired { color: var(--on-surface-variant); }
.campaign-drop-list { display: none; }

body.campaigns-expanded { overflow: hidden; }
.campaigns.is-expanded {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto;
  grid-area: auto; border-radius: 0; padding: clamp(16px, 3vw, 40px);
  background: var(--surface-container-low); opacity: 0; transform: scale(.985);
  transition: opacity .2s ease, transform .2s ease;
}
.campaigns.is-expanded.is-expanded-visible { opacity: 1; transform: scale(1); }
.campaigns.is-expanded .panel-heading {
  position: sticky; top: 0; z-index: 1; padding-top: var(--s2);
  background: var(--surface-container-low);
}
.campaigns.is-expanded .cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  align-content: start; max-height: none; overflow: visible;
}
.campaigns.is-expanded .campaign-drop-list {
  display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s3);
  padding-top: var(--s3); border-top: 1px solid var(--outline-variant);
}
.campaign-drop { display: flex; flex-direction: column; gap: 6px; }
.campaign-drop-head { display: flex; justify-content: space-between; gap: var(--s3); align-items: flex-start; }
.campaign-drop-rewards { display: flex; flex: 1; flex-wrap: wrap; gap: var(--s2) var(--s3); min-width: 0; }
.campaign-reward { display: inline-flex; min-width: 0; align-items: center; gap: var(--s2); color: var(--on-surface); font-size: var(--t-sm); }
.campaign-reward-image {
  flex: 0 0 auto; width: 40px; height: 40px; object-fit: contain;
  border: 1px solid var(--outline-variant); border-radius: var(--radius-xs);
  background: var(--surface-container-highest);
}
.campaign-reward-name { min-width: 0; overflow-wrap: anywhere; }
.campaign-drop-status { flex: 0 0 auto; color: var(--on-surface-variant); font-family: var(--font-mono); font-size: var(--t-xs); white-space: nowrap; }
.campaign-drop-status.claimed { color: var(--success); font-family: var(--font); font-weight: 500; }
.campaign-drop-meter { height: 4px; overflow: hidden; border-radius: 999px; background: var(--surface-container-highest); }
.campaign-drop-meter > div { height: 100%; border-radius: inherit; background: var(--primary); }
.campaign-drop-empty { margin: 0; color: var(--on-surface-variant); font-size: var(--t-sm); }

/* --- console readout ----------------------------------------------------- */
.screen {
  font-family: var(--font-mono); font-size: var(--t-sm); line-height: 1.5;
  background: var(--screen-bg);
  color: var(--screen-fg);
  border-radius: var(--radius-sm); padding: var(--s3);
  height: 240px; overflow: auto;
  border: 1px solid var(--outline-variant);
}
.screen .line { white-space: pre-wrap; word-break: break-word; }
.screen .stamp { color: var(--on-surface-variant); margin-right: var(--s2); }
.screen .s-error { color: var(--danger); }
.screen .s-warn  { color: var(--warning); }
.screen .s-notify { color: var(--primary-hover); font-weight: 500; }
.screen:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* --- dialog (MD3) -------------------------------------------------------- */
.modal-root {
  /* Hidden by default; JS adds .open to show. Base state is display:none so
     the full-screen overlay can never blanket the page / eat clicks until a
     modal is actually opened (MD3 scrim). */
  display: none;
  position: fixed; inset: 0; z-index: 50;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.52);
  padding: var(--s4);
}
.modal-root.open { display: flex; }
.modal {
  width: min(560px, 100%);
  background: var(--surface-container-high);
  border-radius: var(--radius-xl);
  box-shadow: var(--elev-5);
  padding: var(--s6);
  max-height: 85vh; overflow: auto;
}
.modal h3 { font-family: var(--font-display); font-size: var(--t-xl); font-weight: 400; margin: 0 0 var(--s4); color: var(--on-surface); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s6); }
.field { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); }
.field label { font-size: var(--t-sm); font-weight: 500; color: var(--on-surface-variant); }
/* MD3 outlined text field / select */
.field input, .field select {
  font-family: var(--font); font-size: var(--t-md); color: var(--on-surface);
  padding: var(--s3); border-radius: var(--radius-xs);
  border: 1px solid var(--outline); background: var(--surface-container);
}
.field input:focus-visible, .field select:focus-visible { outline: none; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

/* theme colour picker (Settings) */
.swatches { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; padding: 0;
  background: var(--sw, #fff);
  box-shadow: var(--elev-1);
  transition: transform .12s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch:focus-visible { outline: 3px solid var(--on-surface); outline-offset: 2px; }
.swatch.active { border-color: var(--on-surface); box-shadow: 0 0 0 2px var(--surface-container-high), 0 0 0 4px var(--sw, #fff); }
.swatch-custom { width: 34px; height: 34px; border-radius: 50%; border: 2px dashed var(--outline); background: transparent; padding: 0; cursor: pointer; }

/* MD3 segmented button (light / dark appearance toggle) */
.seg { display: flex; width: 100%; border: 1px solid var(--outline); border-radius: 999px; overflow: hidden; }
.seg-btn {
  position: relative; flex: 1 1 0; text-align: center;
  font-family: var(--font); font-size: var(--t-sm); font-weight: 500;
  color: var(--on-surface-variant); background: transparent; cursor: pointer;
  padding: var(--s2) var(--s4); border: none; border-right: 1px solid var(--outline);
  transition: background .15s ease, color .15s ease;
}
.seg-btn:last-child { border-right: none; }
.seg-btn::after {
  content: ""; position: absolute; inset: 0; background: var(--primary);
  opacity: 0; transition: opacity .15s ease; pointer-events: none;
}
.seg-btn:hover::after { opacity: .08; }
.seg-btn.active { background: var(--primary-faint); color: var(--on-surface); font-weight: 600; }
.seg-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.code-ticket {
  font-family: var(--font-mono); font-size: var(--t-2xl); font-weight: 600;
  letter-spacing: 6px; text-align: center; padding: var(--s4);
  color: var(--on-primary-container);
  background: var(--primary-container);
  border-radius: var(--radius-sm); user-select: all;
}
.login-url { font-family: var(--font-mono); font-size: var(--t-sm); word-break: break-all; color: var(--primary); font-weight: 500; }

.list-editor { display: flex; flex-direction: column; gap: var(--s2); max-height: 220px; overflow: auto; }
.list-row { display: flex; align-items: center; gap: var(--s2); padding: var(--s2); border-radius: var(--radius-xs); background: var(--surface-container); }
.list-row .grow { flex: 1; }
.add-row { display: flex; gap: var(--s2); margin-top: var(--s3); }
.add-row input { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: var(--s6); transform: translateX(-50%);
  background: var(--surface-container-highest);
  color: var(--on-surface); padding: var(--s3) var(--s4);
  border-radius: var(--radius-xs); box-shadow: var(--elev-3); font-size: var(--t-sm);
  opacity: 0; transition: opacity .2s ease; pointer-events: none; z-index: 60;
}
.toast.show { opacity: 1; }

#btn-update.is-loading .ico { animation: engine-update-spin .85s linear infinite; }
#btn-update.is-up-to-date { color: var(--success); background: var(--success-container); }
@keyframes engine-update-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .campaigns.is-expanded { transition: none; }
  #btn-update.is-loading .ico { animation: none; }
}
