/* Shared by index.html (dashboard) and login.html. Always dark: the background image is a night-sky scene */
:root {
  color-scheme: dark;
  --bg: #05070d;
  --surface: rgba(12, 16, 26, .55);
  --surface-hover: rgba(16, 24, 40, .72);
  --border: rgba(255, 255, 255, .12);
  --text: #eef3ff;
  --muted: rgba(214, 226, 255, .72);
  --accent: #4cc3ff;
  --accent-2: #7ef0d8;
  --accent-soft: rgba(76, 195, 255, .16);
  --danger: #ff7a8a;
  --shadow: 0 8px 32px rgba(0, 0, 0, .35);
  /* Pointer position in [-1, 1], eased in fx.js; drives the parallax layers */
  --px: 0;
  --py: 0;
}
* { box-sizing: border-box; }
/* The hidden attribute always wins over display rules like .login-card form { display: grid } */
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 72px 16px 32px;
  overflow-x: hidden;
}

/* ---------- Background: parallax image + slow drift + shade ---------- */
.scene { position: fixed; inset: 0; z-index: -3; overflow: hidden; pointer-events: none; }
.bg {
  position: absolute; inset: -6%;
  transform: translate3d(calc(var(--px) * -22px), calc(var(--py) * -16px), 0);
}
.bg::before {
  content: "";
  position: absolute; inset: 0;
  background: url(/img/ludens.webp) 62% center / cover no-repeat;
  animation: drift 38s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: scale(1.04) translate3d(-1%, 0, 0); }
  to   { transform: scale(1.12) translate3d(1.5%, -1.5%, 0); }
}
.shade {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 30%, transparent 0%, rgba(5, 7, 13, .35) 70%),
    linear-gradient(180deg, rgba(5, 7, 13, .3) 0%, rgba(5, 7, 13, .5) 55%, rgba(5, 7, 13, .88) 100%);
}
#sky { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }
/* Soft light that follows the cursor (pointer devices only) */
.spot {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(420px circle at var(--sx, 50%) var(--sy, 30%), rgba(76, 195, 255, .10), transparent 70%);
  opacity: 0; transition: opacity .6s ease;
}
.has-pointer .spot { opacity: 1; }

/* ---------- Header ---------- */
body > header { text-align: center; margin-bottom: 40px; text-shadow: 0 2px 16px rgba(0, 0, 0, .6); }
.avatar {
  position: relative;
  width: 80px; height: 80px;
  margin: 0 auto 18px;
  animation: float 6s ease-in-out infinite;
}
/* Rotating glow ring around the profile photo */
.avatar::before {
  content: "";
  position: absolute; inset: -4px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), transparent 30%, var(--accent-2) 55%, transparent 80%, var(--accent));
  filter: drop-shadow(0 0 10px rgba(76, 195, 255, .7));
  animation: spin 6s linear infinite;
}
.logo {
  position: relative;
  display: block;
  width: 80px; height: 80px; border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg);
  background: var(--bg);
}
@keyframes spin { to { transform: rotate(1turn); } }
@keyframes float { 50% { transform: translateY(-6px); } }
h1 {
  margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -0.02em;
  background: linear-gradient(100deg, #fff 0%, #fff 40%, var(--accent) 50%, #fff 60%, #fff 100%) 0 0 / 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: shimmer 7s ease-in-out infinite;
  filter: drop-shadow(0 2px 14px rgba(0, 0, 0, .6));
}
@keyframes shimmer { 0%, 35% { background-position: 100% 0; } 65%, 100% { background-position: 0% 0; } }
.tagline { margin: 6px 0 0; color: var(--muted); }
.badge {
  display: inline-block; margin-top: 12px;
  padding: 2px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600;
  box-shadow: 0 0 0 1px rgba(76, 195, 255, .35), 0 0 18px rgba(76, 195, 255, .25);
}
.badge[hidden] { display: none; }

/* Entrance: everything rises in, staggered by --i */
.rise { animation: rise .8s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 90ms + 80ms); }
@keyframes rise { from { opacity: 0; translate: 0 18px; filter: blur(4px); } to { opacity: 1; translate: 0 0; filter: none; } }

