@font-face {
  font-family: "Comic Neue";
  src: url("assets/comic-neue-700.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #fffdf5;
  --ink: #16203b;
  --muted: #596076;
  --sun: #ffdc58;
  --blue: #5367ff;
  --blue-deep: #4052d9;
  --pink: #ff5a8a;
  --green: #b9ed73;
  --line: #16203b;
  --comic: "Comic Neue", "Comic Sans MS", "Chalkboard SE", cursive;
  --body: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow: 5px 6px 0 var(--ink);
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--body);
  min-width: 320px;
  overflow: auto;
}
button, input { font: inherit; }
button, label[for] { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.noscript-message {
  margin: 0;
  padding: 14px 20px;
  border-bottom: 2px solid var(--ink);
  background: var(--sun);
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
  min-height: 100vh;
}
.workspace > * { min-width: 0; }
.preview-zone {
  position: sticky;
  top: 0;
  align-self: start;
  --frame-width: min(100%, calc(100vh - 260px), 680px);
  height: 100vh;
  padding: clamp(22px, 3vw, 46px);
  background: var(--blue-deep);
  color: white;
  border-right: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}
.preview-heading {
  width: var(--frame-width);
  margin: 0 auto 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
}
.kicker {
  margin: 0 0 10px;
  font-family: var(--comic);
  font-size: 1rem;
  font-weight: 700;
}
h1 {
  max-width: 16ch;
  margin: 0;
  font-family: var(--comic);
  font-weight: 700;
  font-size: clamp(2.2rem, 3.5vw, 3.65rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
  text-wrap: balance;
}
.scribble {
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  display: grid;
  place-content: center;
  text-align: center;
  background: var(--sun);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 47% 53% 50% 45%;
  transform: rotate(7deg);
  font-family: var(--comic);
  font-weight: 700;
  line-height: 0.95;
  box-shadow: 4px 4px 0 var(--ink);
}
.canvas-shell {
  position: relative;
  width: var(--frame-width);
  margin: 0 auto;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border: 3px solid var(--ink);
  background: white;
  box-shadow: 10px 12px 0 var(--ink);
  overflow: hidden;
  cursor: pointer;
  touch-action: auto;
}
.canvas-shell.has-photo {
  cursor: grab;
  touch-action: pan-y pinch-zoom;
}
.canvas-shell:focus-visible {
  outline: 4px solid var(--sun);
  outline-offset: 5px;
}
.canvas-shell.has-photo:active { cursor: grabbing; }
.canvas-shell.is-dragging .drag-hint { opacity: 1; transform: translate(-50%, 0); }
.canvas-shell:not(.has-photo) .drag-hint {
  opacity: 1;
  transform: translate(-50%, 0);
}
canvas { display: block; width: 100%; height: 100%; }
.drag-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translate(-50%, 8px);
  background: var(--ink);
  color: white;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 750;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}
.preview-note {
  width: var(--frame-width);
  margin: 12px auto 0;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 650;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.controls {
  min-width: 0;
  min-height: 100vh;
  padding: clamp(22px, 3vw, 38px) clamp(24px, 4vw, 54px);
  background: var(--paper);
}
.control-group {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 2px solid var(--line);
}
.upload-group { margin-top: 0; padding-top: 0; border-top: 0; }
.group-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 10px;
}
.group-heading h2 {
  margin: 0;
  font-family: var(--comic);
  font-size: 1.25rem;
  line-height: 1.15;
}
.group-heading span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}
.upload-button {
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  border: 2px dashed var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: white;
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease-out, transform 160ms ease-out;
}
.upload-button:hover { background: #eef0ff; transform: translateY(-2px); }
.upload-button span { font-size: 1.4rem; line-height: 1; }
.zoom-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.82rem;
  font-weight: 750;
}
input[type="range"] { width: 100%; accent-color: var(--blue); }
input[type="range"]:disabled { opacity: 0.35; }
.text-button {
  padding: 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
}
.text-button:disabled { opacity: 0.35; cursor: not-allowed; }
.photo-actions {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.crop-hint { margin-top: 6px; }
.remove-photo {
  border-bottom: 0;
  flex: 0 0 auto;
  min-height: 32px;
  padding-block: 6px;
  color: var(--ink);
  font-weight: 700;
}
.field-error { margin: 8px 0 0; color: #b4233b; font-size: 0.8rem; font-weight: 750; }
.preset-list {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 7px;
}
.preset-button {
  min-height: 34px;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px 850px 999px 900px;
  background: white;
  font-family: var(--comic);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease-out, transform 140ms ease-out, box-shadow 140ms ease-out;
}
.preset-button:hover { background: var(--green); transform: rotate(-1deg) translateY(-1px); }
.preset-button[aria-pressed="true"] {
  background: var(--sun);
  box-shadow: 3px 3px 0 var(--ink);
  transform: translate(-2px, -2px) rotate(1deg);
}
.custom-label { display: block; margin: 12px 0 6px; font-size: 0.76rem; font-weight: 800; }
.custom-field { position: relative; }
.custom-field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 68px 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: white;
  color: var(--ink);
  font-family: var(--comic);
  font-size: 1rem;
  font-weight: 700;
}
.custom-field input[aria-invalid="true"] {
  border-color: #b4233b;
}
.custom-field span {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
}
.field-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}
.font-label {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.78rem;
  font-weight: 800;
}
#fontSelect {
  width: 100%;
  min-height: 42px;
  padding: 8px 38px 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: white;
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}

