@import url("./tokens.css?v=32");

/* Hallmark · genre: atmospheric · macrostructure: Ecosystem Index · theme: custom
 * vibe: "temple lamp, sindoor bindu, gold leaf, night sanctum"
 * tone: invocatory · nav: N9 · footer: Ft5 · enrichment: E5 lotus + diya
 * designed-as-app · the kula and the field
 * audience: first-time readers of the Mahabharata · use: sit with a name, walk the kula, tie two figures
 */

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

html,
body {
  height: 100%;
  overflow-x: clip;
  overflow-y: clip;
}

html.is-doc,
body.is-doc {
  height: auto;
  min-height: 100%;
  overflow-x: clip;
  overflow-y: auto;
}

body.is-doc {
  overscroll-behavior: auto;
}

html {
  min-height: 100%;
  background: var(--color-paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Touch: no grey flash on tap, and no pull-to-refresh stealing a map drag. */
* {
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color-scheme: dark;
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 400;
  line-height: 1.55;
  font-optical-sizing: auto;
  background-color: var(--color-paper);
  background-image:
    radial-gradient(ellipse 55% 42% at 8% -8%, oklch(58% 0.12 78 / 0.3), transparent 58%),
    radial-gradient(ellipse 48% 38% at 96% 108%, oklch(38% 0.13 32 / 0.24), transparent 55%);
  background-attachment: fixed;
}

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

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

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

a {
  color: inherit;
}

:focus {
  outline: none;
}

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

::selection {
  background: color-mix(in oklch, var(--color-accent) 32%, var(--color-paper));
  color: var(--color-ink);
}

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

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes draw {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes haul {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1.03);
  }
  50% {
    transform: translate3d(-1.1%, 0.35%, 0) scale(1.045);
  }
}

@keyframes flame {
  0%,
  100% {
    opacity: 0.82;
    transform: scaleY(1) scaleX(1);
  }
  50% {
    opacity: 1;
    transform: scaleY(1.12) translateY(-1px) scaleX(0.9);
  }
}

/* ── Masthead (N9 edge-aligned lintel) ──────────────────────────────── */

.mast {
  position: relative;
  z-index: var(--z-sticky);
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-sm);
  align-items: center;
  padding: calc(var(--space-sm) + var(--safe-t)) max(var(--space-md), var(--safe-r)) var(--space-sm)
    max(var(--space-md), var(--safe-l));
  background: color-mix(in oklch, var(--color-paper) 92%, transparent);
  border-bottom: 0;
}

.mast::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--color-accent);
  transform-origin: left center;
  animation: draw 900ms var(--ease-out) both;
  pointer-events: none;
}

.mast::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  height: 1px;
  background: color-mix(in oklch, var(--color-accent) 38%, transparent);
  pointer-events: none;
}

.mast__brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: var(--space-sm);
  align-items: center;
  min-width: 0;
  text-decoration: none;
}

.diya {
  grid-row: 1 / span 2;
  position: relative;
  width: 14px;
  height: 20px;
  flex: none;
}

.diya__bowl {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 12px;
  height: 5px;
  margin-left: -6px;
  border: 1px solid var(--color-accent);
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.diya__flame {
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 5px;
  height: 11px;
  margin-left: -2.5px;
  background: var(--color-accent);
  border-radius: 50% 50% 40% 40%;
  transform-origin: 50% 100%;
  animation: flame 2.4s var(--ease-in-out) infinite;
}

.mast__names {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35em 0.5em;
  min-width: 0;
}

.mast__sa {
  font-family: var(--font-outlier);
  font-style: normal;
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 1;
  color: var(--color-accent);
}

.mast__word {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: var(--text-lg);
  letter-spacing: 0.06em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.mast__issue {
  grid-column: 2;
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.searchpill {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 44px;
  width: 100%;
  padding: 0 var(--space-sm);
  background: var(--color-paper-2);
  border: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 22%, var(--color-rule));
  color: var(--color-muted);
  text-align: left;
}

.searchpill:hover,
.searchpill.is-hover {
  border-color: var(--color-accent);
  color: var(--color-ink);
}

.searchpill:active,
.searchpill.is-active {
  transform: translateY(1px);
}

.searchpill:disabled,
.searchpill.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.searchpill[data-state="loading"] .searchpill__text::after {
  content: " …";
}

.searchpill[data-state="error"] {
  border-color: var(--color-danger);
}

.searchpill[data-state="success"] {
  border-color: var(--color-ok);
}

.searchpill__text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.searchpill__kbd {
  display: none;
  gap: 0.2rem;
  font-family: var(--font-display);
  font-size: var(--text-2xs);
  letter-spacing: 0.06em;
}

.searchpill__kbd kbd {
  display: inline-block;
  padding: 0.1em 0.35em;
  border: var(--rule-hair) solid var(--color-rule);
  background: var(--color-paper);
}

.mast__nav {
  display: none;
  gap: var(--space-md);
  align-items: center;
}

.mast__link {
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: var(--rule-hair) solid transparent;
  background: none;
  padding: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.mast__link:hover,
.mast__link.is-hover {
  border-bottom-color: var(--color-accent);
  color: var(--color-accent);
}

.mast__link.is-on {
  border-bottom-color: var(--color-accent);
  color: var(--color-accent);
}

.mast__link:active,
.mast__link.is-active {
  transform: translateY(1px);
}

.mast__link:disabled,
.mast__link.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Phones: one short lintel. Search and navigation live in the thumb zone instead. */
@media (max-width: 39.99rem) {
  .mast {
    padding-block: calc(var(--space-xs) + var(--safe-t)) var(--space-xs);
  }

  .mast__brand {
    grid-template-rows: auto;
    align-items: center;
  }

  .diya {
    grid-row: auto;
  }

  .mast__sa {
    font-size: 1.15rem;
  }

  .mast__word {
    font-size: var(--text-md);
  }

  .mast__issue {
    display: none;
  }

  .searchpill {
    display: none;
  }
}

@media (min-width: 40rem) {
  .mast {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-inline: max(var(--space-lg), var(--safe-l)) max(var(--space-lg), var(--safe-r));
  }

  .searchpill {
    grid-column: 1 / -1;
  }

  .searchpill__kbd {
    display: inline-flex;
  }
}

@media (min-width: 60rem) {
  .mast {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
  }

  .mast__nav {
    display: flex;
  }

  .searchpill {
    grid-column: 3;
  }

  .mast__map {
    grid-column: 4;
    justify-self: end;
  }
}

/* ── Tab bar: the whole companion within thumb reach ─────────────────── */

.tabbar {
  display: none;
  position: fixed;
  z-index: var(--z-sticky);
  inset: auto 0 0 0;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  padding-bottom: var(--safe-b);
  padding-inline: var(--safe-l) var(--safe-r);
  background: color-mix(in oklch, var(--color-paper) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 30%, var(--color-rule));
}

.tabbar__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-width: 0;
  height: 3.25rem;
  padding: 0 var(--space-2xs);
  color: var(--color-muted);
  text-decoration: none;
}

.tabbar__btn svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabbar__btn span {
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.06em;
  line-height: 1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabbar__btn.is-on {
  color: var(--color-accent);
}

.tabbar__btn:active {
  background: color-mix(in oklch, var(--color-accent) 10%, transparent);
}

@media (max-width: 59.99rem) {
  :root {
    --tabbar-h: 3.25rem;
  }

  .tabbar {
    display: grid;
  }

  .searchpill {
    display: none;
  }
}

/* ── Toolbar: counts + kula strip ──────────────────────────────────────── */

.toolbar {
  flex: none;
  display: grid;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md) var(--space-sm);
  border-bottom: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 18%, var(--color-rule));
  background: color-mix(in oklch, var(--color-paper) 92%, transparent);
}

.toolbar__lead {
  display: grid;
  gap: var(--space-2xs);
  min-width: 0;
}

.toolbar__blurb {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-ink-2);
  max-width: 65ch;
}

