/* ============================================================
   SATURN · Combined Operations Console
   Hand written stylesheet. No framework, no build step.
   Theme system: html[data-theme="..."] swaps the token block.
   Effects:      html[data-fx~="stars|grid|scan"] gates layers.
   ============================================================ */

/* ---------- design tokens (default: Jovian Storm) ---------- */
:root,
html[data-theme="jovian"] {
  --bg0: #0a0714;
  --bg1: #120c22;
  --surface: rgba(22, 16, 40, 0.66);
  --surface2: rgba(34, 25, 60, 0.55);
  --line: rgba(255, 179, 71, 0.14);
  --line-strong: rgba(255, 179, 71, 0.34);
  --text: #ede7f8;
  --text-dim: #9b92b8;
  --accent: #ffb347;
  --accent2: #67e8f9;
  --good: #4ade80;
  --warn: #facc15;
  --bad: #f87171;
  --orb-base: #2a1f3f;
  --grid-color: rgba(255, 179, 71, 0.05);
  --star-color: 255, 220, 180;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

html[data-theme="nebula"] {
  --bg0: #0b0716;
  --bg1: #160e2b;
  --surface: rgba(28, 18, 52, 0.66);
  --surface2: rgba(42, 28, 76, 0.55);
  --line: rgba(167, 139, 250, 0.16);
  --line-strong: rgba(167, 139, 250, 0.38);
  --text: #efeafd;
  --text-dim: #a39bc4;
  --accent: #a78bfa;
  --accent2: #f472b6;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --orb-base: #241742;
  --grid-color: rgba(167, 139, 250, 0.05);
  --star-color: 220, 200, 255;
}

html[data-theme="cyber"] {
  --bg0: #04070d;
  --bg1: #081120;
  --surface: rgba(10, 22, 40, 0.68);
  --surface2: rgba(14, 32, 56, 0.58);
  --line: rgba(34, 211, 238, 0.16);
  --line-strong: rgba(34, 211, 238, 0.4);
  --text: #e6f6ff;
  --text-dim: #84a3bd;
  --accent: #22d3ee;
  --accent2: #f0abfc;
  --good: #4ade80;
  --warn: #fde047;
  --bad: #fb7185;
  --orb-base: #0c2236;
  --grid-color: rgba(34, 211, 238, 0.06);
  --star-color: 170, 230, 255;
}

html[data-theme="matrix"] {
  --bg0: #020806;
  --bg1: #06140e;
  --surface: rgba(8, 26, 18, 0.7);
  --surface2: rgba(12, 38, 26, 0.6);
  --line: rgba(52, 211, 153, 0.16);
  --line-strong: rgba(52, 211, 153, 0.4);
  --text: #e4fff4;
  --text-dim: #7faa94;
  --accent: #34d399;
  --accent2: #a3e635;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --orb-base: #0a241a;
  --grid-color: rgba(52, 211, 153, 0.06);
  --star-color: 170, 255, 210;
}

html[data-theme="ice"] {
  --bg0: #eef4fb;
  --bg1: #ffffff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface2: rgba(240, 246, 252, 0.85);
  --line: rgba(2, 132, 199, 0.18);
  --line-strong: rgba(2, 132, 199, 0.4);
  --text: #14253b;
  --text-dim: #5a708c;
  --accent: #0284c7;
  --accent2: #7c3aed;
  --good: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --orb-base: #cfe4f5;
  --grid-color: rgba(2, 132, 199, 0.06);
  --star-color: 2, 132, 199;
  --shadow: 0 14px 40px rgba(20, 50, 90, 0.12);
}

html[data-theme="ember"] {
  --bg0: #140607;
  --bg1: #220b0c;
  --surface: rgba(44, 16, 16, 0.62);
  --surface2: rgba(62, 24, 22, 0.52);
  --line: rgba(248, 113, 113, 0.16);
  --line-strong: rgba(248, 113, 113, 0.4);
  --text: #fdeee8;
  --text-dim: #c09a8e;
  --accent: #f87171;
  --accent2: #fbbf24;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --orb-base: #3a1413;
  --grid-color: rgba(248, 113, 113, 0.05);
  --star-color: 255, 190, 160;
}

:root {
  --font-display: 'Orbitron', 'Segoe UI', sans-serif;
  --font-body: 'Rajdhani', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
  --radius: 14px;
  --radius-sm: 9px;
  --dock-w: 240px;
  --dock-w-min: 76px;
  --glow: color-mix(in srgb, var(--accent) 32%, transparent);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

/* The hidden attribute must always win: author display rules (flex/grid on a class)
   otherwise override the UA's [hidden]{display:none} and "hidden" elements stay on
   screen (this bit the palette, dropzone, upload bar, notes editor and plex panes). */
[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 85% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, color-mix(in srgb, var(--accent2) 8%, transparent), transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: 0.04em; margin: 0; }

.mono { font-family: var(--font-mono); font-size: 0.92em; }
.dim { color: var(--text-dim); }
.small { font-size: 0.86rem; }
.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 9px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- background effect layers ---------- */
#starfield {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
  display: none;
}
html[data-fx~="stars"] #starfield { display: block; }

.fx-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; display: none;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 0%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 0%, black 30%, transparent 80%);
}
html[data-fx~="grid"] .fx-grid { display: block; }

.fx-scan {
  position: fixed; inset: 0; z-index: 60; pointer-events: none; display: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 3px,
    rgba(0, 0, 0, 0.08) 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.5;
}
html[data-fx~="scan"] .fx-scan { display: block; }
html[data-theme="ice"] .fx-scan { opacity: 0.12; }

/* ---------- shell layout ---------- */
.shell { position: relative; z-index: 1; }

.dock {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--dock-w);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 12px;
  background: color-mix(in srgb, var(--bg0) 72%, transparent);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 40;
  transition: width 0.25s ease;
  overflow: hidden;
}

html[data-dock="min"] .dock { width: var(--dock-w-min); }
html[data-dock="min"] .dock-label,
html[data-dock="min"] .dock-logo-text { display: none; }
html[data-dock="min"] .dock-collapse .icon { transform: rotate(180deg); }

