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

.clamp-layout {
  display: grid;
  grid-template-columns: minmax(280px, 320px) 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 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  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;
  letter-spacing: 0;
}

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

.chip-group {
  display: flex;
  flex-wrap: wrap;
  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;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

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

.input-suffix-wrap {
  position: relative;
}

.text-input {
  width: 100%;
  min-width: 0;
  padding: 8px 16px;
  padding-right: 36px;
  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;
}

.input-suffix {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  color: #6b665b;
  pointer-events: none;
  user-select: none;
}

.input-arrow {
  flex-shrink: 0;
  color: #6b665b;
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  padding-bottom: 8px;
}

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

.calc-result {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: #f4f1e8;
  border: 1px solid #d9d3c3;
  border-radius: 2px;
}

.calc-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

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

.calc-val {
  font-family: "Inter", "Noto Sans TC", sans-serif;
  font-size: 1rem;
  font-style: normal;
  color: #1c1b18;
  text-align: right;
}

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

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

.clamp-chart {
  display: block;
  width: 100%;
  height: auto;
}

.preview-text-wrap {
  min-height: 80px;
  padding: 24px;
  background: #ece7d9;
  border: 1px solid #d9d3c3;
  border-radius: 2px;
  display: flex;
  align-items: center;
}

.preview-text {
  margin: 0;
  color: #1c1b18;
  line-height: 1.4;
  transition: font-size 0.12s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.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) {
  .clamp-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
  .controls {
    position: static;
    top: auto;
  }
}
