:root {
  --mixed-color: #c75a6a;
  --panel-bg: rgba(255, 242, 245, 0.58);
  --panel-stroke: rgba(255, 255, 255, 0.62);
  --panel-shadow: rgba(92, 18, 36, 0.28);
  --text: #39151e;
  --muted: rgba(57, 21, 30, 0.62);
  --hairline: rgba(57, 21, 30, 0.18);
  --white-soft: rgba(255, 255, 255, 0.66);
  --control-bg: rgba(255, 255, 255, 0.38);
  --control-bg-strong: rgba(255, 255, 255, 0.72);
  --focus-ring: rgba(255, 255, 255, 0.9);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--mixed-color);
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background: var(--mixed-color);
  transition: background-color 220ms ease, color 220ms ease;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  display: none;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.18), transparent 40%),
    linear-gradient(295deg, rgba(54, 0, 20, 0.14), transparent 52%);
  mix-blend-mode: soft-light;
}

body.beauty-on {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(58, 0, 18, 0.16)),
    var(--mixed-color);
}

body.beauty-on::before {
  display: block;
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  position: relative;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: clamp(20px, 5vw, 64px);
}

.mixer-panel {
  width: min(780px, 100%);
  padding: clamp(18px, 3.2vw, 32px);
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius);
  background: var(--panel-bg);
  box-shadow:
    0 32px 80px var(--panel-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(28px) saturate(1.25);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.beauty-toggle {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0 12px 0 10px;
  background: var(--control-bg);
  color: rgba(57, 21, 30, 0.72);
  cursor: pointer;
  font-size: 13px;
  font-weight: 760;
  letter-spacing: 0;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.beauty-toggle:hover,
.beauty-toggle.is-active {
  border-color: rgba(255, 255, 255, 0.78);
  background: var(--control-bg-strong);
  color: var(--text);
}

.switch-track {
  position: relative;
  width: 34px;
  height: 19px;
  flex: 0 0 auto;
  border: 1px solid rgba(57, 21, 30, 0.2);
  border-radius: 999px;
  background: rgba(57, 21, 30, 0.14);
  transition: background 160ms ease, border-color 160ms ease;
}

.switch-track span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(57, 21, 30, 0.2);
  transition: transform 160ms ease;
}

.beauty-toggle.is-active .switch-track {
  border-color: rgba(255, 255, 255, 0.64);
  background: var(--mixed-color);
}

.beauty-toggle.is-active .switch-track span {
  transform: translateX(15px);
}

.panel-header h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 760;
  line-height: 1.05;
  letter-spacing: 0;
}

.panel-header p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--control-bg);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.icon-button:hover {
  border-color: rgba(255, 255, 255, 0.8);
  background: var(--control-bg-strong);
  transform: translateY(-1px);
}

.icon-button svg,
.mode-tab svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin: 0 auto 24px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.2);
}

.mode-tab {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: rgba(57, 21, 30, 0.64);
  cursor: pointer;
  font-size: 15px;
  font-weight: 720;
  letter-spacing: 0;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.mode-tab.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.66);
  box-shadow: 0 12px 28px rgba(80, 18, 32, 0.12);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 3vw, 28px);
  margin-bottom: 24px;
}

.color-well {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 0;
}

.color-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.swatch-button {
  position: relative;
  display: grid;
  width: clamp(72px, 11vw, 112px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  background: var(--swatch);
  box-shadow: none;
  overflow: hidden;
}

.swatch-button::after {
  position: absolute;
  top: 14%;
  left: 18%;
  width: 38%;
  height: 18%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  content: "";
  display: none;
  filter: blur(3px);
  transform: rotate(-22deg);
}

body.beauty-on .swatch-button {
  box-shadow:
    inset 0 0 0 8px rgba(255, 255, 255, 0.18),
    inset 18px 18px 18px rgba(255, 255, 255, 0.16),
    0 18px 30px rgba(71, 18, 30, 0.18);
}

body.beauty-on .swatch-button::after {
  display: block;
}

.swatch-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.share-chip {
  position: relative;
  z-index: 1;
  display: inline-flex;
  min-width: 52px;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--chip-text);
  background: transparent;
  font-size: 14px;
  font-weight: 780;
  line-height: 1;
  box-shadow: none;
}

body.beauty-on .share-chip {
  background: rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.hex-input {
  width: min(124px, 100%);
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, 0.28);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 720;
  text-align: center;
  text-transform: uppercase;
}

.mode-panel {
  display: none;
}

.mode-panel.is-active {
  display: block;
}

.slider-list {
  display: grid;
  gap: 18px;
}

