:root {
  --paper: #f3efe6;
  --paper-2: #efe8d9;
  --ink: #1c1915;
  --muted: #6d665c;
  --line: #ddd4c6;
  --moss: #12b5a7;
  --ash: #1c1915;
  --food: #2f6a45;
  --hazard: #8a3030;
  --unknown: #b7ad9c;
  --energy: #c45c26;
  --integrity: #2f6a45;
  --uncertainty: #3e4e7a;
  --tab-h: 3.65rem;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Figtree, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

#app {
  min-height: 100dvh;
  min-height: 100svh;
}

.shell {
  max-width: 42rem;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(0.55rem, env(safe-area-inset-top)) 1rem calc(var(--tab-h) + env(safe-area-inset-bottom) + 1.25rem);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Newsreader, Georgia, serif;
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.lede {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 22rem;
}

.tick {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  padding-top: 0.35rem;
}

.paused-note {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.toolbar button,
.ask button {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 0.42rem 0.8rem;
  font-size: 0.86rem;
  font-weight: 500;
}

.toolbar button.ghost,
.ask button.ghost {
  background: transparent;
  color: var(--ink);
}

.toolbar button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.toolbar button:disabled {
  opacity: 0.4;
}

.view-switch {
  display: flex;
  gap: 0;
  margin: 0 0 0.75rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
}

.view-switch button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 0.4rem 0.85rem;
  font-size: 0.86rem;
  font-weight: 500;
}

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

.view-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.world-wrap {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.65rem;
  max-width: 17.5rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  gap: 3px;
  aspect-ratio: 1;
  width: 100%;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 4px;
  background: #e7dfd0;
}

.cell.wall {
  background: #cbbda6;
}

.cell.food .mark:not(.creature) {
  width: 38%;
  height: 38%;
  border-radius: 3px;
  background: var(--food);
}

.cell.hazard .mark:not(.creature) {
  width: 42%;
  height: 42%;
  background: var(--hazard);
  transform: rotate(45deg);
}

.cell.unknown {
  background: repeating-linear-gradient(
    -45deg,
    #e7dfd0,
    #e7dfd0 3px,
    #ddd3c3 3px,
    #ddd3c3 6px
  );
}

.cell.mismatch {
  outline: 2px solid var(--energy);
  outline-offset: -1px;
}

.mark {
  display: block;
  pointer-events: none;
}

.creature {
  width: 54%;
  height: 54%;
  border-radius: 50%;
  background: var(--ash);
  --pulse: var(--ink);
}

.creature.moss {
  background: var(--moss);
  --pulse: var(--moss);
}

.creature.calling,
.creature.helping {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pulse) 35%, transparent);
}

.being.calling h2 .dot,
.being.helping h2 .dot {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pulse) 22%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
  .creature.calling,
  .creature.helping,
  .being.calling h2 .dot,
  .being.helping h2 .dot {
    animation: call-pulse 1.1s ease-out infinite;
  }
}

@keyframes call-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--pulse) 40%, transparent);
  }
  100% {
    box-shadow: 0 0 0 8px transparent;
  }
}

.cell .marks {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
}

.cell .marks .creature {
  width: 42%;
  height: 42%;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.swatch {
  width: 0.6rem;
  height: 0.6rem;
  background: var(--ink);
  border-radius: 50%;
}

.swatch.moss {
  background: var(--moss);
}

.swatch.food {
  border-radius: 2px;
  background: var(--food);
}

.swatch.hazard {
  background: var(--hazard);
  transform: rotate(45deg);
  border-radius: 1px;
}

.hint {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.meters {
  display: grid;
  gap: 0.4rem;
  margin: 0.7rem 0 0.35rem;
}

.meter header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}

.meter header span:last-child {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.track {
  height: 0.42rem;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.fill {
  display: block;
  height: 100%;
  width: 0;
  max-width: 100%;
  background: var(--accent);
}

.fill.valence {
  background: var(--ink);
}

.fill.energy {
  background: var(--energy);
}

.fill.integrity {
  background: var(--integrity);
}

.fill.uncertainty {
  background: var(--uncertainty);
}

.fill.connection {
  background: var(--moss);
}

.pair {
  display: grid;
  gap: 1rem;
}

.being {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.being h2 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: none;
  letter-spacing: 0;
  font-family: Newsreader, Georgia, serif;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--ink);
}

.being h2 .dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--ash);
  --pulse: var(--ink);
}

.being.moss h2 .dot {
  background: var(--moss);
  --pulse: var(--moss);
}

.being.collapsed p {
  color: var(--hazard);
}

.relation {
  margin: 0 0 0.75rem;
  font-family: Newsreader, Georgia, serif;
  font-size: 1.02rem;
}

.thought {
  margin-bottom: 0.35rem;
}

.thought h2,
.panel h2,
.ideas h2 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.thought p,
.answer p {
  margin: 0;
  font-family: Newsreader, Georgia, serif;
  font-size: 1.02rem;
  line-height: 1.35;
}

