:root {
  --bg: #05070a;
  --panel: #0b1015;
  --panel-raised: #111821;
  --panel-rgb: 11, 16, 21;
  --panel-raised-rgb: 17, 24, 33;
  --surface-sunken: #020305;
  --surface-hover: #182029;
  --border: #1c262e;
  --text: #dbe8e6;
  --text-muted: #63777c;
  --copper: #8f7cf5;
  --copper-dim: #423a78;
  --moss: #3fe0ab;
  --moss-glow: rgba(63, 224, 171, 0.4);
  --rust: #e14369;
  --spark: #baf7e4;
  --glow: rgba(143, 124, 245, 0.42);
  --radius: 7px;
  --radius-sm: 4px;
  --shadow-color: 2, 2, 4;
  --pulse-speed: 1;
}

/* Multiplier applied to every ambient pulse (veins, particles, sensor mark,
   status dot, scan sweep) — toggled by JS during a pending restart or a
   metric alert so the whole UI visibly quickens. */
:root.alert-active { --pulse-speed: 2.6; }

:root[data-theme="light"] {
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-raised: #f2f4f7;
  --panel-rgb: 255, 255, 255;
  --panel-raised-rgb: 242, 244, 247;
  --surface-sunken: #e2e7eb;
  --surface-hover: #dde2e7;
  --border: #d2d9df;
  --text: #161a1f;
  --text-muted: #5b6570;
  --copper: #5b4bc4;
  --copper-dim: #b6abee;
  --moss: #15875f;
  --moss-glow: rgba(21, 135, 95, 0.22);
  --rust: #b02a49;
  --spark: #2f8f7a;
  --glow: rgba(91, 75, 196, 0.2);
  --shadow-color: 40, 44, 56;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after,
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Cross-document page transitions (progressive enhancement — Chrome/Edge 126+, Safari 18.2+) */
@view-transition {
  navigation: auto;
}
::view-transition-old(root) {
  animation: page-out 0.18s ease forwards;
}
::view-transition-new(root) {
  animation: page-in 0.38s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
::view-transition-group(nav-indicator) {
  animation-duration: 0.38s;
  animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
}
@keyframes page-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
}

body {
  background-image:
    radial-gradient(ellipse 900px 520px at 8% -8%, rgba(143, 124, 245, 0.10), transparent 60%),
    radial-gradient(ellipse 760px 460px at 96% 104%, rgba(63, 224, 171, 0.08), transparent 60%),
    radial-gradient(circle, var(--border) 1px, transparent 1.3px);
  background-size: auto, auto, 26px 26px;
  background-position: 0 0, 0 0, 0 0;
  background-attachment: fixed;
  background-repeat: no-repeat, no-repeat, repeat;
}

a { color: var(--copper); }

/* ---------- sculk vein network (site-wide, decorative) ---------- */
.bg-veins { position: fixed; inset: 0; z-index: -2; width: 100%; height: 100%; pointer-events: none; }
.bg-veins .vein-base {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
  opacity: 0.7;
}
.bg-veins .vein-pulse {
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 0.05 1;
  filter: drop-shadow(0 0 6px currentColor);
  animation: vein-travel linear infinite;
}
.bg-veins .vein-pulse.teal { stroke: var(--moss); color: var(--moss-glow); animation-duration: calc(10s / var(--pulse-speed)); }
.bg-veins .vein-pulse.violet { stroke: var(--copper); color: var(--glow); animation-duration: calc(13s / var(--pulse-speed)); }
.bg-veins .vein-pulse:nth-of-type(2) { animation-delay: -2s; }
.bg-veins .vein-pulse:nth-of-type(4) { animation-delay: -6s; }
.bg-veins .vein-pulse:nth-of-type(6) { animation-delay: -9s; }
.bg-veins .vein-pulse:nth-of-type(8) { animation-delay: -3s; }
.bg-veins .vein-pulse:nth-of-type(10) { animation-delay: -7s; }
.bg-veins .vein-pulse:nth-of-type(12) { animation-delay: -1s; }
@keyframes vein-travel {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -1.05; }
}

