body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgb(255, 230, 190), transparent 24%),
    radial-gradient(circle at 85% 14%, rgb(255, 211, 201), transparent 18%),
    radial-gradient(circle at 50% 100%, rgb(250, 221, 173), transparent 24%),
    rgb(241, 236, 227);
  color: rgb(29, 31, 36);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(57, 44, 26, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57, 44, 26, 0.03) 1px, transparent 1px);
  background-size: 38px 38px;
  pointer-events: none;
  opacity: 0.35;
}

.page {
  position: relative;
  max-width: 1480px;
  margin: 0 auto;
  padding: 30px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 34px;
  border: 2px solid rgb(29, 31, 36);
  border-radius: 30px;
  background: linear-gradient(135deg, rgb(255, 201, 129), rgb(255, 239, 196));
  box-shadow: 0 24px 54px rgba(100, 69, 25, 0.12);
}

.eyebrow {
  margin-bottom: 10px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgb(144, 88, 21);
}

h1 {
  font-size: clamp(38px, 6vw, 68px);
  line-height: 0.95;
}

h2 {
  font-size: 25px;
}

.hero-text {
  margin-top: 14px;
  max-width: 700px;
  color: rgb(86, 76, 62);
  line-height: 1.6;
}

.hero-tip,
.panel-text,
.graph-hint {
  margin-top: 12px;
  color: rgb(114, 103, 87);
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  margin-top: 24px;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 560px;
  padding: 24px;
  border: 2px solid rgb(29, 31, 36);
  border-radius: 28px;
  background: rgb(255, 251, 245);
  box-shadow: 0 18px 38px rgba(95, 73, 38, 0.1);
  overflow: hidden;
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 214, 150, 0.14), transparent 42%);
  pointer-events: none;
}

.panel > * {
  position: relative;
  z-index: 1;
}

.panel-graph,
.panel-export {
  grid-column: 1 / -1;
}

.panel-source textarea {
  min-height: 620px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

textarea,
select,
input[type="number"] {
  width: 100%;
  border: 2px solid rgb(29, 31, 36);
  border-radius: 20px;
  padding: 14px 16px;
  background: rgb(252, 248, 242);
  color: rgb(29, 31, 36);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition:
    border-color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

textarea {
  flex: 1;
  min-height: 320px;
  resize: vertical;
  line-height: 1.55;
}

textarea:focus,
select:focus,
input[type="number"]:focus {
  outline: none;
  border-color: rgb(214, 108, 40);
  box-shadow: 0 0 0 4px rgba(214, 108, 40, 0.14);
  transform: translateY(-1px);
}

button,
input::file-selector-button {
  border: 2px solid rgb(29, 31, 36);
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgb(29, 31, 36), rgb(61, 69, 82));
  color: rgb(255, 251, 245);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow:
    0 12px 22px rgba(70, 53, 21, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease,
    background 180ms ease;
}

button:hover,
input::file-selector-button:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow:
    0 18px 30px rgba(98, 74, 25, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  filter: brightness(1.04);
}

button:active,
input::file-selector-button:active {
  transform: translateY(1px) scale(0.99);
}

button:focus-visible,
input::file-selector-button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px rgba(214, 108, 40, 0.16),
    0 16px 30px rgba(98, 74, 25, 0.18);
}

.ghost {
  background: rgb(255, 251, 245);
  color: rgb(29, 31, 36);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.status-box {
  min-height: 98px;
  padding: 16px;
  border: 2px solid rgb(29, 31, 36);
  border-radius: 20px;
  background: rgb(243, 239, 232);
  color: rgb(29, 31, 36);
  white-space: pre-wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 16px;
  border: 2px solid rgb(29, 31, 36);
  border-radius: 20px;
  background: rgb(247, 240, 231);
}

.stat-card span,
.filters span {
  display: block;
  margin-bottom: 7px;
  color: rgb(112, 104, 95);
}

.stat-card strong {
  font-size: 22px;
}

.stat-card.wide {
  grid-column: span 3;
}

.nodes-view,
.paths-view {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.node-card,
.path-card {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 18px;
  border: 2px solid rgb(29, 31, 36);
  border-radius: 22px;
  background: rgb(255, 251, 245);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.node-card:hover,
.path-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 26px rgba(95, 73, 38, 0.12);
}

.node-card.action {
  border-color: rgba(70, 232, 183, 0.42);
}

.node-card.branch {
  border-color: rgba(150, 132, 255, 0.48);
}

.node-card.end {
  border-color: rgba(255, 124, 161, 0.46);
}

.muted {
  margin: 4px 0 8px;
  color: rgb(112, 104, 95);
}

.link-line {
  margin-top: 8px;
  color: rgb(39, 118, 83);
  font-weight: 700;
}

.branch-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  list-style: none;
}

.branch-list li {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border-radius: 16px;
  background: rgb(244, 238, 230);
  color: rgb(29, 31, 36);
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.filters label {
  display: grid;
  gap: 8px;
}

.graph-shell {
  display: grid;
  gap: 14px;
}

.graph-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.legend {
  padding: 8px 12px;
  border: 2px solid rgb(29, 31, 36);
  border-radius: 999px;
  background: rgb(255, 251, 245);
  color: rgb(29, 31, 36);
  font-size: 13px;
}

.legend.action {
  background: rgb(231, 247, 239);
  box-shadow: inset 0 0 0 1px rgba(39, 118, 83, 0.28);
}

.legend.branch {
  background: rgb(239, 232, 255);
  box-shadow: inset 0 0 0 1px rgba(126, 97, 214, 0.28);
}

.legend.end {
  background: rgb(255, 232, 238);
  box-shadow: inset 0 0 0 1px rgba(178, 76, 107, 0.28);
}

.graph-stage {
  position: relative;
  min-height: 860px;
  border: 2px solid rgb(29, 31, 36);
  border-radius: 30px;
  background:
    radial-gradient(circle at 24% 24%, rgba(145, 126, 255, 0.16), transparent 24%),
    radial-gradient(circle at 72% 74%, rgba(115, 188, 255, 0.12), transparent 20%),
    linear-gradient(180deg, rgb(255, 248, 237), rgb(243, 233, 221));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.2),
    0 14px 28px rgba(95, 73, 38, 0.08);
  overflow: hidden;
  --shift-x: 0px;
  --shift-y: 0px;
}

.graph-stage::before,
.graph-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.graph-stage::before {
  background:
    linear-gradient(rgba(57, 44, 26, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57, 44, 26, 0.04) 1px, transparent 1px);
  background-size: 72px 72px;
  opacity: 0.9;
}

.graph-stage::after {
  background:
    radial-gradient(circle at 20% 24%, rgba(255, 199, 129, 0.26), transparent 18%),
    radial-gradient(circle at 72% 70%, rgba(255, 223, 192, 0.22), transparent 20%);
  transform: translate(calc(var(--shift-x) * 0.35), calc(var(--shift-y) * 0.35));
  transition: transform 140ms ease;
}

#graph-svg {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 860px;
  display: block;
  transform: translate(calc(var(--shift-x) * 0.16), calc(var(--shift-y) * 0.16));
  transition: transform 140ms ease;
}

.graph-orb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(147, 123, 255, 0.16), rgba(147, 123, 255, 0.04) 46%, transparent 68%);
  filter: blur(18px);
  transform: translate(calc(-50% + var(--shift-x) * 0.7), calc(-50% + var(--shift-y) * 0.7));
  transition: transform 140ms ease;
  pointer-events: none;
  z-index: 0;
}

