:root {
  color-scheme: light;
  --ink: #303d51;
  --muted: #626e80;
  --line: #e3e7ee;
  --blue: #526fa8;
  --soft: #edf1f9;
  font-family: 'Zen Maru Gothic', 'Yu Gothic', Meiryo, sans-serif;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 20px; }
body { max-width: 556px; min-height: 100vh; margin: 0 auto; background: #fff; font-size: 15px; line-height: 1.7; }
h1, h2, h3, p { margin: 0; }
button, textarea { font: inherit; }
button { cursor: pointer; }
button, a, input { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-underline-offset: 4px; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, a:focus-visible, textarea:focus-visible, summary:focus-visible, select:focus-visible { outline: 3px solid #607fb8; outline-offset: 4px; }
[hidden] { display: none !important; }
svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.skip-link { position: absolute; left: 12px; top: -100px; padding: 10px 16px; background: #fff; z-index: 2; }
.skip-link:focus { top: 10px; }

/* One mobile layout at every screen width. */
.page { padding: 0 20px 24px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.mascot-greeting { display: flex; align-items: center; justify-content: flex-start; gap: 16px; padding: 20px 0 24px; }
.greeting-mascot { display: block; width: 64px; height: auto; flex: none; }
.greeting-bubble { position: relative; display: flex; align-items: center; gap: 5px; padding: 12px 16px; border: 1px solid #e8d797; border-radius: 10px; background: #fff2b8; font-size: 16px; font-weight: 700; }
.greeting-bubble::before { content: ''; position: absolute; left: -7px; top: calc(50% - 6px); width: 12px; height: 12px; border-left: 1px solid #e8d797; border-bottom: 1px solid #e8d797; background: #fff2b8; transform: rotate(45deg); }
.greeting-cup { display: block; width: auto; height: 24px; flex: none; object-fit: contain; transform: translateY(-2px); }
.greeting-bubble > span { white-space: nowrap; }
.logo-carrot { display: block; width: auto; height: 48px; flex: none; object-fit: contain; }
.greeting-soil { display: block; width: auto; height: 48px; margin-left: auto; flex: none; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; }
.input-panel, .preview-panel { min-width: 0; }
.field-title { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.step-number { color: var(--blue); background: var(--soft); border-radius: 50%; width: 25px; height: 25px; display: inline-grid; place-items: center; flex: none; font-size: 12px; font-weight: 700; line-height: 1; }
.preset-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.preset-actions .button { min-width: 0; min-height: 44px; font-size: 14px; }
.preset-icon { display: block; width: auto; height: 28px; flex: none; object-fit: contain; }
textarea { width: 100%; display: block; min-height: 116px; max-height: 400px; resize: vertical; padding: 12px 14px; border: 1px solid #b9c3d1; border-radius: 12px; background: #fff; color: var(--ink); font-size: 16px; line-height: 1.8; }
textarea::placeholder { color: var(--muted); }
textarea[aria-invalid=true] { border-color: #aa535b; }
.input-meta { display: flex; gap: 8px; justify-content: space-between; margin-top: 7px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
#counter { white-space: nowrap; }
.input-error { color: #a53d4a; font-size: 13px; margin-top: 6px; }
.input-error:empty { display: none; }
.background-field { border: 0; margin: 24px 0 0; padding: 0; min-width: 0; }
.background-field legend { padding: 0; }
.background-categories { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 14px; }
.background-category { min-width: 0; min-height: 44px; padding: 8px 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); font-size: 14px; font-weight: 700; }
.background-category[aria-pressed=true] { border-color: var(--blue); background: var(--blue); color: #fff; }
.background-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.more-backgrounds { width: 100%; margin-top: 14px; }
.background-choice { position: relative; cursor: pointer; min-width: 0; }
.background-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.background-card { display: block; position: relative; border: 2px solid var(--line); border-radius: 10px; padding: 4px 4px 7px; text-align: center; font-size: 12px; color: var(--muted); transition: border-color .15s, background .15s; }
.background-card canvas { display: block; width: 100%; height: auto; aspect-ratio: 2; border-radius: 5px; margin-bottom: 6px; background: #fff; }
.selected-mark { display: none; position: absolute; top: -7px; right: -3px; width: 20px; height: 20px; line-height: 20px; border-radius: 50%; color: #fff; background: var(--blue); font-size: 12px; }
.background-choice input:checked + .background-card { border-color: var(--blue); background: var(--soft); color: #3b568b; }
.background-choice input:checked + .background-card .selected-mark { display: block; }
.background-choice input:focus-visible + .background-card { outline: 3px solid #607fb8; outline-offset: 4px; }

/* X-like frame is display-only; the PNG is 1032 x 516. */
.preview-mat { background: #fff; border-radius: 16px; min-width: 0; position: relative; overflow: hidden; }
.preview-mat::after { content: ''; position: absolute; inset: 0; border: 1px solid #cfd9de; border-radius: inherit; pointer-events: none; }
.preview-mat img { display: block; width: 100%; max-width: 516px; height: auto; aspect-ratio: 2; }
.preview-placeholder { aspect-ratio: 2; display: grid; place-items: center; font-size: 14px; color: var(--muted); text-align: center; }
.output-actions { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 10px; margin: 16px 0 10px; }
.preview-mat[aria-busy=true] + .save-panel .output-actions button:disabled { opacity: 1; }
.button { border: 1px solid var(--blue); border-radius: 12px; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; font-size: 15px; font-weight: 700; transition: background .15s; }
.primary { background: var(--blue); color: #fff; }
.secondary { background: #fff; color: var(--ink); border-color: #b9c3d1; }
.download-label { word-break: keep-all; }
.output-help { font-size: 13px; color: var(--muted); text-align: center; }
.status { font-size: 13px; line-height: 1.7; text-align: center; color: var(--blue); overflow-wrap: anywhere; }
.status:not(:empty) { margin-top: 10px; }
.status[data-kind="copy-success"]:not(:empty),
.status[data-kind="download-start"]:not(:empty) { padding: 10px 14px; border-radius: 10px; background: #fff5cc; font-size: 14px; font-weight: 700; }
.status[data-error=true] { color: #a53d4a; }
.recovery { display: flex; justify-content: center; gap: 8px 16px; flex-wrap: wrap; margin-top: 8px; }
.text-button { border: 0; background: transparent; text-decoration: underline; text-underline-offset: 4px; color: var(--blue); font-size: 13px; min-height: 44px; padding: 6px; }
.notice { background: #fff0e9; padding: 14px; margin-bottom: 20px; }

.stamp-panel { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; }
.stamp-panel summary { min-height: 44px; padding: 10px 14px; cursor: pointer; color: var(--ink); font-size: 14px; font-weight: 700; }
.stamp-panel summary::marker { color: var(--blue); }
.stamp-content { padding: 0 12px 12px; }
.stamp-help { margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.stamp-series-picker { display: grid; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.stamp-series-picker select { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: inherit; }
.stamp-series-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.stamp-series-title { color: var(--ink); font-size: 13px; font-weight: 700; }
.stamp-status[data-reserve=true] { min-height: 44px; margin-top: 10px; }
.stamp-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stamp-button { display: block; min-width: 0; min-height: 44px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.stamp-button img { display: block; width: 100%; height: auto; aspect-ratio: 2; border-radius: 6px; }
.stamp-button[data-copied=true] { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }

.steps { padding: 0; margin: 0; list-style: none; display: grid; gap: 20px; }
.steps li { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.credits-panel { margin: 0 20px 20px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-size: 13px; }
.credits-panel summary { min-height: 44px; padding: 10px 14px; cursor: pointer; font-weight: 700; }
.credits-panel summary::marker { color: var(--blue); }
.credits-content { padding: 0 14px 14px; }
.credits-list { display: grid; gap: 12px; margin: 0; }
.credits-list dt { font-weight: 700; }
.credits-list dd { margin: 2px 0 0; }
.credits-content a { color: var(--blue); text-underline-offset: 3px; }
.credits-thanks { margin-top: 12px; }
.site-footer { margin: 0 20px; border-top: 1px solid var(--line); padding: 20px 0 28px; display: flex; justify-content: center; align-items: center; font-size: 12px; color: var(--muted); }
.site-footer a { padding: 8px 0; text-decoration: none; }

.desktop-side { display: block; padding: 20px; }
.desktop-side--left .side-content,
.side-guide { padding: 24px 20px; background: #fff; border-radius: 20px; }
.desktop-side--left .side-content { text-align: center; }
.side-logo { display: inline-flex; align-items: center; gap: 6px; padding: 8px 0; font-size: 28px; font-weight: 700; letter-spacing: .04em; }
.side-description { margin-top: 14px; font-size: 15px; line-height: 1.9; text-align: left; }
.side-description-full { display: none; }
.keep-together { white-space: nowrap; }
.side-guide { text-align: left; border: 1px solid var(--line); }
.side-guide h2 { margin-bottom: 18px; font-size: 15px; }

@media (max-width: 399.98px) {
  .mascot-greeting { gap: 10px; }
}
@media (max-width: 359.98px) {
  .page { padding: 0 16px 24px; }
  .desktop-side { padding-inline: 16px; }
  .mascot-greeting { gap: 8px; }
  .greeting-mascot { width: 48px; }
  .greeting-bubble { padding: 10px 8px; font-size: 14px; }
  .background-list { gap: 6px; }
  .background-card { font-size: 11px; }
  .site-footer { margin-inline: 16px; }
  .credits-panel { margin-inline: 16px; }
}
@media (min-width: 640px) {
  :root { background: #f4f6f9; }
  body { border-inline: 1px solid var(--line); max-width: 558px; }
}
@media (min-width: 1280px) {
  .desktop-side {
    display: flex;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: calc((100% - 558px) / 2);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    padding: 16px 24px;
    justify-content: center;
    text-align: center;
  }
  .desktop-side--left { left: 0; }
  .desktop-side--left .side-content { border: 1px solid var(--line); }
  .desktop-side--right { right: 0; }
  .side-content { width: 100%; max-width: 300px; }
  .side-logo { font-size: 30px; }
  .side-description { margin-top: 22px; font-size: 16px; line-height: 2; text-align: left; }
  .side-description-full { display: inline; }
  .side-description-short { display: none; }
}
@media (hover: hover) {
  .primary:hover:not(:disabled) { background: #435f97; }
  .secondary:hover:not(:disabled) { background: #f4f6fa; }
  .background-choice:hover .background-card { border-color: #8da3c9; }
  .stamp-button:hover:not(:disabled):not([data-copied=true]) { border-color: #8da3c9; background: var(--soft); }
  .site-footer a:hover { text-decoration: underline; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