/* ---------- Tiles ---------- */
/* Each tile sets --tile-accent (from links.json); the glow, border and caption use it */
@property --spin { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
main.tiles {
  width: 100%; max-width: 820px;
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  perspective: 900px;
}
a.tile {
  --tile-accent: var(--accent);
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 240px;
  padding: 24px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
  transform-style: preserve-3d;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), border-color .25s ease, box-shadow .3s ease;
}
/* Glowing light that races around the border on hover */
a.tile::before {
  content: "";
  position: absolute; inset: 0; z-index: 3; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--spin), transparent 0deg 200deg, var(--tile-accent) 300deg, #fff 345deg, transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0; transition: opacity .3s ease;
  animation: border-spin 2.6s linear infinite;
}
@keyframes border-spin { to { --spin: 360deg; } }
/* Glare that follows the cursor across the tile */
a.tile::after {
  content: "";
  position: absolute; inset: 0; z-index: 2; border-radius: inherit; pointer-events: none;
  background: radial-gradient(280px circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .16), transparent 60%);
  opacity: 0; transition: opacity .25s ease;
}
a.tile:hover, a.tile:focus-visible {
  border-color: transparent;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .5), 0 0 40px color-mix(in srgb, var(--tile-accent) 38%, transparent);
  outline: none;
}
a.tile:hover::before, a.tile:focus-visible::before,
a.tile:hover::after, a.tile:focus-visible::after { opacity: 1; }
a.tile:focus-visible { transform: translateY(-4px); }
a.tile:active { transform: scale(.98) !important; }

/* Title block, pinned to the bottom of the tile */
.tile-body { position: relative; z-index: 1; }
.tile h2 {
  margin: 0;
  display: flex; align-items: center; gap: 10px;
  font-size: 32px; font-weight: 800; line-height: 1.05; letter-spacing: -0.03em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .75);
  transition: letter-spacing .4s cubic-bezier(.2, .8, .2, 1);
}
a.tile:hover h2, a.tile:focus-visible h2 { letter-spacing: -0.01em; }
.go {
  font-size: 24px; font-weight: 700; color: var(--tile-accent);
  opacity: 0; translate: -12px 0;
  transition: opacity .25s ease, translate .35s cubic-bezier(.3, 1.6, .5, 1);
}
a.tile:hover .go, a.tile:focus-visible .go { opacity: 1; translate: 0 0; }
.tile p {
  margin: 8px 0 0;
  font-size: 12px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--tile-accent);
  text-shadow: 0 1px 10px rgba(0, 0, 0, .85);
}
/* Accent bar that stretches on hover */
.tile-body::after {
  content: ""; display: block;
  width: 36px; height: 3px; margin-top: 14px; border-radius: 3px;
  background: var(--tile-accent);
  box-shadow: 0 0 14px var(--tile-accent);
  transition: width .45s cubic-bezier(.2, .8, .2, 1);
}
a.tile:hover .tile-body::after, a.tile:focus-visible .tile-body::after { width: 96px; }

/* One light sweep across the tile each time it's hovered */
.sweep { position: absolute; inset: 0; z-index: 2; overflow: hidden; border-radius: inherit; pointer-events: none; }
.sweep::before {
  content: ""; position: absolute; top: -20%; bottom: -20%; left: -70%; width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .22), transparent);
  transform: skewX(-14deg);
}
a.tile:hover .sweep::before { animation: tile-sweep .9s cubic-bezier(.3, .6, .3, 1); }
@keyframes tile-sweep { to { left: 140%; } }