.trail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2xs);
  min-width: 0;
}

.trail__k {
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-right: var(--space-2xs);
  white-space: nowrap;
}

.trail__btn {
  font-size: var(--text-xs);
  white-space: nowrap;
  border-bottom: var(--rule-hair) solid var(--color-rule);
  min-height: 44px;
}

.trail__btn:hover,
.trail__btn.is-hover {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.trail__sep {
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.legend {
  display: flex;
  gap: var(--space-2xs);
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.legend::-webkit-scrollbar {
  height: 0;
}

.legend__chip {
  scroll-snap-align: start;
}

body.is-thread .legend {
  display: none;
}

body.is-thread .trail {
  display: none;
}

body.is-thread .toolbar__meta {
  display: none;
}

.legend__chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 44px;
  padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-rule);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: var(--color-paper-2);
}

.legend__chip:hover,
.legend__chip.is-hover {
  border-color: var(--color-accent);
}

.legend__chip:active,
.legend__chip.is-active {
  transform: translateY(1px);
}

.legend__chip.is-on {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border-color: var(--color-accent);
}

.legend__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--tick, var(--color-accent));
}

@media (min-width: 60rem) {
  .toolbar {
    padding-inline: var(--space-lg);
  }

  .legend {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    max-width: none;
  }

  .legend__chip {
    min-height: 36px;
  }
}

/* ── Workbench: full map, card on the canvas ──────────────────────────── */

.bench {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  border-top: 0;
  margin-bottom: var(--tabbar-total);
}

.map {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(color-mix(in oklch, var(--color-accent) 12%, var(--color-rule)) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in oklch, var(--color-accent) 12%, var(--color-rule)) 1px, transparent 1px),
    var(--color-paper-2);
  background-size: 48px 48px;
  background-position: center;
}

.map::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 42%, oklch(8% 0.03 38 / 0.55) 100%);
}

.map canvas {
  cursor: grab;
}

.map.is-on-dot canvas {
  cursor: pointer;
}

.map.is-panning canvas {
  cursor: grabbing;
}

.map canvas {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.map.is-busy .map__status,
.map.is-busy .map__key,
.map.is-busy .map__coach {
  opacity: 0;
}

.map__status,
.map__hint {
  position: absolute;
  z-index: var(--z-raised);
  margin: 0;
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-paper);
  border: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 25%, var(--color-rule));
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  pointer-events: none;
  max-width: min(28rem, calc(100% - 5rem));
}

.map__status {
  top: var(--space-sm);
  left: max(var(--space-sm), var(--safe-l));
  color: var(--color-ink);
}

.map__hint {
  top: calc(var(--space-sm) + 1.85rem);
  left: max(var(--space-sm), var(--safe-l));
}

