:root {
  color-scheme: light;
  --cream: #f7efd9;
  --paper: #fffaf0;
  --soil: #2a1a12;
  --bark-900: #221610;
  --bark-800: #342018;
  --bark-700: #4c2d1f;
  --bark-600: #6b4026;
  --bark-200: #dfc7a4;
  --moss-900: #182613;
  --moss-800: #25391f;
  --moss-700: #314b27;
  --moss-600: #3f612e;
  --moss-500: #517937;
  --moss-300: #95b96a;
  --moss-100: #dfeccf;
  --lichen: #c9d7a1;
  --fern: #244a2c;
  --clay-800: #3b2019;
  --clay-700: #5b2c20;
  --clay-600: #793b25;
  --clay-300: #d29455;
  --river: #365f63;
  --slate: hsl(215 24% 24%);
  --indigo: hsl(237 38% 36%);
  --emerald: hsl(151 45% 28%);
  --ring: hsla(87, 35%, 58%, 0.52);
  --glass: rgba(247, 239, 217, 0.78);
  --glass-strong: rgba(255, 250, 240, 0.92);
  --border: rgba(76, 45, 31, 0.2);
  --shadow-soft: 0 24px 80px rgba(42, 26, 18, 0.16);
  --shadow-lift: 0 18px 48px rgba(42, 26, 18, 0.2), 0 2px 0 rgba(255, 255, 255, 0.45) inset;
  --shadow-moss: 0 18px 50px rgba(49, 75, 39, 0.24);
  --inset-paper: inset 0 0 0 1px rgba(76, 45, 31, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.68);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.dark {
  color-scheme: dark;
  --glass: rgba(42, 26, 18, 0.72);
  --glass-strong: rgba(34, 22, 16, 0.9);
  --border: rgba(247, 239, 217, 0.16);
  --ring: hsla(75, 41%, 74%, 0.52);
  --shadow-soft: 0 28px 90px rgba(0, 0, 0, 0.34);
  --shadow-lift: 0 18px 54px rgba(0, 0, 0, 0.36), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
  --inset-paper: inset 0 0 0 1px rgba(247, 239, 217, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

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

html {
  min-width: 320px;
  -webkit-text-size-adjust: 100%;
  text-rendering: geometricPrecision;
}

body {
  margin: 0;
  font-family: "Nunito Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-attachment: fixed;
  isolation: isolate;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  z-index: 0;
  pointer-events: none;
  filter: blur(2px);
}

body::before {
  width: 34rem;
  height: 34rem;
  left: -12rem;
  top: 10rem;
  border-radius: 47% 53% 62% 38% / 42% 35% 65% 58%;
  background: radial-gradient(circle, rgba(149, 185, 106, 0.32), transparent 68%);
  animation: floatLeaf 16s var(--ease) infinite alternate;
}

body::after {
  width: 30rem;
  height: 30rem;
  right: -10rem;
  bottom: 5rem;
  border-radius: 62% 38% 47% 53% / 50% 61% 39% 50%;
  background: radial-gradient(circle, rgba(210, 148, 85, 0.22), transparent 68%);
  animation: floatLeaf 18s var(--ease) infinite alternate-reverse;
}

.dark body::before {
  background: radial-gradient(circle, rgba(81, 121, 55, 0.22), transparent 68%);
}

.dark body::after {
  background: radial-gradient(circle, rgba(54, 95, 99, 0.2), transparent 68%);
}

p,
h1,
h2,
h3,
h4,
h5,
h6,
span,
div,
a,
button,
label,
legend,
strong,
em,
small,
li,
dt,
dd,
output,
select,
option,
textarea,
input {
  overflow-wrap: break-word;
  word-wrap: break-word;
  min-width: 0;
}

img,
svg,
video,
canvas,
iframe,
picture {
  max-width: 100%;
  height: auto;
}

button,
select,
input,
textarea {
  font: inherit;
}

button,
a,
select,
input[type="range"],
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  transform: translateZ(0);
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
  filter: saturate(0.7);
}

::selection {
  color: #fffaf0;
  background: rgba(49, 75, 39, 0.9);
}

.dark ::selection {
  color: #182613;
  background: rgba(201, 215, 161, 0.92);
}

::-webkit-scrollbar {
  width: 0.85rem;
  height: 0.85rem;
}

::-webkit-scrollbar-track {
  background: rgba(239, 227, 207, 0.55);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--moss-600), var(--clay-600));
  border: 3px solid rgba(247, 239, 217, 0.9);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--fern), var(--bark-700));
}

