:root {
  --paper: #f2eee5;
  --surface: #fffdf7;
  --ink: #171914;
  --muted: #697069;
  --line: #c8cdc5;
  --green: #008b72;
  --lime: #b5ff2d;
  --coral: #ff6855;
  --blue: #6d73f5;
  --yellow: #ffd86d;
  --soft: #e4e8e0;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); background: radial-gradient(circle at 7% 2%, #6d73f516, transparent 30rem), var(--paper); font-family: "Helvetica Neue", Arial, "Noto Sans JP", sans-serif; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 4px solid #175cff; outline-offset: 4px; }
button { cursor: pointer; }
code, pre { font-family: var(--mono); }

.page { width: min(1740px, calc(100% - 48px)); margin: auto; padding: 32px 0 50px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 10px 18px 28px; }
.hero-copy { min-width: 0; }
.eyebrow, .label, .section-heading p, .inspector header p, .layer-list > p, .code-block p, .usage-block > p { margin: 0 0 8px; color: var(--green); font: 900 11px/1.4 var(--mono); letter-spacing: .12em; }
.eyebrow { display: flex; align-items: center; gap: 10px; }
.eyebrow i { width: 18px; height: 18px; border: 2px solid var(--blue); border-radius: 5px; box-shadow: 5px 5px 0 var(--lime); }
h1 { margin: 0; font-size: clamp(34px, 4.2vw, 64px); line-height: 1.05; letter-spacing: 0; white-space: nowrap; }
.lead { margin: 17px 0 0; color: var(--muted); font-size: clamp(16px, 1.45vw, 23px); font-weight: 750; }
.lead strong { color: var(--ink); }
.hero-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.hero-actions button, .section-heading > button { min-height: 48px; padding: 0 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); font-size: 12px; font-weight: 900; }
.hero-actions button:hover, .section-heading > button:hover { border-color: var(--ink); }
.hero-actions .dark { border-color: var(--ink); color: white; background: var(--ink); }

