:root {
  --bg: #0a0a0b;
  --panel: rgba(18, 18, 20, 0.72);
  --line: rgba(255, 255, 255, 0.09);
  --tx: #ececed;
  --dim: #8b8b91;
  --faint: #5a5a60;
  --ok: #d8d8dc;
  --bad: #e0555a;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--tx);
  font: 14px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

/* ---------- backdrop ---------- */

.bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.2s ease;
  z-index: 1;
}
.bg.ready { opacity: 1; }

.bg-fallback {
  position: fixed;
  inset: -20%;
  z-index: 0;
  background:
    radial-gradient(38% 42% at 22% 28%, rgba(255,255,255,0.20), transparent 62%),
    radial-gradient(34% 38% at 78% 22%, rgba(255,255,255,0.13), transparent 60%),
    radial-gradient(46% 50% at 62% 82%, rgba(255,255,255,0.11), transparent 64%),
    radial-gradient(30% 34% at 12% 84%, rgba(255,255,255,0.09), transparent 60%),
    #08080a;
  filter: blur(28px) saturate(0.5);
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1.04); }
  50%  { transform: translate3d(2%, 1.5%, 0) scale(1.10); }
  100% { transform: translate3d(-1%, 2%, 0) scale(1.06); }
}

.veil {
  position: fixed;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(8,8,10,0.34) 0%, rgba(8,8,10,0.16) 38%, rgba(8,8,10,0.62) 100%),
    radial-gradient(70% 60% at 50% 45%, transparent 0%, rgba(6,6,8,0.42) 100%);
  pointer-events: none;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  opacity: 0.16;
  pointer-events: none;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='0.55'/></svg>");
}

/* ---------- shell ---------- */

.gate {
  position: relative;
  z-index: 4;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.dash {
  position: relative;
  z-index: 4;
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 22px 72px;
}

/* ---------- card ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 24px 60px rgba(0,0,0,0.45);
}

.enter {
  width: min(430px, 100%);
  padding: 30px 28px 24px;
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.mark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.08), 0 0 18px rgba(255,255,255,0.5);
}

.brand {
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: #fff;
}

.lede {
  margin: 18px 0 22px;
  color: var(--dim);
  font-size: 13.5px;
}

.field { display: block; }

.field > span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 7px;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 0.16em;
  color: var(--tx);
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input[type="text"]::placeholder { color: #3d3d43; letter-spacing: 0.16em; }

input[type="text"]:focus {
  border-color: rgba(255,255,255,0.34);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--line);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

button:active { transform: translateY(1px); }

.primary {
  width: 100%;
  margin-top: 14px;
  padding: 12px 16px;
  background: #fff;
  color: #08080a;
  border-color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.primary:hover { background: #e9e9ec; border-color: #e9e9ec; }

.primary[disabled] { opacity: 0.45; cursor: default; }

.ghost {
  padding: 7px 13px;
  background: rgba(255,255,255,0.04);
  color: var(--tx);
}

.ghost:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.2); }

.small { padding: 6px 12px; font-size: 12.5px; color: var(--dim); }

.err {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--bad);
  line-height: 1.45;
}

/* ---------- tool ---------- */

.tool {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.tool summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--dim);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool summary::-webkit-details-marker { display: none; }

.tool summary::before {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}

.tool[open] summary::before { transform: rotate(45deg); }
.tool summary:hover { color: var(--tx); }

.hint {
  margin: 12px 0 8px;
  font-size: 12px;
  color: var(--faint);
}

.cmd {
  margin: 0 0 10px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  color: #b9b9c0;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--line);
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 168px;
  overflow: auto;
}

/* ---------- dashboard ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.wide { grid-column: span 3; }

.card h2 {
  margin: 0 0 10px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

.value {
  margin: 0;
  font-size: 16px;
  color: var(--tx);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  letter-spacing: 0.08em;
  word-break: break-all;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--dim);
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6a6a72;
}

.pill.on { color: #fff; }
.pill.on::before { background: #fff; box-shadow: 0 0 10px rgba(255,255,255,0.7); }
.pill.off::before { background: var(--bad); }

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
}

.feed li {
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13.5px;
  color: var(--tx);
}

.feed li:last-child { border-bottom: 0; }

.feed time {
  display: block;
  font-size: 11px;
  color: var(--faint);
  margin-top: 3px;
}

.dim { color: var(--faint); }

@media (max-width: 760px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wide { grid-column: span 2; }
  .dash { padding: 26px 16px 56px; }
}

@media (max-width: 460px) {
  .grid { grid-template-columns: 1fr; }
  .wide { grid-column: span 1; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-fallback { animation: none; }
  .enter { animation: none; }
}

/* ---------- splash ---------- */

.splash {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: rgba(6, 6, 8, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: opacity 0.9s ease, visibility 0.9s ease;
}

.splash.gone {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-inner {
  text-align: center;
  animation: rise 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.splash h1 {
  margin: 14px 0 0;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  color: #fff;
}

.splash p {
  margin: 10px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
  animation: pulse 2.6s ease-in-out infinite;
}

.dot.big {
  display: inline-block;
  width: 11px;
  height: 11px;
  box-shadow: 0 0 0 6px rgba(255,255,255,0.06), 0 0 26px rgba(255,255,255,0.55);
}

@keyframes pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}

/* dashboard: no video, no motion, flat palette */
body.dash-mode { background: #0a0a0b; }
body.dash-mode .bg,
body.dash-mode .bg-fallback,
body.dash-mode .veil,
body.dash-mode .grain { display: none; }

/* static still behind the video, so something real is visible while it loads */
.still {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  transition: opacity 1.2s ease;
}
.still.gone { opacity: 0; }
