:root {
  color-scheme: dark;
  --bg: #03050a;
  --panel: rgba(10, 16, 28, 0.72);
  --border: rgba(61, 240, 255, 0.16);
  --text: #f4fbff;
  --muted: #7d93a8;
  --cyan: #3df0ff;
  --magenta: #ff4de3;
  --ok: #34d399;
  --down: #f43f5e;
  --accent: var(--cyan);
}

* { box-sizing: border-box; }
html { overflow-x: clip; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: clip;
  font-family: "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 90% 55% at 50% -18%, rgba(61, 240, 255, 0.16), transparent 55%),
    radial-gradient(ellipse 50% 40% at 110% 10%, rgba(255, 77, 227, 0.10), transparent 50%),
    radial-gradient(ellipse 40% 30% at -10% 90%, rgba(61, 240, 255, 0.06), transparent 50%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(61, 240, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(61, 240, 255, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 20%, transparent 75%);
  opacity: 0.5;
}

.hidden { display: none !important; }

.login-page,
.hub-page {
  position: relative;
  z-index: 1;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: block;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(61, 240, 255, 0.25), 0 12px 40px rgba(61, 240, 255, 0.18);
}

.wordmark {
  margin: 0;
  font-size: clamp(1.45rem, 4.2vw, 2.7rem);
  font-weight: 800;
  letter-spacing: -0.07em;
  line-height: 0.92;
  text-transform: lowercase;
  white-space: nowrap;
}
.wordmark span { color: var(--cyan); }

.login-card {
  width: min(440px, 100%);
  margin: 8vh auto 0;
  padding: 32px 26px 26px;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(14, 22, 38, 0.88), rgba(7, 11, 18, 0.92));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(61, 240, 255, 0.12);
  backdrop-filter: blur(18px);
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .brand-mark { margin: 0 auto 16px; width: 72px; height: 72px; border-radius: 22px; }
.login-brand .sub {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.login-form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; font-size: 0.82rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #070b14;
  color: var(--text);
  font-size: 16px;
}
.field input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--cyan) 55%, var(--border));
  box-shadow: 0 0 0 3px rgba(61, 240, 255, 0.12);
}

.login-error { margin: 0; color: #fb7185; font-size: 0.9rem; }
.login-foot { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }

.login-split {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.login-split::before,
.login-split::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.btn.primary {
  background: linear-gradient(135deg, #3df0ff, #2563eb);
  color: #041018;
  box-shadow: 0 8px 28px rgba(61, 240, 255, 0.22);
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.passkey {
  background: rgba(61, 240, 255, 0.08);
  color: var(--cyan);
  border: 1px solid rgba(61, 240, 255, 0.28);
}
.btn.block { width: 100%; }
.btn-sm {
  padding: 7px 11px;
  font-size: 0.78rem;
  border-radius: 11px;
  min-height: 34px;
}
.btn:disabled { opacity: 0.55; cursor: wait; }

.hub-shell {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}

.hub-top {
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.hub-brand-text { min-width: 0; }
.hub-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.hub-top-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.hub-weather {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  cursor: default;
  user-select: none;
}
.hub-weather-icon { font-size: 1.1rem; line-height: 1; }
.hub-weather-temp { font-size: 0.95rem; font-weight: 700; }
.hub-weather.is-loading .hub-weather-icon {
  opacity: 0.45;
  animation: pulse 1.2s ease-in-out infinite;
}
.hub-weather.is-error { cursor: pointer; }
@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.hub-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hub-user {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: 14px;
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: linear-gradient(165deg, rgba(16, 24, 40, 0.92), rgba(8, 12, 20, 0.88));
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  min-height: 88px;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  box-shadow: inset 3px 0 0 var(--accent);
}
.tile::after {
  content: "";
  position: absolute;
  inset: auto -20%  -40% auto;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 28%, transparent), transparent 70%);
  pointer-events: none;
}
.tile:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  box-shadow: inset 3px 0 0 var(--accent), 0 16px 40px rgba(0, 0, 0, 0.35);
}
.tile-icon { font-size: 1.65rem; line-height: 1; z-index: 1; }
.tile-body { display: grid; gap: 4px; flex: 1; min-width: 0; z-index: 1; }
.tile-title { font-weight: 800; letter-spacing: -0.03em; font-size: 1.08rem; }
.tile-desc { color: var(--muted); font-size: 0.86rem; }
.tile-arrow { color: var(--muted); font-size: 1.15rem; z-index: 1; }

.tile-plex {
  width: 100%;
  cursor: pointer;
  font: inherit;
  text-align: left;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.status-dot {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 52px;
  height: 22px;
  padding: 0 8px 0 7px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.22);
}
.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}
.status-dot.up {
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(6, 78, 59, 0.55);
}
.status-dot.up::before {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.95);
  animation: status-pulse 1.8s ease-in-out infinite;
}
.status-dot.down {
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.5);
  background: rgba(76, 5, 25, 0.55);
}
.status-dot.down::before {
  background: var(--down);
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.85);
}
@keyframes status-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.86); }
}

.tile, .btn, .field input { min-height: 44px; }
.btn-sm { min-height: 34px; }

.account-btn {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.8rem;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
}
.account-btn[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--cyan) 45%, var(--border));
  color: var(--cyan);
}
.account-menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(3, 5, 10, 0.55);
}
.account-menu-scrim.hidden,
.account-menu.hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
.account-menu {
  position: fixed;
  z-index: 230;
  top: 0;
  right: 0;
  left: auto;
  width: min(280px, calc(100vw - 1.25rem));
  max-height: min(70dvh, 480px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #0c1220;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  padding: 0.65rem 0.55rem 0.7rem;
}
.account-menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.35rem 0.55rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.35rem;
}
.account-menu-label {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.account-menu-user {
  margin: 0.15rem 0 0;
  font-size: 0.95rem;
  font-weight: 700;
}
.account-menu-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  cursor: pointer;
}
.account-menu-section {
  margin: 0.55rem 0.35rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.account-menu-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.account-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 0.55rem;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
.account-menu-item:hover,
.account-menu-item:focus-visible {
  background: rgba(61, 240, 255, 0.08);
  outline: none;
}
.account-menu-item--danger { color: #f87171; }
body.account-menu-open { overflow: hidden; }

@media (max-width: 640px) {
  .hub-grid { grid-template-columns: 1fr; }
  .wordmark { font-size: 1.55rem; }
  .brand-mark { width: 44px; height: 44px; border-radius: 14px; }
  .hub-sub { display: none; }
  .login-card { margin-top: 5vh; }
  .account-btn { font-size: 0.75rem; padding: 8px 12px; }
}

.pwa-standalone .hub-page {
  padding-bottom: max(22px, env(safe-area-inset-bottom));
}

/* —— Page /join —— */
.join-app-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 2px 0 16px;
}
.join-pill {
  font-size: 0.78rem;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(61, 240, 255, 0.22);
  background: rgba(61, 240, 255, 0.08);
  color: var(--cyan);
  letter-spacing: 0.04em;
}
.join-ok {
  margin: 0 0 14px;
  color: var(--ok);
  font-size: 0.95rem;
  text-align: center;
}
.join-app-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
a.join-app-btn,
a#join-go-hub {
  display: block;
  text-align: center;
  text-decoration: none;
}
#join-go-hub {
  margin-top: 4px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.join-qr {
  display: flex;
  justify-content: center;
  margin: 4px auto 14px;
  padding: 14px;
  width: fit-content;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.join-qr svg {
  width: 176px;
  height: 176px;
}
.join-blocked-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.4;
}