/* One-time gesture coach, shown only to touch readers. */
.map__coach {
  position: absolute;
  z-index: var(--z-raised);
  left: 50%;
  bottom: calc(var(--space-md) + var(--tabbar-total) + var(--space-xs));
  margin: 0;
  padding: var(--space-xs) var(--space-sm);
  background: color-mix(in oklch, var(--color-paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border: var(--rule-hair) solid var(--color-accent);
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink);
  text-align: center;
  pointer-events: none;
  max-width: calc(100% - 2rem);
  transform: translateX(-50%);
  animation: rise var(--dur-long) var(--ease-out);
  transition: opacity var(--dur-long) var(--ease-out);
}

.map__coach[hidden] {
  display: none;
}

.map__coach.is-fading {
  opacity: 0;
}

.map__tools {
  position: absolute;
  left: max(var(--space-sm), var(--safe-l));
  bottom: max(var(--space-sm), var(--safe-b));
  z-index: var(--z-raised);
  display: flex;
  flex-direction: column;
  background: var(--color-paper);
  border: var(--rule-hair) solid var(--color-accent);
}

.map__tools button {
  width: 44px;
  height: 44px;
  border-bottom: var(--rule-hair) solid var(--color-rule);
  font-family: var(--font-display);
  font-size: var(--text-md);
  line-height: 1;
  color: var(--color-ink);
}

.map__tools button:last-child {
  border-bottom: 0;
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map__tools button:hover,
.map__tools button.is-hover {
  background: var(--color-paper-2);
  color: var(--color-accent);
}

.map__tools button:active,
.map__tools button.is-active {
  transform: translateY(1px);
}

.map__tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: var(--z-tooltip);
  margin: 0;
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-accent);
  color: var(--color-accent-ink);
  font-size: var(--text-xs);
  pointer-events: none;
  white-space: nowrap;
  max-width: min(20rem, 70vw);
  overflow: hidden;
  text-overflow: ellipsis;
}

.map__tip[hidden] {
  display: none;
}

.map__key {
  position: absolute;
  right: max(var(--space-sm), var(--safe-r));
  bottom: max(var(--space-sm), var(--safe-b));
  z-index: var(--z-raised);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-xs);
  margin: 0;
  pointer-events: none;
}

.map__key[hidden] {
  display: none;
}

.map__swatch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-paper);
  border: var(--rule-hair) solid var(--color-rule);
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.map__swatch::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--tick);
}

.map__swatch--you::before {
  background: var(--color-accent);
}

.map__swatch--family::before {
  background: var(--color-ink);
}

.map__swatch--taught::before {
  background: var(--color-related);
}

.map__swatch--kin::before {
  background: var(--color-paper);
  border: 1.5px solid var(--color-related);
  box-sizing: border-box;
}

.card {
  position: absolute;
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(ellipse 90% 50% at 0% 0%, oklch(70% 0.12 82 / 0.1), transparent 55%),
    var(--color-paper-2);
  border: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 45%, var(--color-rule));
  box-shadow:
    0 0 0 1px color-mix(in oklch, var(--color-accent) 18%, transparent),
    0 24px 48px oklch(8% 0.04 38 / 0.55);
  overflow: hidden;
  inset: auto var(--space-sm) var(--space-sm) var(--space-sm);
  max-height: min(42dvh, 24rem);
  animation: rise var(--dur-short) var(--ease-out);
}

.card[hidden],
.desk[hidden],
.toolbar[hidden],
.threadbar[hidden],
.bench[hidden],
.trail[hidden],
.map__key[hidden],
.map__tip[hidden] {
  display: none;
}

.card__grab {
  display: none;
}

.card__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-xs);
  align-items: start;
  padding: var(--space-md) var(--space-md) var(--space-sm);
  border-bottom: var(--rule-hair) solid var(--color-rule);
  background: transparent;
}

