@import url("https://fonts.googleapis.com/css2?family=Archivo+Black&family=Noto+Sans+JP:wght@500;700;800;900&display=swap");

:root {
  --paper: #f3f0e8;
  --card: #fffdf8;
  --ink: #17201d;
  --muted: #6d7772;
  --line: #d8d9d1;
  --violet: #6f48ff;
  --violet-soft: #ece7ff;
  --blue: #3e79ff;
  --blue-soft: #e7eeff;
  --green: #08a47b;
  --green-soft: #e0f5ed;
  --yellow: #efb92f;
  --yellow-soft: #fbf0cc;
  --coral: #f36f55;
  --shadow: 0 24px 60px rgb(28 40 35 / 10%);
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans JP", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background:
    radial-gradient(circle at 3% 3%, rgb(36 187 177 / 12%), transparent 30rem),
    radial-gradient(circle at 97% 3%, rgb(111 72 255 / 13%), transparent 32rem),
    var(--paper);
}

body { min-width: 320px; margin: 0; background: transparent; }
button, input { font: inherit; }
button, input[type="range"], input[type="color"] { cursor: pointer; }
button { color: inherit; }
code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
h1, h2, h3, p, pre { margin: 0; }

.page {
  width: min(1580px, calc(100% - 38px));
  margin: 0 auto;
  padding: 26px 0 44px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
  padding: 0 4px 24px;
}

.hero-title { flex-basis: 100%; min-width: 0; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: #5736c9;
  font-family: "Archivo Black", sans-serif;
  font-size: 11px;
  letter-spacing: .15em;
}

.eyebrow i {
  position: relative;
  width: 22px;
  height: 18px;
  background: linear-gradient(90deg, var(--violet), var(--green));
  clip-path: polygon(0 78%, 0 58%, 20% 58%, 20% 38%, 40% 38%, 40% 22%, 60% 22%, 60% 8%, 80% 8%, 80% 0, 100% 0, 100% 100%, 80% 100%, 80% 88%, 60% 88%, 60% 78%, 40% 78%, 40% 68%, 20% 68%, 20% 78%);
}

h1 {
  font-family: "Archivo Black", "Noto Sans JP", sans-serif;
  font-size: clamp(48px, 5.1vw, 82px);
  line-height: 1.03;
}

.lead {
  flex: 1 1 440px;
  min-width: 300px;
  color: var(--muted);
  font-size: clamp(15px, 1.45vw, 21px);
  font-weight: 900;
}

.lead code { color: var(--violet); }

.hero-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  margin-left: auto;
}

.support-chip, .button {
  min-height: 44px;
  border-radius: 13px;
  font-size: 11px;
  font-weight: 900;
}

.support-chip {
  display: inline-flex;
  align-items: center;
  padding: 0 15px;
  border: 1px solid #b9a8ff;
  color: #5736c9;
  background: var(--violet-soft);
}

