:root {
  --bg: #fff8f0;
  --surface: #fffefa;
  --ink: #38241f;
  --muted: #785f57;
  --line: #ecdcd3;
  --acc: #a83d59;
  --acc-hover: #90314a;
  --pink: #fbe2e9;
  --blush: #fff1f4;
  --paper: #fff5e9;
  --radius: 22px;
  color-scheme: light;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; }
::selection { background: #f4b9cb; color: var(--ink); }
h1, h2, p { margin: 0; }

.wrap { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.topbar { border-bottom: 1px solid var(--line); background: #fffbf6; }
.topbar-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 21px; font-weight: 800; }

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 41px;
  height: 41px;
  flex: none;
  border: 1px solid #edc9a5;
  border-radius: 13px;
  background: #ffe7bd;
  color: #884b39;
  transform: rotate(-6deg);
}
.cat-face {
  position: relative;
  width: 23px;
  height: 17px;
  border: 1.6px solid currentColor;
  border-radius: 48% 48% 45% 45%;
  background:
    radial-gradient(circle at 31% 52%, currentColor 1px, transparent 1.5px),
    radial-gradient(circle at 69% 52%, currentColor 1px, transparent 1.5px),
    radial-gradient(ellipse at 50% 72%, #c96a71 1.4px, transparent 1.8px),
    #fff6e5;
  margin-top: 4px;
}
.cat-face::before, .cat-face::after {
  position: absolute;
  top: -5px;
  width: 6px;
  height: 6px;
  background: #fff6e5;
  border-top: 1.6px solid currentColor;
  border-left: 1.6px solid currentColor;
  border-radius: 2px 1px 0 1px;
  content: "";
}
.cat-face::before { left: 0; transform: rotate(12deg); }
.cat-face::after { right: 0; transform: rotate(76deg); }

.quota-actions { display: flex; align-items: center; gap: 8px; }
.quota-actions .button { padding: 6px 9px; }

.badge, .ratio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  border-radius: 999px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.badge { color: #814250; background: var(--pink); padding: 6px 12px; font-size: 12px; }
.ticket-icon {
  width: 13px;
  height: 9px;
  border: 1px solid currentColor;
  border-radius: 2px;
  background: linear-gradient(currentColor, currentColor) center / 1px 4px no-repeat;
  transform: rotate(-13deg);
}

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  gap: 8px;
}
.intro h1 { font-size: 39px; font-weight: 800; line-height: 1.2; letter-spacing: -.035em; }
.intro h1:focus { outline: none; }
.intro h1 span { color: var(--acc); }
.intro-decoration { position: relative; width: 97px; height: 60px; flex: none; }

.paw {
  --paw-ink: #e7a2b3;
  position: absolute;
  width: 36px;
  height: 35px;
  background:
    radial-gradient(ellipse at center, var(--paw-ink) 64%, transparent 70%) 1px 10px / 7px 10px,
    radial-gradient(ellipse at center, var(--paw-ink) 64%, transparent 70%) 9px 3px / 8px 11px,
    radial-gradient(ellipse at center, var(--paw-ink) 64%, transparent 70%) 19px 3px / 8px 11px,
    radial-gradient(ellipse at center, var(--paw-ink) 64%, transparent 70%) 28px 10px / 7px 10px,
    radial-gradient(ellipse at center, var(--paw-ink) 66%, transparent 71%) 7px 17px / 22px 16px;
  background-repeat: no-repeat;
}
.sparkle {
  position: absolute;
  width: 22px;
  aspect-ratio: 1;
  background: #e8a038;
  clip-path: polygon(50% 0, 62% 37%, 100% 50%, 62% 63%, 50% 100%, 38% 63%, 0 50%, 38% 37%);
}
.intro-paw { right: 13px; top: 6px; transform: rotate(24deg); }
.intro-sparkle { width: 17px; right: 59px; bottom: 9px; }

.studio {
  display: grid;
  grid-template-columns: minmax(310px, .76fr) minmax(0, 1.24fr);
  align-items: stretch;
  gap: 24px;
  padding-bottom: 24px;
}
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.panel h2 { font-size: 16px; font-weight: 750; }
.preview { display: flex; flex-direction: column; padding: 17px; }
.preview-heading, .section-heading, .preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.preview-heading { margin: 0 2px 14px; }
.ratio { color: #7e4d52; background: var(--blush); font-size: 12px; padding: 3px 9px; }
.preview-mat {
  position: relative;
  display: grid;
  flex: 1;
  place-items: center;
  isolation: isolate;
  padding: 13px 24px;
  overflow: hidden;
  border: 1px solid #f0cfd7;
  border-radius: 15px;
  background-color: #fae8ec;
  background-image: radial-gradient(#d79fac 1px, transparent 1px);
  background-size: 16px 16px;
}
.film {
  z-index: 1;
  width: min(100%, 237px);
  padding: 6px;
  border: 1px solid #efcfd6;
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 7px 18px #864a5320;
}
#stage { display: block; width: 100%; height: auto; aspect-ratio: 9 / 16; border-radius: 9px; background: #dccec1; }
.mat-sparkle { top: 14%; left: 7.5%; transform: rotate(11deg); }
.mat-star { width: 12px; top: 21%; left: 12%; background: #dc8ca2; }
.mat-paw { --paw-ink: #db93a5; bottom: 9%; right: 4%; transform: rotate(24deg); }
.preview-toolbar { margin: 14px 1px 0; }
#hint { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

.editor { display: flex; flex-direction: column; padding: 0 24px; }
.editor-section { min-width: 0; padding: 12px 0 13px; }
.editor-section + .editor-section { border-top: 1px solid var(--line); }
.section-heading { min-height: 33px; margin-bottom: 5px; }
.choices {
  display: flex;
  align-items: start;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding: 3px 3px 7px;
  margin-inline: -3px;
  scrollbar-width: thin;
  scrollbar-color: #dca8b6 transparent;
}
.cat {
  position: relative;
  display: block;
  flex: 1 0 56px;
  min-width: 56px;
  height: 61px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 11px;
  background: var(--paper);
  overflow: hidden;
}
.cat img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center 59%; }
.cat:not(.up-slot) img { object-position: center 66%; }
.cat.on { border-color: var(--acc); }
.cat.on::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--acc);
  content: "";
}
.cat:hover:not(.on), .bb:hover:not(.on) canvas { border-color: #d78b9e; }

.bb {
  flex: 1 0 69px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: transparent;
}
.bb canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #765960;
}
.bb span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.bb.on canvas { border-color: var(--acc); outline: 1px solid var(--acc); outline-offset: 1px; }
.bb.on span { color: var(--acc); font-weight: 750; }

.message { background: #fff9f6; border: 1px solid var(--line); border-radius: 13px; }
.message:focus-within { border-color: var(--acc); box-shadow: 0 0 0 2px #f7dce5; }
textarea {
  display: block;
  width: 100%;
  min-height: 65px;
  padding: 10px 12px 1px;
  border: 0;
  outline: none;
  background: transparent;
  resize: vertical;
  caret-color: var(--acc);
}
textarea:focus-visible { outline: none; }
textarea::placeholder, #code::placeholder { color: #846b62; }
.count { padding: 1px 12px 6px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.templates { margin-top: 10px; }
.template-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.tpl button {
  flex: none;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: #fff9f2;
  font-size: 12px;
  white-space: nowrap;
}
.tpl button:hover { background: var(--blush); border-color: #dfa5b4; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.3;
  transition: background-color .15s, border-color .15s, transform .15s;
}
.button:active:not(:disabled), .tpl button:active { transform: translateY(1px); }
.button:focus-visible, .cat:focus-visible, .bb:focus-visible, .tpl button:focus-visible { outline-offset: 1px; }
.primary { background: var(--acc); color: #fff; }
.primary:hover:not(:disabled) { background: var(--acc-hover); }
.secondary { border-color: #e7c6cd; background: #fff9f7; color: #73404b; }
.secondary:hover, .audition:hover, .text-button:hover { background: var(--pink); }
.audition { min-width: 79px; flex: none; color: #83334a; background: var(--blush); border-color: #eed2dc; }
.text-button { min-height: 34px; font-size: 12px; color: var(--acc); padding: 5px 9px; }
.upload { background: var(--blush); }
.reset { color: var(--muted); }

.play-icon { width: 9px; height: 11px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.plus-icon { width: 11px; height: 11px; background: linear-gradient(currentColor, currentColor) center / 11px 1px no-repeat, linear-gradient(currentColor, currentColor) center / 1px 11px no-repeat; }
.download-icon {
  position: relative;
  width: 13px;
  height: 14px;
  border-bottom: 1.5px solid currentColor;
  background: linear-gradient(currentColor, currentColor) top / 1.5px 9px no-repeat;
}
.download-icon::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  content: "";
}
.export-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 16px 0 20px;
}
.export-actions .button { min-height: 47px; }
.button-ratio { font-size: 11px; font-weight: 600; opacity: .9; white-space: nowrap; }

.toast {
  position: fixed;
  z-index: 2;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 11px;
  background: #4a2b2e;
  color: #fff;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity .18s, transform .18s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.gate {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  padding: 24px;
}
.gate-card {
  display: grid;
  grid-template-columns: minmax(0, .93fr) minmax(0, 1.07fr);
  width: min(100%, 780px);
  border: 1px solid var(--line);
  border-radius: 28px;
  overflow: hidden;
  background: var(--surface);
}
.gate-art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 392px;
  padding: 32px;
  overflow: hidden;
  background-color: #f8dfe7;
  background-image: radial-gradient(#dca3b3 1px, transparent 1px);
  background-size: 17px 17px;
}
.gate-art img {
  display: block;
  width: min(100%, 217px);
  height: 282px;
  border: 6px solid #fffaf0;
  border-radius: 15px;
  object-fit: cover;
  object-position: center 75%;
  transform: rotate(-7deg);
  box-shadow: 0 8px 18px #864a5330;
}
.gate-sparkle { width: 27px; top: 13%; right: 13%; background: #d89639; }
.gate-paw { --paw-ink: #cf8298; right: 10%; bottom: 9%; transform: rotate(16deg); }
.gate-body { align-self: center; padding: 35px 40px; }
.gate-body h1 { margin: 22px 0; font-size: 32px; line-height: 1.2; letter-spacing: -.035em; }
.gate-body label { display: block; font-size: 15px; font-weight: 750; }
.gate-body p { margin: 4px 0 12px; color: var(--muted); font-size: 13px; }
.gate-body input {
  display: block;
  width: 100%;
  min-height: 47px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff9f6;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.gate-body .button { width: 100%; min-height: 46px; }

@media (max-width: 900px) {
  .wrap { width: calc(100% - 40px); }
  .studio { grid-template-columns: minmax(270px, .8fr) minmax(0, 1.2fr); gap: 16px; }
  .preview { padding: 14px; }
  .editor { padding-inline: 17px; }
  .preview-mat { padding-inline: 20px; }
}
@media (max-width: 700px) {
  .wrap { width: min(100% - 28px, 510px); }
  .topbar-inner { min-height: 60px; }
  .brand { gap: 9px; font-size: 19px; }
  .brand-mark { width: 35px; height: 35px; border-radius: 11px; }
  .intro { min-height: 76px; }
  .intro h1 { font-size: 28px; }
  .intro-decoration { width: 54px; height: 49px; }
  .intro-paw { right: 1px; top: 4px; transform: scale(.77) rotate(24deg); }
  .intro-sparkle { right: 37px; bottom: 8px; width: 12px; }
  .studio { grid-template-columns: minmax(0, 1fr); padding-bottom: 24px; }
  .preview-mat { padding-block: 12px; }
  .film { width: min(100%, 197px); }
  .mat-sparkle { left: 8%; }
  .mat-star { left: 11%; top: 22%; }
  .mat-paw { right: 7%; bottom: 12%; transform: scale(.84) rotate(24deg); }
  .cats { gap: 6px; }
  .cats .cat { flex: 1 0 49px; min-width: 49px; }
  .gate-card { grid-template-columns: minmax(0, 1fr); width: min(100%, 410px); }
  .gate-art { min-height: 0; padding: 15px; }
  .gate-art img { width: 145px; height: 166px; transform: rotate(-6deg); }
  .gate-body { padding: 23px; }
  .gate-body h1 { margin-block: 17px; font-size: 27px; }
}
@media (max-width: 365px) {
  .intro h1 { font-size: 25px; }
  .intro-decoration { width: 43px; }
  .intro-sparkle { right: 30px; }
  .editor { padding-inline: 12px; }
  .export-actions { gap: 7px; }
  .export-actions .button { padding-inline: 7px; gap: 5px; }
  .mat-paw { right: 2%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .button:active:not(:disabled), .tpl button:active { transform: none; }
}
