:root {
  --puli-orange: #ff9d00;
  --puli-red: #ff0000;
  --puli-turquoise: #00ffc0;
  --puli-blue: #0009ff;
  --theme-bg: #087f75;
  --theme-accent: var(--puli-turquoise);
  --white: #fff;
  --text: rgba(255, 255, 255, 0.96);
  --text-soft: rgba(255, 255, 255, 0.55);
  --text-faint: rgba(255, 255, 255, 0.27);
  --rule: rgba(255, 255, 255, 0.2);
  --bar-height: 72px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  height: 100svh;
  overflow: hidden;
  color: var(--text);
  background: var(--theme-bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 480ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

button,
a { font: inherit; }

a { color: inherit; }

.site-shell {
  height: 100svh;
  overflow: hidden;
  display: grid;
  grid-template-rows: var(--bar-height) minmax(0, 1fr) var(--bar-height);
}

.topbar,
.bottombar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 0 clamp(22px, 3vw, 52px);
  background: var(--theme-bg);
  transition: background-color 480ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.topbar { border-bottom: 1px solid var(--rule); }
.bottombar { border-top: 1px solid var(--rule); }

.brand {
  display: block;
  width: 126px;
  height: 60px;
  padding: 5px 0;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
}

.topnav,
.footnav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px clamp(16px, 2vw, 30px);
}

.topnav a,
.footnav a {
  color: var(--text);
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
  text-underline-offset: 5px;
}

.topnav a:hover,
.topnav a:focus-visible,
.footnav a:hover,
.footnav a:focus-visible {
  text-decoration: underline;
}

.workspace {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(250px, 30fr) minmax(350px, 38fr) minmax(350px, 32fr);
}

.topic-pane,
.graph-pane,
.note-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.topic-pane {
  overflow: hidden;
  border-right: 1px solid var(--rule);
}

.pane-label,
.graph-heading {
  position: absolute;
  z-index: 4;
  top: 22px;
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.pane-label { left: clamp(22px, 3vw, 50px); }

.topic-list {
  height: 100%;
  overflow-y: auto;
  padding: 76px clamp(22px, 3vw, 50px) 90px;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.topic-list::-webkit-scrollbar { display: none; }

.topic-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 11px;
  align-items: baseline;
  width: 100%;
  padding: 6px 0;
  border: 0;
  color: var(--text-faint);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: color 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.topic-item:hover,
.topic-item:focus-visible {
  color: rgba(255, 255, 255, 0.72);
  outline: 0;
  transform: translateX(5px);
}

.topic-item[aria-pressed="true"] {
  color: var(--white);
  transform: translateX(5px);
}

.topic-item[aria-pressed="true"] .topic-id::before {
  opacity: 1;
  transform: translate(-13px, -50%) scale(1);
}

.topic-id {
  position: relative;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.topic-id::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--theme-accent);
  opacity: 0;
  transform: translate(-13px, -50%) scale(0.4);
  transition: opacity 180ms ease, transform 180ms ease, background-color 480ms ease;
}

.topic-name {
  font-size: clamp(17px, 1.5vw, 25px);
  font-weight: 790;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.scroll-fade {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  height: 68px;
  pointer-events: none;
}

.scroll-fade-top {
  top: 52px;
  background: linear-gradient(var(--theme-bg) 10%, transparent);
}

.scroll-fade-bottom {
  bottom: 0;
  background: linear-gradient(transparent, var(--theme-bg) 88%);
}

.scroll-fade-top,
.scroll-fade-bottom {
  transition: background 480ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.graph-pane {
  overflow: hidden;
  border-right: 1px solid var(--rule);
}

.graph-heading {
  right: 22px;
  left: 22px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.graph-instruction {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 24px;
  left: 0;
  color: var(--text-soft);
  font-size: 9px;
  font-weight: 780;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  pointer-events: none;
}

.note-pane {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.note-scroll {
  min-height: 0;
  overflow: hidden;
  padding: clamp(24px, 3.5vh, 42px) clamp(22px, 3vw, 48px) 20px;
}

.page-path {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: clamp(18px, 3.2vh, 34px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 720;
}

.page-path button {
  padding: 0;
  border: 0;
  color: var(--text-soft);
  background: transparent;
  cursor: pointer;
}

.page-path button:hover,
.page-path button:focus-visible { color: var(--white); }

.page-number {
  margin-bottom: 9px;
  color: var(--theme-accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  transition: color 480ms ease;
}

.note-pane h1 {
  max-width: 12ch;
  margin: 0 0 clamp(18px, 3vh, 30px);
  font-size: clamp(32px, min(3.6vw, 6.4vh), 56px);
  font-weight: 850;
  letter-spacing: -0.065em;
  line-height: 0.94;
}

.roam-blocks {
  display: grid;
  gap: clamp(10px, 1.6vh, 16px);
  font-size: clamp(13px, min(0.96vw, 1.85vh), 16px);
  line-height: 1.45;
}

.roam-block {
  position: relative;
  margin: 0;
  padding-left: 20px;
}

.roam-block::before {
  content: "";
  position: absolute;
  top: 0.68em;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
}

.roam-block.indent {
  margin-left: 22px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.9em;
}

.page-ref {
  color: var(--white);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 760;
  text-decoration: underline;
  text-decoration-color: var(--theme-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.backlinks {
  margin-top: clamp(18px, 3vh, 32px);
  padding-top: clamp(12px, 2vh, 18px);
  border-top: 1px solid var(--rule);
}

.backlinks h2 {
  margin: 0 0 16px;
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#backlink-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.backlink-button {
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  font-size: 11px;
  font-weight: 720;
  cursor: pointer;
}

.backlink-button:hover,
.backlink-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.56);
  color: var(--white);
}

.build-status {
  display: flex;
  gap: 11px;
  align-items: center;
  min-height: 48px;
  padding: 12px clamp(24px, 3.4vw, 54px);
  border-top: 1px solid var(--rule);
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.35;
}

.status-pulse {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--theme-accent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--theme-accent) 18%, transparent);
  animation: pulse 2.4s ease-in-out infinite;
}

.footer-mark {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.82); opacity: 0.7; }
  50% { transform: scale(1.08); opacity: 1; }
}

@media (max-height: 760px) and (min-width: 901px) {
  :root { --bar-height: 60px; }
  .page-path { margin-bottom: 14px; }
  .note-pane h1 { margin-bottom: 16px; font-size: clamp(32px, 5.8vh, 48px); }
  .roam-blocks { gap: 9px; font-size: clamp(12px, 1.8vh, 14px); }
  .backlinks { margin-top: 15px; padding-top: 10px; }
  .backlink-button { padding: 5px 8px; font-size: 10px; }
  .build-status { min-height: 42px; }
}

@media (max-width: 900px) {
  body { height: auto; overflow: auto; }
  .site-shell { height: auto; min-height: 100svh; overflow: visible; }
  .workspace { overflow: visible; }
  :root { --bar-height: 66px; }
  .topnav { display: none; }
  .brand { width: 108px; height: 56px; }
  .workspace { display: block; }
  .topic-pane {
    height: 300px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
  .topic-list { padding-top: 68px; }
  .topic-name { font-size: 20px; }
  .graph-pane {
    height: 58svh;
    min-height: 440px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
  .note-pane { min-height: 640px; }
  .note-scroll { overflow: visible; }
  .note-pane h1 { max-width: 10ch; }
  .bottombar { align-items: flex-start; padding-top: 14px; padding-bottom: 14px; }
  .footnav { gap: 7px 14px; }
  .footnav a,
  .footer-mark { font-size: 10px; }
}

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