.graph-node {
  cursor: pointer;
  transition: transform 220ms ease, opacity 220ms ease, filter 220ms ease;
}

.graph-node.is-dim {
  opacity: 0.32;
}

.graph-node.is-active .node-core {
  filter: url(#node-glow);
}

.node-ring {
  fill: rgba(255, 255, 255, 0.55);
  stroke: rgba(63, 54, 44, 0.12);
  stroke-width: 1.5;
}

.node-core {
  stroke-width: 2.2;
  filter: drop-shadow(0 12px 18px rgba(95, 73, 38, 0.12));
}

.node-core.action {
  fill: rgb(231, 247, 239);
  stroke: rgb(39, 118, 83);
}

.node-core.branch {
  fill: rgb(239, 232, 255);
  stroke: rgb(126, 97, 214);
}

.node-core.end {
  fill: rgb(255, 232, 238);
  stroke: rgb(178, 76, 107);
}

.node-title {
  fill: rgb(29, 31, 36);
  font-size: 18px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
}

.node-subtitle {
  fill: rgba(77, 69, 58, 0.74);
  font-size: 12px;
  text-anchor: middle;
  dominant-baseline: middle;
}

.graph-edge {
  fill: none;
  stroke: rgba(109, 101, 176, 0.54);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 220ms ease, stroke 220ms ease, stroke-width 220ms ease;
}

.graph-edge.is-dim {
  opacity: 0.18;
}

.graph-edge.is-active {
  stroke: rgba(109, 101, 176, 0.95);
  stroke-width: 4;
}

.edge-label {
  fill: rgb(67, 58, 111);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
}

.edge-dot {
  fill: rgba(109, 101, 176, 0.8);
}

.edge-label-bg {
  fill: rgba(255, 248, 237, 0.92);
  stroke: rgba(109, 101, 176, 0.18);
  stroke-width: 1;
}


.graph-stage.is-moving .graph-node {
  transition: transform 90ms linear, opacity 180ms ease, filter 180ms ease;
}

.path-card p {
  line-height: 1.55;
}

#analysis-summary:empty {
  display: none;
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel,
.node-card,
.path-card,
.stat-card {
  animation: panel-enter 420ms ease;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel-graph,
  .panel-export {
    grid-column: auto;
  }
}

@media (max-width: 900px) {
  .page {
    padding: 16px;
  }

  .hero,
  .panel-head,
  .graph-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-grid,
  .filters,
  .nodes-view,
  .paths-view {
    grid-template-columns: 1fr;
  }

  .stat-card.wide {
    grid-column: span 1;
  }

  .graph-stage,
  #graph-svg {
    min-height: 620px;
  }
}
