:root {
  --bg: #f6f0e8;
  --ink: #102f3a;
  --muted: #4f6a74;
  --panel: rgba(255, 255, 255, 0.72);
  --line: rgba(16, 47, 58, 0.16);
  --accent: #ff6b3d;
  --accent-2: #c87416;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
  --font-body: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
}

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,700;9..144,400&family=Space+Grotesk:wght@400;500;700&display=swap");

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #fff8ef, transparent 38%),
    radial-gradient(circle at 80% 100%, #ffe2c4, transparent 44%), var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.45;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(16, 47, 58, 0.26) 1.1px, transparent 1.2px);
  background-size: 24px 24px;
  opacity: 0.42;
  z-index: -1;
}

.site-header,
.layout,
.site-footer {
  width: min(1080px, 92vw);
  margin-inline: auto;
}

.site-header {
  padding-top: 1.4rem;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2vw, 1.4rem);
  letter-spacing: 0.02em;
}

.site-nav {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font-size: 0.92rem;
  transition: transform 0.22s ease, border-color 0.22s ease, background-color 0.22s ease;
}

.site-nav a:hover,
.site-nav a.active {
  transform: translateY(-1px);
  border-color: var(--accent);
  background-color: rgba(255, 107, 61, 0.1);
}

.layout {
  padding: 1.3rem 0 3rem;
}

.hero,
.panel,
.page-intro {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  backdrop-filter: blur(7px);
}

.hero,
.page-intro {
  padding: clamp(1.5rem, 5vw, 3rem);
  margin-bottom: 1.2rem;
  animation: rise 420ms ease both;
}

.hero h1,
.page-intro h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 0.98;
  margin: 0.35rem 0 1rem;
  max-width: 16ch;
}

.hero p,
.page-intro p {
  margin: 0;
  max-width: 58ch;
  color: var(--muted);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.panel {
  padding: 1.15rem;
  margin-bottom: 1rem;
  animation: rise 620ms ease both;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
}

.panel-head a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--accent-2);
  padding-bottom: 0.1rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.8rem;
}

.card,
.entry {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  padding: 0.9rem;
}

.card h3,
.entry h3 {
  margin: 0 0 0.5rem;
  font-size: 1.12rem;
  line-height: 1.16;
}

.card p,
.entry p {
  margin: 0;
  color: var(--muted);
}

.card-meta,
.entry-meta {
  margin: 0 0 0.5rem;
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 600;
}

.card a,
.entry a {
  color: inherit;
}

.stack {
  display: grid;
  gap: 0.75rem;
}

.tags {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  background: rgba(255, 107, 61, 0.12);
  border: 1px solid rgba(255, 107, 61, 0.32);
  color: #8f3d14;
}

.site-footer {
  padding: 0.5rem 0 2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.home-tree-page {
  display: grid;
  place-items: center;
}

.home-tree-layout {
  width: min(900px, 92vw);
  min-height: 88vh;
  display: grid;
  align-content: center;
  gap: 2rem;
  position: relative;
  z-index: 3;
}

.home-tree-root {
  display: grid;
  justify-items: center;
}

.home-tree-root h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.branch-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 1rem;
  align-items: start;
}

.branch {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
  padding: 0.9rem;
  position: relative;
}

.branch::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -30px;
  width: 1px;
  height: 30px;
  background: rgba(16, 47, 58, 0.28);
}

.branch-trigger {
  width: 100%;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(255, 224, 189, 0.72));
  color: var(--ink);
  border-radius: 16px;
  padding: 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.branch-trigger:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 11px 28px rgba(16, 47, 58, 0.13);
}

.branch-trigger[aria-expanded="true"] {
  border-color: var(--accent-2);
}

.branch-children {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.55rem;
  padding: 0.6rem 0.2rem 0.2rem;
}

.branch-children[hidden] {
  display: none !important;
}

.branch-children a,
.branch-children button {
  border: 1px solid rgba(16, 47, 58, 0.25);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  text-align: left;
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.branch-children a:hover,
.branch-children button:hover {
  transform: translateX(3px);
  border-color: var(--accent-2);
  background: rgba(255, 226, 196, 0.62);
}

.branch.open .branch-children {
  animation: rise 260ms ease both;
}

#graffiti-snapshot-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#graffiti-snapshot-layer.visible {
  opacity: 1;
}

#graffiti-canvas-bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
}

.drawing-enabled .home-tree-layout,
.drawing-enabled .home-tree-layout * {
  cursor: crosshair;
}

.drawing-enabled .graffiti-dock,
.drawing-enabled .graffiti-dock * {
  cursor: auto;
}

