:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: #222018;
  background: var(--paper);
  --ink: #222018;
  --muted: #615b4a;
  --rule: #cbc2ac;
  --paper: #f7f3e9;
  --white: #fffdf6;
  --yellow: #f8de3f;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background-image: radial-gradient(#5b4e221a .65px, transparent .65px);
  background-size: 6px 6px;
}

.workspace {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(14px, 4vw, 56px) 22px;
}

.masthead, .playback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.masthead {
  min-height: 65px;
  border-bottom: 1px solid var(--ink);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 800 clamp(.92rem, 2vw, 1.15rem)/1 var(--mono);
  letter-spacing: -.045em;
}

.mark {
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  background:
    conic-gradient(from 90deg, var(--yellow) 0 25%, var(--ink) 0 50%, var(--white) 0 75%, var(--ink) 0);
  border: 1px solid var(--ink);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, .93fr) minmax(0, 1.07fr);
  gap: clamp(24px, 4.8vw, 68px);
  margin: clamp(24px, 4vw, 56px) 0 24px;
  align-items: start;
}

h1, p { margin: 0; }

h1 {
  font-size: clamp(2.85rem, 6.5vw, 6rem);
  font-weight: 900;
  line-height: 1.16;
  letter-spacing: -.075em;
  white-space: nowrap;
}

h1 mark {
  display: inline-block;
  padding: 0 .12em .07em 0;
  color: var(--ink);
  background: linear-gradient(transparent 52%, var(--yellow) 52% 92%, transparent 92%);
}

.intro p {
  margin: 13px 0 24px;
  color: var(--muted);
  font-size: clamp(.98rem, 1.6vw, 1.1rem);
  line-height: 1.6;
}

.source-drop {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 79px;
  padding: 11px 12px;
  background: var(--white);
  border: 1px dashed #7d755f;
}

.thumb, .upload-mark {
  display: block;
  width: 50px;
  height: 50px;
  background: #eee8d8;
}

.upload-mark {
  position: relative;
  border: 1px solid var(--rule);
}

.upload-mark::before {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 7px;
  height: 7px;
  content: "";
  background: var(--ink);
  box-shadow: 8px 0 var(--ink), 0 8px var(--ink), 8px 8px var(--yellow), 8px 16px var(--ink);
}

.input-info { min-width: 0; }
.input-info label { display: block; font-size: .95rem; font-weight: 760; }
.filename {
  display: block;
  margin-top: 4px;
  font-size: .82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resolution { min-width: 0; margin: 17px 0 0; padding: 0; border: 0; }
.resolution legend { width: 100%; padding: 0; font-size: .9rem; font-weight: 750; }
.resolution legend span { float: right; color: var(--muted); font-size: .82rem; font-weight: 400; }
.resolution-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 8px; }
.resolution-options label { position: relative; }
.resolution-options input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.resolution-options label span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--rule);
  background: var(--white);
  font: 700 .96rem/1 var(--mono);
  cursor: pointer;
}
.resolution-options label:hover span { border-color: var(--ink); }
.resolution-options input:checked + span { color: var(--white); border-color: var(--ink); background: var(--ink); }

.button {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--ink);
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: .88rem;
  font-weight: 730;
  white-space: nowrap;
  cursor: pointer;
}

.button:focus-visible, .resolution-options input:focus-visible + span, .stage-placeholder:focus-visible, .footer a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
.button:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--yellow); }
.button:disabled, .button[aria-disabled="true"] { opacity: .55; cursor: default; }
.button.small { min-height: 36px; padding: 0 9px; }

.button.primary {
  width: 100%;
  min-height: 52px;
  margin-top: 15px;
  background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 1.1rem;
  font-weight: 830;
}
.button.primary:hover:not(:disabled) { background: #ffe95d; }
.button.primary:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.button.primary:disabled { opacity: .68; box-shadow: 2px 2px 0 var(--ink); }

.error, .status { font-size: .86rem; line-height: 1.55; }
.error { margin-top: 8px; color: #9c2419; overflow-wrap: anywhere; }

.preview { min-width: 0; border: 1px solid var(--ink); background: var(--white); box-shadow: 5px 5px 0 var(--ink); }

.stage {
  display: grid;
  place-items: center;
  height: clamp(344px, 43vw, 486px);
  padding: 12px;
  overflow: hidden;
  border-bottom: 1px solid var(--ink);
  background-color: #f5de54;
  background-image: radial-gradient(#29221028 1px, transparent 1px);
  background-size: 11px 11px;
}

.stage-placeholder {
  display: grid;
  justify-items: center;
  gap: 17px;
  padding: 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 760;
  cursor: pointer;
}

.stage-mark {
  display: grid;
  place-items: center;
  width: 69px;
  height: 69px;
  border: 1px solid var(--ink);
  background: var(--white);
  box-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-4deg);
}
.stage-mark::before, .stage-mark::after {
  grid-area: 1 / 1;
  width: 26px;
  height: 5px;
  background: var(--ink);
  content: "";
}
.stage-mark::after { transform: rotate(90deg); }
.stage-placeholder:hover .stage-mark { transform: rotate(0); }

.stage canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
}
[data-source-drop].is-dragging {
  background-color: #fff193;
  box-shadow: inset 0 0 0 2px var(--ink);
}

.playback {
  justify-content: flex-start;
  flex-wrap: wrap;
  padding: 10px 12px;
  gap: 7px;
}
.view-buttons { display: flex; gap: 4px; }
.view-buttons .button[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.view-buttons .button[aria-pressed="true"]:hover { background: #494331; color: var(--white); }
.play-button, .download-button { display: inline-flex; align-items: center; gap: 7px; }
.play-button { margin-left: auto; }
.download-button { background: var(--yellow); text-decoration: none; }
.download-button:hover:not([aria-disabled="true"]) { background: #ffe95d; }
.play-icon {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}
.play-icon.is-playing { width: 8px; height: 10px; border: 0; border-inline: 2px solid currentColor; }

.status { margin: 0 12px 10px; color: var(--muted); }
.status:empty { margin: 0; }
.footer { padding-top: 11px; border-top: 1px solid var(--rule); font-size: .82rem; }
.footer a { color: var(--muted); text-underline-offset: 3px; }
.footer a:hover { color: var(--ink); }

@media (max-width: 780px) {
  .layout { grid-template-columns: 1fr; gap: 20px; }
  .masthead { min-height: 52px; }
  .intro p { margin: 8px 0 15px; }
  .stage { height: clamp(266px, 80vw, 430px); }
}

@media (max-width: 380px) {
  .source-drop { gap: 8px; padding: 10px; }
  .play-button, .download-button { min-height: 36px; padding: 0 8px; }
  .play-button { margin-left: 0; }
}