.card__kicker {
  margin: 0 0 var(--space-2xs);
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.card__name {
  margin: 0;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  font-size: var(--text-xl);
  line-height: 1.12;
  overflow-wrap: anywhere;
  min-width: 0;
}

.card__aliases {
  margin: var(--space-2xs) 0 0;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.card__titles {
  margin: var(--space-3xs) 0 0;
  font-size: var(--text-xs);
}

.card__close {
  position: relative;
  width: 44px;
  height: 44px;
  margin: -0.4rem -0.4rem 0 0;
  color: var(--color-muted);
  font-family: var(--font-display);
  font-size: var(--text-md);
  line-height: 1;
}

.card__close::before {
  content: "";
  position: absolute;
  inset: 0;
}

.card__close:hover,
.card__close.is-hover {
  color: var(--color-accent);
}

.card__close:active,
.card__close.is-active {
  transform: translateY(1px);
}

.card__close:disabled,
.card__close.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card__body {
  min-width: 0;
  overflow: auto;
  padding: var(--space-sm) var(--space-md) var(--space-lg);
  overscroll-behavior: contain;
}

.card__who {
  margin: 0;
  font-size: var(--text-md);
  line-height: 1.45;
}

.card__when {
  margin: var(--space-sm) 0 0;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.card__when strong {
  display: block;
  margin-bottom: var(--space-3xs);
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-related-ink);
}

.card__note {
  margin: var(--space-sm) 0 0;
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}

.map.is-reading .map__tools {
  bottom: calc(min(42dvh, 24rem) + var(--space-md));
}

@media (min-width: 40rem) {
  .card {
    inset: var(--space-lg) var(--space-lg) auto auto;
    width: min(22rem, calc(100% - 3rem));
    max-height: calc(100% - 3rem);
  }

  .map.is-reading .map__tools {
    bottom: var(--space-sm);
  }

  .map.is-reading .map__key {
    display: flex;
    right: calc(23rem + var(--space-lg));
  }
}

.rel {
  margin: var(--space-md) 0 0;
}

.rel__h {
  margin: 0 0 var(--space-xs);
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.rel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.rel--pills .rel__list {
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--space-2xs);
}

.rel--story .rel__h {
  color: var(--color-related-ink);
}

.rel__btn {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: var(--space-2xs) 0;
  text-align: left;
  border-bottom: var(--rule-hair) solid var(--color-rule);
  font-size: var(--text-sm);
}

.rel--pills .rel__btn {
  width: auto;
  min-height: 44px;
  padding: 0.4rem 0.7rem;
  border: var(--rule-hair) solid var(--color-rule);
  background: var(--color-paper);
  font-size: var(--text-xs);
}

.rel__name {
  display: block;
}

.rel__sub {
  display: block;
  margin-top: var(--space-3xs);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.rel__btn:hover,
.rel__btn.is-hover {
  color: var(--color-accent);
}

.rel--pills .rel__btn:hover,
.rel--pills .rel__btn.is-hover {
  border-color: var(--color-accent);
  background: var(--color-paper-2);
}

.rel__btn:hover .rel__sub,
.rel__btn.is-hover .rel__sub {
  color: var(--color-accent);
}

.rel__btn:active,
.rel__btn.is-active {
  transform: translateY(1px);
}

.rel__btn:disabled,
.rel__btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rel__more {
  margin: var(--space-xs) 0 0;
  color: var(--color-accent);
  font-size: var(--text-xs);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.rel__more:hover,
.rel__more.is-hover {
  color: var(--color-ink);
}

.rel__empty {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.card__onward {
  margin: var(--space-sm) 0 0;
  font-size: var(--text-sm);
}

.card__next {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  white-space: nowrap;
}

.card__next:hover,
.card__next.is-hover {
  color: var(--color-ink);
}

.card__onward-note {
  display: block;
  margin-top: var(--space-3xs);
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.card__actions {
  margin: var(--space-sm) 0 0;
}

.card__tie {
  min-height: 44px;
  padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-accent);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.card__tie:hover,
.card__tie.is-hover {
  background: color-mix(in oklch, var(--color-accent) 12%, transparent);
  color: var(--color-accent);
}

.card__tie:active,
.card__tie.is-active {
  transform: translateY(1px);
}

.card__tie:disabled,
.card__tie.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Desk (Ecosystem Index) ─────────────────────────────────────────── */

.desk {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding: 0;
  scroll-padding-bottom: var(--tabbar-total);
  -webkit-overflow-scrolling: touch;
}

.desk__hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.desk__hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: min(42vh, 18rem);
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 48%, var(--color-paper) 100%);
}

.desk__scene {
  position: relative;
  z-index: 0;
  flex: none;
  height: min(42vh, 18rem);
  overflow: hidden;
  pointer-events: none;
}

.desk__sketch {
  position: absolute;
  top: 0;
  right: -12%;
  height: 108%;
  width: auto;
  max-width: none;
  min-width: 125%;
  object-fit: cover;
  object-position: 82% 30%;
  mix-blend-mode: screen;
  opacity: 0.9;
  animation: haul 18s var(--ease-in-out) infinite;
  -webkit-mask-image: linear-gradient(180deg, black 0%, black 68%, transparent 100%);
  mask-image: linear-gradient(180deg, black 0%, black 68%, transparent 100%);
}

.desk__intro {
  position: relative;
  z-index: 2;
  max-width: none;
  padding: var(--space-md) var(--space-md) var(--space-xl);
  animation: rise var(--dur-long) var(--ease-out);
  background: var(--color-paper);
}

.desk__bless {
  margin: 0 0 var(--space-2xs);
  font-family: var(--font-outlier);
  font-size: var(--text-sm);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.desk__kicker {
  margin: var(--space-md) 0 0;
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.desk__title {
  margin: 0;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: var(--text-display);
  line-height: 1.08;
  overflow-wrap: anywhere;
  min-width: 0;
  color: var(--color-ink);
}

.desk__lede {
  margin: var(--space-md) 0 0;
  font-size: var(--text-md);
  line-height: 1.55;
  max-width: 52ch;
  color: var(--color-ink-2);
}

.desk__cast {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  margin-top: var(--space-md);
}

.desk__cast button,
.desk__cast a {
  min-height: 44px;
  padding: 0 var(--space-sm);
  border: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 40%, var(--color-rule));
  background: color-mix(in oklch, var(--color-paper) 70%, transparent);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.desk__cast button:hover,
.desk__cast button.is-hover,
.desk__cast a:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.desk__cast button:active,
.desk__cast button.is-active {
  transform: translateY(1px);
}

.desk__body {
  position: relative;
  z-index: 1;
  padding: 0 max(var(--space-md), var(--safe-r)) calc(var(--space-2xl) + var(--tabbar-total))
    max(var(--space-md), var(--safe-l));
}

.desk__rail {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 22%, var(--color-rule));
}

.desk__h {
  margin: 0;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: var(--text-lg);
  overflow-wrap: anywhere;
}

.desk__sub {
  margin: var(--space-2xs) 0 var(--space-md);
  color: var(--color-muted);
  font-size: var(--text-sm);
  max-width: 55ch;
}

.days {
  display: grid;
  gap: var(--space-2xs);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: none;
}

.days li {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: var(--space-sm);
  align-items: baseline;
  min-height: 44px;
  padding: 0.35rem 0;
  border-bottom: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 14%, var(--color-rule));
}

.days a {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: var(--space-sm);
  align-items: baseline;
  min-height: 44px;
  text-decoration: none;
  color: inherit;
}

.days a:hover .days__t {
  color: var(--color-accent);
}

.days li:last-child {
  border-bottom: 0;
}

.days__n {
  font-family: var(--font-outlier);
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  color: var(--color-accent);
}

.days__t {
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}

@media (min-width: 40rem) {
  .days {
    grid-template-columns: 1fr 1fr;
    column-gap: var(--space-lg);
  }

  .days li:nth-child(9),
  .days li:nth-child(18) {
    border-bottom: 0;
  }
}

@media (min-width: 60rem) {
  .days {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .days li:nth-child(9),
  .days li:nth-child(18) {
    border-bottom: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 14%, var(--color-rule));
  }

  .days li:nth-child(6),
  .days li:nth-child(12),
  .days li:nth-child(18) {
    border-bottom: 0;
  }
}

.uselist {
  display: grid;
  gap: var(--space-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}

.uselist > li {
  display: grid;
}

.usestep {
  position: relative;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: var(--space-sm);
  padding: var(--space-md);
  border: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 22%, var(--color-rule));
  background: var(--color-paper-2);
  animation: rise var(--dur-long) var(--ease-out);
}

.uselist li:nth-child(1) .usestep {
  animation-delay: 40ms;
}

.uselist li:nth-child(2) .usestep {
  animation-delay: 80ms;
}

.uselist li:nth-child(3) .usestep {
  animation-delay: 120ms;
}

.usestep--lead {
  border-color: color-mix(in oklch, var(--color-accent) 55%, var(--color-rule));
  background:
    radial-gradient(ellipse 80% 80% at 0% 0%, oklch(70% 0.12 82 / 0.1), transparent 50%),
    var(--color-paper-2);
}

.usestep__n {
  font-family: var(--font-outlier);
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  color: var(--color-accent);
}

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

.usestep__title {
  margin: 0;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  font-size: var(--text-lg);
  overflow-wrap: anywhere;
}

.usestep__lede {
  margin: var(--space-2xs) 0 0;
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}

.usestep__do {
  margin: auto 0 0;
  padding-top: var(--space-sm);
}

.usestep__do button,
.usestep__do a {
  min-height: 44px;
  padding: 0 var(--space-sm);
  border: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 40%, var(--color-rule));
  background: color-mix(in oklch, var(--color-paper) 70%, transparent);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.usestep__do button:hover,
.usestep__do button.is-hover,
.usestep__do a:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.usestep__do button:active,
.usestep__do button.is-active {
  transform: translateY(1px);
}

.namelist,
.kulalist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2xs);
}

a.namecard,
a.kulacard {
  text-decoration: none;
  color: inherit;
}

.namecard,
.kulacard {
  display: grid;
  gap: var(--space-3xs);
  width: 100%;
  min-height: 44px;
  padding: var(--space-sm);
  text-align: left;
  border: var(--rule-hair) solid var(--color-rule);
  background: var(--color-paper-2);
}

.namecard__name,
.kulacard__name {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.namecard__who,
.kulacard__blurb {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.kulacard {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--space-sm);
}

.kulacard__copy {
  min-width: 0;
}

.namecard:hover,
.namecard.is-hover,
.kulacard:hover,
.kulacard.is-hover {
  border-color: var(--color-accent);
}

.namecard:active,
.kulacard:active {
  transform: translateY(1px);
}

.desk__colophon {
  margin: var(--space-2xl) 0 0;
  padding-top: var(--space-lg);
  border-top: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 22%, var(--color-rule));
  font-size: var(--text-sm);
  color: var(--color-muted);
  max-width: 55ch;
}

.desk__colophon a {
  color: var(--color-accent);
  text-underline-offset: 0.15em;
}

.desk__host {
  font-family: var(--font-outlier);
  letter-spacing: 0.04em;
  color: var(--color-accent);
}

.desk__colophon a:hover {
  color: var(--color-ink);
}

@media (min-width: 40rem) {
  .desk__intro {
    padding-inline: var(--space-lg);
  }

  .desk__body {
    padding-inline: max(var(--space-lg), var(--safe-l)) max(var(--space-lg), var(--safe-r));
  }

  .desk__scene,
  .desk__hero::after {
    height: min(44vh, 22rem);
  }

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

@media (min-width: 60rem) {
  .desk__hero {
    display: grid;
    min-height: min(82dvh, 46rem);
    align-items: start;
  }

  .desk__hero::after {
    inset: 0;
    height: auto;
    background:
      linear-gradient(
        90deg,
        var(--color-paper) 0%,
        color-mix(in oklch, var(--color-paper) 94%, transparent) 26%,
        color-mix(in oklch, var(--color-paper) 42%, transparent) 52%,
        transparent 72%
      ),
      linear-gradient(
        180deg,
        var(--color-paper) 0%,
        transparent 18%,
        transparent 78%,
        var(--color-paper) 100%
      );
  }

  .desk__scene {
    position: absolute;
    inset: 0;
    height: auto;
  }

  .desk__sketch {
    top: 0;
    right: -2%;
    min-width: 68%;
    height: 108%;
    object-position: 78% 42%;
    opacity: 0.86;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 48%);
    mask-image: linear-gradient(90deg, transparent 0%, black 48%);
  }

  .desk__intro {
    max-width: 30rem;
    padding-inline: var(--space-xl);
    padding-block: var(--space-2xl);
    background: linear-gradient(
      90deg,
      var(--color-paper) 0%,
      color-mix(in oklch, var(--color-paper) 80%, transparent) 72%,
      transparent 100%
    );
  }

  .desk__body {
    padding-inline: var(--space-xl);
    padding-bottom: var(--space-3xl);
  }

  .desk__lede {
    max-width: 42ch;
  }

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

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

/* ── Thread bar ─────────────────────────────────────────────────────────── */

.threadbar {
  flex: none;
  display: grid;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: var(--color-paper-2);
  color: var(--color-ink);
  border-bottom: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 40%, var(--color-rule));
}

.threadbar__kicker {
  margin: 0;
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.threadbar__title {
  margin: 0;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  font-size: var(--text-md);
  overflow-wrap: anywhere;
}

.threadbar__count {
  margin: 0;
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.threadbar__nav {
  display: flex;
  gap: var(--space-2xs);
}

.threadbar__nav button {
  min-height: 44px;
  padding: 0 var(--space-sm);
  border: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 35%, var(--color-rule));
  color: var(--color-ink);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.threadbar__nav button:hover,
.threadbar__nav button.is-hover {
  background: color-mix(in oklch, var(--color-accent) 12%, transparent);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.threadbar__nav button:active,
.threadbar__nav button.is-active {
  transform: translateY(1px);
}

.threadbar__nav button:disabled,
.threadbar__nav button.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (min-width: 40rem) {
  .threadbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    padding-inline: var(--space-lg);
  }
}

@media (max-width: 39.99rem) {
  /* The in-map status chip already names the kula and the count, so drop the
     duplicate row and give the canvas the height back. */
  .toolbar {
    padding: var(--space-2xs) max(var(--space-md), var(--safe-l)) var(--space-2xs)
      max(var(--space-md), var(--safe-r));
  }

  .toolbar__lead {
    display: none;
  }

  .trail {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }

  .trail::-webkit-scrollbar {
    height: 0;
  }

  .trail__btn {
    min-height: 34px;
  }

  .legend__chip {
    min-height: 38px;
    font-size: var(--text-2xs);
  }

  .threadbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: var(--space-2xs) max(var(--space-md), var(--safe-l)) var(--space-2xs)
      max(var(--space-md), var(--safe-r));
  }

  .threadbar__title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .threadbar__count {
    display: none;
  }

  .threadbar__nav {
    display: flex;
    gap: var(--space-2xs);
  }

  .threadbar__nav button {
    min-width: 0;
    min-height: 40px;
    padding-inline: var(--space-2xs);
  }

  .map__status {
    display: none;
  }

  .map__hint {
    display: none;
  }

  .map__tools {
    flex-direction: row;
    left: auto;
    right: max(var(--space-sm), var(--safe-r));
    top: var(--space-sm);
    bottom: auto;
  }

  .map__tools button {
    width: 40px;
    height: 40px;
    border-bottom: 0;
    border-right: var(--rule-hair) solid var(--color-rule);
  }

  .map__tools button:last-child {
    border-right: 0;
  }

  .map.is-reading .map__tools {
    left: auto;
    right: max(var(--space-sm), var(--safe-r));
    top: var(--space-sm);
    bottom: auto;
  }

  .map.is-reading .map__key {
    display: none;
  }

  .desk__scene,
  .desk__hero::after {
    height: min(28vh, 11rem);
  }

  .desk {
    overscroll-behavior: contain;
  }

  /* ── The card becomes a draggable sheet ─────────────────────────────── */

  .card {
    inset: var(--space-xs) 0 0 0;
    max-height: none;
    border-inline: 0;
    border-bottom: 0;
    border-top-color: var(--color-accent);
    animation: none;
    transform: translateY(var(--sheet-y, 100%));
    transition: transform var(--dur-short) var(--ease-out);
    will-change: transform;
  }

  .card.is-dragging {
    transition: none;
  }

  .card__grab {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 100%;
    height: 1.75rem;
    touch-action: none;
    cursor: grab;
  }

  .card__grab::before {
    content: "";
    width: 2.5rem;
    height: 3px;
    background: color-mix(in oklch, var(--color-accent) 60%, var(--color-rule));
  }

  .card.is-dragging .card__grab {
    cursor: grabbing;
  }

  .card__head {
    padding-top: var(--space-2xs);
    touch-action: none;
  }

  .card__name {
    font-size: var(--text-lg);
  }

  .card.is-peek .card__body {
    overflow: hidden;
  }

  .card__body {
    padding-bottom: calc(var(--space-xl) + var(--tabbar-total));
  }
}

/* iPad and landscape phones: keep zoom keys off the tab bar. */
@media (min-width: 40rem) and (max-width: 59.99rem) {
  .map__hint {
    display: none;
  }

  .map__status {
    display: none;
  }

  .map__tools {
    flex-direction: row;
    left: auto;
    right: max(var(--space-sm), var(--safe-r));
    top: var(--space-sm);
    bottom: auto;
  }

  .map__tools button {
    width: 40px;
    height: 40px;
    border-bottom: 0;
    border-right: var(--rule-hair) solid var(--color-rule);
  }

  .map__tools button:last-child {
    border-right: 0;
  }

  .map.is-reading .map__tools {
    left: max(var(--space-sm), var(--safe-l));
    right: auto;
    top: var(--space-sm);
    bottom: auto;
  }

  .map.is-reading .map__key {
    display: none;
  }

  .toolbar__lead {
    display: none;
  }
}

/* Landscape handheld: reading sits beside the map instead of eating the height. */
@media (max-height: 32rem) and (min-width: 40rem) and (max-width: 59.99rem) {
  :root {
    --tabbar-h: 2.6rem;
  }

  .mast {
    padding-block: calc(2px + var(--safe-t)) 2px;
  }

  .mast__issue {
    display: none;
  }

  .toolbar {
    padding-block: 0;
  }

  .trail {
    display: none;
  }

  .legend__chip {
    min-height: 32px;
  }

  .threadbar {
    padding-block: 2px;
  }

  .tabbar__btn {
    height: 2.6rem;
  }

  .card {
    inset: 0 0 0 auto;
    width: min(22rem, 42vw);
    max-height: none;
    height: 100%;
    transform: none;
    border: 0;
    border-left: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 45%, var(--color-rule));
    animation: rise var(--dur-short) var(--ease-out);
  }

  .card__grab {
    display: none;
  }

  .card__head {
    padding: var(--space-xs) var(--space-sm);
  }

  .card__name {
    font-size: var(--text-md);
  }

  .card__body {
    padding: var(--space-xs) var(--space-sm) var(--space-md);
  }

  .map.is-reading .map__tools {
    left: max(var(--space-sm), var(--safe-l));
    right: auto;
  }
}

/* ── Tie names ───────────────────────────────────────────────────────── */

.tie {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-short) var(--ease-out), visibility var(--dur-short);
}

.tie.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.tie__backdrop {
  position: absolute;
  inset: 0;
  background: oklch(8% 0.03 38 / 0.72);
}

.tie__panel {
  position: absolute;
  top: max(8vh, 7.25rem);
  left: 50%;
  width: min(36rem, calc(100vw - 2rem));
  max-height: 80dvh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background:
    radial-gradient(ellipse 80% 40% at 0% 0%, oklch(70% 0.12 82 / 0.1), transparent 50%),
    var(--color-paper-2);
  border: 1px solid var(--color-accent);
  transform: translateX(-50%) translateY(-8px);
  transition: transform var(--dur-short) var(--ease-out);
}

.tie.is-open .tie__panel {
  transform: translateX(-50%) translateY(0);
}

.tie__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-xs);
  align-items: start;
}

