:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ee;
  --accent: #1769e0;
  --accent-dark: #0d4fb3;
  --good: #116149;
  --warn: #8a4b00;
  --iti-path-flags-1x: url('/assets/intl-tel-input/flags.webp');
  --iti-path-flags-2x: url('/assets/intl-tel-input/flags@2x.webp');
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 48px);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--ink); font-weight: 800; }
.topbar nav { display: flex; gap: 16px; flex-wrap: wrap; }
.page { width: min(1100px, calc(100% - 32px)); margin: 28px auto 56px; }
.stack { display: grid; gap: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}
.hero {
  display: grid;
  gap: 12px;
  padding: clamp(24px, 6vw, 52px) 0 20px;
}
h1, h2, h3 { line-height: 1.15; margin: 0 0 10px; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #b8c7dc;
  border-radius: 8px;
  padding: 12px;
  font: inherit;
  background: #fff;
}
.iti { width: 100%; }
textarea { min-height: 96px; resize: vertical; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--accent-dark); text-decoration: none; }
.button.secondary { background: #e9eff7; color: var(--ink); }
.notice {
  border-left: 4px solid var(--accent);
  background: #eef5ff;
  padding: 12px 14px;
  border-radius: 8px;
}
.error {
  border-left: 4px solid #c32929;
  background: #fff1f1;
  padding: 12px 14px;
  border-radius: 8px;
}
.ok {
  border-left: 4px solid var(--good);
  background: #edf9f4;
  padding: 12px 14px;
  border-radius: 8px;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.relation-list { display: grid; gap: 8px; padding: 0; list-style: none; }
.relation-list li { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdff; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .table { display: block; overflow-x: auto; }
}

.cosmic-family {
  position: relative;
  width: min(1500px, calc(100vw - 24px));
  height: clamp(560px, 76vh, 840px);
  margin: -12px 50% 0;
  transform: translateX(-50%);
  overflow: hidden;
  border: 1px solid rgba(122, 169, 255, .18);
  border-radius: 22px;
  background: #000106;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .58), inset 0 0 70px rgba(70, 80, 105, .05);
  color: #eef6ff;
}
#familyCosmos { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#familyCosmos:active { cursor: grabbing; }
.cosmic-vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 130px 40px rgba(0, 0, 0, .68); }
.cosmic-heading { position: absolute; left: clamp(18px, 4vw, 54px); top: clamp(18px, 5vw, 58px); max-width: min(420px, 70%); pointer-events: none; text-shadow: 0 3px 20px #000; }
.cosmic-heading h1 { margin: 3px 0 4px; font-size: clamp(1.8rem, 4vw, 3.6rem); letter-spacing: -.04em; }
.cosmic-heading p { color: rgba(202, 218, 255, .72); }
.cosmic-heading .cosmic-path { max-width: 34rem; color: rgba(151, 174, 225, .72); font-size: .82rem; line-height: 1.35; }
.cosmic-heading a { color: #8eeeff; pointer-events: auto; }
.cosmic-kicker { color: rgba(137, 217, 255, .78); font-size: .72rem; letter-spacing: .24em; }
.return-to-me { position: absolute; z-index: 3; top: 28px; left: 50%; transform: translateX(-50%); border: 1px solid rgba(138, 230, 255, .5); border-radius: 999px; padding: 11px 19px; background: rgba(5, 14, 38, .72); color: #dffcff; box-shadow: 0 0 28px rgba(91, 215, 255, .18); backdrop-filter: blur(14px); animation: cosmic-float 4.8s ease-in-out infinite; }
.return-to-me span { width: 7px; height: 7px; border-radius: 50%; background: #78edff; box-shadow: 0 0 12px #78edff; }
.return-to-me:hover { background: rgba(16, 42, 83, .9); }
.view-mode-toggle { position: absolute; z-index: 4; top: 84px; left: 50%; transform: translateX(-50%); border: 1px solid rgba(150,180,255,.36); border-radius: 999px; padding: 8px 13px; background: rgba(5,14,38,.68); color: rgba(225,238,255,.9); box-shadow: 0 0 24px rgba(91,150,255,.12); backdrop-filter: blur(14px); font-size: .78rem; }
.view-mode-toggle span { width: 7px; height: 7px; border-radius: 50%; background: #88aaff; box-shadow: 0 0 10px #88aaff; }
.view-mode-toggle.is-free { border-color: rgba(122,238,255,.62); color: #e6fcff; }
.view-mode-toggle.is-free span { background: #70f0ff; box-shadow: 0 0 13px #70f0ff; }
.view-mode-toggle:hover { background: rgba(16,42,83,.9); }
.cosmic-hint { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); white-space: nowrap; color: rgba(196, 211, 246, .58); font-size: .78rem; pointer-events: none; }
@keyframes cosmic-float { 0%,100% { transform: translate(-50%,0); } 50% { transform: translate(-50%,9px); } }
@media (max-width: 640px) { .cosmic-family { height: 72vh; min-height: 520px; border-radius: 14px; } .return-to-me { top: auto; bottom: 48px; } .cosmic-hint { bottom: 16px; } }
@media (prefers-reduced-motion: reduce) { .return-to-me { animation: none; } }

/* Authenticated constellation landing */
.cosmic-home { background: #000106; }
.cosmic-home .topbar {
  position: fixed;
  z-index: 20;
  inset: 12px 14px auto;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}
.cosmic-home .brand,
.cosmic-home .topbar nav {
  border: 1px solid rgba(138, 196, 255, .23);
  background: rgba(3, 5, 12, .76);
  box-shadow: 0 12px 42px rgba(0, 0, 0, .46), inset 0 0 20px rgba(180, 200, 230, .025);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  pointer-events: auto;
}
.cosmic-home .brand {
  padding: 10px 15px;
  border-radius: 999px;
  color: #eaf7ff;
  text-shadow: 0 0 16px rgba(113, 224, 255, .5);
}
.cosmic-home .topbar nav {
  max-width: min(78vw, 1080px);
  padding: 6px;
  border-radius: 999px;
  gap: 3px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.cosmic-home .topbar nav::-webkit-scrollbar { display: none; }
.cosmic-home .topbar nav a {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 999px;
  color: rgba(224, 239, 255, .82);
  font-size: .82rem;
  transition: color .2s ease, background .2s ease, box-shadow .2s ease;
}
.cosmic-home .topbar nav a:hover {
  color: #fff;
  text-decoration: none;
  background: rgba(83, 147, 255, .2);
  box-shadow: 0 0 18px rgba(73, 205, 255, .12);
}
.cosmic-home .page { width: 100%; margin: 0; }
.cosmic-home .cosmic-family {
  width: 100%;
  height: 100svh;
  min-height: 620px;
  margin: 0;
  transform: none;
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 0 100px rgba(65, 75, 100, .045);
}
.cosmic-home .cosmic-heading { top: clamp(86px, 13vh, 132px); }
.cosmic-more {
  position: absolute;
  z-index: 5;
  right: clamp(16px, 3vw, 42px);
  bottom: clamp(18px, 3vw, 34px);
  display: grid;
  gap: 1px;
  min-width: 82px;
  padding: 10px 15px;
  border: 1px solid rgba(138, 230, 255, .42);
  border-radius: 999px;
  background: rgba(5, 14, 38, .68);
  color: #dffcff;
  box-shadow: 0 0 30px rgba(91, 215, 255, .16);
  backdrop-filter: blur(14px);
  animation: cosmic-more-float 3.8s ease-in-out infinite;
}
.cosmic-more span { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.cosmic-more b { font-size: 1rem; line-height: 1; }
.cosmic-more:hover { background: rgba(16, 42, 83, .9); }
.home-below {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
  scroll-margin-top: 24px;
}
.cosmic-home:has(.home-below) { background: linear-gradient(#000106 0 100svh, var(--bg) 100svh); }
@keyframes cosmic-more-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
@media (max-width: 760px) {
  .cosmic-home .topbar { align-items: stretch; inset: 8px 8px auto; gap: 6px; }
  .cosmic-home .brand { align-self: flex-start; padding: 7px 11px; font-size: .82rem; }
  .cosmic-home .topbar nav { width: 100%; max-width: none; }
  .cosmic-home .cosmic-family { height: 100svh; min-height: 560px; border-radius: 0; }
  .cosmic-home .cosmic-heading { top: 116px; max-width: 76%; }
  .cosmic-home .return-to-me { top: auto; bottom: 58px; }
  .cosmic-home .view-mode-toggle { top: 106px; left: auto; right: 10px; transform: none; }
  .cosmic-home .cosmic-hint { bottom: 24px; }
  .cosmic-more { right: 12px; bottom: 18px; min-width: 64px; padding: 9px 11px; }
  .cosmic-more span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cosmic-more { animation: none; }
}