/* ---------- ambient particle field (site-wide, decorative) ---------- */
.bg-particles { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-particles span {
  position: absolute;
  bottom: -6%;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--moss);
  box-shadow: 0 0 8px 1px var(--moss-glow);
  opacity: 0;
  animation: spore-rise linear infinite;
}
.bg-particles span:nth-child(3n) {
  background: var(--copper);
  box-shadow: 0 0 8px 1px var(--glow);
}
@keyframes spore-rise {
  0% { transform: translate(0, 0); opacity: 0; }
  8% { opacity: 0.55; }
  50% { transform: translate(14px, -55vh); }
  92% { opacity: 0.55; }
  100% { transform: translate(-10px, -108vh); opacity: 0; }
}
.bg-particles span:nth-child(1)  { left: 4%;  width: 2px; height: 2px; animation-duration: calc(26s / var(--pulse-speed)); animation-delay: -2s; }
.bg-particles span:nth-child(2)  { left: 12%; width: 3px; height: 3px; animation-duration: calc(32s / var(--pulse-speed)); animation-delay: -18s; }
.bg-particles span:nth-child(3)  { left: 20%; width: 2px; height: 2px; animation-duration: calc(22s / var(--pulse-speed)); animation-delay: -9s; }
.bg-particles span:nth-child(4)  { left: 29%; width: 4px; height: 4px; animation-duration: calc(38s / var(--pulse-speed)); animation-delay: -24s; }
.bg-particles span:nth-child(5)  { left: 37%; width: 2px; height: 2px; animation-duration: calc(28s / var(--pulse-speed)); animation-delay: -4s; }
.bg-particles span:nth-child(6)  { left: 46%; width: 3px; height: 3px; animation-duration: calc(34s / var(--pulse-speed)); animation-delay: -14s; }
.bg-particles span:nth-child(7)  { left: 54%; width: 2px; height: 2px; animation-duration: calc(24s / var(--pulse-speed)); animation-delay: -19s; }
.bg-particles span:nth-child(8)  { left: 61%; width: 4px; height: 4px; animation-duration: calc(40s / var(--pulse-speed)); animation-delay: -6s; }
.bg-particles span:nth-child(9)  { left: 68%; width: 2px; height: 2px; animation-duration: calc(27s / var(--pulse-speed)); animation-delay: -22s; }
.bg-particles span:nth-child(10) { left: 75%; width: 3px; height: 3px; animation-duration: calc(31s / var(--pulse-speed)); animation-delay: -11s; }
.bg-particles span:nth-child(11) { left: 82%; width: 2px; height: 2px; animation-duration: calc(23s / var(--pulse-speed)); animation-delay: -16s; }
.bg-particles span:nth-child(12) { left: 89%; width: 4px; height: 4px; animation-duration: calc(36s / var(--pulse-speed)); animation-delay: -8s; }
.bg-particles span:nth-child(13) { left: 95%; width: 2px; height: 2px; animation-duration: calc(29s / var(--pulse-speed)); animation-delay: -27s; }
.bg-particles span:nth-child(14) { left: 8%;  width: 3px; height: 3px; animation-duration: calc(33s / var(--pulse-speed)); animation-delay: -30s; }
.bg-particles span:nth-child(15) { left: 44%; width: 2px; height: 2px; animation-duration: calc(21s / var(--pulse-speed)); animation-delay: -12s; }
.bg-particles span:nth-child(16) { left: 71%; width: 3px; height: 3px; animation-duration: calc(35s / var(--pulse-speed)); animation-delay: -3s; }

