:root {
  color-scheme: light;
  --page: #f5f5f7;
  --surface: #fff;
  --ink: #19191c;
  --muted: #5d5d64;
  --line: #d7d7dc;
  --focus: #2959b5;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--page); color: var(--ink); }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
h1, p, figure { margin: 0; }

.site-header {
  display: flex;
  align-items: center;
  width: min(1192px, calc(100% - 64px));
  min-height: 72px;
  margin-inline: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  font-size: 1rem;
  font-weight: 790;
  letter-spacing: -.048em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 19px;
  height: 19px;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  transform: rotate(5deg);
}
.brand-mark i { background: currentColor; border-radius: 1px 7px 1px 7px; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { border-radius: 7px 1px 7px 1px; }

.studio {
  width: min(1040px, calc(100% - 64px));
  min-height: calc(100svh - 72px);
  margin-inline: auto;
  display: grid;
  align-items: center;
  padding: 32px 0 max(56px, 9svh);
}

.view h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 760;
  line-height: 1.13;
  letter-spacing: -.065em;
  word-break: keep-all;
  text-wrap: balance;
}
.view h1:focus { outline: none; }
.upload-view, .progress-view { width: min(100%, 652px); margin-inline: auto; text-align: center; }
.upload-card {
  width: 100%;
  min-height: clamp(236px, 34svh, 350px);
  margin-top: 32px;
  padding: 28px 20px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 9px;
  border: 1px dashed #b8b8bf;
  border-radius: 24px;
  color: inherit;
  background: var(--surface);
  transition: border-color 160ms ease, background-color 160ms ease;
}
.upload-card:is(:hover, .dragging) { border-color: var(--ink); background: #eeeef1; }
.upload-card.dragging { border-style: solid; }
.upload-icon { width: 52px; height: 52px; margin-bottom: 8px; border-radius: 50%; background: var(--ink); position: relative; }
.upload-icon::before, .upload-icon::after {
  content: "";
  width: 17px;
  height: 2px;
  position: absolute;
  top: calc(50% - 1px);
  left: calc(50% - 8.5px);
  border-radius: 1px;
  background: #fff;
}
.upload-icon::after { transform: rotate(90deg); }
.upload-label { font-size: 1.28rem; font-weight: 740; letter-spacing: -.035em; }
.upload-instruction { color: var(--muted); font-size: .95rem; word-break: keep-all; }
.file-hint { margin-top: 9px; color: var(--muted); font-size: .8125rem; }
.feedback { margin-top: 13px; color: var(--muted); font-size: .9rem; line-height: 1.5; word-break: keep-all; }
.upload-view .feedback { color: #9a313c; }

.progress-group {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 380px);
  margin: 34px auto 12px;
}
progress { flex: 1; min-width: 0; width: 100%; height: 6px; border: none; border-radius: 999px; background: #dddde3; appearance: none; }
progress::-webkit-progress-bar { background: #dddde3; border-radius: 999px; }
progress::-webkit-progress-value { background: var(--ink); border-radius: 999px; transition: width 150ms ease-out; }
progress::-moz-progress-bar { background: var(--ink); border-radius: 999px; }
#progressPercent { width: 4ch; color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.progress-status { color: var(--muted); font-size: .95rem; }

.result-view {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  grid-template-areas: "heading preview" "actions preview";
  align-items: center;
  column-gap: clamp(30px, 7vw, 100px);
  row-gap: 20px;
}
.result-heading { grid-area: heading; align-self: end; }
.result-heading h1 { text-wrap: wrap; }
.result-heading p { margin-top: 13px; color: var(--muted); line-height: 1.65; word-break: keep-all; }
.board-preview {
  grid-area: preview;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 30px;
  border-radius: 26px;
  background: #eaeaec;
}
.board-edit-toggle { margin-bottom: 14px; }
.board-edit-toggle[aria-expanded="true"] { color: white; background: var(--ink); border-color: var(--ink); }
.board-art {
  position: relative;
  width: min(100%, 310px, calc(58svh * .5625));
  border-radius: 6px;
}
.board-preview canvas {
  display: block;
  height: auto;
  width: 100%;
  border-radius: inherit;
  box-shadow: 0 14px 34px #23232c29, 0 0 0 1px #1d1d211c;
}
.board-art.is-editing canvas { cursor: grab; touch-action: none; }
.board-art.is-dragging canvas { cursor: grabbing; }
.board-art canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.photo-outline {
  position: absolute;
  border: 2px solid white;
  box-shadow: inset 0 0 0 1px #1b1b21a6, 0 0 0 1px #1b1b21a6;
  pointer-events: none;
}
.photo-controls { margin-top: 13px; text-align: center; color: var(--muted); font-size: .8125rem; word-break: keep-all; }
.position-reset { min-height: 36px; border: 0; padding: 0 8px; color: var(--ink); background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.position-reset:disabled { cursor: default; text-decoration: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.result-actions { grid-area: actions; align-self: start; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.button { border: 1px solid transparent; border-radius: 999px; min-height: 46px; padding: 0 16px; font-size: .9rem; font-weight: 690; }
.button-primary { background: var(--ink); color: #fff; }
.button-primary:hover { background: #36363b; }
.button-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.button-secondary:hover { border-color: #76767d; }
.button-link { flex-basis: 100%; justify-self: start; width: max-content; text-align: left; padding-inline: 2px; color: var(--muted); background: transparent; }
.button-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.result-actions .feedback { flex-basis: 100%; margin: 0; }

@media (max-width: 690px) {
  .site-header, .studio { width: calc(100% - 36px); }
  .site-header { min-height: 58px; }
  .studio { min-height: calc(100svh - 58px); padding: 24px 0 44px; }
  .upload-card { margin-top: 22px; border-radius: 20px; }
  .result-view {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "heading" "preview" "actions";
    row-gap: 14px;
    width: min(100%, 420px);
    margin-inline: auto;
    text-align: center;
  }
  .result-heading p { margin-top: 7px; }
  .board-preview { padding: 14px; border-radius: 20px; }
  .board-art { width: min(100%, 260px, max(150px, calc(51svh * .5625))); }
  .result-actions { justify-content: center; }
  .button { padding-inline: 14px; }
  .button-link { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .upload-card, progress::-webkit-progress-value { transition: none; }
}