.dark ::-webkit-scrollbar-track {
  background: rgba(24, 38, 19, 0.7);
}

.dark ::-webkit-scrollbar-thumb {
  border-color: rgba(34, 22, 16, 0.92);
  background: linear-gradient(135deg, var(--lichen), var(--river));
}

.hidden,
[hidden] {
  display: none !important;
}

.sr-only {
  white-space: nowrap;
}

#app-shell {
  background-image:
    linear-gradient(rgba(76, 45, 31, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(76, 45, 31, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
}

.dark #app-shell {
  background-image:
    linear-gradient(rgba(247, 239, 217, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(247, 239, 217, 0.03) 1px, transparent 1px);
}

#floating-identity {
  animation: slideDown 720ms var(--ease) both;
}

#floating-identity > div,
#quick-actions-nav,
#mobile-action-bar,
#hero-ridge,
#canvas-grove,
#fold-timeline,
#fold-parameters-card,
#export-nest-card,
#pattern-library-modal > div {
  position: relative;
  box-shadow: var(--shadow-soft);
}

#floating-identity > div::before,
#quick-actions-nav::before,
#mobile-action-bar::before,
#hero-ridge::before,
#canvas-grove::before,
#fold-timeline::before,
#fold-parameters-card::before,
#export-nest-card::before,
#pattern-library-modal > div::before {
  content: "";
  position: absolute;
  inset: 0.06rem;
  z-index: -1;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.5), transparent 42%),
    radial-gradient(circle at 15% 10%, rgba(201, 215, 161, 0.28), transparent 34%);
  pointer-events: none;
}

.dark #floating-identity > div::before,
.dark #quick-actions-nav::before,
.dark #mobile-action-bar::before,
.dark #hero-ridge::before,
.dark #canvas-grove::before,
.dark #fold-timeline::before,
.dark #fold-parameters-card::before,
.dark #export-nest-card::before,
.dark #pattern-library-modal > div::before {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 42%),
    radial-gradient(circle at 15% 10%, rgba(201, 215, 161, 0.12), transparent 34%);
}

#brand-home-link span[aria-hidden="true"] {
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.34), transparent 22%),
    linear-gradient(135deg, var(--fern), var(--moss-500));
}

#main-workspace {
  animation: fadeIn 760ms var(--ease) 90ms both;
}

#tool-vine-sidebar button,
#canvas-toolbar button,
#quick-actions-nav button,
#mobile-action-bar button,
#fold-timeline button,
#living-settings-panel button,
#pattern-library-modal button,
#brand-home-link,
select,
input[type="radio"] {
  transition:
    transform 220ms var(--ease),
    box-shadow 220ms var(--ease),
    background-color 220ms var(--ease),
    border-color 220ms var(--ease),
    color 220ms var(--ease),
    filter 220ms var(--ease);
}

#tool-vine-sidebar button:hover,
#canvas-toolbar button:hover,
#quick-actions-nav button:hover,
#mobile-action-bar button:hover,
#fold-timeline button:hover,
#living-settings-panel button:hover,
#pattern-library-modal button:hover,
#brand-home-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

#tool-vine-sidebar button:active,
#canvas-toolbar button:active,
#quick-actions-nav button:active,
#mobile-action-bar button:active,
#fold-timeline button:active,
#living-settings-panel button:active,
#pattern-library-modal button:active {
  transform: translateY(0) scale(0.985);
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px var(--ring), 0 0 0 7px rgba(255, 250, 240, 0.65), var(--shadow-lift) !important;
}

