: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;
}

.gradient-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 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;
}

.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;
}

.stops-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;
}

.angle-presets {
  gap: 4px;
}

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

.gradient-track {
  position: relative;
  height: 32px;
  margin-bottom: 24px;
  border: 1.5px solid #1c1b18;
  border-radius: 2px;
  cursor: copy;
  touch-action: none;
  background-color: #f4f1e8;
  background-image: linear-gradient(45deg, #d9d3c3 25%, transparent 25%), linear-gradient(-45deg, #d9d3c3 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d9d3c3 75%), linear-gradient(-45deg, transparent 75%, #d9d3c3 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.gradient-track-fill {
  position: absolute;
  inset: 0;
  border-radius: 1px;
  pointer-events: none;
}

.stop-handle {
  position: absolute;
  top: 100%;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  padding: 0;
  transform: translate(-50%, 0) rotate(45deg);
  background: var(--stop-color, #1c1b18);
  border: 1.5px solid #1c1b18;
  border-radius: 2px;
  cursor: grab;
  transition: box-shadow 0.4s cubic-bezier(0.22, 0.61, 0.36, 1), transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.stop-handle:hover {
  transform: translate(-50%, -2px) rotate(45deg);
}
.stop-handle.is-active {
  box-shadow: 0 0 0 2px #ece7d9, 0 0 0 3px #d8442a;
  z-index: 1;
}

.layer-editor {
  gap: 24px;
  padding: 16px;
  background: #f4f1e8;
  border: 1px solid #d9d3c3;
  border-radius: 2px;
}

.stop-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.layer-del-btn {
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  color: #6b665b;
  background: none;
  border: 1px solid #d9d3c3;
  border-radius: 2px;
  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);
}
.layer-del-btn:hover:not(:disabled) {
  color: #f4f1e8;
  background: #d8442a;
  border-color: #d8442a;
}
.layer-del-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-swatch {
  flex: 0 0 auto;
  width: 40px;
  height: 32px;
  padding: 0;
  border: 1.5px solid #1c1b18;
  border-radius: 2px;
  background: none;
  cursor: pointer;
}
.color-swatch::-webkit-color-swatch-wrapper {
  padding: 2px;
}
.color-swatch::-webkit-color-swatch {
  border: none;
  border-radius: 1px;
}

.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;
}

.color-hex {
  text-transform: uppercase;
}

.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;
}

.gradient-stage {
  min-height: 360px;
  border: 1.5px solid #1c1b18;
  border-radius: 2px;
  transition: background 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.code-wrap {
  position: relative;
}

.code-block {
  margin: 0;
  padding: 24px;
  padding-right: 132px;
  max-height: 280px;
  overflow: auto;
  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) {
  .gradient-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
}