.tie__kicker {
  margin: 0;
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
  grid-column: 1;
}

.tie__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  font-size: var(--text-xl);
  grid-column: 1;
  overflow-wrap: anywhere;
}

.tie__head .card__close {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.tie__lede {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-muted);
  max-width: 55ch;
}

.tie__picks {
  display: grid;
  gap: var(--space-xs);
  align-items: center;
}

.tie__pick {
  min-height: 44px;
  padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-rule);
  background: var(--color-paper);
  text-align: left;
  font-size: var(--text-sm);
}

.tie__pick.is-set {
  border-color: var(--color-accent);
  font-family: var(--font-display);
  font-weight: 700;
}

.tie__pick:hover,
.tie__pick.is-hover {
  border-color: var(--color-accent);
}

.tie__to {
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
  text-align: center;
}

.tie__empty {
  margin: var(--space-sm) 0 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.path {
  list-style: none;
  margin: var(--space-sm) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-xs);
}

.path__hop {
  display: grid;
  gap: var(--space-3xs);
}

.path__rel {
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-related-ink);
}

.path__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-md);
  text-align: left;
  border-bottom: var(--rule-hair) solid var(--color-rule);
  min-height: 44px;
}

.path__name:hover,
.path__name.is-hover {
  color: var(--color-accent);
}

