/* Reset, typography, body/app shell layout. */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg-main);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--c-primary); }
ul { margin: 0; padding: 0; list-style: none; }

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: var(--weight-heading);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-2xs);
}
p { margin: 0 0 var(--space-sm); line-height: 1.6; color: var(--text-secondary); }

.hide { display: none !important; }

/* ---------- Starfield: a fixed backdrop behind the whole app, visible through every page's own
   gaps/margins (the app shell's cards all carry their own solid/glass backgrounds, so this only
   shows where content doesn't cover it - content areas, page padding, card gaps). Populated once
   by initStarfield() in app.js with randomly-placed .star spans so each one twinkles on its own
   timing instead of a single shared pulse; a minority get .glitter for an occasional brighter
   flash, not a constant shimmer. */
.starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 65% 50% at 88% 6%, rgba(139, 92, 246, 0.32), transparent 62%),
    radial-gradient(ellipse 60% 45% at 4% 88%, rgba(51, 214, 255, 0.22), transparent 62%),
    radial-gradient(ellipse 50% 40% at 55% 45%, rgba(255, 79, 163, 0.1), transparent 65%),
    var(--bg-main);
  background-size: 180% 180%, 180% 180%, 160% 160%, 100% 100%;
  animation: nebula-drift 50s ease-in-out infinite alternate;
}
@keyframes nebula-drift {
  0% { background-position: 0% 0%, 0% 0%, 0% 0%, 0 0; }
  100% { background-position: -12% 8%, 10% -10%, 8% 8%, 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .starfield { animation: none; }
}
.star {
  position: absolute;
  border-radius: 50%;
  background: #ffffff;
  opacity: 0.5;
  animation: star-twinkle var(--dur, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.star.glitter {
  animation: star-glitter var(--dur, 6s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes star-twinkle {
  0%, 100% { opacity: 0.28; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.05); }
}
@keyframes star-glitter {
  0%, 85%, 100% { opacity: 0.3; transform: scale(0.75); box-shadow: none; }
  91% { opacity: 1; transform: scale(1.8); box-shadow: 0 0 7px 2px rgba(255, 255, 255, 0.85); }
  96% { opacity: 0.55; transform: scale(1.1); box-shadow: 0 0 3px 1px rgba(255, 255, 255, 0.4); }
}
@media (prefers-reduced-motion: reduce) {
  .star { animation: none; opacity: 0.45; }
}

/* A distant sun, fixed in one corner - the spaceship's flight path below aims toward it so the
   two read as one scene (a ship heading somewhere) rather than unrelated floating effects. */
.bg-sun {
  position: absolute;
  top: 9%;
  right: 13%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fff 0%, #FFE9A3 32%, #FFD23F 62%, rgba(255, 178, 63, 0) 100%);
  box-shadow: 0 0 40px 14px rgba(255, 210, 63, 0.35), 0 0 100px 46px rgba(255, 178, 63, 0.12);
  animation: sun-glow 8s ease-in-out infinite;
}
@keyframes sun-glow {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

/* A quick meteor streaks past every so often - a single bright point with a fading tail, gone in
   about two seconds so it reads as a passing event rather than a looping decoration. */
.shooting-star {
  position: absolute;
  top: 16%;
  left: -6%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.9), 0 0 20px 5px rgba(150, 210, 255, 0.7);
  animation: shooting-star-fly 17s linear infinite;
  animation-delay: 3s;
}
.shooting-star::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 100%;
  width: 140px;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85));
  transform-origin: right center;
  transform: translateY(-50%) rotate(22deg);
}
@keyframes shooting-star-fly {
  0% { transform: translate(0, 0); opacity: 0; }
  2% { opacity: 1; }
  13% { opacity: 1; }
  19% { transform: translate(72vw, 34vh); opacity: 0; }
  100% { transform: translate(72vw, 34vh); opacity: 0; }
}

/* A sleek, minimal spaceship (a plain dart silhouette, not a cartoon rocket) drifts slowly across
   toward .bg-sun - much slower and rarer than the meteor so it feels deliberate, like something
   actually travelling somewhere, not another sparkle. */
.spaceship {
  position: absolute;
  bottom: 18%;
  left: 3%;
  width: 26px;
  height: 10px;
  filter: drop-shadow(0 0 5px rgba(150, 210, 255, 0.6));
  animation: spaceship-fly 30s ease-in-out infinite;
  animation-delay: 9s;
}
.spaceship svg { width: 100%; height: 100%; display: block; }
.spaceship::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 100%;
  width: 70px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(150, 210, 255, 0.55));
  transform: translateY(-50%);
}
@keyframes spaceship-fly {
  0% { transform: translate(0, 0) rotate(-16deg) scale(0.9); opacity: 0; }
  10% { opacity: 0.9; }
  82% { opacity: 0.8; }
  100% { transform: translate(80vw, -48vh) rotate(-16deg) scale(0.35); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bg-sun { animation: none; }
  .shooting-star, .spaceship { display: none; }
}

/* app shell: sidebar + main */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

/* No fill, no border - the sidebar sits directly on .starfield like the rest of the app now does,
   instead of reading as its own separate panel. */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: transparent;
  border-right: none;
  padding: var(--space-sm) var(--space-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.nav button {
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-2xs) var(--space-xs);
  color: var(--text-secondary);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--speed-fast) var(--ease-smooth), color var(--speed-fast) var(--ease-smooth);
}
.nav button:hover { background: var(--bg-surface); color: var(--text-primary); }
.nav button.active {
  background: var(--bg-surface);
  color: var(--c-primary-glow-text);
  text-shadow: 0 0 10px rgba(51, 214, 255, 0.6);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-main);
  transition: transform var(--speed-med) var(--ease-smooth);
}
.topbar.topbar-hidden { transform: translateY(-100%); }

.account-actions { display: flex; align-items: center; gap: var(--space-2xs); margin-left: auto; }

.content { padding: var(--space-md); max-width: 1180px; margin: 0 auto; width: 100%; }

.page { display: none; }
.page.active { display: block; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-circle);
  background: var(--c-primary-dark);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}

/* Consolidated breakpoint scale — reused everywhere instead of re-declaring per component.
   Mobile-down: 780px. Desktop-up: 1180px, 1500px. */
@media (max-width: 780px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-default);
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* legacy Edge/IE */
  }
  .sidebar::-webkit-scrollbar { display: none; } /* Chrome/Safari/Edge */
  .nav { flex-direction: row; }
  .content { padding: var(--space-sm); }
}

@media (min-width: 1180px) {
  .content { max-width: 1300px; }
}
