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

:root {
  --ink: #151916;
  --paper: #f4f1e8;
  --panel: #fffdf6;
  --line: #cdd1c8;
  --muted: #717a73;
  --blue: #5574ff;
  --blue-soft: #e8edff;
  --coral: #ff6f57;
  --coral-soft: #ffe5dc;
  --lime: #b9ff3d;
  --yellow: #ffd75f;
  --green: #0aa67d;
  --shadow: 0 22px 48px rgba(21, 25, 22, 0.1);
  --radius: 25px;
}

* { box-sizing: border-box; }

html { background: var(--paper); color: var(--ink); }

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, "Noto Sans JP", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  background:
    radial-gradient(circle at 0 10%, rgba(185, 255, 61, 0.22), transparent 25rem),
    radial-gradient(circle at 100% 18%, rgba(85, 116, 255, 0.14), transparent 32rem),
    var(--paper);
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
select {
  appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%23151916' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 12px auto;
}

.page { width: min(1600px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 56px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: 0 4px 24px;
}

.eyebrow, .section-heading p {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow { display: flex; align-items: center; gap: 10px; color: #256f58; }
.eyebrow i { position: relative; width: 28px; height: 20px; display: inline-block; }
.eyebrow i::before, .eyebrow i::after { content: ""; position: absolute; left: 0; width: 27px; height: 5px; border-radius: 999px; background: var(--ink); }
.eyebrow i::before { top: 2px; }
.eyebrow i::after { bottom: 2px; width: 18px; background: var(--coral); }

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(48px, 6.2vw, 96px); line-height: 0.92; font-weight: 900; letter-spacing: 0; }
h1 span { color: var(--blue); }
.lead { margin: 16px 0 0; color: var(--muted); font-size: clamp(16px, 1.5vw, 22px); font-weight: 800; }
.lead strong { color: var(--ink); }

.hero-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.hero-actions a, .hero-actions button, .preview-actions button, .code-header > button {
  display: grid; place-items: center;
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.72);
  color: var(--ink);
  text-decoration: none;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.hero-actions a:hover, .hero-actions button:hover, .preview-actions button:hover, .code-header > button:hover { transform: translateY(-2px); }
.button--dark, .hero-actions .button--dark, .preview-actions .button--dark { color: #fff; background: var(--ink); border-color: var(--ink); }

.preset-shell, .control-panel, .preview-panel, .code-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,253,246,.9);
  box-shadow: var(--shadow);
}

.preset-shell { padding: 20px; }
.section-header, .panel-header, .code-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-header { margin-bottom: 17px; align-items: flex-start; }
.preset-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.preset-search, #presetSearch {
  width: min(220px, 100%);
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  outline: none;
}
#presetSearch:focus { border-color: var(--blue); }
#showAllPresets {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
#showAllPresets[aria-pressed="true"] { background: #fff; color: var(--ink); }
.section-heading { display: flex; align-items: center; gap: 13px; min-width: 0; }
.section-heading > span {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 14px;
  color: #fff; background: var(--ink); font-size: 12px; font-weight: 900;
}
.section-heading--blue > span { background: var(--blue); }
.section-heading--coral > span { background: var(--coral); }
.section-heading--coral p { color: var(--coral); }
.section-heading h2 { margin: 0; font-size: clamp(19px, 2vw, 27px); line-height: 1.06; font-weight: 900; }

