:root {
  --panel: rgba(255, 249, 240, 0.58);
  --line: #1e2d56;
  --accent: #ec5f2a;
  --accent-2: #2c9fb5;
  --text: #4a3820;
  --muted: #7a6348;
}

* {
  box-sizing: border-box;
}

html {
  background: transparent;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "Avenir Next", "Avenir", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: transparent;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  padding: 8px 0;
  gap: 10px;
}

.panel {
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid rgba(210, 138, 54, 0.28);
  padding: 10px;
}

h1,
h2 {
  margin: 0 0 10px;
}

h1 {
  font-size: 1rem;
}

h2 {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diagram {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  border: 1px solid rgba(122, 158, 126, 0.28);
  background: rgba(255, 255, 255, 0.38);
}

#joint-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.link {
  stroke: var(--line);
  stroke-width: 8;
  stroke-linecap: round;
}

.joint {
  fill: #0b214d;
}

.handle {
  cursor: grab;
}

.handle:active {
  cursor: grabbing;
}

.attach-1 {
  fill: var(--accent);
}

.attach-2 {
  fill: var(--accent-2);
}

.tendon {
  stroke: #d94f2a;
  stroke-width: 4;
  fill: none;
  stroke-linecap: round;
}

.zero-guide {
  stroke: #8aa0cb;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 8 7;
  opacity: 0.7;
}

.ctrl-grid {
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 8px;
  align-items: center;
}

.control {
  margin-top: 2px;
}

label {
  font-size: 0.78rem;
}

input[type='range'] {
  width: 100%;
}

.value {
  font-size: 0.76rem;
  color: var(--muted);
  text-align: right;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 6px;
  margin-top: 4px;
}

.metric {
  background: rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  padding: 6px 8px;
  border: 1px solid rgba(122, 158, 126, 0.22);
}

.metric strong {
  display: block;
  font-size: 0.64rem;
  color: var(--muted);
}

.metric span {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
}

.graph {
  width: 100%;
  margin-bottom: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(122, 158, 126, 0.22);
  padding: 6px;
}

.graph-controls {
  margin-bottom: 8px;
  font-size: 0.74rem;
  color: var(--muted);
}

.graph-controls label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

canvas {
  width: 100%;
  height: 170px;
  display: block;
}

.graph-title {
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 4px;
}

@media (max-width: 640px) {
  .app {
    grid-template-columns: 1fr;
    padding: 8px 0;
  }

  .left {
    order: 1;
  }

  .right {
    order: 2;
  }

  canvas {
    height: 190px;
  }
}
