:root {
  color-scheme: light;
  --ink: #24222b;
  --muted: #5e5967;
  --paper: #f7f6ef;
  --white: #fffefa;
  --line: #dcd8d3;
  --purple: #ded2fb;
  --lime: #e0fb69;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid #6538c5; outline-offset: 3px; }
h1, h2, p { margin: 0; }
.shell { width: min(1120px, calc(100% - 72px)); margin: auto; }
.masthead { height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.wordmark { display: flex; align-items: center; gap: 9px; font: 900 14px/1 system-ui, sans-serif; letter-spacing: .15em; }
.button { display: flex; align-items: center; justify-content: center; gap: 8px; border: 2px solid var(--ink); border-radius: 11px; font-weight: 800; min-height: 46px; background: var(--white); }
.button:active { transform: translateY(2px); box-shadow: none; }
.save { padding: 0 15px; font-size: .82rem; }
.save span { font-size: 1.25rem; }
.intro { margin: 38px 0 24px; }
h1 { font-size: clamp(2.9rem, 6.5vw, 5.7rem); line-height: 1.05; font-weight: 1000; letter-spacing: -.09em; }
h1 span { color: #6040a3; }
.intro p { margin-top: 12px; font-size: .92rem; font-weight: 650; color: var(--muted); }
.workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, 1fr); gap: 20px; align-items: start; }
.preview, .controls { border: 2px solid var(--ink); border-radius: 20px; box-shadow: 4px 4px 0 var(--ink); }
.preview { overflow: hidden; background: var(--white); }
.stage-line { min-height: 40px; padding: 6px 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .72rem; font-weight: 750; }
.stage-line i { display: inline-block; margin-right: 5px; width: 8px; height: 8px; border-radius: 50%; background: #a17de5; }
.artboard { position: relative; display: grid; place-items: center; overflow: hidden; border-block: 2px solid var(--ink); background-color: var(--purple); background-image: linear-gradient(#4b358821 1px, transparent 1px), linear-gradient(90deg, #4b358821 1px, transparent 1px); background-size: 25px 25px; background-position: center; }
#face { display: block; width: min(100%, 455px); height: auto; overflow: visible; z-index: 1; user-select: none; -webkit-user-select: none; }
.spark { position: absolute; color: #6040a3; font-size: clamp(1.2rem, 4vw, 2.3rem); pointer-events: none; }
.spark-a { left: 13%; top: 14%; transform: rotate(-12deg); }
.spark-b { right: 12%; bottom: 16%; transform: rotate(12deg); }
.feature, .feature > * { touch-action: none; cursor: grab; }
.feature:active { cursor: grabbing; }
.feature.locked, .feature.locked > * { cursor: default; touch-action: auto; }
.feature:focus-visible { filter: drop-shadow(0 0 2px #55309c); outline-offset: 1px; }
.hint { color: var(--muted); }
.controls { background: var(--white); padding: 16px; }
.mode { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 4px; background: #eeebf2; border-radius: 12px; gap: 4px; }
.mode button { min-height: 44px; padding: 5px 4px; border: 1px solid transparent; border-radius: 9px; background: transparent; font-size: .84rem; font-weight: 800; }
.mode button[aria-pressed="true"] { background: var(--white); border-color: var(--ink); box-shadow: 1px 1px 0 var(--ink); }
.generate { width: 100%; min-height: 57px; background: var(--lime); box-shadow: 2px 3px 0 var(--ink); margin-top: 11px; font-size: 1.07rem; }
.generate span { font-size: 1.3rem; }
.part-heading, .palette-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 22px 0 6px; }
.controls h2 { font-size: .91rem; }
.part-heading > span { color: var(--muted); font-size: .71rem; font-weight: 700; }
.part-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 44px 44px; align-items: center; gap: 7px; min-height: 53px; border-bottom: 1px solid var(--line); }
.part-row:last-child { border-bottom: 0; }
.part-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: #efe8fb; }
.part-icon svg { width: 20px; height: 20px; }
.part-label { font-size: .86rem; font-weight: 750; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 9px; border: 1px solid var(--line); background: var(--white); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn[aria-pressed="true"] { background: var(--purple); border-color: var(--ink); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.palette-heading { margin-top: 14px; }
.palette { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; max-width: 300px; }
.swatch { position: relative; display: grid; place-items: center; min-width: 0; min-height: 44px; padding: 2px; background: transparent; border: 1px solid transparent; border-radius: 9px; }
.swatch[aria-pressed="true"] { border-color: var(--ink); }
footer { border-top: 1px solid var(--line); margin-top: 28px; padding: 15px 0 max(18px, env(safe-area-inset-bottom)); font: 800 .67rem/1.3 system-ui, sans-serif; letter-spacing: .12em; color: var(--muted); }
footer span { color: #6040a3; }
.toast { position: fixed; z-index: 3; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 28px); width: max-content; border-radius: 10px; background: var(--ink); color: white; padding: 10px 14px; font-size: .82rem; font-weight: 700; pointer-events: none; }
.toast:empty { display: none; }
@media (hover: hover) {
  .button:hover, .icon-btn:not(:disabled):hover, .mode button:hover { filter: brightness(.95); }
}
@media (max-width: 740px) {
  .shell { width: calc(100% - 28px); }
  .masthead { height: 62px; }
  .intro { margin: 20px 0 15px; }
  h1 { font-size: clamp(2.3rem, 9.9vw, 4rem); }
  .intro p { margin-top: 7px; font-size: .81rem; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .preview, .controls { border-radius: 15px; box-shadow: 3px 3px 0 var(--ink); }
  #face { width: min(100%, 36svh, 390px); }
  .stage-line { min-height: 35px; padding-inline: 9px; font-size: .66rem; }
  .controls { padding: 11px; }
  .part-heading { margin-top: 17px; }
}
@media (pointer: coarse) { .hint span:last-child { display: none; } }
@media (max-width: 740px) and (max-height: 650px) {
  #face { width: min(100%, 30svh); }
  .intro { margin-top: 15px; }
}
h1 { font-size: clamp(2rem, 5.2vw, 4rem); letter-spacing: -.07em; }
.moods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 9px; }
.moods button, .options button { border: 1px solid var(--line); background: var(--white); border-radius: 9px; min-height: 44px; padding: 6px 8px; font-size: .78rem; font-weight: 750; }
.moods button[aria-pressed="true"], .options button[aria-pressed="true"] { border-color: var(--ink); background: var(--purple); }
.candidates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 14px 0 9px; }
.candidate { display: block; padding: 0; background: #f4f0fb; border: 2px solid transparent; border-radius: 12px; min-width: 0; overflow: hidden; }
.candidate svg { display: block; width: 100%; height: 116px; pointer-events: none; }
.candidate[aria-pressed="true"] { border-color: var(--ink); background: #edf5cc; box-shadow: 2px 2px 0 var(--ink); }
.nearby { width: 100%; font-size: .8rem; }
.options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.preview { position: sticky; top: 15px; }
@media(max-width:740px) {
  h1 { font-size: clamp(1.7rem, 7.3vw, 3rem); }
  .preview { position: static; }
  .controls { padding: 13px; }
  .candidate svg { height: 123px; }
  .moods button { padding-inline: 2px; }
}