.preset-filter, .mode-switch, .segmented, .code-tabs {
  position: relative;
  display: grid;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #eff1ec;
  overflow: hidden;
  isolation: isolate;
}
.preset-filter { grid-template-columns: repeat(4, 1fr); }
.mode-switch { grid-template-columns: repeat(2, 1fr); min-width: 146px; }
.segmented { grid-template-columns: repeat(3, 1fr); }
.code-tabs { grid-template-columns: repeat(3, 1fr); width: min(380px, 100%); }
.preset-filter button, .mode-switch button, .segmented button, .code-tabs button {
  position: relative; z-index: 2; min-height: 37px; padding: 0 12px; border: 0; background: transparent; font-size: 10px; font-weight: 900; cursor: pointer;
}
.preset-filter i, .mode-switch i, .segmented i, .code-tabs i {
  position: absolute; z-index: 1; top: 4px; bottom: 4px; left: 4px;
  border-radius: 9px; background: #fff; box-shadow: 0 3px 8px rgba(21,25,22,.1);
  transition: translate .28s cubic-bezier(.22,1,.36,1), width .28s cubic-bezier(.22,1,.36,1);
}
.preset-filter i { width: calc((100% - 8px) / 4); }
.mode-switch i { width: calc((100% - 8px) / 2); }
.segmented i, .code-tabs i { width: calc((100% - 8px) / 3); }