.dock-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 14px;
  text-decoration: none !important;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.dock-logo-text {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 0.18em;
  color: var(--text);
  text-shadow: 0 0 18px var(--glow);
  white-space: nowrap;
}

/* The nav scrolls within the dock so every deck stays reachable in short viewports. */
.dock-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; }

/* Section dividers grouping the (now numerous) decks. Hidden on the collapsed rail and the
   phone bottom-bar, where labels disappear and a flat icon strip reads better. */
.dock-group-label {
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-dim); opacity: 0.65; padding: 12px 12px 3px; white-space: nowrap;
}
.dock-group-label:first-child { padding-top: 2px; }
html[data-dock="min"] .dock-group-label { display: none; }

.dock-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.86rem;
  border: 1px solid transparent;
  text-decoration: none !important;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.dock-link:hover { color: var(--text); background: var(--surface2); }
.dock-link.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.dock-foot { border-top: 1px solid var(--line); padding-top: 8px; }
.dock-collapse {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: none; border: none;
  color: var(--text-dim);
  font-family: var(--font-body); font-weight: 600; font-size: 0.84rem;
  letter-spacing: 0.05em; text-transform: uppercase;
  border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
}
.dock-collapse:hover { color: var(--text); background: var(--surface2); }
.dock-collapse .icon { transition: transform 0.25s ease; }

.main {
  margin-left: var(--dock-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}
html[data-dock="min"] .main { margin-left: var(--dock-w-min); }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 22px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg0) 62%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.32rem; font-weight: 700; text-transform: uppercase; }

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.85;
}

.topbar-clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.clock-time { font-size: 1.08rem; color: var(--accent2); text-shadow: 0 0 14px color-mix(in srgb, var(--accent2) 40%, transparent); }
.clock-date { font-size: 0.78rem; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.leds { display: flex; gap: 8px; padding: 0 4px; }
.led {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-dim); opacity: 0.5;
}
.led.ok { background: var(--good); opacity: 1; box-shadow: 0 0 10px var(--good); animation: pulse 2.4s ease-in-out infinite; }
.led.bad { background: var(--bad); opacity: 1; box-shadow: 0 0 10px var(--bad); }
@keyframes pulse { 50% { opacity: 0.55; } }

.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: var(--bg0);
  font-family: var(--font-display); font-weight: 700; font-size: 0.86rem;
}
.user-pop {
  position: absolute; right: 0; top: calc(100% + 10px);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 8px;
  z-index: 50;
}
.user-name { padding: 8px 10px; font-weight: 700; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-pop a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px;
  color: var(--text); text-decoration: none !important;
}
.user-pop a:hover { background: var(--surface2); color: var(--accent); }

/* ---------- content ---------- */
.content {
  padding: 26px 28px 56px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px;
}

/* ---------- cards ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow, 0 14px 40px rgba(0, 0, 0, 0.35));
}
.card::before {
  content: "";
  position: absolute; top: 0; left: 14px; right: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h3 {
  display: flex; align-items: center; gap: 9px;
  font-size: 0.92rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
}
.card-head h3 .icon { color: var(--accent); }
.card-link {
  font-family: var(--font-mono); font-size: 0.74rem;
  letter-spacing: 0.1em; text-transform: uppercase;
}

/* min(Npx, 100%) lets every grid collapse below its preferred card width
   instead of overflowing on narrow screens. */