.path__count {
  margin: var(--space-sm) 0 0;
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

@media (min-width: 40rem) {
  .tie__picks {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }
}

@media (max-width: 39.99rem) {
  .tie__panel {
    top: 0;
    left: 0;
    width: 100%;
    max-height: none;
    height: calc(100dvh - var(--kb-h, 0px));
    padding: calc(var(--space-md) + var(--safe-t)) max(var(--space-md), var(--safe-r))
      calc(var(--space-lg) + var(--safe-b)) max(var(--space-md), var(--safe-l));
    transform: none;
    border: 0;
    overscroll-behavior: contain;
  }

  .tie.is-open .tie__panel {
    transform: none;
  }

  .tie__pick {
    min-height: 52px;
  }
}

/* ── Command palette ──────────────────────────────────────────────────── */

.cmdk {
  position: fixed;
  inset: 0;
  z-index: var(--z-toast);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-short) var(--ease-out), visibility var(--dur-short);
}

.cmdk.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.cmdk__backdrop {
  position: absolute;
  inset: 0;
  background: oklch(8% 0.03 38 / 0.72);
}

.cmdk__panel {
  position: absolute;
  top: max(8vh, 7.25rem);
  left: 50%;
  width: min(36rem, calc(100vw - 2rem));
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 80% 40% at 0% 0%, oklch(70% 0.12 82 / 0.1), transparent 50%),
    var(--color-paper-2);
  border: 1px solid var(--color-accent);
  transform: translateX(-50%) translateY(-8px);
  transition: transform var(--dur-short) var(--ease-out);
}