/* ---------- app shell ---------- */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  background: linear-gradient(180deg, rgba(var(--panel-raised-rgb), 0.92), rgba(var(--panel-rgb), 0.95));
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-right: 1px solid var(--border);
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.6rem 1.6rem;
}
/* Sensor mark — a glowing core with an outward ping, like a sculk sensor listening */
.brand-mark {
  position: relative;
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark::before, .brand-mark::after {
  content: '';
  position: absolute;
  width: 8px; height: 8px;
  margin: auto; inset: 0;
  border-radius: 50%;
  border: 1px solid var(--moss);
  animation: sensor-ping calc(2.6s / var(--pulse-speed)) ease-out infinite;
}
.brand-mark::after { animation-delay: 1.3s; }
@keyframes sensor-ping {
  0% { width: 8px; height: 8px; opacity: 0.75; border-color: var(--moss); }
  100% { width: 24px; height: 24px; opacity: 0; }
}
.brand-mark-core {
  position: relative;
  z-index: 1;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--spark), var(--moss));
  box-shadow: 0 0 10px var(--moss-glow);
  animation: core-pulse calc(2.6s / var(--pulse-speed)) ease-in-out infinite;
}
@keyframes core-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
.brand-text {
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.sidebar-links { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }

/* ---------- server switcher ---------- */
.server-switcher { position: relative; margin: 0 0 0.9rem; }
.server-switcher-trigger {
  width: 100%;
  display: flex; align-items: center; gap: 0.55rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  font-size: 0.8rem;
  color: var(--text);
}
.server-switcher-trigger:hover { border-color: var(--copper-dim); background: var(--surface-hover); }
.server-switcher-trigger svg { width: 12px; height: 12px; flex-shrink: 0; color: var(--text-muted); }
.server-switcher-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-switcher-menu {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  margin-top: 4px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem;
  z-index: 25;
  box-shadow: 0 16px 36px -12px rgba(var(--shadow-color), 0.6);
  max-height: 260px;
  overflow-y: auto;
}
.server-switcher-menu.open { display: block; }
.server-switcher-item {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 3px;
  font-size: 0.8rem;
  color: var(--text);
  text-decoration: none;
}
.server-switcher-item:hover { background: var(--surface-hover); }
.server-switcher-item.active { color: var(--copper); }
.server-switcher-item.add { color: var(--text-muted); }
.server-switcher-divider { height: 1px; background: var(--border); margin: 0.3rem 0.2rem; }

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  z-index: 1;
  transition: color 0.15s ease;
}
.sidebar-link:hover { color: var(--text); }
.sidebar-link.active { color: var(--text); font-weight: 500; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; position: relative; z-index: 1; }
.sidebar-link span:last-child { position: relative; z-index: 1; }

.nav-indicator {
  position: absolute;
  inset: 0;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px -8px var(--glow);
  z-index: 0;
}
.nav-indicator::before {
  content: '';
  position: absolute;
  left: -1px; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--copper);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.signal-wave { width: 100%; height: 14px; display: block; margin-bottom: -0.1rem; }
.signal-wave path {
  fill: none;
  stroke: var(--moss);
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: 0.6;
  filter: drop-shadow(0 0 4px var(--moss-glow));
  stroke-dasharray: 6 4;
  animation: signal-scroll calc(2.4s / var(--pulse-speed)) linear infinite;
}
@keyframes signal-scroll { to { stroke-dashoffset: -20; } }
.sidebar-actions { display: flex; gap: 0.5rem; }
.sidebar-actions button { flex: 1; justify-content: center; padding: 0.5rem; }

.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 0.9rem; left: 0.9rem;
  z-index: 40;
  padding: 0.5rem;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.mobile-nav-toggle svg { width: 18px; height: 18px; display: block; }
.sidebar-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 25;
}

