:root {
  --void: #0b0a1a;
  --dusk: #1c1834;
  --panel: rgba(24, 22, 47, 0.78);
  --panel-strong: rgba(30, 27, 57, 0.94);
  --aurora: #7c6bff;
  --teal: #4fd6c5;
  --dawn: #ffb59e;
  --halo: #fcefc7;
  --pearl: #f6f4ff;
  --muted: #bdb8d8;
  --line: rgba(246, 244, 255, 0.14);
  --line-bright: rgba(252, 239, 199, 0.34);
  --danger: #ff8b8b;
  --success: #b8f6d2;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--void);
  color: var(--pearl);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at 18% 12%, rgba(124, 107, 255, 0.28), transparent 28rem),
    radial-gradient(circle at 82% 10%, rgba(255, 181, 158, 0.16), transparent 25rem),
    linear-gradient(135deg, var(--void), #111528 46%, #151225);
  color: var(--pearl);
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    radial-gradient(circle, rgba(252, 239, 199, 0.65) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(79, 214, 197, 0.35) 0 1px, transparent 1.5px);
  background-size: 120px 120px, 180px 180px;
  background-position: 0 0, 50px 80px;
  animation: drift 46s linear infinite;
}

body.theme-midnight {
  --void: #080705;
  --dusk: #1e1710;
  --panel: rgba(29, 23, 16, 0.82);
  --panel-strong: rgba(33, 26, 17, 0.96);
  --aurora: #d6ae55;
  --teal: #b8f6d2;
  --dawn: #e8c97d;
  --halo: #fff0bd;
  --pearl: #fff8e7;
  --muted: #cdbf9a;
}

body.theme-aurora {
  --void: #06161b;
  --dusk: #10252b;
  --panel: rgba(12, 39, 45, 0.82);
  --panel-strong: rgba(10, 45, 52, 0.96);
  --aurora: #6ee7d2;
  --teal: #a6ffcb;
  --dawn: #ffc2a9;
  --halo: #e8ffd6;
  --pearl: #effffc;
  --muted: #a4d1cb;
}

body.theme-pearl {
  --void: #f2f0ff;
  --dusk: #ffffff;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --aurora: #6859d9;
  --teal: #047b72;
  --dawn: #c96855;
  --halo: #9b6d19;
  --pearl: #151325;
  --muted: #645f7d;
  --line: rgba(21, 19, 37, 0.14);
  --line-bright: rgba(104, 89, 217, 0.32);
  background:
    radial-gradient(circle at 18% 12%, rgba(124, 107, 255, 0.18), transparent 28rem),
    radial-gradient(circle at 82% 10%, rgba(255, 181, 158, 0.18), transparent 25rem),
    linear-gradient(135deg, #fbf9f0, #eef3ff 48%, #f9eef0);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.eyebrow,
.panel-kicker,
.stat-label,
.small-label {
  color: var(--halo);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.threshold {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}

.threshold__media {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.threshold__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(11, 10, 26, 0.94), rgba(11, 10, 26, 0.76) 42%, rgba(11, 10, 26, 0.3)),
    linear-gradient(0deg, rgba(11, 10, 26, 0.78), transparent 38%);
}

.threshold__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.threshold__content {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 44px 0;
}

.threshold h1 {
  max-width: 880px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 7.4rem);
  line-height: 0.92;
  font-weight: 500;
  letter-spacing: 0;
}

.threshold__copy {
  max-width: 580px;
  margin: 22px 0 34px;
  color: var(--muted);
  font-size: 1.16rem;
  line-height: 1.7;
}

.threshold-grid {
  display: grid;
  grid-template-columns: minmax(290px, 430px) minmax(260px, 340px);
  gap: 14px;
  align-items: start;
}

.threshold-panel,
.glass-panel,
.metric-card,
.catalog-card,
.feed-item,
.document,
.share-card,
.topbar,
.sidebar,
.life-feed,
.realm-hero,
.toolbar,
.data-table,
.oracle-note,
.manifest-card {
  border: 1px solid var(--line);
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  border-radius: var(--radius);
}

.threshold-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.threshold-panel h2 {
  margin: 4px 0 0;
  font-size: 1.2rem;
}

.threshold-panel--quiet {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: none;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 7, 19, 0.5);
  color: var(--pearl);
  padding: 12px 12px;
  outline: none;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-bright);
  box-shadow: 0 0 0 3px rgba(252, 239, 199, 0.1);
}

.primary-action,
.secondary-action,
.icon-text-button,
.round-button,
.hold-button {
  min-height: 42px;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  color: var(--pearl);
  background: rgba(255, 255, 255, 0.06);
  padding: 0 14px;
}