.dark :where(a, button, input, select, textarea, [tabindex]):focus-visible {
  box-shadow: 0 0 0 4px var(--ring), 0 0 0 7px rgba(24, 38, 19, 0.72), var(--shadow-lift) !important;
}

button[aria-pressed="true"] {
  box-shadow: 0 14px 34px rgba(36, 74, 44, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

#tool-vine-sidebar > div {
  box-shadow: var(--shadow-soft);
}

#tool-vine-sidebar > div::after {
  content: "";
  position: absolute;
  inset: 0.75rem auto 0.75rem 50%;
  width: 2px;
  z-index: -1;
  background: linear-gradient(to bottom, transparent, rgba(49, 75, 39, 0.24), transparent);
}

@media (max-width: 1023px) {
  #tool-vine-sidebar > div::after {
    inset: 50% 0.75rem auto 0.75rem;
    width: auto;
    height: 2px;
  }
}

#hero-ridge {
  overflow: hidden;
}

#hero-ridge::after {
  content: "✧";
  position: absolute;
  right: clamp(1rem, 4vw, 3rem);
  top: -1.6rem;
  color: rgba(49, 75, 39, 0.12);
  font-family: "Fraunces", serif;
  font-size: clamp(6rem, 18vw, 14rem);
  line-height: 1;
  pointer-events: none;
  transform: rotate(-12deg);
}

.dark #hero-ridge::after {
  color: rgba(201, 215, 161, 0.08);
}

#project-health-panel,
#insight-compost-card {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 12%, rgba(201, 215, 161, 0.28), transparent 32%),
    linear-gradient(135deg, var(--moss-700), var(--fern) 55%, var(--moss-800));
}

#project-health-panel::before,
#insight-compost-card::before {
  content: "";
  position: absolute;
  inset: -35% -20% auto auto;
  width: 16rem;
  height: 16rem;
  border-radius: 45% 55% 35% 65% / 55% 35% 65% 45%;
  background: rgba(255, 255, 255, 0.08);
  animation: breathe 7s ease-in-out infinite;
}

#project-health-panel > *,
#insight-compost-card > * {
  position: relative;
  z-index: 1;
}

#canvas-grove {
  overflow: hidden;
}

#canvas-grove::after {
  content: "";
  position: absolute;
  inset: 4.6rem 1rem 1rem;
  z-index: -1;
  border-radius: 3rem;
  background:
    radial-gradient(circle at 18% 20%, rgba(54, 95, 99, 0.13), transparent 26%),
    radial-gradient(circle at 85% 85%, rgba(149, 185, 106, 0.18), transparent 32%);
}

#origami-canvas {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(76, 45, 31, 0.12) 1px, transparent 0),
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(247, 239, 217, 0.88));
  background-size: 22px 22px, auto;
  box-shadow: var(--inset-paper), 0 14px 45px rgba(76, 45, 31, 0.12);
}

.dark #origami-canvas {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(247, 239, 217, 0.08) 1px, transparent 0),
    linear-gradient(135deg, rgba(52, 32, 24, 0.94), rgba(24, 38, 19, 0.88));
}

#paper-sheet {
  transform-style: preserve-3d;
  transition: transform 420ms var(--ease), box-shadow 420ms var(--ease), filter 420ms var(--ease);
  animation: paperEnter 900ms var(--ease) 160ms both;
}

#origami-canvas:hover #paper-sheet,
#origami-canvas:focus #paper-sheet {
  transform: perspective(900px) rotateX(5deg) rotateY(-4deg) translateY(-3px);
  box-shadow: 0 30px 70px rgba(42, 26, 18, 0.22);
}

#paper-sheet::before,
#paper-sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

#paper-sheet::before {
  background:
    linear-gradient(90deg, rgba(76, 45, 31, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(76, 45, 31, 0.035) 1px, transparent 1px);
  background-size: 16px 16px;
  mix-blend-mode: multiply;
}