.collapsed .thought p {
  color: var(--hazard);
}

.ask {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.55rem 0 0;
}

.ask input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
}

.ask button {
  flex: none;
}

.answer {
  margin-top: 0.75rem;
  padding: 0.75rem 0 0;
  border-top: 1px dashed var(--line);
}

.answer .who {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.beliefs,
.episodes {
  display: grid;
  gap: 0.55rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  line-height: 1.3;
  overflow: visible;
}

.chip.food {
  color: var(--food);
  border-color: color-mix(in srgb, var(--food) 40%, var(--line));
}

.chip.idea {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--ink) 22%, var(--line));
}

.chip.hazard {
  color: var(--hazard);
  border-color: color-mix(in srgb, var(--hazard) 40%, var(--line));
}

.thoughts-fold {
  margin-top: 0.65rem;
}

.thoughts-fold summary {
  cursor: pointer;
  width: fit-content;
  max-width: 100%;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  list-style: none;
}

.thoughts-fold summary::-webkit-details-marker,
.thoughts-fold summary::marker {
  display: none;
  content: "";
}

.thoughts-fold summary::after {
  content: "";
  display: inline-block;
  width: 0.32rem;
  height: 0.32rem;
  margin-left: 0.4rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-0.12em) rotate(45deg);
}

.thoughts-fold[open] summary::after {
  transform: translateY(0.08em) rotate(225deg);
}

.figured {
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.2rem;
}

.figured li {
  font-size: 0.82rem;
  color: var(--muted);
}

.figured li::before {
  content: "· ";
  color: var(--ink);
}

.panel-block h2 {
  margin-top: 1.1rem;
}

.panel-block h2:first-child {
  margin-top: 0;
}

.episode {
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}

.episode .meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.episode p {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
}

.empty {
  color: var(--muted);
}

.ideas article {
  margin: 0 0 1.4rem;
}

.ideas h2 {
  text-transform: none;
  letter-spacing: -0.02em;
  font-family: Newsreader, Georgia, serif;
  font-size: 1.28rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 0.45rem;
}

.ideas p {
  margin: 0 0 0.75rem;
  font-family: Newsreader, Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.5;
}

.log-page {
  padding-bottom: max(2rem, env(safe-area-inset-bottom) + 1.25rem);
}

.log-page .lede {
  max-width: 28rem;
}

.world-tools {
  margin: 0 0 1.6rem;
  padding: 0 0 1.25rem;
  border-bottom: 1px solid var(--line);
}

.log-page .world-tools p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-family: Figtree, "Helvetica Neue", sans-serif;
  font-size: 0.88rem;
  line-height: 1.45;
  max-width: 28rem;
}

.world-tools .toolbar {
  margin-bottom: 0.45rem;
}

.world-tools .tool-status a {
  color: inherit;
}

.log article {
  margin: 0 0 1.35rem;
  padding: 0 0 1.25rem;
  border-bottom: 1px solid var(--line);
}

.log article:last-child {
  border-bottom: 0;
}

.log .when {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.log h2 {
  margin: 0 0 0.4rem;
  font-family: Newsreader, Georgia, serif;
  font-size: 1.22rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.log p,
.log li {
  font-family: Newsreader, Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.5;
}

.log p {
  margin: 0 0 0.65rem;
}

.log ul {
  margin: 0;
  padding: 0 0 0 1.1rem;
}

.log li {
  margin: 0 0 0.35rem;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--paper) 92%, white);
  border-top: 1px solid var(--line);
}

.tabs button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.tabs button[aria-current="page"] {
  color: var(--ink);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.world-col {
  margin-top: 0.7rem;
}

@media (min-width: 880px) {
  .shell {
    max-width: 64rem;
    padding-bottom: 2rem;
  }

  h1 {
    font-size: 1.7rem;
  }

  .watch-layout {
    display: grid;
    grid-template-columns: minmax(20rem, 26rem) 1fr;
    grid-template-areas: "world side";
    gap: 1.5rem;
    align-items: start;
  }

  .world-col {
    grid-area: world;
    margin-top: 0;
  }

  .world-wrap {
    max-width: none;
  }

  .side-col {
    grid-area: side;
  }

  .thought {
    border-top: 0;
  }

  .tabs {
    display: none;
  }

  .desktop-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0 0 1rem;
  }

  .desktop-nav a {
    appearance: none;
    border: 1px solid var(--ink);
    background: transparent;
    color: var(--ink);
    border-radius: 999px;
    padding: 0.42rem 0.8rem;
    font-size: 0.86rem;
    font-weight: 500;
    text-decoration: none;
  }

  .desktop-nav a:hover {
    background: var(--paper-2);
  }

  .desktop-nav a[aria-current="page"] {
    background: var(--ink);
    color: var(--paper);
  }

  .desktop-nav a:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
  }
}

@media (max-width: 879px) {
  .desktop-nav {
    display: none;
  }

  .side-col {
    margin-top: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fill {
    transition: none;
  }
}