.grid { display: grid; gap: 18px; }
.dash-grid { grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); }
.lib-grid { grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); }
.vault-grid { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.markets-grid { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.pihole-grid { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.pihole-grid .span2 { grid-column: span 2; }

/* ---------- deck headers and sections ---------- */
.deck-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
}
.deck-sub { margin: 4px 0 0; color: var(--text-dim); }
.deck-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.deck-section { display: flex; flex-direction: column; gap: 12px; }
.deck-title {
  font-size: 0.9rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 10px;
}

/* ---------- buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  font-family: var(--font-body); font-weight: 700; font-size: 0.86rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--accent2)));
  color: var(--bg0);
  border-color: transparent;
  box-shadow: 0 6px 22px var(--glow);
}
.btn.ghost { background: transparent; }
.btn.danger { border-color: color-mix(in srgb, var(--bad) 55%, transparent); color: var(--bad); background: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.btn-icon:hover { color: var(--accent); border-color: var(--line-strong); background: var(--surface2); }
.btn-icon.danger:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.btn-icon.on { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px var(--glow); }

.field {
  padding: 9px 13px;
  font-family: var(--font-body); font-size: 0.96rem;
  color: var(--text);
  background: color-mix(in srgb, var(--bg0) 55%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.field::placeholder { color: var(--text-dim); opacity: 0.8; }
.field.title { font-size: 1.25rem; font-weight: 700; flex: 1; min-width: 0; }
.field.area {
  width: 100%; min-height: 380px; resize: vertical;
  font-family: var(--font-mono); font-size: 0.92rem; line-height: 1.6;
}
.field.grow { flex: 1; min-width: 160px; }

input[type="search"].field { min-width: 200px; }
input[type="color"] {
  width: 52px; height: 38px; padding: 3px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface2); cursor: pointer;
}
input[type="range"] { accent-color: var(--accent); width: 260px; max-width: 100%; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }

.icon { width: 18px; height: 18px; flex: none; }
.icon.big { width: 40px; height: 40px; color: var(--text-dim); }

/* ---------- chips, badges, tabs ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface2);
  font-family: var(--font-mono); font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--text);
  white-space: nowrap;
}
.chip.good { border-color: color-mix(in srgb, var(--good) 55%, transparent); color: var(--good); }
.chip.bad { border-color: color-mix(in srgb, var(--bad) 55%, transparent); color: var(--bad); }
.chip.warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); color: var(--warn); }
.chip.accent { border-color: var(--accent); color: var(--accent); }

.badge-change { font-family: var(--font-mono); font-weight: 600; font-size: 0.86rem; }
.badge-change.up { color: var(--good); }
.badge-change.down { color: var(--bad); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  padding: 7px 13px;
  font-family: var(--font-body); font-weight: 600; font-size: 0.82rem;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
.table-wrap.tall { max-height: 460px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
/* Wide tables keep a sensible minimum and scroll sideways on narrow screens
   instead of crushing their columns. */
.net-table { min-width: 780px; }
#query-table { min-width: 600px; }
#files-table { min-width: 460px; }
.table th {
  position: sticky; top: 0;
  text-align: left;
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 12px;
  background: color-mix(in srgb, var(--bg0) 86%, transparent);
  border-bottom: 1px solid var(--line-strong);
  z-index: 1;
}
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.table .num { text-align: right; }
.table td.num { font-family: var(--font-mono); font-size: 0.86rem; }
.table .actions { width: 1%; white-space: nowrap; text-align: right; }
.table .actions .btn-icon { width: 30px; height: 30px; }
.table .actions .icon { width: 15px; height: 15px; }

.row-name { display: flex; align-items: center; gap: 10px; }
.row-name .icon { color: var(--accent); }
.row-name a, .row-name button.linkish {
  background: none; border: none; padding: 0;
  color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
.row-name a:hover, .row-name button.linkish:hover { color: var(--accent); text-decoration: none; }

/* ---------- ranked lists (pihole tops) ---------- */
.rank-list { display: flex; flex-direction: column; gap: 7px; }
.rank-row { position: relative; padding: 7px 10px; border-radius: 7px; overflow: hidden; }
.rank-row .bar {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  transform-origin: left;
}
.rank-row.bad .bar { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.rank-row .lbl {
  position: relative; display: flex; justify-content: space-between; gap: 12px;
  font-family: var(--font-mono); font-size: 0.84rem;
}
.rank-row .lbl .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .lbl .val { color: var(--text-dim); flex: none; }

/* ---------- key value grid ---------- */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 12px;
}
.kv {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg0) 35%, transparent);
}
.kv .k {
  font-family: var(--font-mono); font-size: 0.68rem;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.kv .v { font-weight: 600; word-break: break-word; }

/* ---------- hero ---------- */
.hero {
  display: flex; align-items: center; justify-content: space-between;
  gap: 26px; padding: 30px 34px;
  overflow: hidden;
}
.hero-title {
  font-size: clamp(2.1rem, 4.5vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.22em;
  background: linear-gradient(95deg, var(--text), var(--accent) 55%, var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 38px var(--glow);
}
.hero-sub { color: var(--text-dim); margin: 8px 0 14px; font-size: 1.08rem; }
.hero-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-orb { flex: none; }
.orb { width: 64px; height: 64px; }
.orb.big { width: 190px; height: 190px; filter: drop-shadow(0 0 32px var(--glow)); }
.orb-ring { stroke: var(--line-strong); animation: spin 60s linear infinite; transform-origin: 36px 36px; }
.orb-ring.slow { animation-duration: 95s; animation-direction: reverse; }
.orb-moons { animation: spin 16s linear infinite; transform-origin: 36px 36px; }
.orb-moons.reverse { animation: spin 24s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ticker ---------- */
.ticker { padding: 10px 0; overflow: hidden; white-space: nowrap; }
.ticker-track {
  display: inline-flex; gap: 38px;
  padding-left: 20px;
  animation: ticker 55s linear infinite;
  will-change: transform;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker { to { transform: translateX(-50%); } }
.tick { display: inline-flex; align-items: center; gap: 9px; font-family: var(--font-mono); font-size: 0.88rem; }
.tick .sym { color: var(--text-dim); letter-spacing: 0.06em; }

/* ---------- widgets ---------- */
.widget .card-body { display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.stat-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.stat-big { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--accent); text-shadow: 0 0 18px var(--glow); }
.stat-label { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); }
.mini-list { display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; }
.mini-list .mini-row { display: flex; justify-content: space-between; gap: 12px; }
.mini-list .mini-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .mini-row span:last-child {
  color: var(--text-dim); font-family: var(--font-mono); font-size: 0.84rem;
  flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- progress bars and meters ---------- */
.meter {
  position: relative;
  height: 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--text-dim) 18%, transparent);
  overflow: hidden;
}
.meter > i {
  position: absolute; inset: 0 auto 0 0;
  display: block;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 999px;
}
.meter.thin { height: 4px; }

/* ---------- sparklines and charts ---------- */
.spark { width: 130px; height: 38px; overflow: visible; }
.spark .spark-line { fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark .spark-area { stroke: none; opacity: 0.16; }
.spark.up .spark-line { stroke: var(--good); }
.spark.up .spark-area { fill: var(--good); }
.spark.down .spark-line { stroke: var(--bad); }
.spark.down .spark-area { fill: var(--bad); }
.spark.flat .spark-line { stroke: var(--accent2); }
.spark.flat .spark-area { fill: var(--accent2); }

.chart-wrap { width: 100%; }
.chart-wrap svg { width: 100%; height: 180px; display: block; }
.hbar { fill: var(--accent); opacity: 0.75; }
.hbar.blocked { fill: var(--bad); opacity: 0.85; }
.chart-legend { display: flex; gap: 18px; margin-top: 8px; font-size: 0.82rem; color: var(--text-dim); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut { transform: rotate(-90deg); }
.donut .track { fill: none; stroke: color-mix(in srgb, var(--text-dim) 22%, transparent); }
.donut .value { fill: none; stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }
.donut-label { font-family: var(--font-display); font-size: 1.3rem; color: var(--accent); }

/* ---------- pihole specifics ---------- */
.pihole-status .status-line { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.blocking-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.stat-strip { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 16px; }
.stat-strip .stat { min-width: 110px; }
.qstatus { font-family: var(--font-mono); font-size: 0.78rem; }
.qstatus.blocked { color: var(--bad); }
.qstatus.ok { color: var(--good); }
.qstatus.cached { color: var(--accent2); }
.domain-list { display: flex; flex-direction: column; margin-top: 10px; max-height: 380px; overflow: auto; }
.domain-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
}
.domain-row .d { font-family: var(--font-mono); font-size: 0.88rem; word-break: break-all; }
.domain-row .c { color: var(--text-dim); font-size: 0.84rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.domain-row .btn-icon { margin-left: auto; flex: none; }
.list-add { margin-top: 4px; flex-wrap: wrap; }

/* ---------- plex specifics ---------- */
.server-line { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.server-line .name { font-family: var(--font-display); font-size: 1.15rem; }
.sessions { display: flex; flex-direction: column; gap: 14px; }
.session-card { display: flex; gap: 16px; }
.session-art {
  width: 72px; height: 105px; flex: none;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  background: var(--surface2);
}
.session-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.session-title { font-weight: 700; font-size: 1.04rem; }
.session-meta { display: flex; gap: 8px; flex-wrap: wrap; }
/* Device/player names come from Plex clients and can be long; let the chip wrap its
   text instead of overflowing the session card on narrow screens. */
.session-meta .chip { max-width: 100%; white-space: normal; word-break: break-word; }
.session-actions { flex: none; display: flex; align-items: flex-start; }
.lib-card { display: flex; flex-direction: column; gap: 8px; }
.lib-card .lib-count { font-family: var(--font-display); font-size: 1.6rem; color: var(--accent); }
.lib-card .lib-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.poster-rail { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.poster {
  flex: none; width: 124px;
  text-decoration: none !important; color: var(--text);
}
.poster img {
  width: 124px; height: 184px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface2);
  transition: transform 0.16s ease, border-color 0.16s ease;
}
.poster:hover img { transform: translateY(-3px); border-color: var(--accent); }
.poster .p-title { font-size: 0.84rem; font-weight: 600; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poster .p-sub { font-size: 0.76rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row { display: flex; flex-direction: column; gap: 6px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.activity-row:last-child { border-bottom: none; }

/* ---------- markets specifics ---------- */
.mkt-card { display: flex; flex-direction: column; gap: 10px; }
.mkt-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mkt-name { display: flex; align-items: center; gap: 9px; font-weight: 700; min-width: 0; }
.mkt-name .flag { font-size: 1.25rem; }
.mkt-name img { width: 22px; height: 22px; border-radius: 50%; }
.mkt-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkt-sym { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-dim); }
.mkt-price { font-family: var(--font-display); font-size: 1.45rem; }
.mkt-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.mkt-card .spark { width: 100%; height: 44px; }

/* ---------- files specifics ---------- */
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 10px 16px; font-family: var(--font-mono); font-size: 0.86rem; }
.crumbs a, .crumbs button {
  background: none; border: none; padding: 3px 7px;
  color: var(--text-dim); font: inherit; cursor: pointer; border-radius: 5px;
}
.crumbs a:hover, .crumbs button:hover { color: var(--accent); background: var(--surface2); text-decoration: none; }
.crumbs .sep { color: var(--line-strong); }
.crumbs .here { color: var(--accent); padding: 3px 7px; }
.files-card { position: relative; min-height: 200px; }
.dropzone {
  position: absolute; inset: 8px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent);
  font-weight: 700; letter-spacing: 0.06em;
  z-index: 5;
  pointer-events: none;
}
.upload-progress { display: flex; flex-direction: column; gap: 9px; }
/* display:flex above overrides the UA [hidden] rule, so honor the attribute explicitly
   (same trap as .palette) — otherwise the drop overlay and finished progress bar stay
   on screen forever. */
.dropzone[hidden], .upload-progress[hidden] { display: none; }

/* view switcher (icons / list / details) */
.view-seg { display: flex; gap: 6px; margin-right: 4px; }

.files-empty { padding: 36px 14px; text-align: center; }

/* list view */
.files-list { display: flex; flex-direction: column; }
.files-row {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.files-row:last-child { border-bottom: none; }
.files-row:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.f-name {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
}
/* the folder variant is a button; strip the default button chrome */
button.f-name.linkish {
  background: none; border: none; padding: 0;
  color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
button.f-name.linkish:hover { color: var(--accent); }
.f-name .f-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-size { flex: none; }
.f-actions { flex: none; display: flex; gap: 4px; }
.f-actions .btn-icon { width: 30px; height: 30px; }
.f-actions .icon { width: 15px; height: 15px; }

/* icon (tile) view */
.files-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(132px, 100%), 1fr));
  gap: 12px;
  padding: 4px 0;
}
.file-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 18px 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg0) 30%, transparent);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.13s ease, transform 0.13s ease, background 0.13s ease;
}
.file-tile:hover,
.file-tile:focus-within { border-color: var(--line-strong); background: var(--surface2); }
.file-tile:hover { transform: translateY(-2px); }
.file-tile .icon.big { width: 36px; height: 36px; }
.file-tile .t-name {
  max-width: 100%;
  font-size: 0.84rem; font-weight: 600; line-height: 1.25;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  word-break: break-word;
}
.file-tile .t-size { font-size: 0.7rem; }
.file-tile .t-actions {
  position: absolute; top: 5px; right: 5px;
  display: flex; gap: 3px;
  opacity: 0;
  transition: opacity 0.13s ease;
}
.file-tile:hover .t-actions,
.file-tile:focus-within .t-actions,
.file-tile:focus .t-actions { opacity: 1; }
.t-actions .btn-icon { width: 27px; height: 27px; background: color-mix(in srgb, var(--bg0) 72%, transparent); }
.t-actions .icon { width: 14px; height: 14px; }
/* touch devices have no hover; keep tile actions visible */
@media (pointer: coarse) {
  .file-tile .t-actions { opacity: 1; }
}
.upload-progress .u-row { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }
.upload-progress .u-row .meter { flex: 1; }

/* ---------- notes specifics ---------- */
.notes-layout {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 18px;
  align-items: start;
}
.notes-list-pane { display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 170px); }
.notes-tools { display: flex; gap: 8px; }
.notes-tools .field { flex: 1; min-width: 0; }
.notes-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.notes-tags .chip { cursor: pointer; }
.notes-tags .chip.active { border-color: var(--accent); color: var(--accent); }
.notes-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }
.note-item {
  position: relative;
  padding: 11px 13px 11px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.note-item::before {
  content: "";
  position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px;
  background: var(--note-color, var(--line-strong));
}
.note-item:hover { background: var(--surface2); }
.note-item.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.note-item .n-title { font-weight: 700; display: flex; align-items: center; gap: 7px; }
.note-item .n-title .icon { width: 13px; height: 13px; color: var(--warn); }
.note-item .n-prev { font-size: 0.84rem; color: var(--text-dim); margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.note-item .n-date { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-dim); margin-top: 5px; }
.notes-editor { min-height: 560px; display: flex; flex-direction: column; }
#editor-pane { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.editor-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.editor-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.editor-foot { display: flex; justify-content: flex-end; }
.color-dots { display: flex; gap: 6px; }
.color-dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer; padding: 0;
}
.color-dot.active { border-color: var(--text); box-shadow: 0 0 8px var(--glow); }
.empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--text-dim); text-align: center; min-height: 220px;
}
.note-preview {
  flex: 1; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg0) 40%, transparent);
  overflow: auto; line-height: 1.6;
}
.note-preview h1, .note-preview h2, .note-preview h3 { font-family: var(--font-body); margin: 0.7em 0 0.35em; }
.note-preview code {
  font-family: var(--font-mono); font-size: 0.86em;
  background: var(--surface2); padding: 2px 6px; border-radius: 5px;
}
.note-preview pre {
  background: color-mix(in srgb, var(--bg0) 70%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 15px; overflow: auto;
}
.note-preview pre code { background: none; padding: 0; }
.note-preview ul { margin: 0.4em 0; padding-left: 1.3em; }

/* ---------- vault specifics ---------- */
.vault-card { display: flex; flex-direction: column; gap: 10px; }
.vault-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.vault-name { font-weight: 700; font-size: 1.06rem; display: flex; align-items: center; gap: 9px; min-width: 0; }
.vault-name .icon { color: var(--accent); flex: none; }
.vault-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vault-kv { display: flex; align-items: center; gap: 9px; font-size: 0.92rem; min-width: 0; }
.vault-kv .k { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); width: 74px; flex: none; }
.vault-kv .v { font-family: var(--font-mono); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.vault-kv .btn-icon { width: 28px; height: 28px; flex: none; }
.vault-kv .btn-icon .icon { width: 14px; height: 14px; }
.vault-actions { display: flex; gap: 8px; margin-top: 4px; }

/* live TOTP code + countdown ring */
.otp-kv .otp-code {
  font-weight: 600; letter-spacing: 0.18em;
  color: var(--accent2);
  text-shadow: 0 0 12px color-mix(in srgb, var(--accent2) 35%, transparent);
}
.otp-ring {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--accent2) var(--p, 100%),
    color-mix(in srgb, var(--text-dim) 25%, transparent) 0);
  -webkit-mask: radial-gradient(closest-side, transparent 52%, #000 56%);
  mask: radial-gradient(closest-side, transparent 52%, #000 56%);
  transition: background 0.3s linear;
}
.otp-kv.low .otp-code { color: var(--bad); text-shadow: none; }
.otp-kv.low .otp-ring {
  background: conic-gradient(var(--bad) var(--p, 100%),
    color-mix(in srgb, var(--text-dim) 25%, transparent) 0);
}

/* passkey protection */
.vault-locked {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 56px 24px;
  text-align: center;
}
.vault-locked .icon.big { color: var(--accent); filter: drop-shadow(0 0 18px var(--glow)); }
.vault-locked h3 { letter-spacing: 0.14em; text-transform: uppercase; }
.vault-locked .linkish {
  background: none; border: none; padding: 0;
  font: inherit; cursor: pointer; color: var(--text-dim);
}
.vault-locked .linkish:hover { color: var(--accent); }
.vault-rec-row { display: flex; gap: 8px; width: min(440px, 100%); }

.vault-rec-code {
  margin: 14px 0;
  padding: 16px 18px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  font-size: 1.05rem; letter-spacing: 0.12em; text-align: center;
  word-break: break-all;
  user-select: all;
}
.vault-sec-list { margin: 10px 0 4px; padding-left: 20px; line-height: 1.55; }
.vault-sec-list li { margin-bottom: 8px; }

.pk-list { display: flex; flex-direction: column; }
.pk-row {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
}
.pk-row:last-child { border-bottom: none; }
.pk-row .icon { color: var(--accent); flex: none; }
.pk-row .pk-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-row .btn-icon { width: 30px; height: 30px; flex: none; }

.pw-meter { height: 5px; border-radius: 999px; background: color-mix(in srgb, var(--text-dim) 18%, transparent); overflow: hidden; }
.pw-meter > i { display: block; height: 100%; border-radius: 999px; transition: width 0.2s ease, background 0.2s ease; }

/* ---------- modal ---------- */
#modal-root { position: fixed; inset: 0; z-index: 90; }
.modal-overlay {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg0) 70%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 18px;
  overflow-y: auto;
}
.modal-panel {
  width: 100%; max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: rise 0.18s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 1rem; letter-spacing: 0.1em; text-transform: uppercase; }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 13px; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 0.86rem; color: var(--text-dim); }
