:root {
  --bg-top: #fdf6e5;
  --bg-mid: #d6efe5;
  --bg-bottom: #f4d8cc;
  --panel: rgba(255, 255, 255, 0.82);
  --line: #2d463f;
  --ink: #132320;
  --muted: #516962;
  --accent: #d94826;
  --accent-soft: #f9d7ce;
  --important: #d94826;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  color: var(--ink);
  min-height: 100vh;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.65) 0%, transparent 36%),
    radial-gradient(circle at 85% 75%, rgba(255, 255, 255, 0.45) 0%, transparent 38%),
    linear-gradient(140deg, var(--bg-top), var(--bg-mid) 48%, var(--bg-bottom));
}

.app-shell {
  width: min(1200px, 94vw);
  margin: 24px auto 40px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
}

.app-header p {
  margin-top: 8px;
  color: var(--muted);
}

.mode-switch {
  margin: 16px 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.mode-btn,
button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease;
}

.mode-btn.active {
  background: var(--accent);
  color: white;
}

.mode-btn:hover,
button:hover {
  transform: translateY(-1px);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(280px, 34%) 1fr;
  gap: 16px;
}

.layout-grid.stage-mode {
  grid-template-columns: 1fr;
}

.layout-grid.stage-mode #variant-nav {
  order: 1;
}

.layout-grid.stage-mode .panel:last-child {
  order: 2;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(19, 35, 32, 0.24);
  border-radius: 18px;
  padding: 14px;
  backdrop-filter: blur(2px);
}

.panel h2,
.panel h3 {
  margin: 0;
}

.panel-subtitle {
  color: var(--muted);
  margin: 8px 0 10px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.meta-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(19, 35, 32, 0.18);
  border-radius: 12px;
  padding: 10px;
}

.meta-card h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.meta-card p {
  margin: 6px 0 4px;
  font-weight: 600;
}

.meta-card small {
  color: var(--muted);
}

.variant-form {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

input[type="text"],
input[type="number"] {
  width: 100%;
  border: 1px solid rgba(19, 35, 32, 0.35);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 0.95rem;
}

input[readonly] {
  background: #eff6f2;
}

.slider-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

output {
  min-width: 36px;
  text-align: right;
  font-weight: 600;
}

.actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button.alt {
  background: var(--accent-soft);
}

.tree-wrap,
.leaf-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.tree-row {
  padding-left: calc(var(--depth) * 14px);
}

.tree-children,
.tree-chain-children {
  border-left: 1px dashed rgba(19, 35, 32, 0.25);
  margin-left: 10px;
  padding-left: 8px;
}

.variant-item {
  width: 100%;
  text-align: left;
}

.variant-item.selected {
  background: #132320;
  color: white;
}

.variant-item.important {
  border-color: var(--important);
}

.lineage-badge {
  margin: 8px 0;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.git-tree,
.git-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.git-tree {
  margin-top: 8px;
}

.git-node {
  position: relative;
  padding-left: 18px;
}

.git-node::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  border-left: 1px solid rgba(19, 35, 32, 0.32);
}

.git-node:last-child::before {
  bottom: calc(100% - 20px);
}

.git-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.git-row::before {
  content: "";
  position: absolute;
  left: -11px;
  width: 11px;
  border-top: 1px solid rgba(19, 35, 32, 0.32);
}

.git-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  padding: 0;
  border: 2px solid #6da8f7;
  background: white;
}

.git-dot.selected {
  border-color: #1c4fba;
  background: #1c4fba;
}

.git-dot.important {
  box-shadow: 0 0 0 2px rgba(217, 72, 38, 0.35);
}

.git-label {
  border: none;
  background: transparent;
  padding: 3px 5px;
  border-radius: 8px;
}

.git-label.selected {
  background: rgba(28, 79, 186, 0.12);
}

.git-children {
  margin-left: 2px;
}

.stage-wrap {
  margin-top: 10px;
  border: 1px solid rgba(19, 35, 32, 0.15);
  border-radius: 12px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.72);
}

.stage-svg {
  width: 100%;
  min-width: 920px;
  height: auto;
  display: block;
}

.stage-guide {
  stroke: rgba(19, 35, 32, 0.16);
  stroke-width: 1;
}

.stage-edge {
  fill: none;
  stroke: #72a9f7;
  stroke-width: 2.1;
}

.stage-edge.selected {
  stroke: #7f58ef;
  stroke-width: 3;
}

.stage-node {
  fill: #6eaaf7;
  cursor: pointer;
}

.stage-node.selected {
  fill: #7f58ef;
}

.stage-node.important {
  stroke: #d94826;
  stroke-width: 2;
}

.stage-label {
  font-size: 10px;
  fill: #28403a;
  cursor: pointer;
}

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

  .meta-grid {
    grid-template-columns: 1fr;
  }
}