.primary-action,
.hold-button {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(124, 107, 255, 0.95), rgba(255, 181, 158, 0.84) 56%, rgba(252, 239, 199, 0.92));
  color: #111022;
  font-weight: 850;
}

.secondary-action:hover,
.icon-text-button:hover,
.round-button:hover {
  border-color: var(--halo);
  background: rgba(252, 239, 199, 0.08);
}

.hold-button {
  width: 100%;
  display: grid;
  place-items: center;
}

.hold-button::before {
  content: "";
  position: absolute;
  inset: 0;
  width: calc(var(--hold-progress, 0) * 100%);
  background: rgba(255, 255, 255, 0.42);
  transition: width 80ms linear;
}

.hold-button span {
  position: relative;
  z-index: 1;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.flash {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 139, 139, 0.44);
  border-radius: var(--radius);
  background: rgba(255, 139, 139, 0.1);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.sidebar {
  position: sticky;
  top: 14px;
  height: calc(100vh - 28px);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  color: #111022;
  font-weight: 900;
  background: linear-gradient(135deg, var(--aurora), var(--dawn), var(--halo));
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.realm-nav {
  display: grid;
  gap: 4px;
}

.realm-link {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
}

.realm-link strong,
.realm-link small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.realm-link small {
  font-size: 0.75rem;
}

.realm-link.is-active,
.realm-link:hover {
  color: var(--pearl);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.06);
}

.realm-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(252, 239, 199, 0.09);
  color: var(--halo);
  font-size: 0.72rem;
  font-weight: 850;
}

.logout-form {
  margin-top: auto;
}

.logout-form button {
  width: 100%;
}

.app-main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 6;
  min-height: 64px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-menu {
  display: none;
}

.topbar-metrics {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.mini-metric {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.mini-metric span,
.mini-metric strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-metric span {
  color: var(--muted);
  font-size: 0.72rem;
}

.mini-metric strong {
  margin-top: 3px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.round-button {
  min-width: 44px;
  padding: 0 12px;
}

.realm-stage {
  min-width: 0;
  padding-bottom: 40px;
}

.realm-view {
  display: grid;
  gap: 14px;
}

.realm-hero {
  position: relative;
  overflow: hidden;
  min-height: 330px;
  display: grid;
  align-items: end;
}

.realm-hero img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.78;
}

.realm-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(11, 10, 26, 0.88), rgba(11, 10, 26, 0.34)),
    linear-gradient(0deg, rgba(11, 10, 26, 0.72), transparent 50%);
}

.realm-hero__content {
  position: relative;
  z-index: 2;
  width: min(820px, 100%);
  padding: 28px;
}

.realm-hero h1 {
  margin: 8px 0 12px;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 5.4rem);
  line-height: 0.98;
  font-weight: 500;
}

.realm-hero p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
}

.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 14px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.glass-panel,
.metric-card,
.catalog-card,
.manifest-card,
.oracle-note {
  padding: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-header h2,
.metric-card h3,
.catalog-card h3 {
  margin: 0;
}

.panel-header p,
.catalog-card p,
.metric-card p,
.oracle-note p {
  color: var(--muted);
  line-height: 1.6;
}

.metric-card strong {
  display: block;
  font-size: clamp(1.55rem, 2.55vw, 2.65rem);
  line-height: 1;
  font-family: var(--font-display);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.catalog-card {
  display: grid;
  gap: 12px;
  align-content: start;
}

.catalog-card__image {
  height: 170px;
  margin: -16px -16px 0;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  background: rgba(255, 255, 255, 0.05);
}

.catalog-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pill-list,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill,
.chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.status-pill {
  color: var(--success);
  border-color: rgba(184, 246, 210, 0.28);
}

.toolbar {
  padding: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.toolbar label {
  min-width: min(230px, 100%);
  flex: 1;
}

.toolbar button {
  min-width: 180px;
}

.data-table {
  overflow: hidden;
}

.data-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.data-row:first-child {
  border-top: 0;
}

.data-row span {
  color: var(--muted);
}

.wealth-card-scene,
.vehicle-scene,
.globe-scene {
  min-height: 280px;
  position: relative;
  overflow: hidden;
}

.wealth-card {
  width: min(420px, 82vw);
  aspect-ratio: 1.58;
  margin: 34px auto;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(252, 239, 199, 0.32), transparent 28%),
    linear-gradient(155deg, rgba(124, 107, 255, 0.84), rgba(255, 181, 158, 0.55) 56%, rgba(252, 239, 199, 0.84)),
    #17162a;
  color: #111022;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: perspective(900px) rotateY(-12deg) rotateX(8deg);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.46);
}

.wealth-card small,
.wealth-card strong {
  display: block;
}

.wealth-card strong {
  font-size: 2rem;
  font-family: var(--font-display);
  font-weight: 600;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-top: 4px;
  background: var(--halo);
  box-shadow: 0 0 18px var(--halo);
}

.life-feed {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: min(420px, calc(100vw - 28px));
  height: calc(100vh - 28px);
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  transform: translateX(calc(100% + 28px));
  transition: transform 240ms ease;
}

.life-feed.is-open {
  transform: translateX(0);
}

.life-feed header {
  display: flex;
  gap: 10px;
  align-items: center;
}

.life-feed header h2 {
  flex: 1;
  margin: 0;
}

.feed-list {
  overflow: auto;
  display: grid;
  gap: 10px;
  align-content: start;
}

.feed-item {
  padding: 12px;
  box-shadow: none;
}

.feed-item h3 {
  margin: 2px 0 6px;
}

.feed-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.manifest-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 240ms ease;
  background: rgba(11, 10, 26, 0.18);
}

.manifest-overlay.is-visible {
  opacity: 1;
}

.manifest-bloom {
  position: absolute;
  width: 32vmin;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--halo), rgba(255, 181, 158, 0.44), transparent 68%);
  transform: scale(0.2);
  opacity: 0;
}