.lab, .catalog, .explanation { overflow: hidden; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: 0 15px 45px #17191408; }
.section-heading { display: flex; align-items: center; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.number { display: grid; width: 50px; height: 50px; flex: 0 0 auto; place-items: center; border-radius: 15px; color: white; background: var(--coral); font: 900 12px var(--mono); }
.number.blue { background: var(--blue); }
.number.green { background: var(--green); }
.section-heading h2 { margin: 0; font-size: clamp(21px, 2vw, 31px); line-height: 1.2; }
.section-heading p { margin-bottom: 3px; }
.heading-badges { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.heading-badges span, .heading-badges b { padding: 9px 12px; border-radius: 999px; white-space: nowrap; font: 900 10px/1 var(--mono); }
.heading-badges span { background: var(--soft); }
.heading-badges b { color: white; background: var(--blue); }

.lab-grid { display: grid; grid-template-columns: 286px minmax(560px, 1fr) 326px; min-height: 730px; }
.controls { border-right: 1px solid var(--line); background: #f7f4ec; container: controls / inline-size; }
.controls section { padding: 21px 19px; border-bottom: 1px solid var(--line); }
.controls section:last-child { border-bottom: 0; }
.controls h3 { margin: 0 0 15px; font-size: 16px; }

.pattern-list { display: grid; position: relative; gap: 7px; }
.pattern-list::before { display: none; position: absolute; position-anchor: --selected-pattern; inset: anchor(top) anchor(right) anchor(bottom) anchor(left); z-index: 0; border: 2px solid var(--ink); border-radius: 12px; background: var(--lime); content: ""; translate: 4px 4px; pointer-events: none; transition: inset 180ms ease; }
.pattern-list button { display: grid; min-height: 54px; padding: 7px 9px; position: relative; z-index: 1; grid-template-columns: 38px 1fr; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; }
.pattern-list button:hover { border-color: var(--ink); translate: 2px 0; }
.pattern-list button[aria-pressed="true"] { anchor-name: --selected-pattern; border-color: var(--ink); color: white; background: var(--ink); }
.pattern-list button > i { width: 38px; height: 38px; border: 1px solid currentColor; border-radius: 9px; background-color: var(--pattern-preview-bg, #fff8e8); background-image: var(--pattern-preview-image); background-position: var(--pattern-preview-position, 0 0); background-size: var(--pattern-preview-size, 12px 12px); }
.pattern-list button span, .pattern-list button b, .pattern-list button small { display: block; min-width: 0; }
.pattern-list button b { font-size: 12px; }
.pattern-list button small { margin-top: 3px; overflow: hidden; color: var(--muted); font: 800 10px/1.2 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.pattern-list button[aria-pressed="true"] small { color: #cfd4ca; }
@supports (position-anchor: --selected-pattern) {
  .pattern-list::before { display: block; }
}

.color-grid { display: grid; gap: 8px; }
.color-grid label { display: grid; min-height: 43px; padding: 6px 8px; grid-template-columns: 1fr 30px 68px; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 11px; font-weight: 850; }
.color-grid input { width: 30px; height: 30px; padding: 0; overflow: hidden; border: 0; border-radius: 7px; background: transparent; cursor: pointer; }
.color-grid output { color: var(--muted); font: 800 10px var(--mono); text-align: right; }
.color-opacity-list { display: grid; gap: 10px; margin-top: 13px; }
.color-opacity-list label > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 10px; font-weight: 850; }
.color-opacity-list output { color: var(--blue); font: 900 10px var(--mono); }
.color-opacity-list input { width: 100%; margin: 8px 0 0; accent-color: var(--blue); cursor: pointer; }
.swap-button { width: 100%; min-height: 39px; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; background: transparent; font-size: 11px; font-weight: 900; }
.swap-button:hover { border-color: var(--ink); background: var(--surface); }
.swap-button span { margin-right: 5px; color: var(--blue); font-size: 16px; }

.dot-mode-control { margin-bottom: 15px; }
.dot-mode-control > span { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 850; }
.dot-mode-control > div { display: grid; padding: 3px; position: relative; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); border-radius: 10px; background: #e8ebe4; }
.dot-mode-control > div::before { display: none; position: absolute; position-anchor: --selected-dot-mode; inset: anchor(top) anchor(right) anchor(bottom) anchor(left); z-index: 0; border-radius: 7px; background: var(--ink); content: ""; pointer-events: none; transition: inset 180ms ease; }
.dot-mode-control button { min-height: 34px; position: relative; z-index: 1; border: 0; border-radius: 7px; background: transparent; font-size: 10px; font-weight: 900; }
.dot-mode-control button:hover { background: #ffffff9c; }
.dot-mode-control button[aria-pressed="true"] { color: white; background: var(--ink); }
@supports (position-anchor: --selected-dot-mode) {
  .dot-mode-control > div::before { display: block; }
  .dot-mode-control button[aria-pressed="true"] { anchor-name: --selected-dot-mode; background: transparent; }
}
.range-list { display: grid; gap: 14px; }
.range-list label > span { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; font-weight: 850; }
.range-list output { color: var(--blue); font: 900 10px var(--mono); }
.range-list input[type="range"] { width: 100%; margin: 9px 0 0; accent-color: var(--blue); cursor: pointer; }
.range-list label.is-disabled { opacity: .42; }
.range-list label.is-disabled input { pointer-events: none; }
.tile-toggle { display: flex; align-items: center; gap: 9px; margin-top: 17px; font-size: 11px; font-weight: 900; cursor: pointer; }
.tile-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.tile-toggle > span { width: 37px; height: 21px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: #dfe3dc; }
.tile-toggle > span::before { display: block; width: 13px; height: 13px; border-radius: 50%; background: var(--ink); content: ""; transition: translate 160ms ease; }
.tile-toggle input:checked + span { background: var(--lime); }
.tile-toggle input:checked + span::before { translate: 16px 0; }
.tile-toggle input:focus-visible + span { outline: 4px solid #175cff; outline-offset: 3px; }

.workspace { display: flex; min-width: 0; flex-direction: column; gap: 11px; padding: 18px; background: var(--soft); }
.instruction { display: flex; min-height: 39px; align-items: center; gap: 10px; padding: 0 3px; }
.instruction > span { color: var(--blue); font-size: 27px; font-weight: 900; }
.instruction p { margin: 0; font-size: 12px; font-weight: 800; line-height: 1.45; }
.instruction b { margin-left: auto; padding: 7px 9px; border-radius: 7px; color: white; background: var(--blue); white-space: nowrap; font: 900 10px/1 var(--mono); }
.browser { display: flex; min-height: 600px; flex: 1; flex-direction: column; overflow: hidden; border: 1px solid #b8bfb5; border-radius: 18px; background: var(--surface); }
.browser-bar { display: flex; height: 44px; padding: 0 15px; align-items: center; gap: 10px; border-bottom: 1px solid #b8bfb5; color: #58615b; background: #d6dcd2; font: 800 10px var(--mono); }
.browser-bar .dots { color: var(--coral); letter-spacing: 2px; }
.browser-bar strong { margin-left: auto; padding: 6px 8px; border-radius: 6px; color: white; background: var(--green); font-size: 10px; }
.preview-canvas { display: grid; flex: 1; place-items: stretch; padding: 20px; background: #faf7f0; }
.pattern-surface { display: grid; min-height: 520px; padding: clamp(25px, 5vw, 64px); position: relative; align-content: center; overflow: hidden; border: 2px solid var(--ink); border-radius: 18px; background-color: var(--generated-background); background-image: var(--generated-image); background-size: var(--generated-size); background-position: var(--generated-position, 0 0); isolation: isolate; }
.pattern-surface::after { position: absolute; inset: 0; z-index: -1; background: linear-gradient(135deg, #fff0, #fff4); content: ""; pointer-events: none; }
.sample-card { width: min(440px, 80%); min-height: 276px; padding: 29px; border: 2px solid var(--ink); border-radius: 20px; color: var(--ink); background: #fffdf7e8; box-shadow: 12px 12px 0 var(--ink); backdrop-filter: blur(5px); }
.sample-card > p { margin: 0; color: var(--green); font: 900 10px/1 var(--mono); letter-spacing: .11em; }
.sample-card h3 { margin: 25px 0 43px; font-size: clamp(35px, 4.2vw, 60px); line-height: .9; }
.sample-card > div { display: flex; justify-content: space-between; gap: 12px; }
.sample-card span, .sample-card b { padding: 8px 10px; border: 1px solid var(--ink); border-radius: 999px; font: 900 10px/1 var(--mono); }
.sample-card b { color: white; background: var(--ink); }
.tile-guide { display: none; width: var(--tile-width); height: var(--tile-height); position: absolute; top: 20px; right: 20px; z-index: 3; border: 2px dashed var(--coral); background: #ff68551c; pointer-events: none; }
.tile-guide.is-visible { display: block; }
.tile-guide span { padding: 4px 6px; position: absolute; top: 100%; right: -2px; color: white; background: var(--coral); white-space: nowrap; font: 900 10px/1 var(--mono); }
.value-strip { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; border-radius: 13px; color: white; background: var(--ink); }
.value-strip div { min-width: 0; padding: 13px 14px; border-right: 1px solid #43473e; }
.value-strip div:last-child { border-right: 0; }
.value-strip small, .value-strip strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.value-strip small { color: #aeb5aa; font: 800 10px var(--mono); }
.value-strip strong { margin-top: 6px; color: var(--lime); font: 900 12px var(--mono); }

.inspector { min-width: 0; color: white; background: #20231e; }
.inspector header { display: flex; padding: 21px 18px; align-items: flex-start; justify-content: space-between; gap: 10px; border-bottom: 1px solid #44473f; }
.inspector header p { margin-bottom: 6px; color: #a8afa4; }
.inspector header code { font-size: 14px; font-weight: 900; }
.inspector header > span { padding: 8px 9px; border-radius: 999px; color: var(--ink); background: var(--lime); white-space: nowrap; font: 900 10px/1 var(--mono); }
.layer-list, .code-block, .usage-block { padding: 20px 18px; border-bottom: 1px solid #44473f; }
.layer-list > p, .code-block p, .usage-block > p { color: #a8afa4; }
.layer-list ol { display: grid; gap: 7px; margin: 13px 0 0; padding: 0; list-style: none; }
.layer-list li { display: grid; min-height: 39px; padding: 8px 9px; grid-template-columns: 24px 1fr; align-items: center; gap: 8px; border: 1px solid #4a5045; border-radius: 8px; background: #181b16; }
.layer-list li b { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 6px; color: var(--ink); background: var(--lime); font: 900 10px var(--mono); }
.layer-list li span { color: #d8dcd4; font-size: 10px; font-weight: 800; line-height: 1.35; }
.code-block > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.code-block button { min-height: 31px; padding: 0 10px; border: 1px solid #596057; border-radius: 8px; color: white; background: transparent; font-size: 10px; font-weight: 900; }
.code-block button:hover { border-color: var(--lime); color: var(--lime); }
.code-block pre { min-height: 235px; max-height: 320px; margin: 12px 0 0; padding: 13px; overflow: auto; border: 1px solid #4a5045; border-radius: 10px; color: #d6ff99; background: #11130f; white-space: pre-wrap; font-size: 10px; line-height: 1.65; }
.usage-block > div { display: flex; flex-wrap: wrap; gap: 6px; }
.usage-block span { padding: 7px 9px; border: 1px solid #4a5045; border-radius: 999px; color: #d8dcd4; font-size: 10px; font-weight: 800; }
.inspector-note { margin: 0; padding: 18px; color: #b6bbb2; font-size: 10px; line-height: 1.7; }

.catalog, .explanation { margin-top: 22px; }
.catalog-grid { display: grid; grid-template-columns: repeat(5, 1fr); }
.catalog-grid button { min-width: 0; padding: 15px; border: 0; border-right: 1px solid var(--line); background: var(--surface); text-align: left; }
.catalog-grid button:last-child { border-right: 0; }
.catalog-grid button:hover { background: #f2f0e9; }
.catalog-grid button > i { display: block; height: 112px; border: 2px solid var(--ink); border-radius: 12px; background-color: var(--pattern-preview-bg); background-image: var(--pattern-preview-image); background-position: var(--pattern-preview-position, 0 0); background-size: var(--pattern-preview-size); }
.catalog-grid button span, .catalog-grid button b, .catalog-grid button small { display: block; }
.catalog-grid button b { margin-top: 12px; font-size: 15px; }
.catalog-grid button small { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.explanation-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.explanation-grid article { min-height: 190px; padding: 24px; border-right: 1px solid var(--line); }
.explanation-grid article:last-child { border-right: 0; }
.explanation-grid article > span { color: var(--blue); font: 900 11px var(--mono); }
.explanation-grid h3 { margin: 14px 0 9px; font-size: 18px; }
.explanation-grid p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.75; }
.explanation-grid code { color: var(--blue); font-size: 11px; font-weight: 900; }
.page-footer { display: flex; padding: 27px 4px; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font: 800 11px var(--mono); }
.page-footer a { margin-left: 18px; color: var(--green); }
.toast { padding: 13px 17px; position: fixed; right: 22px; bottom: 22px; z-index: 20; border-radius: 12px; color: white; background: var(--ink); font-size: 12px; font-weight: 900; opacity: 0; translate: 0 12px; pointer-events: none; transition: .2s ease; }
.toast.visible { opacity: 1; translate: 0; }

@container controls (min-width: 520px) {
  .pattern-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pattern-list button:last-child { grid-column: 1 / -1; }
}

@media (max-width: 1280px) {
  .lab-grid { grid-template-columns: 252px minmax(480px, 1fr) 290px; }
  .controls section { padding-right: 14px; padding-left: 14px; }
  .preview-canvas { padding: 14px; }
  .sample-card { width: 85%; }
  .inspector header, .layer-list, .code-block, .usage-block { padding-right: 14px; padding-left: 14px; }
}

@media (max-width: 1030px) {
  .hero { flex-wrap: wrap; }
  .hero-actions { margin-left: auto; }
  .lab-grid { grid-template-columns: 260px minmax(0, 1fr); }
  .inspector { display: grid; grid-column: 1 / -1; grid-template-columns: .8fr 1.1fr 1.5fr .9fr; }
  .inspector header, .layer-list, .code-block, .usage-block { border-right: 1px solid #44473f; border-bottom: 0; }
  .inspector-note { display: none; }
  .browser { min-height: 560px; }
  .pattern-surface { min-height: 480px; }
  .code-block pre { min-height: 170px; max-height: 210px; }
  .catalog-grid { grid-template-columns: repeat(3, 1fr); }
  .catalog-grid button { border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  html { scroll-behavior: auto; }
  .page { width: calc(100% - 24px); padding-top: 18px; }
  .hero { padding: 7px 5px 21px; }
  .eyebrow { font-size: 10px; }
  h1 { font-size: clamp(33px, 11vw, 51px); white-space: normal; }
  .lead { line-height: 1.45; }
  .hero-actions button { min-height: 42px; padding: 0 12px; }
  .section-heading { padding: 15px 13px; gap: 10px; }
  .number { width: 40px; height: 43px; border-radius: 12px; }
  .section-heading h2 { font-size: 20px; }
  .section-heading p { font-size: 10px; }
  .heading-badges span { display: none; }
  .heading-badges b { padding: 8px; }
  .lab-grid { display: block; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; border-right: 0; }
  .controls section { padding: 15px 11px; }
  .controls .pattern-control { grid-column: 1 / -1; }
  .controls section:nth-child(2) { border-right: 1px solid var(--line); }
  .controls h3 { margin-bottom: 11px; font-size: 14px; }
  .pattern-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pattern-list button { min-height: 50px; padding: 6px; grid-template-columns: 31px 1fr; gap: 7px; }
  .pattern-list button > i { width: 31px; height: 31px; border-radius: 7px; }
  .pattern-list button:last-child { grid-column: 1 / -1; }
  .pattern-list button small { display: none; }
  .color-grid label { grid-template-columns: 1fr 26px; padding: 5px 6px; }
  .color-grid output { display: none; }
  .color-grid input { width: 26px; height: 26px; }
  .range-list { gap: 11px; }
  .dot-mode-control > span, .range-list label > span, .swap-button, .tile-toggle { font-size: 10px; }
  .workspace { padding: 11px; }
  .instruction { gap: 6px; }
  .instruction p { font-size: 10px; }
  .instruction b { display: none; }
  .browser { min-height: 500px; }
  .browser-bar { padding: 0 10px; }
  .preview-canvas { padding: 9px; }
  .pattern-surface { min-height: 440px; padding: 24px 18px; }
  .sample-card { width: 88%; min-height: 240px; padding: 22px; box-shadow: 8px 8px 0 var(--ink); }
  .sample-card h3 { margin: 22px 0 37px; font-size: 38px; }
  .value-strip div { padding: 11px 8px; }
  .value-strip small, .value-strip strong { font-size: 10px; }
  .inspector { display: block; }
  .inspector header, .layer-list, .code-block, .usage-block { border-right: 0; border-bottom: 1px solid #44473f; }
  .catalog-grid { grid-template-columns: repeat(2, 1fr); }
  .catalog-grid button:nth-child(2n) { border-right: 0; }
  .catalog-grid button:last-child { grid-column: 1 / -1; }
  .catalog-grid button > i { height: 88px; }
  .explanation-grid { display: block; }
  .explanation-grid article { min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .explanation-grid article:last-child { border-bottom: 0; }
  .page-footer { flex-wrap: wrap; }
  .page-footer a { margin: 0 15px 0 0; }
}

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