:root {
  --bg-top: #02040a;
  --bg-mid: #060b1b;
  --bg-bot: #0c1733;
  --accent: #f4d38c;
  --accent-soft: rgba(244, 211, 140, 0.16);
  --fg: #f3f6ff;
  --fg-muted: rgba(243, 246, 255, 0.66);
  --fg-subtle: rgba(243, 246, 255, 0.42);
  --surface: rgba(8, 12, 24, 0.72);
  --surface-strong: rgba(10, 15, 30, 0.90);
  --line: rgba(243, 246, 255, 0.12);
  --line-strong: rgba(243, 246, 255, 0.24);
  --radius-lg: 14px;
  --radius-md: 9px;
  --radius-sm: 6px;
}

body[data-theme="aurora"] {
  --bg-top: #020810;
  --bg-mid: #061826;
  --bg-bot: #0b2d3b;
  --accent: #8cf0df;
  --accent-soft: rgba(140, 240, 223, 0.16);
}

body[data-theme="violet"] {
  --bg-top: #05040f;
  --bg-mid: #110d2c;
  --bg-bot: #1f174a;
  --accent: #d4b8ff;
  --accent-soft: rgba(212, 184, 255, 0.16);
}

body[data-theme="ember"] {
  --bg-top: #07050a;
  --bg-mid: #160d18;
  --bg-bot: #291620;
  --accent: #ffb88c;
  --accent-soft: rgba(255, 184, 140, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 52%, var(--bg-bot) 100%);
  color: var(--fg);
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

#sky-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle at 50% 42%, transparent 25%, rgba(2, 4, 10, 0.52) 100%);
}

/* ============ VIEW 1: HOME ============ */
.view-home {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 24px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.home-nav {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--fg);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.brand-star {
  color: var(--accent);
  font-size: 14px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-countdown {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--fg-subtle);
  font-variant-numeric: tabular-nums;
}

.nav-link {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.2s, color 0.2s;
}
.nav-link:hover {
  border-color: var(--line-strong);
  color: var(--fg);
}

.hero-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}

.hero-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 28px 26px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 14px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.hero-title {
  font-size: 40px;
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
}

.serif-italic {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 48px;
  color: var(--accent);
  letter-spacing: 0;
}

.hero-sub {
  font-size: 14px;
  line-height: 1.58;
  color: var(--fg-muted);
  margin-bottom: 24px;
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-label {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  margin-bottom: 6px;
}

.text-input,
.text-area {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--fg);
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.text-input:focus,
.text-area:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
}

.text-input::placeholder,
.text-area::placeholder {
  color: var(--fg-subtle);
}

.text-area {
  resize: none;
  line-height: 1.5;
}

.theme-picker-wrap {
  margin-top: 2px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.theme-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 9px 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.theme-pill.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--fg);
}