.modal-body .field { width: 100%; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

/* ---------- command palette ---------- */
.palette {
  position: fixed; inset: 0; z-index: 95;
  background: color-mix(in srgb, var(--bg0) 65%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
/* display:flex above overrides the UA [hidden] rule, so honor the attribute explicitly */
.palette[hidden] { display: none; }
.palette-panel {
  width: min(620px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: hidden;
  animation: rise 0.16s ease;
}
.palette-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.palette-head .icon { color: var(--accent); }
.palette-head input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-family: var(--font-body); font-size: 1.06rem;
}
.palette-head kbd {
  font-family: var(--font-mono); font-size: 0.7rem;
  border: 1px solid var(--line-strong); border-radius: 5px;
  padding: 2px 7px; color: var(--text-dim);
}
.palette-list { list-style: none; margin: 0; padding: 8px; max-height: 46vh; overflow-y: auto; }
.palette-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
}
.palette-item .icon { color: var(--text-dim); }
.palette-item .hint { margin-left: auto; font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-dim); }
.palette-item.sel { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); }
.palette-item.sel .icon { color: var(--accent); }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; right: 22px; bottom: 22px; z-index: 99;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(380px, calc(100vw - 44px));
}
.toast {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 0.94rem;
  animation: rise 0.2s ease;
}
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast .icon { flex: none; }
.toast.good .icon { color: var(--good); }
.toast.bad .icon { color: var(--bad); }
.toast.warn .icon { color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity 0.25s ease, transform 0.25s ease; }

