@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);
  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, select { font: inherit; }
button, input[type="color"], select { 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: 23px;
  height: 20px;
  border: 2px solid var(--violet);
  border-radius: 50%;
  background: linear-gradient(90deg, var(--paper) 50%, var(--violet) 50%);
}

.eyebrow i::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--green);
}

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

.lead {
  flex: 1 1 500px;
  min-width: 300px;
  color: var(--muted);
  font-size: clamp(15px, 1.4vw, 20px);
  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(410px, 460px) minmax(720px, 1fr);
  align-items: start;
  gap: 18px;
}

.control-card, .preview-card, .mapping-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, .role-heading > div:first-child span, .mapping-table small,
.contrast-item small, .output-note > span, .output-note 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--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, .role-heading > div:first-child span { color: #5736c9; }
.control-title h3, .role-heading h3 { margin-top: 3px; font-size: 15px; }
.control-title output { color: #5736c9; font-family: 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: 67px;
  padding: 8px 3px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
}

.preset-grid button[aria-pressed="true"] { border-color: var(--violet); color: #5736c9; background: var(--violet-soft); }
.preset-grid i { width: 29px; height: 29px; border: 2px solid var(--ink); border-radius: 50%; background: var(--preset); box-shadow: 4px 4px 0 rgb(23 32 29 / 12%); }
.preset-grid span { margin-top: 5px; font-size: 9px; font-weight: 900; }

.base-field {
  display: grid;
  grid-template-columns: 45px 1fr 82px;
  gap: 9px;
  align-items: center;
  margin-top: 10px;
}

.base-field > span {
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 47px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.base-field .color-well { padding: 3px; }
.color-well input { width: 100%; height: 39px; padding: 0; border: 0; border-radius: 9px; background: none; }
.base-field small { color: var(--muted); font-size: 7px; font-weight: 900; }
.base-field input[type="text"] { min-width: 0; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-family: monospace; font-size: 12px; font-weight: 900; text-transform: uppercase; }
.base-field b { margin-top: 2px; font-family: monospace; font-size: 13px; }

.palette-strip {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  overflow: hidden;
  height: 48px;
  margin-top: 10px;
  border: 1px solid var(--ink);
  border-radius: 12px;
}

.palette-strip span { display: grid; place-items: end center; padding-bottom: 4px; color: var(--label); background: var(--swatch); font-family: monospace; font-size: 7px; font-weight: 900; }

.role-section { padding-bottom: 16px; }
.role-heading { display: grid; grid-template-columns: minmax(130px, 1fr) 194px; gap: 8px; align-items: end; margin-bottom: 10px; }
.mode-head { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; color: var(--muted); font-size: 8px; text-align: center; }

.role-grid { display: grid; gap: 7px; }
.role-row { display: grid; grid-template-columns: minmax(130px, 1fr) 94px 94px; gap: 7px; align-items: center; }
.role-label { min-width: 0; }
.role-label b { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.role-label small { display: block; margin-top: 1px; color: var(--muted); font-size: 8px; }

.token-select {
  position: relative;
  min-width: 0;
}

.token-select i { position: absolute; z-index: 1; top: 50%; left: 8px; width: 13px; height: 13px; border: 1px solid rgb(23 32 29 / 35%); border-radius: 4px; background: var(--token-color); transform: translateY(-50%); pointer-events: none; }
.token-select select { width: 100%; min-height: 36px; padding: 0 7px 0 26px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; font-family: monospace; font-size: 10px; font-weight: 900; }
.token-select select:focus-visible { outline: 3px solid rgb(111 72 255 / 24%); border-color: var(--violet); }
.hint { margin-top: 11px; padding: 10px 12px; border-radius: 10px; color: #725d20; background: var(--yellow-soft); font-size: 9px; font-weight: 800; line-height: 1.55; }

.preview-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.same-roles, .collection-chip { padding: 8px 11px; border-radius: 999px; color: #315dc2; background: var(--blue-soft); font-family: "Archivo Black", sans-serif; font-size: 8px; letter-spacing: .08em; }
.collection-chip { margin-left: auto; color: #087f63; background: var(--green-soft); }

.preview-switch, .code-tabs {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-width: 194px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f0efe9;
}

.preview-switch button, .code-tabs button { position: relative; z-index: 2; min-height: 34px; padding: 0 10px; border: 0; background: transparent; font-size: 9px; font-weight: 900; }
.preview-switch button[aria-pressed="true"] { anchor-name: --preview-active; }
.switch-indicator {
  position: absolute;
  z-index: 1;
  position-anchor: --preview-active;
  top: anchor(top);
  left: anchor(left);
  width: anchor-size(width);
  height: anchor-size(height);
  border-radius: 9px;
  background: white;
  box-shadow: 0 3px 9px rgb(23 32 29 / 10%);
  transition: top 220ms ease, left 220ms ease, width 220ms ease;
}

.preview-stage { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 18px 18px 14px; background-image: linear-gradient(#e8e7e1 1px, transparent 1px), linear-gradient(90deg, #e8e7e1 1px, transparent 1px); background-size: 24px 24px; }
.preview-stage[data-view="light"] { grid-template-columns: minmax(0, 1fr); }
.preview-stage[data-view="dark"] { grid-template-columns: minmax(0, 1fr); }
.preview-stage[data-view="light"] [data-mode="dark"], .preview-stage[data-view="dark"] [data-mode="light"] { display: none; }

.theme-preview { min-width: 0; overflow: hidden; border: 1px solid var(--pv-border); border-radius: 20px; color: var(--pv-text); background: var(--pv-canvas); box-shadow: 0 15px 35px rgb(23 32 29 / 10%); transition: color 220ms ease, background-color 220ms ease, border-color 220ms ease; }
.theme-preview > header { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-bottom: 1px solid var(--pv-border); }
.theme-preview > header span { font-family: "Archivo Black", sans-serif; font-size: 9px; letter-spacing: .11em; }
.theme-preview > header b { color: var(--pv-primary); font-size: 18px; }

.sample-shell { display: grid; gap: 12px; padding: 14px; }
.sample-nav { display: flex; align-items: center; gap: 8px; color: var(--pv-muted); font-size: 10px; font-weight: 900; }
.sample-nav i { width: 20px; height: 20px; border-radius: 7px; background: var(--pv-primary); box-shadow: inset 0 0 0 5px color-mix(in srgb, var(--pv-surface), transparent 30%); }
.sample-nav b { margin-left: auto; }

.sample-card { padding: 18px; border: 1px solid var(--pv-border); border-radius: 17px; background: var(--pv-surface); transition: color 220ms ease, background-color 220ms ease, border-color 220ms ease; }
.sample-badge { display: inline-flex; padding: 5px 8px; border-radius: 999px; color: var(--pv-primary-text); background: var(--pv-primary); font-size: 7px; font-weight: 900; }
.sample-card h3 { margin-top: 12px; font-size: clamp(18px, 1.8vw, 26px); line-height: 1.12; }
.sample-card p { margin-top: 8px; color: var(--pv-muted); font-size: 10px; font-weight: 700; line-height: 1.6; }
.sample-progress { height: 6px; margin-top: 14px; overflow: hidden; border-radius: 999px; background: var(--pv-border); }
.sample-progress i { display: block; width: 68%; height: 100%; border-radius: inherit; background: var(--pv-primary); }
.sample-card button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 42px; margin-top: 14px; padding: 0 13px; border: 0; border-radius: 11px; color: var(--pv-primary-text); background: var(--pv-primary); font-size: 10px; font-weight: 900; }
.sample-list { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--pv-border); border-radius: 13px; color: var(--pv-muted); background: var(--pv-surface); font-size: 9px; font-weight: 900; }
.sample-list i { display: block; width: 9px; height: 9px; border-radius: 50%; background: var(--pv-primary); }
.sample-list b { margin-left: auto; color: var(--pv-text); }

.contrast-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; padding: 0 18px 18px; }
.contrast-item { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 10px 11px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.contrast-item i { width: 13px; height: 31px; border: 1px solid rgb(23 32 29 / 22%); border-radius: 5px; background: linear-gradient(var(--top) 50%, var(--bottom) 50%); }
.contrast-item div { min-width: 0; }
.contrast-item small { display: block; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.contrast-item strong { display: block; margin-top: 2px; font-size: 15px; }
.contrast-item em { margin-left: auto; padding: 4px 6px; border-radius: 7px; color: #087f63; background: var(--green-soft); font-size: 8px; font-style: normal; font-weight: 900; }
.contrast-item.is-fail em { color: #a23f2c; background: #fde8e3; }

.mapping-table { display: grid; grid-template-columns: repeat(7, minmax(100px, 1fr)); overflow-x: auto; padding: 16px 18px 18px; }
.map-column { min-width: 100px; padding: 0 10px; border-right: 1px solid var(--line); }
.map-column:first-child { padding-left: 0; }
.map-column:last-child { padding-right: 0; border-right: 0; }
.map-column > small { display: block; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.map-column > b { display: block; overflow: hidden; margin-top: 3px; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.map-pair { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; height: 46px; margin-top: 9px; border: 1px solid var(--line); border-radius: 10px; }
.map-pair span { display: grid; place-items: center; color: var(--label); background: var(--color); font-family: monospace; font-size: 8px; font-weight: 900; }

.output-card { color: white; background: #101814; }
.output-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(230px, .65fr); gap: 14px; padding: 15px; }
.code-pane { min-width: 0; overflow: hidden; border: 1px solid #34423b; border-radius: 15px; background: #07100c; }
.code-tabs { grid-template-columns: repeat(2, 1fr); width: 248px; min-width: 0; margin: 10px; border-color: #33423b; background: #1c2822; }
.code-tabs button { color: #aeb9b3; }
.code-tabs button[aria-pressed="true"] { color: var(--ink); anchor-name: --code-active; }
.tab-indicator { position: absolute; z-index: 1; position-anchor: --code-active; top: anchor(top); left: anchor(left); width: anchor-size(width); height: anchor-size(height); border-radius: 9px; background: white; transition: left 220ms ease, width 220ms ease; }
.code-pane pre { min-height: 318px; max-height: 390px; overflow: auto; padding: 3px 18px 19px; color: #dce8e1; font-size: 11px; line-height: 1.65; white-space: pre; }
.code-pane code { color: inherit; }
.output-note { display: flex; flex-direction: column; padding: 18px; border: 1px solid #493b78; border-radius: 15px; background: #1d1b2d; }
.output-note > span { color: #baa9ff; }
.output-note > strong { margin-top: 9px; font-family: "Archivo Black", sans-serif; font-size: 25px; }
.output-note > p { margin-top: 9px; color: #bfc8c3; font-size: 11px; font-weight: 700; line-height: 1.65; }
.output-note > div { margin-top: auto; padding: 13px; border-radius: 11px; background: #0b110e; }
.output-note small { display: block; color: #88a098; }
.output-note code { display: block; margin-top: 5px; color: #a8f0d5; font-size: 10px; }

@supports not (left: anchor(left)) {
  .switch-indicator { top: 4px; left: 4px; width: calc((100% - 8px) / 3); height: calc(100% - 8px); transform: translateX(calc(var(--active-index, 0) * 100%)); }
  .code-tabs .tab-indicator { top: 4px; left: 4px; width: calc((100% - 8px) / 2); height: calc(100% - 8px); transform: translateX(calc(var(--active-index, 0) * 100%)); }
}

@media (max-width: 1160px) {
  .studio { grid-template-columns: 1fr; }
  .control-card { position: static; }
  .role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .role-heading { grid-template-columns: 1fr; }
  .mode-head { display: none; }
  .role-row { grid-template-columns: minmax(120px, 1fr) 94px 94px; }
}

@media (max-width: 780px) {
  .page { width: min(100% - 22px, 680px); padding-top: 17px; }
  .hero { padding-bottom: 17px; }
  h1 { font-size: clamp(38px, 11vw, 58px); }
  .lead { min-width: 0; }
  .hero-actions { width: 100%; margin-left: 0; }
  .support-chip { margin-right: auto; }
  .studio { display: block; }
  .result-stack { margin-top: 14px; }
  .control-card, .preview-card, .mapping-card, .output-card { border-radius: 20px; }
  .role-grid { grid-template-columns: 1fr; }
  .preview-actions { flex-basis: 100%; margin-left: 52px; }
  .preview-stage { grid-template-columns: 1fr; }
  .contrast-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .output-layout { grid-template-columns: 1fr; }
  .output-note > div { margin-top: 20px; }
}

@media (max-width: 520px) {
  .page { width: calc(100% - 14px); }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .support-chip { grid-column: 1 / -1; width: 100%; justify-content: center; }
  .button { padding-inline: 10px; }
  .panel-head { min-height: 70px; padding: 13px; }
  .panel-head h2 { font-size: 16px; }
  .section-mark { width: 36px; height: 36px; border-radius: 11px; }
  .control-section { padding: 15px 13px; }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
  .base-field { grid-template-columns: 44px 1fr 72px; }
  .role-row { grid-template-columns: minmax(104px, 1fr) 82px 82px; gap: 5px; }
  .role-label b { font-size: 10px; }
  .token-select select { padding-left: 23px; font-size: 9px; }
  .preview-actions { margin-left: 0; }
  .same-roles, .collection-chip { display: none; }
  .preview-switch { width: 100%; min-width: 0; }
  .preview-stage { padding: 12px; }
  .contrast-row { gap: 6px; padding: 0 12px 12px; }
  .contrast-item { padding: 8px; }
  .contrast-item strong { font-size: 13px; }
  .mapping-table { padding-inline: 12px; }
  .output-layout { padding: 11px; }
  .code-tabs { width: calc(100% - 20px); }
  .code-pane pre { font-size: 9px; }
}

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