.tp-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.sw-obsidian { background: linear-gradient(135deg, #060b1b, #1d2d57); }
.sw-aurora   { background: linear-gradient(135deg, #061826, #1d6b75); }
.sw-violet   { background: linear-gradient(135deg, #110d2c, #4b3185); }
.sw-ember    { background: linear-gradient(135deg, #160d18, #703940); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--accent);
  color: #070910;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.18s, transform 0.12s;
}

.btn-primary:hover { opacity: 0.92; }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.full-w { width: 100%; }

.btn-glass {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 46px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: rgba(8, 12, 24, 0.72);
  backdrop-filter: blur(12px);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, background 0.2s;
}
.btn-glass:hover {
  border-color: var(--accent);
  background: rgba(14, 20, 38, 0.85);
}

.btn-ghost {
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 12px;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--fg); }

.form-error {
  color: #ff9c9c;
  font-size: 12.5px;
}

.return-banner {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid rgba(244, 211, 140, 0.28);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--fg-muted);
}

.return-banner a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.hero-meta {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.demo-trigger {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s;
}
.demo-trigger:hover { color: var(--accent); }

.global-stats {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  color: var(--fg-subtle);
  font-variant-numeric: tabular-nums;
}

.home-foot {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--fg-subtle);
}

.foot-links {
  display: flex;
  gap: 8px;
}
.foot-links a {
  color: var(--fg-subtle);
  text-decoration: none;
}
.foot-links a:hover { color: var(--fg-muted); }

/* ============ VIEW 2: INTERACTIVE SKY ============ */
.view-sky {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sky-topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(3, 5, 12, 0.72) 0%, transparent 100%);
}

.sky-top-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mini {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(8, 12, 24, 0.65);
  justify-content: center;
  flex-shrink: 0;
}

.sky-identity {
  min-width: 0;
}

.sky-title {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sky-subline {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  color: var(--fg-muted);
  margin-top: 2px;
}

.mono-num {
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
}

.dot-sep { opacity: 0.4; }

.sky-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(8, 12, 24, 0.65);
  color: var(--fg-muted);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.icon-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.pill-btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 12, 24, 0.72);
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.pill-btn:hover { border-color: var(--accent); }

.sky-stage {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.lights-layer {
  position: absolute;
  inset: 0;
}

.sky-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  pointer-events: none;
  white-space: nowrap;
}

/* Individual Drifting Celestial Light Nodes */
.light-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--fg);
  animation: floatDrift var(--dur, 6s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
  transition: transform 0.2s;
}

.light-node:hover {
  z-index: 15;
}

.light-node:hover .light-glyph {
  transform: scale(1.14);
}

.light-node.launching {
  animation: launchRise 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes floatDrift {
  0%   { transform: translate(-50%, -50%) translateY(0px); }
  100% { transform: translate(-50%, -50%) translateY(-10px); }
}

@keyframes launchRise {
  0%   { transform: translate(-50%, 340px) scale(0.5); opacity: 0; }
  35%  { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.light-glyph {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease;
  filter: drop-shadow(0 0 14px rgba(244, 211, 140, 0.32));
}

.light-node[data-kind="star"] .light-glyph,
.light-node[data-kind="comet"] .light-glyph {
  filter: drop-shadow(0 0 14px rgba(162, 224, 255, 0.42));
}

.light-node[data-kind="nova"] .light-glyph {
  filter: drop-shadow(0 0 14px rgba(208, 174, 255, 0.45));
}

.light-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(243, 246, 255, 0.78);
  background: rgba(4, 7, 16, 0.54);
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 2px 7px;
  border-radius: 999px;
  max-width: 112px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bottom Dock */
.sky-dock {
  position: relative;
  z-index: 10;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(3, 5, 12, 0.84) 0%, transparent 100%);
  display: flex;
  justify-content: center;
}

.dock-row {
  width: 100%;
  max-width: 500px;
  display: flex;
  gap: 10px;
}

.dock-main {
  flex: 1;
}

.dock-main b {
  font-weight: 600;
}

/* ============ MODALS ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 4, 10, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 24px 22px 22px;
  max-height: 92dvh;
  overflow-y: auto;
}

.modal-compact {
  max-width: 390px;
}

.center-sheet {
  text-align: center;
  padding: 32px 24px 24px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.modal-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 4px;
}

.modal-title {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.serif-modal {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-size: 32px;
  font-weight: 400;
  margin-bottom: 8px;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg-muted);
  font-size: 13px;
  cursor: pointer;
}
.close-btn:hover { color: var(--fg); border-color: var(--line-strong); }

.field-group {
  margin-bottom: 14px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.char-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--fg-subtle);
}

.light-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.light-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.light-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--fg);
}

.lo-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.seal-note {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  color: var(--fg-subtle);
  margin-bottom: 14px;
}

.view-sender-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sealed-box {
  text-align: center;
  padding: 22px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.seal-emblem {
  font-size: 24px;
  color: var(--accent);
  margin-bottom: 10px;
}

.seal-heading {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-size: 26px;
  margin-bottom: 6px;
}

.seal-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-muted);
  margin-bottom: 14px;
}

.seal-timer {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--accent);
}

.unlocked-box {
  padding: 18px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.unlocked-message {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 23px;
  line-height: 1.42;
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
}

.unlocked-date {
  margin-top: 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--fg-subtle);
}

.success-spark {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 10px;
}

.after-desc {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--fg-muted);
  margin-bottom: 20px;
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(10, 15, 30, 0.94);
  color: var(--fg);
  font-size: 12.5px;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .hero-card { padding: 26px 20px 22px; }
  .hero-title { font-size: 34px; }
  .serif-italic { font-size: 42px; }
  .nav-countdown { display: none; }
  .light-glyph { width: 48px; height: 48px; }
}