/* Rotating background art (media backdrops, MTG deck art) behind a dark fade */
.art {
  position: absolute; inset: 0; z-index: 0; overflow: hidden; border-radius: inherit; pointer-events: none;
  transition: transform .9s cubic-bezier(.2, .8, .2, 1);
}
a.tile:hover .art, a.tile:focus-visible .art { transform: scale(1.06); }
.art img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 30%;
  opacity: 0; scale: 1.04;
  transition: opacity 1.4s ease;
}
.art img.on { opacity: .78; animation: kenburns 12s ease-out forwards; }
a.tile:hover .art img.on, a.tile:focus-visible .art img.on { opacity: .95; }
@keyframes kenburns { from { scale: 1.04; } to { scale: 1.16; } }
.art::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--tile-accent) 26%, transparent), transparent 55%),
    linear-gradient(180deg, rgba(8, 11, 20, .05) 0%, rgba(8, 11, 20, .35) 45%, rgba(8, 11, 20, .9) 100%);
}

/* Illustrated scene (an animated SVG) over the aurora, for tiles without photo art */
.scene-art {
  position: absolute; inset: 0; z-index: 0; overflow: hidden; border-radius: inherit; pointer-events: none;
  transition: transform .9s cubic-bezier(.2, .8, .2, 1);
}
.scene-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-art::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--tile-accent) 18%, transparent), transparent 50%),
    linear-gradient(90deg, rgba(8, 11, 20, .55) 0%, transparent 55%),
    linear-gradient(180deg, transparent 55%, rgba(8, 11, 20, .75) 100%);
}
a.tile:hover .scene-art, a.tile:focus-visible .scene-art { transform: scale(1.05); }

