:root {
  --page: #f4f4f1;
  --paper: #ffffff;
  --ink: #151513;
  --text: #363633;
  --muted: #777773;
  --faint: #b4b4ae;
  --line: rgba(21, 21, 19, 0.09);
  --wash: #e9e9e5;
  --red: #d71920;
  --display: "Iowan Old Style", "Baskerville", "Songti SC", "STSong", serif;
  --body: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --mono: "SFMono-Regular", "Menlo", "Monaco", monospace;
  --header-h: 68px;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

button,
input {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

::selection {
  background: var(--ink);
  color: var(--paper);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 5000;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 4000;
  height: 2px;
  background: transparent;
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--ink);
  transition: width 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 2200;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  min-height: var(--header-h);
  align-items: center;
  padding: 10px clamp(20px, 3.5vw, 52px);
  border-bottom: 1px solid rgba(21, 21, 19, 0.055);
  background: rgba(244, 244, 241, 0.97);
  font-family: var(--body);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

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

.brand-copy strong {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.brand-copy small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.primary-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid rgba(21, 21, 19, 0.07);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: 0 2px 10px rgba(21, 21, 19, 0.025);
}

.primary-nav a {
  display: grid;
  min-width: 74px;
  min-height: 34px;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.primary-nav a:hover,
.primary-nav a[aria-current] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(21, 21, 19, 0.06);
}

.header-index {
  display: flex;
  align-items: baseline;
  justify-self: end;
  gap: 11px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.header-index strong {
  color: var(--ink);
  font-size: 9px;
  font-weight: 500;
}

.spatial-main,
.spatial-shell {
  width: 100%;
  height: 100%;
}

.spatial-shell {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 54% 52%, rgba(255, 255, 255, 0.96) 0, rgba(255, 255, 255, 0.25) 34%, transparent 66%),
    var(--page);
}

.spatial-grid {
  position: absolute;
  z-index: -4;
  inset: 36% -25% -65%;
  background-image:
    linear-gradient(rgba(21, 21, 19, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 21, 19, 0.045) 1px, transparent 1px);
  background-size: 54px 54px;
  opacity: 0.34;
  pointer-events: none;
  transform: perspective(650px) rotateX(65deg) scale(1.34);
  transform-origin: center top;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28%, #000 72%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 28%, #000 72%, transparent);
}

.spatial-vignette {
  position: absolute;
  z-index: 1500;
  inset: 0;
  box-shadow: inset 0 0 120px rgba(244, 244, 241, 0.72);
  pointer-events: none;
}

.spatial-orbit {
  position: absolute;
  z-index: -2;
  right: -8vw;
  bottom: -2vh;
  width: min(42vw, 680px);
  height: auto;
  filter: grayscale(1) contrast(0.8);
  opacity: 0.055;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.spatial-orbit.is-hidden {
  opacity: 0;
}

.space-intro {
  position: absolute;
  z-index: 1700;
  top: calc(var(--header-h) + clamp(24px, 5vh, 56px));
  left: clamp(22px, 4.3vw, 66px);
  max-width: min(320px, 30vw);
  pointer-events: none;
}

.space-kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  line-height: 1.5;
  text-transform: uppercase;
}

.space-intro h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(38px, 4.8vw, 66px);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 1;
}

.space-meta {
  margin: 14px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.spatial-stage {
  position: absolute;
  z-index: 1;
  inset: var(--header-h) 0 0;
  overflow: hidden;
  cursor: grab;
  outline: none;
  perspective: 1100px;
  perspective-origin: 57% 53%;
  touch-action: none;
  user-select: none;
}

.spatial-focus-backdrop {
  position: absolute;
  z-index: 850;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.spatial-stage.has-focus-backdrop .spatial-focus-backdrop {
  opacity: 1;
}

.spatial-focus-backdrop span {
  position: absolute;
  background: rgba(244, 244, 241, 0.055);
  -webkit-backdrop-filter: blur(6px) saturate(0.76);
  backdrop-filter: blur(6px) saturate(0.76);
}

.spatial-focus-backdrop__top {
  top: 0;
  right: 0;
  left: 0;
  height: var(--focus-top, 25%);
}

.spatial-focus-backdrop__right {
  top: var(--focus-top, 25%);
  right: 0;
  bottom: calc(100% - var(--focus-bottom, 75%));
  left: var(--focus-right, 75%);
}

.spatial-focus-backdrop__bottom {
  top: var(--focus-bottom, 75%);
  right: 0;
  bottom: 0;
  left: 0;
}

.spatial-focus-backdrop__left {
  top: var(--focus-top, 25%);
  right: calc(100% - var(--focus-left, 25%));
  bottom: calc(100% - var(--focus-bottom, 75%));
  left: 0;
}

.spatial-stage:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(21, 21, 19, 0.65);
}

.spatial-stage.is-dragging {
  cursor: grabbing;
}

.spatial-stage.is-focusing {
  cursor: progress;
}

.spatial-world {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: opacity 180ms ease;
}

.spatial-world.is-entering {
  opacity: 0;
}

.space-card {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  width: min(650px, calc(100vw - 80px));
  min-height: 330px;
  flex-direction: column;
  padding: 28px 32px 30px;
  overflow: hidden;
  border: 1px solid rgba(21, 21, 19, 0.085);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 12px 36px rgba(21, 21, 19, 0.055);
  transform-origin: center;
  transform-style: preserve-3d;
  contain: layout paint style;
  backface-visibility: hidden;
  will-change: transform, opacity;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.space-card::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.5), transparent 42%);
  content: "";
  pointer-events: none;
}

