:root {
  --color-paper: #f4f1e8;
  --color-paper-deep: #ece7d9;
  --color-ink: #1c1b18;
  --color-ink-soft: #6b665b;
  --color-line: #d9d3c3;
  --color-accent: #d8442a;
  --color-accent-deep: #b0331d;
  --color-mark: #e0a92e;
  --font-display: Inter, Noto Sans TC, sans-serif;
  --font-body: Inter, Noto Sans TC, sans-serif;
  --font-mono: Inter, Noto Sans TC, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

.tool-intro {
  max-width: 64ch;
  margin-block: 24px 40px;
  color: #6b665b;
}

.bezier-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: #ece7d9;
  border: 1px solid #d9d3c3;
  border-radius: 2px;
  position: sticky;
  top: 24px;
}

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

.control-label {
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b665b;
}

.control-label-value {
  font-variant-numeric: tabular-nums;
  color: #1c1b18;
  text-transform: none;
}

.coord-hint {
  color: #6b665b;
  letter-spacing: 0;
}

.control-section {
  padding-top: 24px;
  border-top: 1px solid #d9d3c3;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chip {
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  padding: 4px 16px;
  border: 1px solid #d9d3c3;
  border-radius: 2px;
  color: #6b665b;
  background: #f4f1e8;
  cursor: pointer;
  transition: color 0.4s cubic-bezier(0.22, 0.61, 0.36, 1), border-color 0.4s cubic-bezier(0.22, 0.61, 0.36, 1), background-color 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.chip:hover {
  color: #1c1b18;
  border-color: #1c1b18;
}
.chip.is-active {
  color: #f4f1e8;
  background: #d8442a;
  border-color: #d8442a;
}

.coord-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.coord-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.coord-name {
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b665b;
}

.text-input {
  width: 100%;
  min-width: 0;
  padding: 8px 16px;
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: #1c1b18;
  background: #f4f1e8;
  border: 1.5px solid #1c1b18;
  border-radius: 2px;
  transition: border-color 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.text-input:focus {
  outline: none;
  border-color: #d8442a;
}
.text-input.is-invalid {
  border-color: #d8442a;
}

.range-input {
  width: 100%;
  accent-color: #d8442a;
  cursor: pointer;
}

.output {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.output .section-rule {
  margin-top: 40px;
}

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.stage-hint {
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  color: #6b665b;
}

.preview-bar {
  margin-top: 40px;
}

.curve-wrap {
  padding: 16px;
  background: #f4f1e8;
  border: 1.5px solid #1c1b18;
  border-radius: 2px;
}

.curve {
  display: block;
  width: 100%;
  height: auto;
  max-width: 360px;
  margin: 0 auto;
  touch-action: none;
  overflow: visible;
}

.curve-box {
  fill: none;
  stroke: #1c1b18;
  stroke-width: 1.5;
}

.curve-overshoot {
  fill: #ece7d9;
  opacity: 0.5;
}

.curve-grid line {
  stroke: #d9d3c3;
  stroke-width: 1;
}

.curve-diagonal {
  stroke: #6b665b;
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.6;
}

.curve-guide {
  stroke: #d8442a;
  stroke-width: 1.5;
}

.curve-path {
  stroke: #d8442a;
  stroke-width: 3;
  stroke-linecap: round;
}

.curve-anchor {
  fill: #1c1b18;
}

.curve-handle {
  fill: #f4f1e8;
  stroke: #d8442a;
  stroke-width: 2.5;
  cursor: grab;
  transition: fill 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.curve-handle:hover {
  fill: #d8442a;
}
.curve-handle:focus-visible {
  outline: 2px solid #1c1b18;
  outline-offset: 2px;
}
.curve-handle.is-active {
  fill: #d8442a;
  cursor: grabbing;
}

.preview-track {
  position: relative;
  height: 32px;
  border: 1px solid #d9d3c3;
  border-radius: 2px;
  background: #ece7d9;
}

.preview-ball {
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #d8442a;
  box-shadow: 2px 2px 0 rgba(28, 27, 24, 0.18);
  animation: bezier-move var(--bz-dur, 1.2s) linear infinite alternate;
}

@keyframes bezier-move {
  from {
    left: 0;
  }
  to {
    left: calc(100% - 32px);
  }
}
.code-wrap {
  position: relative;
}

.code-block {
  margin: 0;
  padding: 24px;
  padding-right: 96px;
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: #1c1b18;
  background: #ece7d9;
  border: 1px solid #d9d3c3;
  border-radius: 2px;
  white-space: pre-wrap;
  word-break: break-all;
}

.code-copy {
  position: absolute;
  top: 16px;
  right: 16px;
}

.copy-hint {
  min-height: 1.4em;
  margin: 8px 0 0;
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  color: #d8442a;
}

@media (max-width: 860px) {
  .bezier-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
  .controls {
    position: static;
    top: auto;
  }
}