.support-chip.is-unsupported { border-color: #efb4a7; color: #a23f2c; background: #fde8e3; }

.button {
  padding: 0 16px;
  border: 1px solid var(--line);
  background: white;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.button:hover { transform: translateY(-2px); box-shadow: 0 7px 18px rgb(23 32 29 / 10%); }
.button--dark { border-color: var(--ink); color: white; background: var(--ink); }
.button--coral { border-color: var(--coral); color: white; background: var(--coral); }

.studio {
  display: grid;
  grid-template-columns: minmax(390px, 440px) minmax(720px, 1fr);
  align-items: start;
  gap: 18px;
}

.control-card, .palette-card, .comparison-card, .preview-card, .output-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.control-card { position: sticky; top: 14px; }
.result-stack { display: grid; gap: 18px; min-width: 0; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head--wide { padding-inline: 20px; }
.panel-head--dark { color: white; border-bottom-color: rgb(255 255 255 / 14%); background: #101814; }

.panel-head p, .control-title span, .toggle-section > div > span, .palette-stats small,
.contrast-summary > div:last-child > span, .output-toolbar, .palette-swatch small {
  font-family: "Archivo Black", sans-serif;
  font-size: 8px;
  letter-spacing: .1em;
}

.panel-head p { color: var(--violet); }
.panel-head--dark p { color: #f9b5a8; }
.panel-head h2 { margin-top: 2px; font-size: 19px; line-height: 1.25; }

.section-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  color: white;
  font-family: "Archivo Black", sans-serif;
  font-size: 10px;
}

.section-mark--violet { background: var(--violet); }
.section-mark--blue { background: var(--blue); }
.section-mark--yellow { color: var(--ink); background: var(--yellow); }
.section-mark--green { background: var(--green); }
.section-mark--coral { background: var(--coral); }

.control-section { padding: 18px 19px 19px; border-bottom: 1px solid var(--line); }
.control-section:last-child { border-bottom: 0; }

.control-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.control-title span, .toggle-section > div > span { color: #5736c9; }
.control-title h3, .toggle-section h3 { margin-top: 3px; font-size: 15px; }

.control-title output {
  color: #5736c9;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 900;
}

.preset-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }

.preset-grid button {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 68px;
  padding: 8px 3px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  font-size: 8px;
  font-weight: 900;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.preset-grid button:hover { transform: translateY(-2px); }
.preset-grid button[aria-pressed="true"] { border-color: var(--violet); background: var(--violet-soft); }

.preset-grid i {
  width: 31px;
  height: 31px;
  margin-bottom: 5px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--preset);
  box-shadow: 4px 4px 0 rgb(23 32 29 / 10%);
}

.base-field {
  display: grid;
  grid-template-columns: 54px minmax(95px, .75fr) minmax(150px, 1.25fr);
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
}

.base-field > span:not(.color-well) { display: grid; gap: 4px; min-width: 0; }
.base-field small { color: var(--muted); font-family: "Archivo Black", sans-serif; font-size: 7px; letter-spacing: .08em; }

.color-well { width: 48px; height: 48px; }
.color-well input { width: 100%; height: 100%; padding: 0; border: 0; background: transparent; }
.color-well input::-webkit-color-swatch-wrapper { padding: 0; }
.color-well input::-webkit-color-swatch { border: 3px solid var(--ink); border-radius: 12px; }
.color-well input::-moz-color-swatch { border: 3px solid var(--ink); border-radius: 12px; }

.base-field input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 900;
}

.base-field output { overflow: hidden; font-family: "SFMono-Regular", Consolas, monospace; font-size: 9px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }

.segmented {
  --active-index: 1;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #efeee8;
}

.segmented::before {
  position: absolute;
  z-index: -1;
  top: 4px;
  bottom: 4px;
  left: calc(4px + (100% - 8px) / 3 * var(--active-index));
  width: calc((100% - 8px) / 3);
  border-radius: 9px;
  background: white;
  box-shadow: 0 3px 10px rgb(23 32 29 / 9%);
  content: "";
  transition: left 220ms cubic-bezier(.22, 1, .36, 1), width 220ms cubic-bezier(.22, 1, .36, 1);
}

.segmented button { min-height: 36px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 900; }
.segmented button[aria-pressed="true"] { color: var(--ink); }

@supports (left: anchor(left)) {
  .anchor-switch button[aria-pressed="true"] { anchor-name: --anchor-token; }
  .anchor-switch::before {
    position-anchor: --anchor-token;
    top: anchor(top);
    left: anchor(left);
    width: anchor-size(width);
    height: anchor-size(height);
  }
}

.hint { margin-top: 9px; color: var(--muted); font-size: 8px; font-weight: 700; line-height: 1.55; }
.control-ranges { display: grid; gap: 18px; }

.range-control { display: grid; gap: 7px; }
.range-control > span { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.range-control b { font-size: 12px; }
.range-control output { color: #5736c9; font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; font-weight: 900; }
.range-control small { color: var(--muted); font-size: 8px; font-weight: 700; }

input[type="range"] {
  width: 100%;
  height: 5px;
  margin: 5px 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--violet));
  appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 1px 5px rgb(23 32 29 / 35%);
  appearance: none;
}

input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 3px solid white; border-radius: 50%; background: var(--ink); box-shadow: 0 1px 5px rgb(23 32 29 / 35%); }

.toggle-section { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toggle-section p { max-width: 31em; margin-top: 5px; color: var(--muted); font-size: 8px; font-weight: 700; line-height: 1.5; }
.toggle { display: grid; flex: 0 0 auto; grid-template-columns: auto 22px; align-items: center; gap: 7px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { position: relative; width: 48px; height: 27px; border-radius: 999px; background: #cfd3d0; transition: background 160ms ease; }
.toggle span::after { position: absolute; top: 4px; left: 4px; width: 19px; height: 19px; border-radius: 50%; background: white; box-shadow: 0 2px 6px rgb(23 32 29 / 22%); content: ""; transition: translate 180ms cubic-bezier(.22, 1, .36, 1); }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { translate: 21px 0; }
.toggle b { color: var(--green); font-family: "Archivo Black", sans-serif; font-size: 9px; }

.palette-stats { display: flex; align-items: stretch; gap: 7px; margin-left: auto; }
.palette-stats span { display: grid; min-width: 82px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.palette-stats small { color: var(--muted); }
.palette-stats strong { margin-top: 2px; font-family: "Archivo Black", sans-serif; font-size: 16px; }

.palette-grid {
  display: grid;
  grid-template-columns: repeat(11, minmax(62px, 1fr));
  gap: 7px;
  padding: 18px;
  background:
    linear-gradient(rgb(23 32 29 / 4%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(23 32 29 / 4%) 1px, transparent 1px),
    #f8faf7;
  background-size: 28px 28px;
}

.palette-swatch {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  min-height: 174px;
  padding: 11px 8px 9px;
  border: 2px solid transparent;
  border-radius: 15px;
  color: var(--swatch-text);
  background: var(--swatch);
  text-align: left;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 22%);
  transition: translate 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.palette-swatch:hover { translate: 0 -4px; box-shadow: 0 10px 20px rgb(23 32 29 / 17%); }
.palette-swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px white, 0 0 0 5px var(--ink), 0 12px 24px rgb(23 32 29 / 20%); translate: 0 -2px; }
.palette-swatch > span:first-child { font-family: "Archivo Black", sans-serif; font-size: 13px; }
.palette-swatch > span:last-child { display: grid; gap: 4px; }
.palette-swatch code { overflow: hidden; font-size: 7px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.palette-swatch small { opacity: .82; }
.palette-swatch i { width: fit-content; padding: 3px 5px; border: 1px solid currentColor; border-radius: 999px; font-size: 7px; font-style: normal; font-weight: 900; }
.palette-swatch i.is-warning { color: #8a330f; border-color: #ffb18d; background: #ffe0d2; }

.comparison-note { margin-left: auto; padding: 9px 11px; border-radius: 999px; color: #7a5810; background: var(--yellow-soft); font-family: "Archivo Black", sans-serif; font-size: 8px; letter-spacing: .08em; }
.method-rows { display: grid; gap: 9px; padding: 16px 18px 18px; }
.method-row { display: grid; grid-template-columns: 155px 1fr; align-items: center; gap: 14px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 15px; background: #f6f6f2; }
.method-row--active { border-color: #b9a8ff; background: #f7f4ff; }
.method-row b { display: block; font-family: "Archivo Black", sans-serif; font-size: 15px; }
.method-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; font-weight: 700; }
.method-strip { display: grid; grid-template-columns: repeat(11, 1fr); overflow: hidden; height: 42px; border: 2px solid var(--ink); border-radius: 11px; }
.method-strip i { min-width: 0; }

.lower-grid { display: grid; grid-template-columns: minmax(340px, .92fr) minmax(420px, 1.08fr); gap: 18px; align-items: stretch; }
.preview-card, .output-card { min-width: 0; }

.contrast-summary { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 15px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.selected-color { display: grid; place-items: center; width: 88px; height: 72px; border: 3px solid var(--ink); border-radius: 15px; color: var(--selected-text, white); background: var(--selected-color, var(--violet)); box-shadow: 6px 7px 0 rgb(23 32 29 / 11%); }
.selected-color span { font-family: "Archivo Black", sans-serif; font-size: 18px; }
.contrast-summary > div:last-child > span { color: var(--green); }
.contrast-summary strong { display: block; margin-top: 2px; font-family: "Archivo Black", sans-serif; font-size: 20px; }
.contrast-summary p { margin-top: 2px; font-size: 11px; font-weight: 900; }
.contrast-summary p b { font-family: "SFMono-Regular", Consolas, monospace; }
.contrast-summary p i { margin-left: 5px; padding: 3px 6px; border-radius: 999px; color: #087455; background: var(--green-soft); font-size: 8px; font-style: normal; }

.ui-preview { margin: 16px; padding: 19px; border: 1px solid var(--preview-border); border-radius: 18px; color: var(--preview-ink); background: var(--preview-soft); }
.preview-badge { display: inline-flex; padding: 5px 8px; border-radius: 999px; color: var(--preview-strong); background: var(--preview-badge); font-size: 8px; font-weight: 900; }
.ui-preview h3 { max-width: 13em; margin-top: 15px; font-size: 21px; line-height: 1.15; }
.ui-preview p { margin-top: 8px; color: var(--preview-muted); font-size: 10px; font-weight: 700; line-height: 1.6; }
.ui-preview button { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 18px; padding: 12px 14px; border: 0; border-radius: 11px; color: var(--selected-text); background: var(--selected-color); font-size: 10px; font-weight: 900; }
.ui-preview button span { font-size: 16px; }

.output-card { color: white; background: #101814; }
.output-card .panel-head { position: relative; }
.output-card .button { margin-left: auto; }
.output-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; color: #a9b5af; border-bottom: 1px solid rgb(255 255 255 / 12%); }
.output-toolbar span { display: flex; align-items: center; gap: 7px; }
.output-toolbar i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgb(8 164 123 / 18%); }
.output-card pre { height: 318px; padding: 15px 17px 20px; overflow: auto; color: #dce7e1; background: #09100d; font-size: 10px; line-height: 1.65; tab-size: 2; }

button:focus-visible, input:focus-visible { outline: 3px solid rgb(62 121 255 / 42%); outline-offset: 3px; }

@media (max-width: 1240px) {
  .studio { grid-template-columns: minmax(350px, 390px) minmax(620px, 1fr); }
  .palette-grid { overflow-x: auto; }
  .palette-swatch { min-width: 64px; }
  .lower-grid { grid-template-columns: 1fr; }
  .output-card pre { height: 280px; }
}

@media (max-width: 980px) {
  .page { width: min(780px, calc(100% - 28px)); padding-top: 22px; }
  .hero-actions { flex-wrap: wrap; }
  .studio { grid-template-columns: 1fr; }
  .control-card { position: static; }
  .palette-grid { grid-template-columns: repeat(11, minmax(70px, 1fr)); }
  .lower-grid { grid-template-columns: 1fr 1fr; }
  .output-card pre { height: 345px; }
}

@media (max-width: 700px) {
  .page { width: min(100% - 18px, 580px); padding: 16px 0 28px; }
  .hero { gap: 17px; padding: 0 3px 18px; }
  h1 { overflow-wrap: anywhere; font-size: clamp(39px, 12vw, 59px); }
  .lead { min-width: 0; max-width: 27em; line-height: 1.55; }
  .hero-actions { width: 100%; margin-left: 0; }
  .support-chip { width: 100%; justify-content: center; }
  .hero-actions .button { flex: 1; }
  .control-card, .palette-card, .comparison-card, .preview-card, .output-card { border-radius: 19px; }
  .panel-head { min-height: 70px; padding: 13px; }
  .panel-head--wide { flex-wrap: wrap; }
  .palette-stats { width: 100%; margin-left: 52px; }
  .palette-stats span { flex: 1; }
  .control-section { padding: 16px 14px; }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
  .base-field { grid-template-columns: 50px 1fr; }
  .base-field > span:last-child { grid-column: 1 / -1; }
  .palette-grid { grid-template-columns: repeat(11, 68px); padding: 14px 10px 19px; }
  .palette-swatch { min-height: 160px; }
  .comparison-note { width: 100%; margin-left: 52px; text-align: center; }
  .method-rows { padding: 12px 10px 14px; }
  .method-row { grid-template-columns: 1fr; gap: 9px; }
  .method-strip { height: 38px; }
  .lower-grid { grid-template-columns: 1fr; }
  .output-card pre { height: 300px; }
  .output-card .panel-head { flex-wrap: wrap; }
  .output-card .button { width: 100%; margin-left: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