.slider-row {
  display: grid;
  grid-template-columns: minmax(88px, 124px) 1fr 66px;
  gap: 16px;
  align-items: center;
}

.slider-label {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 740;
}

.dot {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: var(--swatch);
  box-shadow: none;
}

body.beauty-on .dot {
  box-shadow: 0 5px 10px rgba(57, 21, 30, 0.16);
}

.range-wrap {
  position: relative;
  min-width: 0;
}

.range-fill {
  position: absolute;
  top: 50%;
  left: 0;
  width: var(--fill);
  height: 7px;
  border-radius: 999px;
  background: var(--swatch);
  pointer-events: none;
  transform: translateY(-50%);
}

.weight-slider {
  position: relative;
  display: block;
  width: 100%;
  height: 32px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.weight-slider::-webkit-slider-runnable-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
}

.weight-slider::-moz-range-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
}

.weight-slider::-webkit-slider-thumb {
  width: 26px;
  height: 26px;
  margin-top: -9.5px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  appearance: none;
  background: #fff;
  box-shadow: 0 10px 22px rgba(57, 21, 30, 0.22);
}

.weight-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 10px 22px rgba(57, 21, 30, 0.22);
}

.weight-value {
  justify-self: end;
  min-width: 58px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.28);
  font-size: 14px;
  font-weight: 720;
  text-align: center;
}

.total-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 720;
  letter-spacing: 0.08em;
}

.total-row strong {
  color: var(--text);
}

.triangle-wrap {
  position: relative;
  width: min(390px, 100%);
  margin: 0 auto;
  touch-action: none;
  cursor: crosshair;
}

#triangleCanvas {
  display: block;
  width: 100%;
  height: auto;
}

.triangle-marker {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  background: var(--mixed-color);
  box-shadow: none;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

body.beauty-on .triangle-marker {
  box-shadow: 0 12px 28px rgba(58, 9, 22, 0.26);
}

.result-bar {
  display: grid;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--hairline);
}

.result-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
}

.result-color {
  display: grid;
  justify-items: center;
  gap: 5px;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.22);
  cursor: pointer;
  padding: 12px 18px 14px;
  transition: background 160ms ease, transform 160ms ease;
}

.result-color:hover {
  background: rgba(255, 255, 255, 0.38);
  transform: translateY(-1px);
}

.ratio-button {
  min-width: 118px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.34);
  color: var(--text);
  cursor: pointer;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 780;
  letter-spacing: 0;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.ratio-button:hover {
  border-color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.58);
  transform: translateY(-1px);
}

#resultHex {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 760;
  line-height: 0.98;
  letter-spacing: 0;
}

#copyHint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(42, 8, 18, 0.36);
  backdrop-filter: blur(14px);
}

.modal-backdrop[hidden] {
  display: none;
}

.ratio-dialog {
  width: min(520px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius);
  background: rgba(255, 244, 247, 0.96);
  box-shadow: 0 26px 80px rgba(45, 8, 18, 0.3);
  padding: 20px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.dialog-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
}

.dialog-close {
  width: 40px;
  height: 40px;
}

.target-color-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
}

.target-picker,
.target-hex-field {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.target-picker {
  position: relative;
  grid-template-columns: 1fr 58px;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.42);
  cursor: pointer;
  padding: 12px;
}

.target-picker::after {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: var(--radius);
  background: var(--target-color);
  content: "";
}

.target-picker span,
.target-hex-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.target-picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.target-hex-field input {
  width: 100%;
  min-height: 84px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.42);
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 28px;
  font-weight: 760;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.dialog-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  line-height: 1.5;
}

.dialog-message.is-error {
  color: #8e1535;
}

.dialog-message.is-success {
  color: #2c6745;
}

.ratio-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.ratio-comparison[hidden] {
  display: none;
}

.compare-swatch {
  display: grid;
  gap: 7px;
  min-width: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.4);
  color: var(--text);
  cursor: pointer;
  padding: 10px;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.compare-swatch::before {
  display: block;
  height: 72px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: var(--radius);
  background: var(--compare-color);
  content: "";
}

.compare-swatch span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0.04em;
}

.compare-swatch strong {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 780;
  letter-spacing: 0;
}

.compare-swatch small {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 720;
  line-height: 1.3;
}

.compare-swatch:hover,
.compare-swatch.is-actionable:hover {
  border-color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.58);
  transform: translateY(-1px);
}