#paper-sheet::after {
  box-shadow: inset 0 0 55px rgba(76, 45, 31, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

#crease-line-a,
#crease-line-b,
#crease-line-c {
  transform-origin: center;
  filter: drop-shadow(0 0 6px rgba(49, 75, 39, 0.14));
}

#crease-line-a {
  animation: drawVertical 1.1s var(--ease) 450ms both;
}

#crease-line-b {
  animation: drawVertical 1.1s var(--ease) 560ms both;
}

#crease-line-c {
  animation: drawHorizontal 1.1s var(--ease) 670ms both;
}

#fold-node-center {
  animation: pulseNode 2.2s ease-in-out infinite;
}

#paper-fold-flap {
  transform-origin: bottom right;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  animation: flapFold 4.6s var(--ease) infinite alternate;
}

#canvas-hint {
  backdrop-filter: blur(14px);
  background:
    linear-gradient(135deg, rgba(36, 74, 44, 0.96), rgba(49, 75, 39, 0.92));
}

#fold-timeline {
  overflow: hidden;
}

#step-timeline-list {
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--moss-600) rgba(239, 227, 207, 0.72);
}

#step-timeline-list > li {
  scroll-snap-align: start;
  transition: transform 260ms var(--ease), box-shadow 260ms var(--ease), filter 260ms var(--ease);
}

#step-timeline-list > li:hover {
  transform: translateY(-4px) rotate(-0.4deg);
  box-shadow: var(--shadow-lift);
}

#step-timeline-list > li:first-child {
  background:
    radial-gradient(circle at 80% 15%, rgba(201, 215, 161, 0.32), transparent 34%),
    linear-gradient(135deg, var(--moss-700), var(--fern));
}

#fold-parameters-form input[type="range"] {
  appearance: none;
  height: 0.7rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--moss-600), var(--lichen));
  box-shadow: inset 0 1px 3px rgba(42, 26, 18, 0.22);
  cursor: pointer;
}

#fold-parameters-form input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 1.45rem;
  height: 1.45rem;
  border: 3px solid #fffaf0;
  border-radius: 50%;
  background: var(--fern);
  box-shadow: 0 8px 18px rgba(36, 74, 44, 0.32);
  transition: transform 180ms var(--ease), background 180ms var(--ease);
}

#fold-parameters-form input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.12);
  background: var(--moss-600);
}

#fold-parameters-form input[type="range"]::-moz-range-thumb {
  width: 1.2rem;
  height: 1.2rem;
  border: 3px solid #fffaf0;
  border-radius: 50%;
  background: var(--fern);
  box-shadow: 0 8px 18px rgba(36, 74, 44, 0.32);
}

#fold-parameters-form select {
  max-width: 100%;
  box-shadow: var(--inset-paper);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 1.15rem) 52%,
    calc(100% - 0.82rem) 52%;
  background-size: 0.38rem 0.38rem, 0.38rem 0.38rem;
  background-repeat: no-repeat;
  padding-right: 2.4rem;
}

#symmetry-fieldset label:has(input:checked) {
  color: #fff;
  background: linear-gradient(135deg, var(--moss-700), var(--fern));
  border-color: var(--moss-700);
  box-shadow: var(--shadow-moss);
}

#symmetry-fieldset input[type="radio"] {
  flex: 0 0 auto;
}

#insight-compost-card {
  animation: fadeInUp 760ms var(--ease) 220ms both;
}

#apply-suggestion-button {
  color: var(--fern);
  background: var(--paper);
}

#apply-suggestion-button:hover {
  color: var(--soil);
}

#export-nest-card {
  animation: fadeInUp 760ms var(--ease) 280ms both;
}

#pattern-library-modal {
  z-index: 9999;
  animation: modalBackdropIn 220ms ease-out both;
}

#pattern-library-modal:not(.hidden) {
  display: block;
}

