.thought-page {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #f9f8f3;
}

.board-header {
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  padding: 13px clamp(12px, 3.2vw, 38px);
  border-bottom: 1px solid #deded4;
  background: var(--paper);
}

.board-heading, .board-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.board-home {
  display: block;
  color: inherit;
  text-decoration: none;
  flex-shrink: 0;
}

.board-heading p {
  color: var(--muted);
  font-size: .75rem;
  margin-bottom: 3px;
}

.board-heading h1 {
  font: clamp(1.2rem, 2.8vw, 1.9rem)/1.05 var(--serif);
  letter-spacing: -.02em;
}

.board-actions button { white-space: nowrap; }
.board-actions button:disabled { cursor: default; opacity: .47; }

.board-canvas {
  --grid-size: 24px;
  position: relative;
  min-height: 0;
  overflow: hidden;
  outline-offset: -3px;
  background-color: #f8f8f3;
  background-image: radial-gradient(circle, #a0ac9e85 1px, transparent 1.3px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: var(--grid-x, 0px) var(--grid-y, 0px);
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.board-canvas.is-dragging { cursor: grabbing; }
.board-canvas[data-tool="link"] { cursor: crosshair; }

.board-world {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.board-connections {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#blocks {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}

.thought-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  width: 290px;
  padding: 0;
  border: 1px solid var(--node-border);
  border-radius: 15px;
  background: var(--node-bg);
  color: #202a24;
  box-shadow: 0 6px 18px #222d2310;
  text-align: left;
  cursor: grab;
}

.thought-node:hover { border-color: #8a9f8d; }
.thought-node[aria-pressed="true"] { outline: 2px solid #36745a; outline-offset: 3px; }
.thought-node.is-source { outline: 3px solid #8061a6; outline-offset: 4px; }
.board-canvas[data-tool="pan"] .thought-node { cursor: grab; }
.board-canvas[data-tool="link"] .thought-node { cursor: crosshair; }
.board-canvas.is-dragging .thought-node { cursor: grabbing; }

.thought-node[data-kind="generator"] { --node-bg: #eff5eb; --node-border: #c4d5c4; --node-ink: #3e654e; }
.thought-node[data-kind="thought"] { --node-bg: #fff6d9; --node-border: #e5d6a9; --node-ink: #816422; }
.thought-node[data-kind="decision"] { --node-bg: #f1edf9; --node-border: #d6cce6; --node-ink: #684d8a; }
.thought-node[data-kind="note"] { --node-bg: #fffdf8; --node-border: #deded4; --node-ink: #506257; }

.node-motion {
  display: block;
  width: 100%;
  aspect-ratio: 288 / 162;
  border-radius: 14px 14px 0 0;
  pointer-events: none;
}
.thought-node[data-current="true"] {
  border-color: var(--node-ink);
  box-shadow: 0 0 0 4px #b2c5a54d, 0 7px 24px #222d2324;
}
.node-paper {
  transform: translateY(calc(11px * (1 - var(--reveal, 1))));
  opacity: calc(.38 + .62 * var(--reveal, 1));
}
.node-options span {
  opacity: calc(.48 + .52 * var(--choice, 1));
  transform: translateX(calc(-8px * (1 - var(--choice, 1))));
}

.node-content {
  display: grid;
  width: 100%;
  gap: 8px;
  padding: 17px 18px 19px;
  overflow-wrap: anywhere;
}

.node-title { font: 1.38rem/1.12 var(--serif); }
.node-text { color: #49574e; font-size: .87rem; line-height: 1.48; white-space: pre-wrap; }

.node-paper {
  display: block;
  margin: 16px 18px 0;
  padding: 14px;
  border: 1px solid #ead8a3;
  border-radius: 5px 5px 12px 5px;
  background: #fffdf4;
  color: #554721;
  font: 1.06rem/1.22 var(--serif);
}

.node-options { display: grid; gap: 6px; margin: 15px 18px 0; }
.node-options span {
  padding: 7px 10px;
  border-radius: 6px;
  background: #fffdfd;
  color: #554366;
  font-size: .82rem;
}
.node-options .node-choice {
  background: color-mix(in srgb, #e3d8f3 calc(var(--verdict, 1) * 100%), #fffdfd);
  font-weight: 700;
}
.node-choice::after {
  content: '✓';
  margin-left: 7px;
  color: #4b3863;
  opacity: var(--verdict, 1);
}

.board-tools, .board-footer, .board-zoom {
  display: flex;
  align-items: center;
  gap: 5px;
}

.board-tools {
  position: absolute;
  top: 13px;
  left: 13px;
  flex-wrap: wrap;
  padding: 5px;
  border: 1px solid #deded4;
  border-radius: 11px;
  background: var(--paper);
  box-shadow: 0 3px 12px #253a2b12;
  cursor: default;
}

.board-tools button, .board-zoom button { min-height: 33px; padding: 5px 8px; font-size: .81rem; }
.board-tools button[aria-pressed="true"] { border-color: #abc4ad; background: #e8f0e5; color: #214d35; }

.board-footer {
  position: absolute;
  right: 13px;
  bottom: 13px;
  left: 13px;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.board-status, .board-zoom {
  border: 1px solid #deded4;
  border-radius: 10px;
  background: var(--paper);
  color: #3e5146;
  box-shadow: 0 3px 12px #253a2b12;
}

.board-status { padding: 8px 10px; font-size: .81rem; }
.board-zoom { padding: 5px; pointer-events: auto; cursor: default; }
#zoom-label { min-width: 42px; text-align: center; font-size: .8rem; font-variant-numeric: tabular-nums; }
#board-dialog { width: min(440px, calc(100% - 26px)); padding: 20px; }
#board-dialog h2 { margin-bottom: 17px; font: 1.5rem var(--serif); }
#board-dialog .danger { margin-right: auto; }
#board-dialog label[hidden] { display: none; }

@media (max-width: 520px) {
  .board-header { padding: 10px; gap: 8px; }
  .board-heading, .board-actions { gap: 5px; }
  .board-home .mark { width: 28px; height: 32px; font-size: 1rem; }
  .board-heading p { font-size: .63rem; }
  .board-actions button { min-height: 34px; padding: 4px 7px; font-size: .76rem; }
  .board-footer { display: grid; justify-items: end; justify-content: end; gap: 5px; }
  .board-status { grid-row: 2; }
  .board-tools, .board-footer { left: 8px; }
  .board-footer { right: 8px; bottom: 8px; }
}