/* ---------- skeletons ---------- */
.skeleton-block, .skeleton-card, .skeleton-chip {
  position: relative; overflow: hidden;
  background: color-mix(in srgb, var(--text-dim) 12%, transparent);
  border-radius: var(--radius-sm);
}
.skeleton-block { height: 86px; }
.skeleton-card { min-height: 130px; border: 1px solid var(--line); }
.skeleton-chip { color: transparent !important; border-color: transparent !important; min-width: 70px; }
.skeleton-block::after, .skeleton-card::after, .skeleton-chip::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--text) 7%, transparent) 50%, transparent 70%);
  animation: shimmer 1.5s infinite;
  transform: translateX(-100%);
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- theme settings page ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: 14px; }
.theme-card {
  display: flex; flex-direction: column; gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.13s ease, transform 0.13s ease;
}
.theme-card:hover { transform: translateY(-2px); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 8px 24px var(--glow); }
.theme-card .swatches { display: flex; gap: 6px; }
.theme-card .swatches i { width: 26px; height: 26px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, 0.12); }
.theme-card .t-name { font-weight: 700; letter-spacing: 0.06em; }
.test-result {
  margin-top: 14px; padding: 12px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  font-family: var(--font-mono); font-size: 0.86rem;
}
.test-result.good { border-color: var(--good); color: var(--good); }
.test-result.bad { border-color: var(--bad); color: var(--bad); }

