:root {
  color-scheme: dark;
  --bg: #05070c;
  --ink: #f4f6fb;
  --muted: rgba(244, 246, 251, 0.68);
  --line: rgba(255, 255, 255, 0.14);
  --accent: #e100ff;
  --font-display: "Cormorant Garamond", "Playfair Display", Georgia, serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-right: max(12px, env(safe-area-inset-right));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  --safe-left: max(12px, env(safe-area-inset-left));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
}

.app {
  position: fixed;
  inset: 0;
}

.gate[hidden],
.app[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  width: 0;
}

#canvas-wrap {
  position: fixed;
  inset: 0;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-mark {
  display: block;
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 8px 16px rgba(197, 38, 223, 0.34));
}

.brand-mark-revolve {
  transform-box: fill-box;
  transform-origin: center;
}

@media (prefers-reduced-motion: no-preference) {
  .brand-mark-revolve {
    animation: nrlcSphereRevolve 14s linear infinite;
  }
}

@keyframes nrlcSphereRevolve {
  to {
    transform: rotate(360deg);
  }
}

.brand-copy,
.gate-brand .brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.15;
}

.brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding:
    calc(var(--safe-top) + 8px)
    max(20px, var(--safe-right))
    calc(var(--safe-bottom) + 28px)
    max(20px, var(--safe-left));
  background:
    radial-gradient(ellipse 70% 42% at 50% 0%, rgba(225, 0, 255, 0.1), transparent 58%),
    linear-gradient(180deg, rgba(5, 7, 12, 0.55) 0%, rgba(5, 7, 12, 0.78) 42%, rgba(5, 7, 12, 0.92) 100%),
    radial-gradient(ellipse at center, #0c1018 0%, #05070c 74%);
}

.gate-brand {
  position: absolute;
  top: var(--safe-top);
  right: var(--safe-right);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.gate-card {
  width: 100%;
  max-width: 26rem;
  margin: 0 auto;
  padding: 28px 24px 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background: rgba(8, 10, 16, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.38);
  display: flex;
  flex-direction: column;
}

.gate-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.15rem, 7.5vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.02;
  color: #fff;
}

.gate-lede,
.gate-fine {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.5;
}

.gate-lede {
  margin-top: 12px;
  margin-bottom: 22px;
}

.gate-fine {
  margin-top: 16px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(244, 246, 251, 0.52);
}

.gate-card input[type="email"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 48px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.gate-card input[type="email"]::placeholder {
  color: rgba(244, 246, 251, 0.38);
  opacity: 1;
}

.gate-card input[type="email"]:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.065);
}

.gate-card input[type="email"]:focus {
  outline: none;
  border-color: rgba(225, 0, 255, 0.55);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(225, 0, 255, 0.16);
}

.gate-card button[type="submit"] {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  margin: 12px 0 0;
  padding: 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: linear-gradient(105deg, #7b5cff 0%, #c43bff 52%, #e100ff 100%);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.gate-card button[type="submit"]:hover:not(:disabled) {
  filter: brightness(1.06);
}

.gate-card button[type="submit"]:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 3px;
}

.gate-card button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: wait;
}

.gate-error {
  margin: 12px 0 0;
  color: #ffb4c8;
  font-size: 0.875rem;
  line-height: 1.4;
}

@media (min-width: 720px) {
  .gate {
    justify-content: center;
    padding-bottom: var(--safe-bottom);
  }

  .gate-card {
    padding: 32px 28px 28px;
  }
}

.brand {
  position: fixed;
  top: var(--safe-top);
  right: var(--safe-right);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.dock {
  position: fixed;
  left: var(--safe-left);
  right: var(--safe-right);
  bottom: var(--safe-bottom);
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

/* Sheets live inside panels but must position against the whole dock. */
.panel {
  position: static;
  min-width: 0;
}

[hidden] {
  display: none !important;
}

.dock-tab,
.wallet-chip,
.choice,
.back,
.ghost,
.linkish,
#text-submit,
#image-submit,
.lane label {
  appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 10, 16, 0.82);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-transform: none;
  text-align: center;
  text-decoration: none;
  line-height: 1.2;
  cursor: pointer;
}

.dock-tab {
  position: relative;
  z-index: 1;
  backdrop-filter: blur(16px);
}

.dock-tab[aria-expanded="true"],
.wallet-chip[aria-expanded="true"],
.choice:hover,
.back:hover,
.ghost:hover,
.linkish:hover,
.lane label:hover {
  border-color: rgba(225, 0, 255, 0.55);
}

.sheet,
.credits-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 4;
  width: auto;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 10, 16, 0.92);
  backdrop-filter: blur(16px);
  overflow-x: hidden;
}