.graffiti-dock {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 4;
  display: grid;
  justify-items: end;
  gap: 0.45rem;
}

.graffiti-fab {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(16, 47, 58, 0.16);
}

.graffiti-fab:hover {
  border-color: var(--accent);
}

.graffiti-toolbar {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(6px);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-width: 360px;
}

.graffiti-toolbar[hidden] {
  display: none !important;
}

.snapshot-viewer {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 4;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  padding: 0.55rem 0.65rem;
  width: min(320px, calc(100vw - 2rem));
}

.snapshot-viewer p {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

#snapshot-slider {
  width: 100%;
}

.graffiti-options {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.graffiti-options[hidden] {
  display: none !important;
}

.graffiti-toolbar button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  padding: 0.3rem 0.6rem;
  font-family: var(--font-body);
  font-size: 0.86rem;
  cursor: pointer;
}

.graffiti-toolbar button:hover {
  border-color: var(--accent);
}

.graffiti-toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.graffiti-toolbar.is-locked {
  background: rgba(255, 255, 255, 0.62);
}

.graffiti-toolbar.is-locked .graffiti-status {
  opacity: 0.72;
}

#graffiti-eraser[aria-pressed="true"] {
  border-color: var(--accent-2);
  background: rgba(255, 226, 196, 0.7);
}

.graffiti-status {
  margin: 0;
  width: 100%;
  font-size: 0.74rem;
  color: var(--muted);
  opacity: 0.8;
}

.graffiti-palette {
  position: relative;
}

.graffiti-palette summary {
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  font-size: 0.86rem;
  background: rgba(255, 255, 255, 0.76);
  cursor: pointer;
  color: var(--ink);
}

.graffiti-palette summary::-webkit-details-marker {
  display: none;
}

.graffiti-palette-controls {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.45rem);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 0.55rem;
  display: grid;
  gap: 0.35rem;
  min-width: 180px;
}

.graffiti-palette-controls label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.graffiti-palette-controls select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem 0.45rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.88rem;
}

.graffiti-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
}

.graffiti-swatch {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(16, 47, 58, 0.3);
  padding: 0;
  cursor: pointer;
}

.graffiti-swatch[data-color="#ff6b3d"] { background: #ff6b3d; }
.graffiti-swatch[data-color="#232323"] { background: #232323; }
.graffiti-swatch[data-color="#1b75d0"] { background: #1b75d0; }
.graffiti-swatch[data-color="#17a34a"] { background: #17a34a; }
.graffiti-swatch[data-color="#f7ce3e"] { background: #f7ce3e; }
.graffiti-swatch[data-color="#d12f6a"] { background: #d12f6a; }

.graffiti-swatch.is-active {
  box-shadow: 0 0 0 2px rgba(16, 47, 58, 0.4);
}

#graffiti-color {
  width: 42px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0;
}

#graffiti-width {
  width: 100%;
}

#graffiti-opacity,
#graffiti-smoothing {
  width: 100%;
}

#graffiti-width-number {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem 0.45rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.88rem;
  width: 100%;
}

#graffiti-opacity-number,
#graffiti-smoothing-number {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem 0.45rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.88rem;
  width: 100%;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.unlock-layout {
  width: min(560px, 92vw);
  min-height: 88vh;
  display: grid;
  place-items: center;
}

.unlock-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  padding: 1.3rem;
  width: 100%;
}

.unlock-card h1 {
  margin: 0.15rem 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 5vw, 2.7rem);
}

.unlock-card p {
  margin: 0;
  color: var(--muted);
}

.unlock-form {
  margin-top: 1rem;
  display: grid;
  gap: 0.6rem;
}

.unlock-form label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.unlock-form input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
}

.unlock-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.unlock-actions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-family: var(--font-body);
}

.unlock-actions button:hover {
  border-color: var(--accent);
}

.unlock-status {
  margin-top: 0.85rem !important;
  font-size: 0.92rem;
}

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel {
    padding: 0.9rem;
  }

  .hero h1,
  .page-intro h1 {
    max-width: 20ch;
  }

  .home-tree-layout {
    min-height: 84vh;
    gap: 1.2rem;
  }

  .branch-stack {
    grid-template-columns: 1fr;
  }

  .branch::before {
    display: none;
  }

  .graffiti-dock {
    left: 1rem;
    right: 1rem;
    bottom: 0.8rem;
  }

  .snapshot-viewer {
    left: 1rem;
    right: 1rem;
    bottom: 0.8rem;
    width: auto;
  }

  .graffiti-toolbar {
    max-width: none;
    width: 100%;
  }

  .graffiti-palette-controls {
    right: auto;
    left: 0;
    bottom: calc(100% + 0.35rem);
  }
}