.main-content {
  flex: 1;
  min-width: 0;
  max-width: 1400px;
  padding: 2.5rem 3rem 4rem;
}
.main-content--auth {
  max-width: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

/* ---------- cards ---------- */
.panel {
  position: relative;
  background: rgba(var(--panel-rgb), 0.8);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(var(--shadow-color), 0.3), 0 16px 40px -20px rgba(var(--shadow-color), 0.7);
  margin-bottom: 1.1rem;
  animation: card-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--moss), var(--copper), transparent);
  background-size: 200% 100%;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0.5;
  animation: scan-sweep calc(7s / var(--pulse-speed)) linear infinite;
  pointer-events: none;
}
.panel:hover {
  border-color: var(--copper-dim);
  box-shadow: 0 1px 2px rgba(var(--shadow-color), 0.3), 0 20px 48px -18px rgba(var(--shadow-color), 0.75);
}
.panel:nth-of-type(1) { animation-delay: 0.02s; }
.panel:nth-of-type(2) { animation-delay: 0.08s; }
.panel:nth-of-type(3) { animation-delay: 0.14s; }
.panel:nth-of-type(4) { animation-delay: 0.20s; }
.panel:nth-of-type(5) { animation-delay: 0.26s; }
@keyframes card-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scan-sweep { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.panel-header {
  padding: 1.05rem 1.35rem;
  border-bottom: 1px solid var(--border);
  background: rgba(var(--panel-raised-rgb), 0.85);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
h1, h2 { font-family: 'Chakra Petch', sans-serif; margin: 0; }
h1 { font-size: 1.05rem; font-weight: 700; }
h2 { font-size: 0.92rem; font-weight: 700; }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted); flex-shrink: 0; position: relative;
}
.status-dot::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 1px solid transparent; }
.status-dot.running { background: var(--moss); box-shadow: 0 0 8px var(--moss-glow); animation: breathe calc(2.4s / var(--pulse-speed)) ease-in-out infinite; }
.status-dot.running::after { border-color: var(--moss-glow); animation: ring calc(2.4s / var(--pulse-speed)) ease-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes ring { 0% { transform: scale(0.8); opacity: 0.8; } 100% { transform: scale(1.8); opacity: 0; } }

.conn-pill {
  font-size: 0.68rem; padding: 0.3rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-muted); white-space: nowrap;
  transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}