/* Drifting aurora for tiles without art */
.aurora {
  position: absolute; inset: -35%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(circle at 30% 35%, var(--tile-accent), transparent 42%),
    radial-gradient(circle at 72% 58%, #4cc3ff, transparent 38%),
    radial-gradient(circle at 48% 88%, #8a6cff, transparent 42%);
  filter: blur(42px); opacity: .5;
  animation: aurora 14s ease-in-out infinite alternate;
}
.aurora::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(8, 11, 20, .7)); }
a.tile:hover .aurora { opacity: .75; }
@keyframes aurora {
  from { transform: rotate(0deg) scale(1); }
  to   { transform: rotate(28deg) scale(1.18) translate(4%, -3%); }
}
/* A tile with a Request button over it (links.json "request"): the wrapper tilts, the tile fills it */
.tile-wrap {
  position: relative; z-index: 1; display: grid; /* keeps the flag above neighboring tiles */
  transform-style: preserve-3d;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
/* The Request button is a banner flag (SVG from LudensFX.flag) whose pole stands just above the
   Media tile's status light and rises past the card's top. The cloth is hoisted once the tiles appear. */
.tile-request {
  position: absolute; z-index: 5;
  /* The SVG's pole is 8px from its right edge: center it on the status light (right: 16px, 11px wide),
     with its foot just above the light (top: 16px) */
  right: 13.5px; top: -76px; width: 168px; height: 88px;
  padding: 0; border: 0; background: none; cursor: pointer;
}
.flag-svg { display: block; overflow: visible; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .45)); transition: filter .25s ease; }
.flag-label { font-size: 16px; font-weight: 800; letter-spacing: .03em; fill: #fff; paint-order: stroke; stroke: rgba(4, 40, 34, .35); stroke-width: 2px; }
.flag-cloth {
  transform-box: fill-box; transform-origin: right top;
  animation: flag-hoist 1s cubic-bezier(.2, .8, .2, 1) 1s both;
}
/* Only the cloth and the pole are clickable, not the empty corners of the SVG */
.tile-request .flag-svg { pointer-events: none; }
.tile-request .flag-cloth, .tile-request .flag-pole { pointer-events: visiblePainted; }
.tile-request:hover .flag-svg { filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .5)) drop-shadow(0 0 14px rgba(47, 185, 161, .6)) brightness(1.08); }
.tile-request:active .flag-cloth { scale: .97; }
.tile-request:focus-visible { outline: none; }
.tile-request:focus-visible .flag-svg { filter: drop-shadow(0 0 0 #fff) drop-shadow(0 0 3px #fff) drop-shadow(0 0 10px rgba(47, 185, 161, .9)); }
/* Runs up the pole from low down, unfurling as it goes */
@keyframes flag-hoist {
  from { translate: 0 40px; scale: .15 1; opacity: 0; }
  35% { opacity: 1; }
  to { translate: 0 0; scale: 1 1; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .flag-cloth { animation: none; } }
/* Room above the tiles for the flag, so its spear tip doesn't run into the header */
main.tiles:has(.tile-request) { margin-top: 48px; }
@media (max-width: 520px) {
  a.tile { min-height: 200px; }
  .tile h2 { font-size: 28px; }
}
footer { margin-top: auto; padding-top: 48px; font-size: 13px; color: var(--muted); text-align: center; }
footer a, .link-button { color: var(--muted); }
.link-button { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.link-button:hover, footer a:hover { color: var(--text); }
footer form { display: inline; }
.error { grid-column: 1 / -1; text-align: center; color: var(--muted); }

/* ---------- Sign-in page ---------- */
body:has(.login-card) { padding-top: 24px; padding-bottom: 24px; justify-content: center; }
.login-card {
  width: 100%; max-width: 380px;
  margin: auto 0;
  padding: 32px 28px 24px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow), 0 0 60px rgba(76, 195, 255, .08);
  text-align: center;
}
.login-card h1 { font-size: 26px; }
.login-card form { display: grid; gap: 14px; margin-top: 24px; text-align: left; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input-wrap { position: relative; }
.field input {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px; /* 16px stops phones from zooming in on focus */
  line-height: 1.3;
  color: var(--text);
  background: rgba(5, 8, 15, .55);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.field input:focus {
  border-color: var(--accent);
  background: rgba(8, 14, 26, .7);
  box-shadow: 0 0 0 3px rgba(76, 195, 255, .18), 0 0 18px rgba(76, 195, 255, .2);
}
.input-wrap input { padding-right: 48px; }
.reveal {
  position: absolute; right: 6px; top: 50%; translate: 0 -50%;
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  display: grid; place-items: center;
  background: none; color: var(--muted); cursor: pointer;
}
.reveal:hover, .reveal:focus-visible { color: var(--accent); background: var(--accent-soft); outline: none; }
.reveal svg { width: 20px; height: 20px; }
.form-error { margin: -2px 0 0; color: var(--danger); font-size: 14px; text-align: center; }
.form-error[hidden] { display: none; }
.btn {
  position: relative; overflow: hidden;
  margin-top: 6px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.3;
  color: #04121c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 0; border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(76, 195, 255, .35);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.btn:hover { box-shadow: 0 8px 30px rgba(76, 195, 255, .5); filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
/* Light sweep across the button */
.btn::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .45) 50%, transparent 70%);
  translate: -100% 0;
  animation: sweep 3.5s ease-in-out infinite 1.2s;
}
@keyframes sweep { 0%, 60% { translate: -100% 0; } 100% { translate: 100% 0; } }
.btn[disabled] { cursor: progress; filter: saturate(.7) brightness(.9); }
.btn .spinner {
  display: none; width: 18px; height: 18px; margin: -3px 8px -3px 0; vertical-align: middle;
  border: 2px solid rgba(4, 18, 28, .35); border-top-color: #04121c; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn[disabled] .spinner { display: inline-block; }
.back { display: inline-block; margin-top: 18px; font-size: 13px; color: var(--muted); }
.back:hover { color: var(--text); }
.shake { animation: shake .45s cubic-bezier(.36, .07, .19, .97) both !important; }
@keyframes shake {
  10%, 90% { translate: -2px 0; }
  20%, 80% { translate: 4px 0; }
  30%, 50%, 70% { translate: -8px 0; }
  40%, 60% { translate: 8px 0; }
}
.welcome { animation: welcome .55s cubic-bezier(.4, 0, .2, 1) forwards !important; }
@keyframes welcome { to { opacity: 0; scale: 1.06; filter: blur(6px); } }

/* ---------- Status lights on tiles ---------- */
.status {
  position: absolute; top: 16px; right: 16px; z-index: 4;
  width: 11px; height: 11px; border-radius: 50%;
  background: #6b7a90; box-shadow: 0 0 0 3px rgba(8, 11, 20, .55);
}
.status[data-state="up"] { background: #3ee08f; box-shadow: 0 0 0 3px rgba(8, 11, 20, .55), 0 0 12px #3ee08f; }
.status[data-state="degraded"] { background: #ffb347; box-shadow: 0 0 0 3px rgba(8, 11, 20, .55), 0 0 12px #ffb347; }
.status[data-state="down"] { background: #ff5d73; box-shadow: 0 0 0 3px rgba(8, 11, 20, .55), 0 0 12px #ff5d73; }
.status[data-state="up"]::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: #3ee08f; animation: ping 2.4s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping { 70%, 100% { transform: scale(2.6); opacity: 0; } }

/* ---------- Small buttons, pills, tags ---------- */
.btn-sm {
  padding: 6px 12px; border-radius: 9px;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text); background: rgba(255, 255, 255, .06);
  border: 1px solid var(--border); cursor: pointer;
  transition: background .2s ease, border-color .2s ease;
}
.btn-sm:hover { background: rgba(255, 255, 255, .12); }
.btn-sm.ok { border-color: rgba(62, 224, 143, .5); color: #8ff5c0; }
.btn-sm[disabled] { opacity: .5; cursor: progress; }
.btn-ghost {
  padding: 12px 16px; border-radius: 12px;
  font: inherit; font-weight: 600; color: var(--muted);
  background: none; border: 1px solid var(--border); cursor: pointer;
}
.btn-ghost:hover { color: var(--text); }
.pill {
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(255, 255, 255, .06); color: var(--muted);
}
.pill:empty { display: none; }
.pill[data-state="up"] { background: rgba(62, 224, 143, .15); color: #8ff5c0; }
.pill[data-state="degraded"] { background: rgba(255, 179, 71, .15); color: #ffcf8a; }
.pill[data-state="down"] { background: rgba(255, 93, 115, .15); color: #ff9aa8; }
.tag {
  display: inline-block; padding: 0 7px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent);
}
.tag[data-status="pending"] { background: rgba(255, 179, 71, .15); color: #ffcf8a; }
.tag[data-status="joined"] { background: rgba(62, 224, 143, .15); color: #8ff5c0; }
.tag[data-status="denied"] { background: rgba(255, 93, 115, .12); color: #ff9aa8; }
.tag[data-dl="downloading"], .tag[data-dl="importing"] { background: rgba(62, 224, 143, .15); color: #8ff5c0; }
.tag[data-dl="paused"] { background: rgba(255, 179, 71, .15); color: #ffcf8a; }
.tag[data-dl="stuck"] { background: rgba(255, 93, 115, .12); color: #ff9aa8; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 12px; }
code { font-size: 12px; padding: 1px 5px; border-radius: 5px; background: rgba(255, 255, 255, .08); }

/* ---------- Admin panel ---------- */
.admin-panel {
  width: 100%; max-width: 820px; margin-top: 28px;
  display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.admin-panel[hidden] { display: none; }
.panel-card {
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
#health-card, #downloads-card { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.head-right { display: flex; align-items: center; gap: 8px; }
.head-right .btn-sm { padding: 4px 10px; font-size: 12px; }
.pause-mark { font-size: 24px; background: linear-gradient(135deg, #ffb347, #ffd27a); box-shadow: 0 0 30px rgba(255, 179, 71, .4); }
/* Request storage unavailable: show the saved copy read-only */
.panel-body.offline .req-actions { display: none; }
.offline-note {
  margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 13px;
  color: #ffcf8a; background: rgba(255, 179, 71, .1); border: 1px solid rgba(255, 179, 71, .25);
}
.panel-body { padding: 16px 20px 20px; display: grid; gap: 12px; }
.stat-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .04); }
.stat-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat-value { display: block; margin-top: 2px; font-size: 17px; font-weight: 700; }
.svc-row { display: flex; flex-wrap: wrap; gap: 8px; }
.svc { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .05); }
.svc::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #ff5d73; }
.svc[data-state="up"]::before { background: #3ee08f; box-shadow: 0 0 8px #3ee08f; }
.meter-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.meter-top span:first-child { color: var(--text); font-weight: 600; }
.bar { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .8s ease; }
.bar span.warn { background: linear-gradient(90deg, #ffb347, #ffd27a); }
.bar span.bad { background: linear-gradient(90deg, #ff5d73, #ff8a9a); }
.req-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
/* Each request stacks top to bottom so it fits narrow cards: title + status, details, note, invite, buttons */
.req { display: grid; gap: 6px; padding: 14px; border-radius: 12px; background: rgba(255, 255, 255, .04); min-width: 0; }
.req-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.req-title { min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.req-top .tag { flex: none; margin-top: 2px; }
.req-user { color: var(--muted); font-weight: 500; }
.req-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.req-note {
  font-size: 13px; color: var(--text); opacity: .9; white-space: pre-wrap; overflow-wrap: anywhere;
  padding-left: 10px; border-left: 2px solid var(--border);
}
.req-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.req-actions:empty { display: none; }
.req-media { grid-template-columns: 40px 1fr; align-items: start; gap: 12px; }
.req-media > div { display: grid; gap: 6px; min-width: 0; }
.req-poster { width: 40px; height: 60px; border-radius: 6px; object-fit: cover; background: rgba(255, 255, 255, .06); }
.invite { display: grid; gap: 6px; margin-top: 2px; }
.invite-box { display: flex; gap: 6px; }
.invite input {
  flex: 1; min-width: 0; padding: 6px 10px;
  font: inherit; font-size: 12px; color: var(--text);
  background: rgba(5, 8, 15, .6); border: 1px solid var(--border); border-radius: 8px;
}
.stat-sub { display: block; font-size: 12px; color: var(--muted); }
.stat-value { white-space: nowrap; }

/* ---------- Dialogs (request forms) ---------- */
dialog.modal {
  width: min(440px, calc(100% - 32px)); max-height: calc(100% - 32px);
  padding: 0; border: 0; background: none; color: var(--text); overflow: visible;
}
dialog.modal::backdrop { background: rgba(3, 5, 10, .65); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog.modal[open] { animation: pop .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop { from { opacity: 0; scale: .96; translate: 0 8px; } }
.modal-card {
  display: grid; gap: 12px;
  padding: 24px; border-radius: 20px;
  background: rgba(12, 16, 26, .92); border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 60px rgba(76, 195, 255, .08);
  max-height: calc(100vh - 48px); overflow-y: auto;
}
.modal-card h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.modal-sub { margin: -4px 0 4px; color: var(--muted); font-size: 14px; }
.modal-card textarea {
  width: 100%; padding: 12px 14px; resize: vertical;
  font-family: inherit; font-size: 16px; line-height: 1.4; color: var(--text);
  background: rgba(5, 8, 15, .55); border: 1px solid var(--border); border-radius: 12px; outline: none;
}
.modal-card textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(76, 195, 255, .18); }
.optional { font-weight: 500; opacity: .7; }
.field-row { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
@media (max-width: 420px) { .field-row { grid-template-columns: 1fr; } }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.modal-actions .btn { margin-top: 0; }
/* Title search results in the movie/show request form */
.results { list-style: none; margin: -4px 0 0; padding: 0; display: grid; gap: 4px; max-height: min(320px, 45vh); overflow-y: auto; }
.results:empty { display: none; }
.results [role=option] {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.results [role=option]:hover, .results [role=option]:focus-visible { background: rgba(255, 255, 255, .06); outline: none; }
.results [aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); }
.results [aria-disabled="true"] { cursor: default; opacity: .6; }
.results [aria-disabled="true"]:hover { background: none; }
.results img, .results .no-poster { width: 36px; height: 54px; border-radius: 6px; object-fit: cover; background: rgba(255, 255, 255, .06); }
.result-text { display: grid; min-width: 0; }
.result-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-meta { font-size: 13px; color: var(--muted); }
.result-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: rgba(62, 224, 143, .15); color: #8ff5c0; white-space: nowrap; }
.result-badge[data-status="requested"] { background: rgba(255, 179, 71, .15); color: #ffcf8a; }
.results-note { padding: 8px; font-size: 14px; color: var(--muted); text-align: center; }
@media (max-width: 420px) { .result-badge { font-size: 10px; padding: 2px 6px; } }
/* Bot trap: invisible to people, tempting to form-filling bots */
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.modal-done { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 8px 0; }
.done-mark {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  font-size: 28px; font-weight: 800; color: #04121c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 30px rgba(76, 195, 255, .5);
  animation: pop .4s cubic-bezier(.3, 1.6, .5, 1);
}

/* ---------- Quick links drawer ---------- */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(3, 5, 10, .5); opacity: 0; pointer-events: none; transition: opacity .3s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 21;
  width: min(340px, 88vw); padding: 20px;
  background: rgba(10, 14, 24, .94); border-left: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: -20px 0 60px rgba(0, 0, 0, .5);
  translate: 100% 0; transition: translate .35s cubic-bezier(.2, .8, .2, 1);
  overflow-y: auto; visibility: hidden;
}
.drawer-open .scrim { opacity: 1; pointer-events: auto; }
.drawer-open .drawer { translate: 0 0; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.drawer h3 { margin: 18px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.drawer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.drawer a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none;
  background: rgba(255, 255, 255, .03); transition: background .2s ease;
}
.drawer a:hover, .drawer a:focus-visible { background: var(--accent-soft); outline: none; }
.drawer a span { color: var(--muted); }

/* ---------- Join page ---------- */
.join-steps { margin: 4px 0 16px; padding-left: 20px; text-align: left; display: grid; gap: 8px; font-size: 14px; }
.join-steps a { color: var(--accent); }
.btn-link { display: block; text-align: center; text-decoration: none; }
#done { margin-top: 18px; }

/* ---------- Toast (easter egg) ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 30;
  translate: -50% 20px; opacity: 0;
  padding: 12px 20px; border-radius: 999px;
  font-weight: 700; letter-spacing: .02em; color: #04121c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 40px rgba(76, 195, 255, .45);
  transition: opacity .4s ease, translate .4s cubic-bezier(.3, 1.6, .5, 1);
  pointer-events: none;
}
.toast.show { opacity: 1; translate: -50% 0; }
.avatar.celebrate { animation: celebrate 1.4s cubic-bezier(.3, 1.4, .5, 1); }
.avatar.celebrate::before { animation-duration: .6s; }
@keyframes celebrate { 40% { transform: scale(1.25) rotate(-8deg); } 70% { transform: scale(.95) rotate(4deg); } }

/* ---------- Time of day (Eastern time; data-tod on <html>, set by fx.js) ---------- */
.shade::after { content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity 3s ease; }
[data-tod="dawn"] .shade::after { opacity: 1; background: linear-gradient(180deg, rgba(255, 130, 175, .2), rgba(140, 100, 220, .12) 45%, transparent 75%); }
[data-tod="day"] .shade::after { opacity: 1; background: linear-gradient(180deg, rgba(110, 185, 255, .3), rgba(150, 210, 255, .1) 50%, transparent 80%); }
[data-tod="dusk"] .shade::after { opacity: 1; background: linear-gradient(180deg, rgba(150, 90, 230, .26), rgba(255, 110, 150, .12) 45%, transparent 75%); }
[data-tod="late"] .shade::after { opacity: 1; background: rgba(2, 3, 8, .25); }
/* Home scene: lights off in the daytime, just a night-light late at night, a faint daytime moon */
[data-tod="day"] .scene-art .w,
[data-tod="day"] .scene-art .wg,
[data-tod="late"] .scene-art .w:not(.keep),
[data-tod="late"] .scene-art .wg:not(.keep) { animation: none; opacity: .08; }
[data-tod="day"] .scene-art .star { opacity: 0; animation: none; }
[data-tod="day"] .scene-art .moon { opacity: .3; }
[data-tod="day"] .scene-art .aurora { opacity: .75; filter: blur(42px) saturate(.8) brightness(1.3); }
[data-tod="late"] .scene-art .door { animation: none; opacity: .35; }

/* Respect "reduce motion": keep the look, drop the movement */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .bg { transform: none; }
  .spot { display: none; }
}