.color-options { display: flex; flex-wrap: wrap; gap: 9px; }
.color-swatch {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  transition: transform 140ms ease-out, box-shadow 140ms ease-out;
}
.color-swatch:hover { transform: translateY(-2px); }
.color-swatch[aria-pressed="true"] { box-shadow: 3px 4px 0 var(--ink); transform: translate(-2px, -2px); }
.color-picker { display: inline-flex; align-items: center; gap: 9px; margin-top: 10px; font-size: 0.75rem; font-weight: 800; cursor: pointer; }
.color-picker input { width: 34px; height: 26px; padding: 0; border: 1px solid var(--ink); background: white; }
.download-button {
  width: 100%;
  min-height: 56px;
  margin-top: 24px;
  padding: 12px 18px;
  border: 2px solid var(--ink);
  background: var(--sun);
  font-family: var(--comic);
  font-size: 1.08rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 160ms ease-out, box-shadow 160ms ease-out, background 160ms ease-out;
}
.download-button:hover { background: var(--green); transform: translate(-2px, -2px); box-shadow: 7px 8px 0 var(--ink); }
.download-button:disabled,
.download-button:disabled:hover,
.download-button:disabled:active {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--sun);
  transform: none;
  box-shadow: none;
}
.download-button:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.download-button span:last-child { font-family: var(--body); font-size: 1.5rem; }
.download-detail { margin: 8px 0 0; color: var(--muted); text-align: center; font-size: 0.72rem; }
.status-message { min-height: 1.2em; margin: 6px 0 0; text-align: center; font-size: 0.76rem; font-weight: 750; color: #167343; }

.random-button {
  min-height: 44px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: #3447cf;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: color 140ms ease-out, transform 140ms ease-out;
}
.random-button:hover { color: var(--ink); transform: rotate(-1deg); }
.download-button.is-success {
  background: var(--green);
  box-shadow: 3px 4px 0 var(--ink);
  transform: translate(2px, 2px);
}

button:focus-visible, input:focus-visible, label[for]:focus-within, .canvas-shell:focus-visible, a:focus-visible {
  outline: 3px solid white;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--blue);
}


.seo-content {
  padding: clamp(64px, 8vw, 112px) max(24px, calc((100vw - 1120px) / 2));
  border-top: 2px solid var(--ink);
  background: var(--paper);
}
.seo-content__intro {
  max-width: 760px;
  margin-bottom: clamp(40px, 6vw, 72px);
}
.seo-content h2 {
  max-width: 16ch;
  margin: 8px 0 18px;
  font-family: var(--comic);
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}
.seo-content__intro > p:last-child {
  max-width: 68ch;
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.65;
}
.seo-content__columns {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: clamp(40px, 7vw, 88px);
  padding-top: 34px;
  border-top: 2px solid var(--ink);
}
.seo-content h3 {
  margin: 0 0 16px;
  font-family: var(--comic);
  font-size: 1.45rem;
}
.seo-content ol {
  margin: 0;
  padding-left: 1.5rem;
}
.seo-content li {
  padding-left: 8px;
  margin-bottom: 18px;
  line-height: 1.55;
}
.seo-content li::marker { color: var(--blue-deep); font-weight: 900; }
.seo-content__aside {
  padding-left: clamp(24px, 4vw, 48px);
  border-left: 2px solid var(--ink);
}
.seo-content__aside h3:not(:first-child) { margin-top: 34px; }
.seo-content__aside p { margin: 0; line-height: 1.6; }
.seo-content a, .site-footer a {
  color: #3447cf;
  font-weight: 800;
  text-underline-offset: 3px;
}
.site-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 28px;
  padding: 24px;
  border-top: 2px solid var(--ink);
  background: var(--blue-deep);
  color: #fff;
  font-size: 0.82rem;
}
.site-footer a { color: #fff; }
@media (max-width: 760px) {
  .seo-content__columns { grid-template-columns: 1fr; }
  .seo-content__aside {
    padding: 32px 0 0;
    border-top: 2px solid var(--ink);
    border-left: 0;
  }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .workspace { grid-template-columns: 1fr; height: auto; }
  .preview-zone { position: static; height: auto; min-height: 100svh; border-right: 0; border-bottom: 2px solid var(--line); }
  .controls { width: min(100%, 680px); height: auto; margin: 0 auto; overflow: visible; }
}
@media (max-width: 560px) {
  .preview-zone {
    --frame-width: min(100%, 52svh);
    min-height: auto;
    padding: max(18px, env(safe-area-inset-top)) 18px 22px;
  }
  .preview-heading { align-items: center; margin-bottom: 12px; }
  .kicker { margin-bottom: 6px; font-size: 0.88rem; }
  h1 { max-width: 13ch; font-size: clamp(2rem, 9.8vw, 2.75rem); line-height: 0.92; }
  h1 br { display: none; }
  .scribble { width: 58px; height: 58px; font-size: 0.75rem; }
  .canvas-shell { box-shadow: 7px 8px 0 var(--ink); }
  .remove-photo { min-height: 44px; padding-block: 12px; }
  .preview-note { font-size: 0.78rem; }
  .controls { padding: 22px 20px max(44px, env(safe-area-inset-bottom)); }
  .group-heading { align-items: center; }
  .group-heading h2 { max-width: 16ch; }
  .preset-list {
    width: calc(100% + 20px);
    margin-right: -20px;
    padding: 3px 20px 8px 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
    scrollbar-width: none;
  }
  .preset-list::-webkit-scrollbar { display: none; }
  .preset-button {
    flex: 0 0 auto;
    min-height: 44px;
    padding-inline: 13px;
    scroll-snap-align: start;
  }
  .color-swatch { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