.conn-pill.live { color: var(--moss); border-color: var(--moss-glow); background: rgba(63, 224, 171, 0.08); }
.conn-pill.down { color: var(--rust); border-color: rgba(225, 67, 105, 0.4); background: rgba(225, 67, 105, 0.08); animation: pillIn 0.25s ease; }
@keyframes pillIn { from { transform: translateY(-4px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.section-body { padding: 1.25rem 1.35rem; display: flex; flex-direction: column; gap: 1.1rem; }

button {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.82rem; font-weight: 500;
  color: var(--text); background: var(--panel-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.55rem 1rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem;
  transition: transform 0.12s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
button:hover { border-color: var(--copper-dim); background: var(--surface-hover); box-shadow: 0 4px 14px -6px rgba(var(--shadow-color), 0.5); }
button:active { transform: scale(0.96); }
button:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }
button.start:hover { border-color: var(--moss); }
button.stop:hover, button.danger:hover { border-color: var(--rust); color: var(--rust); }
button svg { width: 13px; height: 13px; flex-shrink: 0; }
.send-btn { position: relative; overflow: hidden; background: linear-gradient(135deg, var(--copper-dim), var(--copper)); border-color: var(--copper-dim); color: #14101f; font-weight: 600; }
.send-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 35%, rgba(255, 255, 255, 0.4) 50%, transparent 65%);
  transform: translateX(-130%);
  transition: transform 0.6s ease;
}
.send-btn:hover { filter: brightness(1.1); box-shadow: 0 6px 18px -6px var(--glow); }
.send-btn:hover::after { transform: translateX(130%); }

input[type="text"], input[type="password"], input[type="time"], input[type="number"], input:not([type]) {
  background: var(--surface-sunken); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.55rem 0.7rem; font-family: inherit; font-size: 0.82rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus-visible { outline: none; border-color: var(--copper); box-shadow: 0 0 0 3px rgba(143, 124, 245, 0.18); }
input::placeholder { color: var(--text-muted); }
label { font-size: 0.82rem; font-weight: 500; display: block; margin-bottom: 0.4rem; }
.field-hint { font-size: 0.72rem; color: var(--text-muted); margin: 0.35rem 0 0; }
.inline-fields { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ---------- console ---------- */
.log-filter-row { padding: 0.6rem 1.35rem 0; background: transparent; }
#log-filter { width: 100%; font-size: 0.76rem; padding: 0.45rem 0.7rem; }
#console {
  background: var(--surface-sunken); padding: 1rem 1.35rem; height: min(50vh, 460px);
  overflow-y: auto; font-size: 0.8rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
#console .line {
  position: relative;
  padding-left: 0.6rem;
  border-left: 2px solid transparent;
  animation: line-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
#console .line.dashboard { color: var(--copper); animation-name: line-in-dashboard; }
@keyframes line-in {
  0% { opacity: 0; transform: translateX(-10px); border-left-color: var(--moss); text-shadow: 0 0 8px var(--moss-glow); background: rgba(63, 224, 171, 0.1); }
  40% { opacity: 1; transform: translateX(0); }
  100% { opacity: 1; transform: translateX(0); border-left-color: transparent; text-shadow: none; background: transparent; }
}
@keyframes line-in-dashboard {
  0% { opacity: 0; transform: translateX(-10px); border-left-color: var(--copper); text-shadow: 0 0 8px var(--glow); background: rgba(143, 124, 245, 0.12); }
  40% { opacity: 1; transform: translateX(0); }
  100% { opacity: 1; transform: translateX(0); border-left-color: transparent; text-shadow: none; background: transparent; }
}
#console::-webkit-scrollbar { width: 8px; }
#console::-webkit-scrollbar-track { background: transparent; }
#console::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.command-row {
  position: relative; display: flex; gap: 0.6rem; padding: 0.9rem 1.35rem;
  border-top: 1px solid var(--border);
  background: rgba(var(--panel-raised-rgb), 0.9);
  border-radius: 0 0 var(--radius) var(--radius);
}
#command-input { flex: 1; min-width: 0; }

/* ---------- switch ---------- */
.switch-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.slider {
  position: absolute; inset: 0;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: inset 0 1px 3px rgba(var(--shadow-color), 0.6);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.slider::before {
  content: '';
  position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
  border-radius: 50%;
  background: linear-gradient(155deg, var(--text), #9aa1a8);
  box-shadow: 0 1px 3px rgba(var(--shadow-color), 0.7);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease, box-shadow 0.3s ease;
}
.switch input:checked + .slider {
  background: linear-gradient(90deg, var(--copper-dim), var(--moss));
  border-color: var(--moss);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 12px -2px var(--moss-glow);
}
.switch input:checked + .slider::before {
  transform: translateX(16px);
  background: radial-gradient(circle at 35% 30%, var(--spark), var(--moss));
  box-shadow: 0 0 8px var(--moss-glow), 0 1px 2px rgba(var(--shadow-color), 0.7);
}
.switch input:checked + .slider::after {
  content: '';
  position: absolute; left: 2px; top: 2px; width: 16px; height: 16px;
  border-radius: 50%;
  border: 1px solid var(--moss);
  transform: translateX(16px);
  animation: switch-ping 0.6s ease-out;
  pointer-events: none;
}
@keyframes switch-ping {
  0% { opacity: 0.8; transform: translateX(16px) scale(1); }
  100% { opacity: 0; transform: translateX(16px) scale(2.3); }
}

/* ---------- pill lists ---------- */
.pill-list { list-style: none; margin: 0.6rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.45rem; }
.pill-list:empty::after { content: 'none'; font-size: 0.74rem; color: var(--text-muted); }
.pill-list li {
  display: inline-flex; align-items: center; gap: 0.4rem; background: var(--surface-sunken);
  border: 1px solid var(--border); border-radius: 999px; padding: 0.3rem 0.5rem 0.3rem 0.75rem; font-size: 0.76rem;
  transition: border-color 0.15s ease;
}
.pill-list li .pill-remove { background: transparent; border: none; color: var(--text-muted); padding: 0.15rem 0.35rem; font-size: 0.85rem; line-height: 1; border-radius: 50%; }
.pill-list li .pill-remove:hover { color: var(--rust); background: rgba(225, 67, 105, 0.12); }
.pill-list.backups li, .pill-list.plugins li {
  border-radius: var(--radius-sm); padding: 0.5rem 0.6rem;
  display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 0.75rem;
}
.pill-list.backups, .pill-list.plugins { flex-direction: column; }
.pill-list.plugins li .switch { flex-shrink: 0; }

/* ---------- themed file picker (replaces the native "Choose file" button) ---------- */
.file-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 280px;
  padding: 0.55rem 0.9rem 0.55rem 0.7rem;
  background: var(--surface-sunken);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.file-picker:hover { border-color: var(--copper-dim); color: var(--text); }
.file-picker:has(input:focus-visible) { outline: 2px solid var(--copper); outline-offset: 2px; }
.file-picker.has-file {
  border-style: solid;
  border-color: var(--moss);
  color: var(--text);
  box-shadow: 0 0 12px -4px var(--moss-glow);
}
.file-picker-icon { width: 15px; height: 15px; flex-shrink: 0; color: var(--copper); }
.file-picker.has-file .file-picker-icon { color: var(--moss); }
.file-picker-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-picker input[type="file"] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.backup-meta { color: var(--text-muted); font-size: 0.7rem; }

.pill-list.players li { position: relative; cursor: pointer; }
.pill-list.players li:hover { border-color: var(--copper-dim); }
.player-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 130px;
  z-index: 20;
  box-shadow: 0 18px 36px -14px rgba(var(--shadow-color), 0.65);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.96);
  transform-origin: top left;
  transition: opacity 0.15s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.15s;
  pointer-events: none;
}
.pill-list.players li:hover .player-menu, .pill-list.players li.open .player-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.player-menu button { justify-content: flex-start; padding: 0.45rem 0.6rem; font-size: 0.74rem; background: transparent; border: none; border-radius: 3px; gap: 0.55rem; }
.player-menu button svg { width: 13px; height: 13px; opacity: 0.75; }
.player-menu button:hover { background: var(--surface-hover); }
.player-menu button.danger:hover { color: var(--rust); }
.player-menu button.danger:hover svg { opacity: 1; }
.player-menu-divider { height: 1px; background: var(--border); margin: 0.3rem 0.2rem; }

/* ---------- config editor ---------- */
.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.7rem; }
.config-field label { font-size: 0.7rem; color: var(--text-muted); display: block; margin-bottom: 0.3rem; }
.config-field input { width: 100%; font-size: 0.78rem; }
.config-actions { display: flex; align-items: center; gap: 0.75rem; }

/* ---------- monitoring ---------- */
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.85rem; }
.monitor-card { background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.85rem; transition: border-color 0.2s ease; }
.monitor-card:hover { border-color: var(--copper-dim); }
.monitor-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.monitor-value { font-family: 'Chakra Petch', sans-serif; font-size: 1.35rem; font-weight: 700; margin: 0.3rem 0; }
.sparkline { width: 100%; height: 28px; display: block; }
.sparkline polyline { fill: none; stroke: var(--copper); stroke-width: 1.5; }
.disk-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin-top: 0.4rem; }
.disk-bar-fill { height: 100%; background: linear-gradient(90deg, var(--moss), var(--copper)); width: 0%; transition: width 0.4s cubic-bezier(0.16,1,0.3,1); }

.range-tabs { display: flex; gap: 0.3rem; }
.range-tab {
  padding: 0.35rem 0.7rem;
  font-size: 0.72rem;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.range-tab:hover { color: var(--text); border-color: var(--copper-dim); }
.range-tab.active { color: var(--text); background: var(--surface-hover); border-color: var(--copper-dim); }

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}
.history-chart-card {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
}
.history-chart { width: 100%; height: 160px; display: block; margin-top: 0.4rem; }

/* ---------- table (audit / users) ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
th, td { text-align: left; padding: 0.6rem 0.65rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr { transition: background 0.15s ease; }
tr:hover td { background: var(--surface-hover); }
tr:last-child td { border-bottom: none; }
.table-scroll { max-height: 60vh; overflow-y: auto; }

/* ---------- login page ---------- */
.auth-glow {
  position: absolute;
  left: 50%; bottom: -12%;
  width: min(70vw, 640px); height: min(70vw, 640px);
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--glow), transparent 65%);
  animation: glow-pulse 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes glow-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.95; } }