/* ---------- about deck ---------- */
.about-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  overflow: hidden;
}
.about-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 900; letter-spacing: 0.18em;
  background: linear-gradient(95deg, var(--text), var(--accent) 55%, var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 34px var(--glow);
}
.about-pills { margin-top: 12px; gap: 8px; }
.about-hero .orb.big { width: 116px; height: 116px; flex: none; }
.about-grid { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.about-card .kv-grid { grid-template-columns: 1fr; gap: 8px; }
.about-card .kv { background: color-mix(in srgb, var(--bg0) 30%, transparent); }
.about-card .kv .v { font-family: var(--font-mono); font-size: 0.9rem; }
.about-card .kv .v.good { color: var(--good); }
.about-card .kv .v.bad { color: var(--bad); }

@media (max-width: 640px) {
  .about-hero .orb.big { width: 84px; height: 84px; }
}

/* ---------- error page ---------- */
.error-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.error-card { max-width: 480px; text-align: center; padding: 44px 38px; }
.error-card h1 {
  font-size: 2rem; letter-spacing: 0.22em; margin: 12px 0;
  color: var(--accent); text-shadow: 0 0 26px var(--glow);
}
.error-card p { color: var(--text-dim); margin: 0 0 22px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .pihole-grid .span2 { grid-column: span 1; }
  .notes-layout { grid-template-columns: 1fr; }
  .notes-list-pane { max-height: 330px; }
}

/* Small tablets: the dock collapses to an icon rail. */
@media (max-width: 900px) {
  html { --dock-w: 76px; }
  .dock-label, .dock-logo-text { display: none; }
  .dock-collapse { display: none; }
  .topbar { padding: 12px 16px; gap: 12px; }
  .topbar-clock { display: none; }
  .topbar-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-title .eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .content { padding: 18px 16px 48px; }
  .hero { flex-direction: column-reverse; text-align: center; padding: 24px 20px; }
  .hero-pills { justify-content: center; }
  .orb.big { width: 130px; height: 130px; }
  .deck-head { flex-direction: column; align-items: stretch; }
  input[type="search"].field { min-width: 0; flex: 1; }
}

/* Phones: the dock becomes a fixed bottom tab bar and content goes full width.
   The html[data-dock="min"] selectors must be repeated here because a dock state
   stored on desktop otherwise outranks these rules on the phone. */
@media (max-width: 640px) {
  .dock,
  html[data-dock="min"] .dock {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; height: auto;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .dock::-webkit-scrollbar { display: none; }
  .dock-logo, .dock-foot, .dock-group-label { display: none; }
  .dock-nav {
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    gap: 2px;
    flex: none;
    min-width: 100%;
    overflow: visible;
  }
  .dock-link,
  html[data-dock="min"] .dock-link {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 11px;
    flex: none;
    font-size: 0.58rem;
    letter-spacing: 0.06em;
  }
  .dock-link.active { box-shadow: inset 0 3px 0 var(--accent); }
  .dock-label,
  html[data-dock="min"] .dock-label { display: block; }

  .main,
  html[data-dock="min"] .main { margin-left: 0; }
  .content { padding: 14px 14px calc(88px + env(safe-area-inset-bottom)); gap: 16px; }

  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar-title h1 { font-size: 1.06rem; }

  /* iOS Safari zooms the page when a focused control is under 16px. */
  .field, select.field, textarea.field, .palette-head input { font-size: 16px; }

  /* keep floating chrome clear of the bottom bar */
  #toasts {
    left: 12px; right: 12px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    max-width: none;
  }
  .modal-overlay { padding: 14px 10px calc(88px + env(safe-area-inset-bottom)); }
  .modal-foot { flex-wrap: wrap; }
  .palette { padding-top: 7vh; }

  .card { padding: 15px 14px; }
  .hero { padding: 20px 14px; }
  .table .actions .btn-icon { width: 36px; height: 36px; }
  .session-art { width: 58px; height: 86px; }
  .net-map { min-height: 280px; }
  .net-map .empty { min-height: 260px; }
  .notes-editor { min-height: 420px; }
  .field.area { min-height: 260px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  #starfield { display: none !important; }
  .ticker-track { animation: none; }
}

/* ============================================================
   Network deck · LAN scanner + map
   ============================================================ */
.net-types { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.net-chip { cursor: pointer; }
.net-chip.active { border-color: var(--accent); color: var(--accent); }
.net-swatch { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.net-map-card { margin-bottom: 18px; }
.net-map { position: relative; min-height: 440px; }
.net-map .empty { min-height: 420px; }
.net-svg { width: 100%; height: auto; display: block; overflow: visible; }

.net-edge { stroke: var(--line-strong); stroke-width: 1; opacity: 0.5; }
.net-edge.off { stroke-dasharray: 3 5; opacity: 0.22; }

.net-node { cursor: pointer; }
.net-node:focus { outline: none; }
.net-node .net-ring { fill: none; stroke: var(--c); stroke-width: 1.5; opacity: 0; transition: opacity 0.15s ease; }
.net-node:hover .net-ring { opacity: 0.9; }
/* Keyboard focus gets a distinct, high-contrast cue (accent colour, thicker, dashed) — not the hover halo. */
.net-node:focus-visible .net-ring { opacity: 1; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 5 3; }
.net-node .net-dot {
  fill: color-mix(in srgb, var(--c) 16%, var(--surface));
  stroke: var(--c); stroke-width: 1.6;
  transition: stroke-width 0.15s ease;
}
.net-node:hover .net-dot,
.net-node:focus-visible .net-dot { stroke-width: 2.6; }
.net-node use { color: var(--c); }
.net-node .net-label {
  fill: var(--text); text-anchor: middle;
  font-family: var(--font-mono); font-size: 12px;
}
.net-node.offline { opacity: 0.42; }
.net-node.gw .net-dot { stroke-width: 2.4; filter: drop-shadow(0 0 7px var(--c)); }
.net-node .net-badge { fill: var(--accent); stroke: var(--bg0); stroke-width: 1.5; }

.net-status { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.net-status.ok { background: var(--good); box-shadow: 0 0 6px var(--good); }
.net-status.off { background: var(--text-dim); }

.net-table .icon.tiny { width: 13px; height: 13px; color: var(--accent); }
.pill.net-type, .pill.gw {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--line-strong);
}
.pill.net-type { color: var(--c); border-color: color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 13%, transparent); }
.pill.gw { color: var(--accent2); border-color: color-mix(in srgb, var(--accent2) 45%, transparent); }

.net-edit-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px;
  margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.net-edit-meta .dim.small {
  display: block; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.66rem; margin-bottom: 2px;
}
.net-field { display: block; margin-bottom: 12px; }
.net-field > span { display: block; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 5px; }
.net-field .field { width: 100%; }
.net-field textarea.field { resize: vertical; min-height: 64px; font-family: var(--font-body); }
select.field option { background: var(--bg1); color: var(--text); }

@media (max-width: 720px) {
  .net-edit-meta { grid-template-columns: 1fr; }
  .net-map { min-height: 320px; }
}

/* ============================================================
   Lights deck · Philips Hue + Nanoleaf control
   ============================================================ */
.icon.tiny { width: 13px; height: 13px; }
.btn-icon.tiny { width: 26px; height: 26px; }
.btn-icon.tiny .icon { width: 13px; height: 13px; }

.lights-bridges { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 4px; }
.chip.lights-bridge { gap: 8px; padding: 5px 8px 5px 12px; max-width: 100%; }
/* Bridge names are user-entered (up to 80 chars); shrink and ellipsize them rather
   than letting one wide chip overflow a phone screen. */
.lights-bridge-name {
  font-family: var(--font-body); font-weight: 600; letter-spacing: 0;
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.chip.lights-bridge .dim.small { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.lights-grid { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); margin-top: 4px; }
.lights-empty { display: block; margin-top: 4px; }

.light-card { display: flex; flex-direction: column; gap: 16px; transition: opacity 0.15s ease; }
.light-card.is-off { opacity: 0.72; }
.light-card.is-unreachable { opacity: 0.55; }

.light-top { display: flex; align-items: center; gap: 13px; }
.light-swatch {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--sw, #ffd9a0);
  border: 2px solid color-mix(in srgb, var(--text) 18%, transparent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--sw, #ffd9a0) 65%, transparent);
}
.light-card.is-off .light-swatch { box-shadow: none; filter: grayscale(0.5); }
.light-id { flex: 1; min-width: 0; }
.light-name { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.light-meta { display: flex; align-items: center; gap: 5px; margin-top: 2px; }

.light-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface2);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.light-toggle:hover { color: var(--text); border-color: var(--line-strong); }
.light-toggle.on {
  color: var(--bg0);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--accent2)));
  border-color: transparent;
  box-shadow: 0 0 16px var(--glow);
}

.light-controls { display: flex; flex-direction: column; gap: 11px; }
.light-row {
  display: grid; grid-template-columns: 78px 1fr auto; align-items: center; gap: 12px;
  cursor: default;
}
.light-row-label { font-size: 0.78rem; color: var(--text-dim); letter-spacing: 0.04em; }
.light-row-val { font-family: var(--font-mono); font-size: 0.82rem; min-width: 38px; text-align: right; }
.light-row input[type="range"] { width: auto; min-width: 0; }
.light-row input[type="color"] { justify-self: start; }
.light-row .field { width: 100%; }

/* warm/cool temperature slider gets a gradient track */
.warm-cool {
  -webkit-appearance: none; appearance: none;
  height: 8px; border-radius: 999px; outline: none; padding: 0;
  background: linear-gradient(90deg, #ffb05a 0%, #fff4e6 50%, #bcd4ff 100%);
}
.warm-cool::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text); border: 2px solid var(--bg0);
  box-shadow: 0 0 6px var(--glow); cursor: pointer;
}
.warm-cool::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text); border: 2px solid var(--bg0); cursor: pointer;
}
.warm-cool::-moz-range-track { background: transparent; }