.sheet--tall {
  max-height: min(56dvh, 420px);
  overflow-x: hidden;
  overflow-y: auto;
}

.slide {
  display: grid;
  grid-template-columns: 4.8rem 1fr;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.slide input[type="range"] {
  width: 100%;
  height: 28px;
  accent-color: var(--accent);
}

.look-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: stretch;
}

.check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

#reset {
  appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.wallet-chip {
  grid-column: 1 / -1;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(16px);
}

.pack-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.pack-row button {
  appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 72px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #7b5cff, #e100ff);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.pack-row button:disabled {
  opacity: 0.5;
}

.lane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lane label {
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.lane label:has(input:checked) {
  border-color: rgba(225, 0, 255, 0.55);
  background: rgba(225, 0, 255, 0.1);
}

.lane input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.create-panel {
  display: grid;
  gap: 8px;
}

#create-home {
  display: grid;
  gap: 8px;
}

.create-title {
  margin: 2px 0 4px;
  font-size: 16px;
  letter-spacing: -0.03em;
}

.library-title {
  margin: 2px 0 4px;
  font-size: 14px;
  letter-spacing: -0.02em;
  text-transform: none;
}

.create-label,
.drop {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.choice,
.back,
.ghost,
.linkish {
  background: rgba(255, 255, 255, 0.05);
}

.drop {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 88px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  text-align: center;
  cursor: pointer;
}

.drop input[type="file"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  color: var(--muted);
}

#text-submit,
#image-submit {
  border: 0;
  background: linear-gradient(90deg, #7b5cff, #e100ff);
  color: #fff;
}

#text-submit:disabled,
#image-submit:disabled,
.ghost:disabled,
.choice:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cost {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.library {
  display: grid;
  gap: 8px;
}

.lib-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.lib-item strong {
  display: block;
  font-size: 14px;
}

.lib-item em {
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.lib-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lib-actions button,
.gizmo-row button {
  appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.gizmo-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.gizmo-row[hidden] {
  display: none !important;
}

.gizmo-row button[aria-pressed="true"] {
  border-color: rgba(225, 0, 255, 0.7);
}

.gen-toast {
  position: fixed;
  top: calc(var(--safe-top) + 56px);
  left: 50%;
  z-index: 4;
  width: min(320px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 10, 16, 0.9);
  backdrop-filter: blur(16px);
  pointer-events: none;
}

.gen-toast[hidden] {
  display: none !important;
}

.gen-kicker {
  margin: 0 0 4px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

#gen-stage {
  margin: 0;
  font-weight: 650;
}

.library-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.concierge {
  display: grid;
  gap: 8px;
}

#concierge-prompt {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.file {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  font-size: 13px;
  min-width: 0;
}

.file input[type="file"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  color: var(--muted);
}

#concierge-submit {
  appearance: none;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #7b5cff, #e100ff);
  color: #fff;
  font: inherit;
  font-weight: 650;
}

#concierge-submit:disabled {
  opacity: 0.6;
}

#loader {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, #141826 0%, #05070c 70%);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

#loader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-card {
  width: min(320px, calc(100vw - 48px));
  text-align: center;
}

.bar {
  height: 4px;
  margin: 16px 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

#bar {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7b5cff, #e100ff);
}

#pct {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (min-width: 720px) {
  .gate {
    justify-content: center;
  }

  .gate-card {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(8, 10, 16, 0.55);
    backdrop-filter: blur(18px);
  }

  .brand-mark,
  .gate-brand .brand-mark {
    width: 48px;
    height: 48px;
  }

  .wallet-chip {
    min-height: 44px;
  }

  .dock {
    left: auto;
    right: var(--safe-right);
    width: min(340px, calc(100vw - 40px));
  }

  .sheet,
  .credits-sheet {
    left: 0;
    right: 0;
    width: auto;
  }

  .sheet--tall {
    max-height: min(62dvh, 460px);
  }
}