.compare-swatch.is-actionable {
  box-shadow: inset 0 0 0 1px rgba(57, 21, 30, 0.08);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 780;
  letter-spacing: 0;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.primary-button {
  border: 1px solid rgba(57, 21, 30, 0.16);
  background: var(--text);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.36);
  color: var(--text);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: var(--radius);
  color: #fff;
  background: rgba(45, 14, 22, 0.78);
  box-shadow: 0 18px 50px rgba(44, 5, 16, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 160ms ease, transform 160ms ease;
  backdrop-filter: blur(14px);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .app-shell {
    align-items: start;
    min-height: 100svh;
    padding: 8px;
  }

  .mixer-panel {
    padding: 12px;
  }

  .panel-header {
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
  }

  .header-actions {
    align-items: flex-end;
    flex-direction: column;
    gap: 6px;
  }

  .beauty-toggle {
    min-height: 32px;
    gap: 6px;
    padding-inline: 7px 8px;
    font-size: 11px;
  }

  .switch-track {
    width: 28px;
    height: 16px;
  }

  .switch-track span {
    width: 10px;
    height: 10px;
  }

  .beauty-toggle.is-active .switch-track span {
    transform: translateX(12px);
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .icon-button svg,
  .mode-tab svg {
    width: 16px;
    height: 16px;
  }

  .panel-header h1 {
    font-size: 20px;
    line-height: 1.08;
  }

  .panel-header p {
    margin-top: 4px;
    font-size: 10px;
    letter-spacing: 0.02em;
    line-height: 1.25;
    text-transform: none;
  }

  .mode-tabs {
    margin-bottom: 10px;
    padding: 3px;
  }

  .mode-tab {
    min-height: 36px;
    gap: 6px;
    font-size: 12px;
  }

  .color-grid {
    gap: 8px;
    margin-bottom: 10px;
  }

  .color-well {
    gap: 5px;
  }

  .swatch-button {
    width: min(58px, 18vw);
  }

  .color-name {
    font-size: 10px;
    letter-spacing: 0;
  }

  .hex-input {
    max-width: 88px;
    padding: 5px 4px;
    font-size: 10px;
  }

  .share-chip {
    min-width: 40px;
    padding: 4px 6px;
    font-size: 11px;
  }

  .slider-list {
    gap: 8px;
  }

  .slider-row {
    grid-template-columns: 76px minmax(0, 1fr) 48px;
    gap: 8px;
  }

  .slider-label {
    gap: 6px;
    font-size: 11px;
    white-space: nowrap;
  }

  .dot {
    width: 10px;
    height: 10px;
  }

  .weight-slider {
    height: 28px;
  }

  .weight-slider::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
    margin-top: -7.5px;
  }

  .weight-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }

  .weight-value {
    min-width: 48px;
    padding: 6px 5px;
    font-size: 12px;
  }

  .total-row {
    margin-top: 7px;
    font-size: 11px;
    letter-spacing: 0.03em;
  }

  .triangle-wrap {
    width: min(280px, 100%);
  }

  .triangle-marker {
    width: 22px;
    height: 22px;
  }

  .result-actions {
    grid-template-columns: minmax(0, 1fr) 92px;
    gap: 8px;
  }

  .result-bar {
    margin-top: 10px;
    padding-top: 10px;
  }

  .result-color {
    min-height: 56px;
    gap: 2px;
    padding: 8px 10px;
  }

  .ratio-button {
    min-width: 0;
    min-height: 56px;
    padding: 0 8px;
    font-size: 12px;
  }

  #resultHex {
    font-size: clamp(31px, 9vw, 38px);
  }

  #copyHint {
    font-size: 10px;
    letter-spacing: 0.08em;
  }

  .ratio-dialog {
    padding: 16px;
  }

  .target-color-row {
    grid-template-columns: 1fr;
  }

  .target-hex-field input {
    min-height: 72px;
    font-size: 24px;
  }

  .ratio-comparison {
    gap: 8px;
  }

  .compare-swatch {
    padding: 8px;
  }

  .compare-swatch::before {
    height: 52px;
  }

  .compare-swatch strong {
    font-size: 15px;
  }

  .compare-swatch small {
    font-size: 10px;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 440px) {
  .color-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .color-well {
    justify-items: center;
    gap: 4px;
  }

  .color-name {
    grid-column: auto;
    font-size: 9px;
  }

  .swatch-button {
    grid-row: auto;
    width: min(52px, 16vw);
  }

  .share-chip {
    justify-self: center;
  }

  .hex-input {
    max-width: 76px;
    font-size: 9px;
  }

  .slider-row {
    grid-template-columns: 68px minmax(0, 1fr) 44px;
    gap: 6px;
  }

  .slider-label {
    font-size: 10px;
  }

  .weight-value {
    min-width: 44px;
    font-size: 11px;
  }

  .result-actions {
    grid-template-columns: minmax(0, 1fr) 84px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