.space-card.is-active {
  border-color: rgba(21, 21, 19, 0.13);
  background: rgba(255, 255, 255, 0.985);
  box-shadow: 0 30px 90px rgba(21, 21, 19, 0.12), 0 2px 8px rgba(21, 21, 19, 0.04);
}

.spatial-stage.is-focusing .space-card.is-active {
  border-color: rgba(21, 21, 19, 0.18);
  box-shadow: 0 36px 110px rgba(21, 21, 19, 0.15), 0 2px 8px rgba(21, 21, 19, 0.04);
}

.space-card-focus {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: pointer;
}

.space-card-focus:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -6px;
}

.space-card-chrome,
.space-card-identity,
.space-card-copy {
  position: relative;
  z-index: 2;
  pointer-events: none;
}

.space-card-chrome {
  display: grid;
  grid-template-columns: 1fr auto 14px;
  align-items: center;
  gap: 12px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.space-card-chrome > span:nth-child(2) {
  color: var(--muted);
}

.space-featured {
  color: #6f6b65;
  font-size: 12px;
  line-height: 1;
}

.space-card-identity {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 28px;
}

.space-avatar {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  place-items: center;
  border-radius: 50%;
  background: var(--wash);
  color: #4e4e4a;
  font-family: var(--mono);
  font-size: 11px;
}

.space-card-identity h2 {
  margin: 0;
  font-family: var(--body);
  font-size: 17px;
  font-weight: 580;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.space-card-identity p {
  margin: 3px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.space-card-copy {
  display: -webkit-box;
  max-width: 560px;
  margin: 30px 0 0 61px;
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  font-weight: 380;
  letter-spacing: -0.008em;
  line-height: 1.82;
  text-wrap: pretty;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.space-card:not(.is-active) .space-card-copy {
  -webkit-line-clamp: 3;
}

.spatial-stage.is-dragging .space-card {
  box-shadow: none;
}

.spatial-stage.is-dragging .space-card::after {
  opacity: 0;
}

.space-card-action {
  position: relative;
  z-index: 4;
  display: inline-flex;
  width: max-content;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  margin-top: auto;
  padding: 0 13px;
  border: 1px solid rgba(21, 21, 19, 0.11);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease, color 160ms ease;
}

.space-card.is-active:hover .space-card-action,
.space-card.is-active:focus-within .space-card-action {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.space-card-action:hover,
.space-card-action:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.space-card--archive .space-card-identity {
  display: block;
  margin-top: 44px;
}

.space-card--archive .space-card-identity h2 {
  font-family: var(--display);
  font-size: 36px;
  font-weight: 400;
  letter-spacing: -0.045em;
}

.space-card--archive .space-card-copy {
  margin-left: 0;
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.78;
}

.space-card--builder .space-card-identity {
  margin-top: 40px;
}

.space-card--builder .space-avatar {
  width: 58px;
  height: 58px;
  flex-basis: 58px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
}

.space-card--builder .space-card-identity h2 {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 400;
}

.space-card--builder .space-card-copy {
  margin-left: 73px;
}

.spatial-toolbar,
.spatial-pager,
.spatial-help,
.spatial-status {
  position: absolute;
  z-index: 1800;
}

.spatial-toolbar {
  right: clamp(18px, 2.5vw, 36px);
  top: 50%;
  display: grid;
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(21, 21, 19, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 24px rgba(21, 21, 19, 0.045);
  transform: translateY(-50%);
}

.spatial-toolbar button,
.spatial-pager button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 14px;
  transition: background 160ms ease;
}

.spatial-toolbar button:hover,
.spatial-pager button:hover {
  background: var(--wash);
}

.spatial-pager {
  bottom: clamp(18px, 3vh, 34px);
  left: 50%;
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(21, 21, 19, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 28px rgba(21, 21, 19, 0.06);
  transform: translateX(-50%);
}

.spatial-pager p {
  display: grid;
  min-width: 150px;
  margin: 0;
  padding: 0 10px;
  text-align: center;
}

.spatial-pager p span {
  max-width: 190px;
  overflow: hidden;
  font-size: 10px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spatial-pager p strong {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.06em;
}

.spatial-help {
  bottom: clamp(23px, 3.8vh, 44px);
  left: clamp(22px, 3.4vw, 50px);
  display: flex;
  gap: 18px;
  margin: 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.spatial-help span + span::before {
  margin-right: 18px;
  content: "·";
}

.spatial-status {
  right: clamp(22px, 3.4vw, 50px);
  bottom: clamp(23px, 3.8vh, 44px);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
}

.space-loading,
.space-error {
  position: absolute;
  top: 53%;
  left: 57%;
  display: grid;
  place-items: center;
  text-align: center;
  transform: translate(-50%, -50%);
}

.space-loading span {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(21, 21, 19, 0.14);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.space-loading p,
.space-error > p {
  margin: 14px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.space-error {
  width: min(420px, calc(100vw - 48px));
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}

.space-error h2 {
  margin: 10px 0 22px;
  font-family: var(--display);
  font-size: 30px;
  font-weight: 400;
}

.space-error button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  font-size: 11px;
}

.completion-celebration {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(244, 244, 241, 0.38);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(2px);
  transition: opacity 220ms ease;
}

.completion-celebration.is-active {
  opacity: 1;
}

.completion-fireworks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.completion-message {
  position: relative;
  display: grid;
  min-width: min(270px, calc(100vw - 48px));
  gap: 5px;
  padding: 18px 26px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 18px 50px rgba(21, 21, 19, 0.18);
  text-align: center;
}

.completion-message span {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.15em;
}

.completion-message strong {
  font-size: 17px;
  font-weight: 500;
}

.completion-celebration.is-active .completion-message {
  animation: completion-message 1800ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 5000;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 9px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

@keyframes completion-message {
  0% { opacity: 0; transform: scale(0.82); }
  18%, 72% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}

@media (max-width: 900px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .brand-copy small,
  .header-index {
    display: none;
  }

  .primary-nav {
    justify-self: end;
  }

  .space-intro {
    max-width: 280px;
  }

  .spatial-stage {
    perspective-origin: 50% 54%;
  }

  .spatial-toolbar {
    top: auto;
    right: 18px;
    bottom: 22px;
    display: flex;
    transform: none;
  }

  .spatial-help,
  .spatial-status {
    display: none;
  }
}

@media (max-width: 640px) {
  :root {
    --header-h: 62px;
  }

  .site-header {
    padding: 8px 14px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 10px;
  }

  .brand-copy strong {
    font-size: 12px;
  }

  .primary-nav {
    gap: 2px;
    padding: 3px;
  }

  .primary-nav a {
    min-width: 52px;
    min-height: 30px;
    font-size: 8px;
  }

  .space-intro {
    top: calc(var(--header-h) + 20px);
    left: 18px;
    max-width: calc(100vw - 36px);
  }

  .space-kicker {
    margin-bottom: 8px;
    font-size: 7px;
  }

  .space-intro h1 {
    font-size: 38px;
  }

  .space-meta {
    margin-top: 9px;
    font-size: 8px;
  }

  .space-card {
    width: calc(100vw - 46px);
    min-height: 350px;
    padding: 24px 22px 25px;
    border-radius: 15px;
  }

  .space-card-chrome {
    font-size: 7px;
  }

  .space-card-identity {
    gap: 11px;
    margin-top: 24px;
  }

  .space-avatar {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    font-size: 9px;
  }

  .space-card-identity h2 {
    font-size: 15px;
  }

  .space-card-copy {
    margin: 25px 0 0;
    font-size: 15px;
    line-height: 1.76;
    -webkit-line-clamp: 7;
  }

  .space-card:not(.is-active) .space-card-copy {
    -webkit-line-clamp: 4;
  }

  .space-card-action {
    min-height: 34px;
    font-size: 9px;
  }

  .space-card--archive .space-card-identity {
    margin-top: 34px;
  }

  .space-card--archive .space-card-identity h2 {
    font-size: 29px;
  }

  .space-card--archive .space-card-copy,
  .space-card--builder .space-card-copy {
    margin-left: 0;
  }

  .space-card--builder .space-avatar {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

  .space-card--builder .space-card-identity h2 {
    font-size: 24px;
  }

  .spatial-pager {
    bottom: 14px;
  }

  .spatial-pager p {
    min-width: 126px;
  }

  .spatial-pager p span {
    max-width: 130px;
  }

  .spatial-toolbar {
    top: calc(var(--header-h) + 18px);
    right: 14px;
    bottom: auto;
  }

  .spatial-toolbar button {
    width: 32px;
    height: 32px;
  }

  .spatial-orbit {
    display: none;
  }
}

@media (hover: none) {
  .space-card.is-active .space-card-action {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
}

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

  .completion-fireworks {
    display: none;
  }

  .space-card {
    filter: none !important;
  }
}
