:root {
  --paper: #f9fafb;
  --ink: #111827;
  --muted: #4b5563;
  --muted-light: #9ca3af;
  --faint: rgba(17, 24, 39, 0.07);
  --accent: #6366f1;
  --accent-warm: #a855f7;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --grid: rgba(17, 24, 39, 0.07);
  --font-brand: "Montserrat", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle, var(--grid) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(var(--paper), var(--paper));
  color: var(--ink);
  font-family: var(--font-mono);
  letter-spacing: 0;
  overflow: hidden;
  transition: background-color 240ms ease, color 240ms ease;
}

body.scrollable {
  overflow-y: auto;
}

body.dark {
  --paper: #0f172a;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --muted-light: #64748b;
  --faint: rgba(241, 245, 249, 0.07);
  --grid: rgba(241, 245, 249, 0.05);
}

body.cold {
  --accent: #3b82f6;
  --accent-warm: #6366f1;
  --accent-soft: rgba(59, 130, 246, 0.14);
}

body.alive {
  --accent: #ec4899;
  --accent-warm: #f97316;
  --accent-soft: rgba(236, 72, 153, 0.14);
}

/* ─── Layout ─── */

.notebook {
  position: relative;
  min-height: 100vh;
  padding: clamp(56px, 9vh, 90px) clamp(20px, 7vw, 96px) 48px;
}

/* ─── Logo ─── */

.site-logo {
  margin: 0 0 clamp(42px, 8vh, 76px);
  text-align: center;
  font-family: var(--font-brand);
  font-size: clamp(2rem, 5.5vw, 3.6rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}

.logo-poly {
  color: var(--ink);
}

.logo-stage {
  background: linear-gradient(90deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-dot-ai {
  font-size: 0.52em;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: #a855f7;
  vertical-align: 0.3em;
  margin-left: 0.04em;
}

/* ─── Console ─── */

.page {
  width: min(720px, 100%);
  margin: 0 auto;
  max-height: 68vh;
  overflow: auto;
  scrollbar-width: none;
}

.page::-webkit-scrollbar {
  display: none;
}

.line {
  min-height: 1.6em;
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(0.76rem, 1.6vw, 0.96rem);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.system-line {
  color: var(--muted);
  padding-left: 1.35rem;
  margin-bottom: 0.55rem;
}

.active-line {
  color: var(--ink);
  position: relative;
}

/* Real focus target that triggers the iOS/Android soft keyboard. Invisible
   (we render typed text into #typed and use the heartbeat as the cursor), but
   must stay focusable — so opacity, not display:none. 16px font prevents the
   iOS zoom-on-focus. */
.hidden-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  opacity: 0;
  -webkit-appearance: none;
  appearance: none;
}

.prompt {
  color: var(--accent);
  font-weight: 600;
  margin-right: 0.55ch;
}

.typed {
  vertical-align: baseline;
}

.heartbeat {
  display: inline-block;
  width: 0.55ch;
  height: 1.1em;
  margin-left: 0.08ch;
  vertical-align: -0.16em;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-soft);
  animation: heartbeat 1.32s ease-in-out infinite;
  transform-origin: center;
}

.heartbeat.typing {
  animation-duration: 0.82s;
}

.heartbeat.thinking {
  width: 1.8ch;
  height: 0.72em;
  background:
    linear-gradient(90deg, transparent 0 12%, var(--accent) 12% 20%, transparent 20% 32%, var(--accent) 32% 45%, transparent 45% 58%, var(--accent) 58% 70%, transparent 70% 100%);
  animation: waveform 0.74s ease-in-out infinite;
}

/* ─── Interaction Map ─── */

.map-shell {
  position: fixed;
  right: clamp(18px, 4vw, 58px);
  bottom: clamp(18px, 5vh, 52px);
  width: min(36vw, 420px);
  min-width: 260px;
  aspect-ratio: 1.28;
  opacity: 0;
  pointer-events: none;
  transition: opacity 640ms ease;
}

.map-shell.visible {
  opacity: 1;
}

.node-count {
  position: absolute;
  right: 0;
  bottom: 0;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted-light);
}

svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Connectors — ultra-thin 1px solid lines */
.edge {
  fill: none;
}

.edge-global {
  stroke: var(--muted-light);
  stroke-width: 0.28;
  opacity: 0.4;
}

.edge-accent {
  stroke: var(--accent);
  stroke-width: 0.28;
  opacity: 0.55;
}

/* Node labels — Navigation & Labels spec: monospace, 12-14px equiv, weight 500, lowercase */
.node text {
  font-family: var(--font-mono);
  font-size: 2.8px;
  font-weight: 500;
  letter-spacing: 0;
}

/* Inactive nodes */
.node-global circle {
  fill: var(--muted-light);
  transform-box: fill-box;
  transform-origin: center;
  animation: global-breathe 4.8s ease-in-out infinite;
}

.node-global text {
  fill: var(--muted-light);
}

/* Current node — Brand Indigo, the one we're on right now */
.node-global.active circle {
  fill: var(--accent);
  filter: drop-shadow(0 0 4px var(--accent-soft));
  animation: node-pulse 2.8s ease-in-out infinite;
}

.node-global.active text {
  fill: var(--accent);
}

/* Visited nodes — dark ink, still alive (pulsing + grown), but not current */
.node-global.visited circle {
  fill: var(--ink);
  opacity: 0.72;
  filter: none;
  animation: node-pulse 2.8s ease-in-out infinite;
}

.node-global.visited text {
  fill: var(--ink);
  opacity: 0.6;
}

/* Root node — deep charcoal anchor */
.node-root circle {
  fill: var(--ink);
  opacity: 0.65;
}

.node-root text {
  fill: var(--ink);
  opacity: 0.42;
}

/* ─── Animations ─── */

@keyframes heartbeat {
  0%, 100% {
    transform: scaleY(0.72);
    opacity: 0.62;
    box-shadow: 0 0 0 0 var(--accent-soft);
  }
  14% {
    transform: scaleY(1.18);
    opacity: 1;
    box-shadow: 0 0 0 7px transparent;
  }
  24% {
    transform: scaleY(0.78);
    opacity: 0.72;
  }
  36% {
    transform: scaleY(1.34);
    opacity: 1;
    box-shadow: 0 0 0 10px transparent;
  }
  58% {
    transform: scaleY(0.68);
    opacity: 0.58;
  }
}

@keyframes node-pulse {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  35% { transform: scale(1.2); opacity: 1; }
  65% { transform: scale(0.94); opacity: 0.68; }
}

@keyframes global-breathe {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.08); opacity: 0.48; }
}