.manifest-overlay.is-visible .manifest-bloom {
  animation: bloom 900ms ease-out;
}

.manifest-overlay p {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 8rem);
  margin: 0;
  color: var(--halo);
  text-shadow: 0 0 44px rgba(252, 239, 199, 0.6);
}

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 60;
  width: min(520px, calc(100vw - 28px));
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.share-card-page,
.document-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 18px;
  padding: 24px;
}

.share-card {
  width: min(900px, 100%);
  min-height: min(620px, calc(100vh - 140px));
  padding: clamp(28px, 7vw, 76px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at 22% 18%, rgba(252, 239, 199, 0.22), transparent 22rem),
    radial-gradient(circle at 82% 78%, rgba(124, 107, 255, 0.28), transparent 24rem),
    var(--panel-strong);
}

.share-card h1 {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 7vw, 6.4rem);
  line-height: 1;
  font-weight: 500;
}

.share-card footer,
.document footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.document {
  width: min(760px, 100%);
  padding: clamp(24px, 5vw, 54px);
}

.document h1 {
  margin: 8px 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  font-weight: 500;
}

.document dl {
  display: grid;
  gap: 0;
  margin: 30px 0;
  border-top: 1px solid var(--line);
}

.document dl div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.document dt {
  color: var(--muted);
}

.document dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.wax-seal {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 1px solid var(--line-bright);
  color: #111022;
  background: radial-gradient(circle, var(--halo), var(--dawn));
  text-align: center;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.document-actions {
  display: flex;
  gap: 10px;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

canvas.rdl-scene {
  width: 100%;
  height: 100%;
  display: block;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-120px, -120px, 0); }
}

@keyframes bloom {
  0% { transform: scale(0.2); opacity: 0; }
  28% { opacity: 1; }
  100% { transform: scale(5.8); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 14px auto 14px 14px;
    width: min(300px, calc(100vw - 28px));
    height: auto;
    transform: translateX(calc(-100% - 28px));
    transition: transform 220ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .mobile-menu {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--pearl);
    background: rgba(255, 255, 255, 0.06);
    padding: 0 12px;
  }
}

@media (max-width: 900px) {
  .threshold-grid,
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .topbar-metrics {
    order: 3;
    flex-basis: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .realm-hero {
    min-height: 300px;
  }
}

@media (max-width: 560px) {
  .threshold__content {
    width: min(100% - 24px, 1180px);
    justify-content: start;
    padding-top: 34px;
  }

  .threshold h1 {
    font-size: clamp(2.7rem, 15vw, 4.8rem);
  }

  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  .topbar {
    top: 8px;
  }

  .topbar-metrics {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .round-button {
    flex: 1;
  }

  .realm-hero__content,
  .glass-panel,
  .metric-card,
  .catalog-card,
  .manifest-card,
  .oracle-note {
    padding: 14px;
  }

  .catalog-card__image {
    margin: -14px -14px 0;
  }

  .data-row,
  .document dl div {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
    color: #111;
  }

  body::before,
  .document-actions {
    display: none;
  }

  .document {
    box-shadow: none;
    border-color: #111;
    background: #fff;
  }
}