.login-wrap { position: relative; z-index: 1; width: 100%; max-width: 380px; }
.login-wrap .panel { padding: 2rem; animation: card-in 0.5s cubic-bezier(0.16,1,0.3,1) backwards; }
.login-wrap h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  animation: title-glow 4s ease-in-out infinite;
}
@keyframes title-glow {
  0%, 100% { text-shadow: 0 0 12px var(--glow); }
  50% { text-shadow: 0 0 26px var(--glow); }
}
.login-wrap label { margin-top: 0.9rem; }
.login-wrap input { width: 100%; }
.login-wrap button { width: 100%; justify-content: center; margin-top: 1.4rem; }
.login-error { color: var(--rust); font-size: 0.78rem; margin-top: 0.9rem; text-align: center; }
.login-note { font-size: 0.7rem; color: var(--text-muted); text-align: center; margin-top: 1.1rem; max-width: 380px; }

.hint { text-align: center; font-size: 0.7rem; color: var(--text-muted); margin-top: 0.9rem; }
.role-badge {
  font-size: 0.68rem; padding: 0.35rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.03em; text-align: center;
}
.role-badge.admin { color: var(--copper); border-color: var(--copper-dim); box-shadow: 0 0 12px -4px var(--glow); }

/* ---------- sidebar search trigger ---------- */
.cmdk-trigger {
  margin-left: auto;
  padding: 0.3rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
}
.cmdk-trigger svg { width: 15px; height: 15px; }
.cmdk-trigger:hover { color: var(--text); background: var(--surface-hover); border-color: var(--border); }