.preset-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.preset-card {
  position: relative;
  display: grid;
  align-content: start;
  min-height: 168px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.preset-card:hover { transform: translateY(-3px); }
.preset-card[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.preset-card[hidden] { display: none; }
.preset-card > span:not(.preset-live) { display: block; color: var(--blue); font-size: 10px; font-weight: 900; letter-spacing: .13em; }
.preset-card strong { display: block; margin-top: 6px; font-size: 13px; font-weight: 900; }
.preset-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.preset-card > .preset-live {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  height: 58px;
  min-height: 58px;
  margin-top: 10px;
  padding: 8px 10px;
  overflow: hidden;
  border-radius: 10px;
  background: #151916;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0;
  white-space: nowrap;
  text-transform: uppercase;
  text-align: center;
  pointer-events: none;
  perspective: 700px;
}
.preset-card > .preset-live > * { flex: 0 0 auto; }
.preset-shell.is-gallery .preset-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.preset-shell.is-gallery .preset-card { min-height: 248px; }
.preset-shell.is-gallery .preset-card > .preset-live { height: 118px; min-height: 118px; font-size: clamp(16px, 1.7vw, 24px); }
.preset-empty { margin: 18px 0 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.preset-empty[hidden] { display: none; }

.studio { display: grid; grid-template-columns: minmax(330px, .82fr) minmax(0, 1.58fr); gap: 16px; margin-top: 16px; align-items: start; }
.control-panel, .preview-panel { overflow: hidden; }
.panel-header { min-height: 83px; padding: 16px 20px; border-bottom: 1px solid var(--line); }

.control-section { padding: 17px 20px; border-bottom: 1px solid var(--line); }
.control-section:last-child { border-bottom: 0; }
.text-fields label, .two-column-controls label { display: block; margin-bottom: 7px; font-size: 10px; font-weight: 900; }
.text-fields textarea, .two-column-controls select, .scramble-control select, .scramble-control input[type="text"] {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background-color: #fff; color: var(--ink); outline: none;
}
.text-fields textarea { min-height: 59px; padding: 12px 14px; resize: vertical; font-size: 12px; line-height: 1.45; font-weight: 800; }
.scramble-control { display: none; }
body[data-engine="scramble"] .scramble-control { display: block; }
.scramble-control select, .scramble-control input[type="text"] { min-height: 44px; padding: 0 12px; font-size: 12px; font-weight: 800; }
.scramble-control select { padding-right: 38px; }
.scramble-control input[type="text"] { font-variant-ligatures: none; }
.text-fields textarea:focus, .two-column-controls select:focus, .scramble-control select:focus, .scramble-control input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(85,116,255,.13); }
.text-fields label:nth-of-type(2) { margin-top: 12px; }
.text-fields > p { margin: 9px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.control-label { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.control-label span { display: block; color: var(--green); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.control-label strong { display: block; margin-top: 3px; font-size: 13px; }
.control-label output { color: var(--blue); font-size: 10px; font-weight: 900; }
.range-stack { display: grid; gap: 17px; }
.range-stack label > span { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 11px; font-weight: 900; }
.range-stack output { color: var(--blue); }
input[type="range"] { width: 100%; accent-color: var(--blue); cursor: pointer; }
.two-column-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two-column-controls select { min-height: 44px; padding: 0 38px 0 12px; font-size: 11px; font-weight: 800; }
.toggle-list { display: grid; gap: 7px; margin-top: 13px; }
.toggle-list label { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; padding: 8px 10px 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.toggle-list span { min-width: 0; }
.toggle-list strong, .toggle-list small { display: block; }
.toggle-list strong { font-size: 11px; }
.toggle-list small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.toggle-list input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-list i { position: relative; flex: 0 0 auto; width: 38px; height: 23px; border-radius: 999px; background: #d8dcd5; transition: background .2s ease; }
.toggle-list i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: translate .22s ease; }
.toggle-list input:checked + i { background: var(--blue); }
.toggle-list input:checked + i::after { translate: 15px 0; }
.advanced-control { display: none; }
body[data-mode="advanced"] .advanced-control { display: block; }

.preview-panel { min-height: 718px; }
.preview-actions { display: flex; align-items: center; gap: 7px; }
.preview-actions button { min-height: 38px; padding-inline: 13px; }
.preview-actions button[aria-pressed="true"]:not(.button--dark) { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.preview-stage-wrap { padding: 18px 18px 0; overflow-x: auto; }
.preview-stage {
  position: relative;
  width: 960px;
  max-width: 100%;
  height: 490px;
  margin: 0 auto;
  border: 2px solid var(--ink);
  border-radius: 22px;
  background: #151916;
  color: #fff;
  overflow: hidden;
  outline: none;
  perspective: 900px;
  transition: width .24s ease;
  cursor: default;
}
.preview-stage[data-trigger="click"] { cursor: pointer; }
.stage-grid { position: absolute; inset: 0; opacity: .16; background-image: linear-gradient(rgba(255,255,255,.16) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.16) 1px, transparent 1px); background-size: 28px 28px; }
.stage-orbit { position: absolute; border: 2px solid currentColor; border-radius: 50%; opacity: .9; }
.stage-orbit--one { width: 430px; height: 430px; right: -145px; top: -180px; color: var(--lime); }
.stage-orbit--two { width: 310px; height: 310px; left: -125px; bottom: -175px; color: var(--coral); }
.preview-copy { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; width: min(760px, calc(100% - 72px)); margin: auto; }
.preview-kicker { display: block; margin-bottom: 18px; color: var(--lime); font-size: 11px; font-weight: 900; letter-spacing: .2em; }
.preview-text { margin: 0; font-size: clamp(48px, 6vw, 92px); line-height: .92; font-weight: 900; letter-spacing: 0; text-transform: uppercase; white-space: pre-line; perspective: 900px; }
.preview-note { margin: 19px 0 0; color: rgba(255,255,255,.62); font-size: 13px; }
.interaction-hint { position: absolute; right: 16px; bottom: 16px; padding: 8px 11px; border-radius: 999px; color: var(--ink); background: var(--yellow); font-size: 10px; font-weight: 900; letter-spacing: .1em; }

.preview-toolbar { padding: 14px 18px 18px; }
.preview-toolbar > label { display: grid; grid-template-columns: auto minmax(120px, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.preview-toolbar > label span, .preview-toolbar > label output { font-size: 10px; font-weight: 900; }
.preview-toolbar > label output { color: var(--blue); }
.preview-toolbar dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 0; }
.preview-toolbar dl div { min-width: 0; padding: 12px 13px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.preview-toolbar dt { color: var(--blue); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.preview-toolbar dd { margin: 5px 0 0; font-size: 11px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.code-panel { margin-top: 16px; overflow: hidden; background: var(--ink); border-color: var(--ink); color: #fff; }
.code-header { min-height: 84px; padding: 16px 20px; border-bottom: 1px solid #36403a; }
.code-header > button { color: var(--ink); background: var(--coral); border-color: var(--coral); }
.code-body { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .55fr); }
.code-editor { min-width: 0; padding: 16px 20px 20px; border-right: 1px solid #36403a; }
.code-tabs { background: #222a25; border-color: #3c4740; }
.code-tabs i { background: #fff; }
.code-tabs button { color: #aab2ac; }
.code-tabs button[aria-selected="true"] { color: var(--ink); }
.code-editor pre { height: 340px; margin: 14px 0 0; padding: 18px; border: 1px solid #36403a; border-radius: 15px; background: #090c0a; overflow: auto; }
.code-editor code { color: #e7ece8; font: 600 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
.recipe-card { padding: 22px; background: #1c2420; }
.recipe-card > span { color: var(--yellow); font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.recipe-card h3 { margin: 10px 0 0; font-size: 28px; font-weight: 900; }
.recipe-card > p { color: #b8c0ba; font-size: 11px; line-height: 1.65; }
.recipe-card dl { display: grid; gap: 8px; margin: 20px 0; }
.recipe-card dl div { padding: 11px 12px; border: 1px solid #3b4740; border-radius: 11px; background: #131815; }
.recipe-card dt { color: #7f8982; font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.recipe-card dd { margin: 4px 0 0; color: var(--lime); font-size: 11px; font-weight: 900; overflow-wrap: anywhere; }
.recipe-card .accessibility-note { padding: 12px; border-radius: 12px; color: #d7ddd9; background: rgba(85,116,255,.15); }
.accessibility-note strong { display: block; margin-bottom: 5px; color: #92a5ff; font-size: 10px; letter-spacing: .14em; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; translate: -50% 20px; padding: 11px 16px; border-radius: 999px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: 11px; font-weight: 900; opacity: 0; pointer-events: none; transition: opacity .2s ease, translate .2s ease; }
.toast.is-visible { opacity: 1; translate: -50% 0; }

@media (max-width: 1180px) {
  .preset-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .preset-shell.is-gallery .preset-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .studio { grid-template-columns: minmax(300px, .75fr) minmax(0, 1.25fr); }
  .preview-stage { height: 450px; }
}

@media (max-width: 880px) {
  .page { width: min(100% - 20px, 720px); padding-top: 20px; }
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero-actions { justify-content: flex-start; }
  .section-header { align-items: flex-start; flex-direction: column; }
  .preset-toolbar, .preset-filter, #presetSearch, #showAllPresets { width: 100%; }
  .preset-shell.is-gallery .preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preset-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .studio { grid-template-columns: 1fr; }
  .preview-panel { min-height: 0; }
  .code-body { grid-template-columns: 1fr; }
  .code-editor { border-right: 0; border-bottom: 1px solid #36403a; }
}

@media (max-width: 580px) {
  .page { width: calc(100% - 12px); }
  h1 { font-size: 44px; }
  .preset-shell { padding: 13px; }
  .preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preset-shell.is-gallery .preset-grid { grid-template-columns: 1fr; }
  .preset-card { min-height: 126px; }
  .preset-shell.is-gallery .preset-card { min-height: 220px; }
  .panel-header, .code-header { align-items: flex-start; flex-direction: column; padding: 14px; }
  .preview-header { flex-direction: row; }
  .preview-header .section-heading h2 { font-size: 17px; }
  .preview-header .section-heading > span { width: 38px; height: 38px; }
  .preview-actions { flex-wrap: wrap; justify-content: flex-end; }
  .control-section { padding-inline: 14px; }
  .preview-stage-wrap { padding: 10px 10px 0; }
  .preview-stage { height: 410px; }
  .preview-copy { width: calc(100% - 38px); }
  .preview-text { font-size: clamp(38px, 12vw, 58px); }
  .preview-toolbar { padding: 10px; }
  .preview-toolbar > label { grid-template-columns: 1fr auto; }
  .preview-toolbar > label input { grid-column: 1 / -1; grid-row: 2; }
  .preview-toolbar dl { grid-template-columns: 1fr; }
  .two-column-controls { grid-template-columns: 1fr; }
  .code-header { flex-direction: row; align-items: center; }
  .code-editor { padding: 13px; }
  .code-editor pre { height: 300px; }
}

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