.cmdk.is-open .cmdk__panel {
  transform: translateX(-50%) translateY(0);
}

.cmdk__field {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-bottom: var(--rule-hair) solid var(--color-rule);
}

.cmdk__field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  min-height: 44px;
}

.cmdk__field kbd {
  font-family: var(--font-display);
  font-size: var(--text-2xs);
  padding: 0.15em 0.4em;
  border: var(--rule-hair) solid var(--color-rule);
}

.cmdk__results {
  overflow: auto;
  flex: 1;
  padding: var(--space-xs) 0;
}

.cmdk__group {
  margin: var(--space-sm) var(--space-md) var(--space-2xs);
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.cmdk__item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3xs);
  width: 100%;
  min-height: 44px;
  padding: var(--space-xs) var(--space-md);
  text-align: left;
}

.cmdk__item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cmdk__item:hover,
.cmdk__item.is-hover,
.cmdk__item.is-active {
  background: color-mix(in oklch, var(--color-accent) 8%, transparent);
}

.cmdk__item small {
  color: var(--color-muted);
  font-size: var(--text-xs);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.cmdk__none {
  margin: var(--space-lg);
  color: var(--color-muted);
}

.cmdk__foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-xs) var(--space-md);
  border-top: var(--rule-hair) solid var(--color-rule);
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.cmdk__foot kbd {
  border: var(--rule-hair) solid var(--color-rule);
  padding: 0 0.3em;
}