/* ---------- command palette ---------- */
.cmdk-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.cmdk-overlay.open { display: flex; }
.cmdk-panel {
  width: 100%;
  max-width: 560px;
  margin: 0 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.7);
  overflow: hidden;
  animation: cmdk-in 0.16s cubic-bezier(0.16,1,0.3,1);
}
@keyframes cmdk-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.cmdk-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 1rem 1.2rem;
  font-size: 0.92rem;
  font-family: inherit;
}
.cmdk-input:focus-visible { outline: none; }
.cmdk-list { max-height: 340px; overflow-y: auto; padding: 0.4rem; }
.cmdk-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text);
}
.cmdk-item.selected { background: var(--surface-hover); }
.cmdk-hint { font-size: 0.7rem; color: var(--text-muted); }
.cmdk-empty { padding: 1.2rem; text-align: center; font-size: 0.8rem; color: var(--text-muted); }

/* ---------- console command autocomplete ---------- */
.autocomplete-dropdown {
  position: absolute;
  bottom: 100%;
  left: 1.35rem; right: 1.35rem;
  margin-bottom: 6px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 -12px 28px -10px rgba(var(--shadow-color), 0.6);
  z-index: 15;
}
.autocomplete-item {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.5rem 0.8rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.autocomplete-item.selected { background: var(--surface-hover); }
.autocomplete-hint { color: var(--text-muted); font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- restart countdown ---------- */
.conn-pill.countdown {
  color: var(--copper);
  border-color: var(--copper-dim);
  background: rgba(143, 124, 245, 0.12);
  animation: pillIn 0.2s ease;
}

@media (max-width: 900px) {
  .mobile-nav-toggle { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16,1,0.3,1);
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.open { display: block; }
  .main-content { padding: 4.5rem 1.1rem 2.5rem; }
  .config-grid { grid-template-columns: 1fr; }
}