#pattern-library-modal > div {
  max-height: calc(100vh - 7rem);
  overflow: auto;
  animation: modalPanelIn 360ms var(--ease) both;
}

#pattern-library-grid button {
  box-shadow: var(--inset-paper);
}

#pattern-library-grid button:hover {
  border-color: var(--moss-600);
  background:
    radial-gradient(circle at 88% 16%, rgba(201, 215, 161, 0.28), transparent 30%),
    var(--cream);
}

.dark #pattern-library-grid button:hover {
  background:
    radial-gradient(circle at 88% 16%, rgba(201, 215, 161, 0.12), transparent 30%),
    var(--bark-800);
}

#mobile-action-bar {
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  animation: slideUp 560ms var(--ease) both;
}

@supports (backdrop-filter: blur(16px)) {
  #floating-identity > div,
  #quick-actions-nav,
  #mobile-action-bar,
  #hero-ridge,
  #canvas-grove,
  #fold-timeline,
  #fold-parameters-card,
  #export-nest-card,
  #tool-vine-sidebar > div {
    backdrop-filter: blur(18px) saturate(1.15);
  }
}

@supports not selector(:has(*)) {
  #symmetry-fieldset label {
    position: relative;
  }

  #symmetry-fieldset label input:checked + span {
    color: var(--moss-700);
    text-decoration: underline;
    text-decoration-thickness: 0.16em;
  }
}

@media (max-width: 767px) {
  #main-workspace {
    padding-bottom: 6.8rem;
  }

  #floating-identity {
    align-items: stretch;
  }

  #floating-identity > div {
    max-width: calc(100vw - 2rem);
  }

  #hero-ridge h1 {
    font-size: clamp(2.35rem, 13vw, 3.45rem);
  }

  #project-health-panel dl {
    grid-template-columns: 1fr;
    text-align: left;
  }

  #canvas-toolbar > div {
    width: 100%;
  }

  #canvas-toolbar button {
    flex: 1 1 auto;
  }

  #origami-canvas {
    min-height: min(32rem, 78vh);
  }

  #paper-sheet {
    width: 88%;
  }

  #canvas-hint {
    font-size: 0.82rem;
  }
}

@media (max-width: 420px) {
  #tool-vine-sidebar > div {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #canvas-toolbar button {
    width: 100%;
  }

  #zoom-output {
    flex: 1 1 auto;
  }

  #step-timeline-list > li {
    min-width: 11.5rem;
    max-width: 11.5rem;
  }
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(1rem) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(1.25rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatLeaf {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
  }
  to {
    transform: translate3d(1.8rem, -1.2rem, 0) rotate(8deg) scale(1.05);
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.12) rotate(10deg);
    opacity: 0.42;
  }
}

@keyframes paperEnter {
  from {
    opacity: 0;
    transform: perspective(900px) rotateX(16deg) rotateY(-12deg) translateY(1.5rem) scale(0.96);
  }
  to {
    opacity: 1;
    transform: perspective(900px) rotateX(0) rotateY(0) translateY(0) scale(1);
  }
}

@keyframes drawVertical {
  from {
    opacity: 0;
    transform: scaleY(0) rotate(var(--r, 0deg));
  }
  to {
    opacity: 1;
    transform: scaleY(1) rotate(var(--r, 0deg));
  }
}

@keyframes drawHorizontal {
  from {
    opacity: 0;
    transform: scaleX(0);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

@keyframes pulseNode {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 0 0 rgba(121, 59, 37, 0.38);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow: 0 0 0 0.8rem rgba(121, 59, 37, 0);
  }
}

@keyframes flapFold {
  from {
    transform: perspective(560px) rotateX(0deg) rotateY(0deg);
    filter: brightness(1);
  }
  to {
    transform: perspective(560px) rotateX(4deg) rotateY(-14deg);
    filter: brightness(1.04);
  }
}

@keyframes modalBackdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalPanelIn {
  from {
    opacity: 0;
    transform: translateY(1.5rem) scale(0.965);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}