/* pairing modal */
.lights-kind { margin-bottom: 12px; }
.lights-help { margin: 0 0 14px; line-height: 1.5; }
.lights-help a { font-weight: 600; }

@media (max-width: 720px) {
  .light-row { grid-template-columns: 70px 1fr auto; }
}

/* ============================================================
   Climate deck · Nest thermostat + Protect alarms (via HA)
   ============================================================ */
.climate-grid { grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); }
.protect-grid { grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); }
.climate-steps { margin: 12px 0 6px; padding-left: 20px; line-height: 1.7; }
.climate-steps li { margin-bottom: 6px; }

/* thermostat card */
.thermo-card {
  display: flex; flex-direction: column; gap: 16px;
  --mode-c: var(--accent);
}
.thermo-card.mode-heat { --mode-c: #ff8a4c; }
.thermo-card.mode-cool { --mode-c: #38bdf8; }
.thermo-card.mode-auto { --mode-c: var(--good); }
.thermo-card.mode-dry { --mode-c: #fbbf24; }
.thermo-card.mode-fan { --mode-c: #a78bfa; }
.thermo-card.mode-off { --mode-c: var(--text-dim); }
.thermo-card.is-locked { opacity: 0.9; }

.thermo-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.thermo-name { font-weight: 700; font-size: 1.06rem; }
.thermo-action {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text-dim);
  white-space: nowrap; flex: none;
}
.thermo-action.heat { color: #ff8a4c; border-color: color-mix(in srgb, #ff8a4c 50%, transparent); }
.thermo-action.cool { color: #38bdf8; border-color: color-mix(in srgb, #38bdf8 50%, transparent); }
.thermo-action.dry { color: #fbbf24; border-color: color-mix(in srgb, #fbbf24 50%, transparent); }

.thermo-body { display: flex; justify-content: center; padding: 4px 0; }
.thermo-offline { color: var(--text-dim); text-align: center; padding: 18px 0; }

.thermo-dual { display: flex; gap: 26px; }
.stepper { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.stepper-label { display: flex; align-items: center; gap: 5px; }
.stepper-label .icon.tiny { width: 13px; height: 13px; }
.stepper-ctl { display: flex; align-items: center; gap: 10px; }
.stepper-val {
  font-family: var(--font-display); font-size: 2.1rem; font-weight: 700;
  min-width: 92px; text-align: center; color: var(--mode-c);
  text-shadow: 0 0 18px color-mix(in srgb, var(--mode-c) 35%, transparent);
}
.thermo-dual .stepper-val { font-size: 1.6rem; min-width: 70px; }
.stepper .btn-icon { width: 34px; height: 34px; border-radius: 50%; }
.stepper .btn-icon:hover { color: var(--mode-c); border-color: var(--mode-c); }

.thermo-modes { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg {
  padding: 8px 6px; text-align: center; cursor: pointer;
  font-family: var(--font-body); font-weight: 600; font-size: 0.82rem; letter-spacing: 0.03em;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg0) 35%, transparent); color: var(--text-dim);
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.seg:hover { color: var(--text); }
.seg.active { color: var(--bg0); border-color: transparent; }
.seg-heat.active { background: #ff8a4c; }
.seg-cool.active { background: #38bdf8; }
.seg-auto.active { background: var(--good); }
.seg-dry.active { background: #fbbf24; }
.seg-fan.active { background: #a78bfa; }
.seg-off.active { background: var(--text-dim); }
.seg:disabled { opacity: 0.5; cursor: not-allowed; }

.thermo-extras { display: flex; flex-direction: column; gap: 10px; }
.thermo-presets { display: flex; align-items: center; gap: 8px; }
.thermo-preset { cursor: pointer; }
.thermo-preset.active { border-color: var(--good); color: var(--good); }
.thermo-presets .dim { margin-left: auto; }
.thermo-fan { display: flex; align-items: center; gap: 10px; }
.thermo-fan .field { flex: 1; }

/* protect / smoke card */
.protect-card { display: flex; flex-direction: column; gap: 12px; }
.protect-card.is-alarm {
  border-color: color-mix(in srgb, var(--bad) 60%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--bad) 30%, transparent), var(--shadow);
  animation: alarmPulse 1.4s ease-in-out infinite;
}
@keyframes alarmPulse { 50% { box-shadow: 0 0 22px color-mix(in srgb, var(--bad) 45%, transparent), var(--shadow); } }
.protect-head { display: flex; align-items: center; gap: 10px; }
.protect-name { font-weight: 700; font-size: 1.02rem; flex: 1; min-width: 0; }
.pill.alarm {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.12em;
  padding: 3px 9px; border-radius: 999px;
  color: var(--bg0); background: var(--bad); font-weight: 700;
}
.protect-rows { display: flex; flex-direction: column; gap: 7px; }
.protect-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.92rem; }
.protect-row-label { color: var(--text-dim); }
.protect-status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.protect-status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.protect-status.good { color: var(--good); }
.protect-status.bad { color: var(--bad); }
.protect-status.dim { color: var(--text-dim); }
.protect-foot { border-top: 1px solid var(--line); padding-top: 8px; }

@media (max-width: 720px) {
  .thermo-dual { gap: 14px; }
}

/* Phone fixes for the deck sections above; lives after them so it wins the cascade.
   Stepper buttons grow to a comfortable touch size and the dual heat/cool steppers
   compact (wrapping as a last resort) so wide Orbitron temperatures cannot overflow. */
@media (max-width: 640px) {
  .stepper .btn-icon { width: 40px; height: 40px; }
  .thermo-dual { gap: 12px; flex-wrap: wrap; justify-content: center; }
  .thermo-dual .stepper-ctl { gap: 6px; }
  .thermo-dual .stepper .btn-icon { width: 38px; height: 38px; }
  .thermo-dual .stepper-val { font-size: 1.25rem; min-width: 0; }
}
