:root {
  --paper: #F2F1EC;
  --ink: #161616;
  --muted: #5C5B57;
  --accent: #2B50E8;
  --white: #FFFFFF;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); }
body { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }
button { font: inherit; color: inherit; }
a { color: var(--ink); }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.muted { color: var(--muted); }

.bar { height: 32px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 16px; border-bottom: 1px solid var(--ink); font-size: 12px; }
.bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }

.desk { position: relative; flex: 1 1 auto; overflow: hidden; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  background-image: radial-gradient(#CFCDC4 1px, transparent 1px); background-size: 24px 24px; }
.desk.grabbing, .desk.grabbing .node { cursor: grabbing; }
#brain { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#nodes { position: absolute; inset: 0; pointer-events: none; }

.node { position: absolute; left: 0; top: 0; display: flex; align-items: center; padding: 12px; background: none; border: 0; cursor: pointer; pointer-events: auto; color: var(--ink); will-change: transform, opacity; }
.node .lbl { background: var(--paper); white-space: nowrap; }
.node:hover .lbl { text-decoration: underline; }
.node.theme { gap: 10px; transform-origin: 19px 19px; }
.node.theme .pip { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 4px rgba(22,22,22,0.08); flex: 0 0 auto; }
.node.theme.on .pip { background: var(--accent); }
.node.theme .lbl { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 4px; }
.node.note { gap: 8px; transform-origin: 17px 17px; }
.node.note .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--white); border: 1.5px solid var(--ink); flex: 0 0 auto; }
.node.note.on .pip { background: var(--accent); border-color: var(--accent); }
.node.note .lbl { font-size: 11px; padding: 1px 4px; }

.intro { position: absolute; z-index: 3000; left: 24px; top: 24px; width: 340px; max-width: calc(100% - 48px); background: var(--paper); border: 1px solid var(--ink); padding: 20px 22px; cursor: default; user-select: text; -webkit-user-select: text; }
.intro h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.intro p { margin: 10px 0 0; font-size: 14px; line-height: 1.5; }

.zoom { position: absolute; z-index: 3000; right: 20px; bottom: 20px; display: flex; flex-direction: column; border: 1px solid var(--ink); background: var(--paper); cursor: default; }
.zoom button { width: 40px; height: 40px; border: 0; border-bottom: 1px solid var(--ink); background: none; cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; padding: 0; }
.zoom button:last-child { border-bottom: 0; }
.zoom button:hover { background: var(--ink); color: var(--paper); }

.win { position: absolute; z-index: 4000; left: 50%; top: 40px; transform: translateX(-50%); width: 680px; max-width: calc(100% - 32px); max-height: calc(100% - 80px); display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--ink); box-shadow: 8px 8px 0 rgba(22,22,22,0.14); cursor: default; user-select: text; -webkit-user-select: text; }
.win[hidden] { display: none; }
.win-bar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 36px; padding: 0 6px 0 14px; border-bottom: 1px solid var(--ink); background: var(--paper); font-size: 12px; }
#win-file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-close { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: none; border: 1px solid var(--ink); cursor: pointer; padding: 0; }
.win-close:hover { background: var(--ink); color: var(--paper); }
.win-body { overflow: auto; padding: 36px 48px 40px; }
.win-meta { margin: 0; font-size: 11px; color: var(--muted); }
#win-title { margin: 10px 0 0; font-family: 'Source Serif 4', Georgia, serif; font-size: 34px; line-height: 1.15; font-weight: 600; }
.prose { margin-top: 22px; font-family: 'Source Serif 4', Georgia, serif; font-size: 18px; line-height: 1.65; max-width: 62ch; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre { margin: 0 0 16px; }
.prose h3, .prose h4, .prose h5, .prose h6 { font-family: 'JetBrains Mono', monospace; font-size: 14px; margin: 28px 0 10px; text-transform: lowercase; }
.prose blockquote { border-left: 2px solid var(--ink); padding-left: 16px; color: #2E2D2A; }
.prose code { font-family: 'JetBrains Mono', monospace; font-size: 0.85em; background: var(--paper); padding: 1px 4px; }
.prose pre { background: var(--paper); padding: 14px; overflow: auto; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px dashed var(--ink); margin: 24px 0; }
.prose a[data-note] { text-decoration-style: dashed; }
.win-foot { margin-top: 28px; padding-top: 18px; border-top: 1px dashed var(--ink); display: flex; flex-direction: column; gap: 12px; font-size: 12px; }
.win-foot:empty { display: none; }
.win-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.win-row .k { color: var(--muted); width: 72px; }
.chip { font-size: 11px; padding: 6px 10px; min-height: 30px; background: none; border: 1px solid var(--ink); cursor: pointer; }
.chip.theme { text-transform: uppercase; letter-spacing: 0.08em; }
.chip.link { border-style: dashed; }
.chip:hover { background: var(--ink); color: var(--paper); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.noscript { position: fixed; bottom: 12px; left: 12px; font-size: 12px; }

@media (max-width: 640px) {
  .intro { left: 12px; top: 12px; padding: 14px 16px; }
  .intro h1 { font-size: 20px; }
  .win { top: 12px; max-height: calc(100% - 24px); }
  .win-body { padding: 24px 20px 28px; }
  #win-title { font-size: 26px; }
  .prose { font-size: 17px; }
  .zoom { right: 12px; bottom: 12px; }
}