@media (max-width: 39.99rem) {
  /* --kb-h tracks the on-screen keyboard via visualViewport, so results are
     never buried under it. */
  .cmdk__panel {
    top: 0;
    left: 0;
    width: 100%;
    max-height: none;
    height: calc(100dvh - var(--kb-h, 0px));
    padding-top: var(--safe-t);
    transform: none;
    border: 0;
  }

  .cmdk.is-open .cmdk__panel {
    transform: none;
  }

  .cmdk__field {
    padding-inline: max(var(--space-md), var(--safe-l)) max(var(--space-md), var(--safe-r));
  }

  .cmdk__results {
    padding-bottom: calc(var(--space-lg) + var(--safe-b));
    overscroll-behavior: contain;
  }

  .cmdk__item {
    min-height: 56px;
    padding-inline: max(var(--space-md), var(--safe-l)) max(var(--space-md), var(--safe-r));
  }

  .cmdk__field kbd {
    display: none;
  }

  .cmdk__field input {
    font-size: 16px;
  }

  .cmdk__foot {
    display: none;
  }
}

/* ── Reduced motion ───────────────────────────────────────────────────── */

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

  .cmdk,
  .cmdk__panel,
  .tie,
  .tie__panel {
    transition: opacity 150ms linear;
  }

  .diya__flame,
  .mast::after,
  .desk__sketch {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
}

/* ── Document pages ───────────────────────────────────────────────────── */

.page {
  flex: 1;
  width: min(46rem, calc(100% - 2 * max(var(--space-md), var(--safe-l))));
  margin: 0 auto;
  padding: var(--space-lg) 0 calc(var(--space-3xl) + var(--tabbar-total));
}

.page__head {
  margin-bottom: var(--space-lg);
}

.page__kicker {
  margin: 0 0 var(--space-2xs);
  font-family: var(--font-outlier);
  font-size: var(--text-2xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.page__lede {
  margin: var(--space-md) 0 0;
  font-size: var(--text-md);
  color: var(--color-ink-2);
  max-width: 52ch;
}

.page__cta {
  margin-top: var(--space-lg);
}

.mapcta {
  margin: 0 0 var(--space-lg);
}

.mapcta--hero {
  margin: var(--space-md) 0 0;
}

.mapcta--bottom {
  margin: var(--space-xl) 0 0;
}

.mapcta a,
.mast__map {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 var(--space-md);
  border: var(--rule-hair) solid var(--color-accent);
  background: color-mix(in oklch, var(--color-accent) 16%, var(--color-paper));
  color: var(--color-accent);
  text-decoration: none;
  letter-spacing: 0.03em;
  font-size: var(--text-sm);
}

.mapcta a:hover,
.mast__map:hover {
  background: color-mix(in oklch, var(--color-accent) 28%, var(--color-paper));
  color: var(--color-accent);
}

.mapcta a:active,
.mast__map:active {
  transform: translateY(1px);
}

.mast__map {
  min-height: 40px;
  padding: 0 var(--space-sm);
  font-size: var(--text-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  justify-self: end;
}

.mast__map-full {
  display: none;
}

.mast__map-short {
  display: inline;
}

@media (min-width: 28rem) {
  .mast__map-full {
    display: inline;
  }

  .mast__map-short {
    display: none;
  }
}

.page__cta a,
.prose a,
.crumbs a,
.sitefoot a,
.plainlist a,
.castlist a,
.warlist a,
.reltable a,
.fallback a {
  color: var(--color-accent);
}

.desk__strap {
  margin: var(--space-sm) 0 0;
  color: var(--color-muted);
  font-family: var(--font-display);
  font-style: italic;
}

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  margin: 0 0 var(--space-md);
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.crumbs li:not(:last-child)::after {
  content: "·";
  margin-left: 0.6rem;
  color: var(--color-rule-2);
}

.prose p,
.prose li {
  max-width: 60ch;
}

.prose h2,
.page h2 {
  margin: var(--space-xl) 0 var(--space-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-lg);
}

.timeline,
.castlist,
.warlist,
.plainlist {
  margin: 0;
  padding: 0 0 0 1.1rem;
}

.warlist {
  list-style: none;
  padding: 0;
}

.warlist > li {
  padding: var(--space-md) 0;
  border-bottom: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 16%, var(--color-rule));
}

.warlist h2 {
  margin: 0 0 var(--space-xs);
}

.aliases,
.titles,
.byline {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.sitefoot {
  margin-top: var(--space-2xl);
  padding-top: var(--space-lg);
  border-top: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 22%, var(--color-rule));
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.reltable {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.reltable th,
.reltable td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.4rem;
  border-bottom: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 14%, var(--color-rule));
}

.fallback {
  margin: var(--space-lg) 0;
}

.fallback summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.tree-download {
  margin: var(--space-lg) 0;
}

.tree-download img {
  width: 100%;
  height: auto;
  background: var(--color-paper-2);
}

.tree-download figcaption {
  margin-top: var(--space-xs);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

body.is-tree .tree-intro,
body.is-tree .tree-after {
  width: min(46rem, calc(100% - 2 * max(var(--space-md), var(--safe-l))));
  margin: 0 auto;
}

body.is-tree .tree-intro {
  padding: var(--space-md) 0 var(--space-sm);
}

body.is-tree .tree-intro .page__head {
  margin-bottom: var(--space-sm);
}

body.is-tree .tree-intro .page__lede {
  margin-top: var(--space-xs);
}

body.is-tree .tree-after {
  padding: var(--space-lg) 0 calc(var(--space-2xl) + var(--tabbar-total));
}

body.is-tree .bench {
  min-height: min(78vh, 56rem);
  width: 100%;
  margin-bottom: 0;
}

body.is-tree #toolbar,
body.is-tree #bench {
  position: relative;
}

a.rel__btn,
a.card__next,
a.path__name,
a.trail__btn,
a.legend__chip {
  text-decoration: none;
  color: inherit;
}

.mast__nav {
  flex-wrap: wrap;
}