@keyframes waveform {
  0%, 100% {
    transform: scaleY(0.6);
    opacity: 0.64;
  }
  50% {
    transform: scaleY(1.12);
    opacity: 1;
  }
}

/* ─── Footer ─── */

.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px clamp(20px, 7vw, 96px);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted-light);
  letter-spacing: 0.01em;
  pointer-events: none;
}

.site-footer a {
  color: var(--muted-light);
  pointer-events: all;
  text-decoration: none;
  border-bottom: 1px solid var(--faint);
}

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

/* ─── Privacy Page ─── */

.privacy-back-home {
  display: inline-flex;
  align-items: center;
  gap: 0.5ch;
  margin-bottom: clamp(32px, 6vh, 56px);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
  padding-bottom: 2px;
  transition: opacity 160ms ease, border-color 160ms ease;
}

.privacy-back-home:hover {
  opacity: 0.72;
  border-color: var(--accent);
}

.privacy-page {
  max-width: 680px;
  margin: 0 auto;
}

.privacy-body {
  padding-bottom: 64px;
}

.privacy-body h2 {
  font-family: var(--font-brand);
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.privacy-body h3 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  margin: 2rem 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.privacy-body p {
  font-size: 0.86rem;
  line-height: 1.8;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.privacy-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
}

.privacy-body a:hover {
  opacity: 0.8;
}

.privacy-body code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--faint);
  padding: 0.1em 0.4em;
  border-radius: 3px;
}

.privacy-meta {
  color: var(--muted-light) !important;
  font-size: 0.74rem !important;
  margin-bottom: 2rem !important;
}

/* ─── Responsive ─── */

@media (max-width: 720px) {
  .notebook {
    padding-inline: 22px;
  }

  .map-shell {
    width: min(86vw, 360px);
    right: 7vw;
    bottom: 26px;
    opacity: 0.92;
  }

  .page {
    max-height: 56vh;
  }
}
