/* Shared styles for both tool pages. Layout: one centered column; step 1 = form, step 2 = preview + sticky save bar */
:root {
  --bg: #f6f8fb; --surface: #ffffff; --ink: #23283a; --muted: #5d6478; --line: #d9e2ec;
  --pink: #de3462; --pink-soft: #fdeef2; --orange: #f2692a; --sky: #e5f0f8; --focus: #2f78cf;
  --oi: #2f86d6; --oi-soft: #eaf5fd; --oi-line: #b7dbf5;
  --f-display: "Zen Maru Gothic", "Noto Sans JP", "Hiragino Maru Gothic ProN", sans-serif;
  --f-body: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161a24; --surface: #1f2431; --ink: #eef1f7; --muted: #a6aec2; --line: #333b4d;
    --pink: #ff6f95; --pink-soft: #3a2230; --orange: #ff8a52; --sky: #1c2a3a; --focus: #78b0ff;
    --oi: #78b8f0; --oi-soft: #1b2b3d; --oi-line: #2f4a66; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.7;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px 48px;
}
.wrap { max-width: 1180px; margin: 0 auto; display: grid; gap: 24px; }
header { display: grid; gap: 4px; }
h1 { font-family: var(--f-display); font-weight: 900; font-size: clamp(24px, 4vw, 34px); line-height: 1.3; margin: 0; text-wrap: balance; }
h1 .accent { color: var(--pink); }
.nw { white-space: nowrap; }
.back { font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none; justify-self: start; }
.back:hover { color: var(--pink); }
.lead { margin: 0; color: var(--muted); max-width: 62ch; }
.main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; max-width: 680px; width: 100%; margin: 0 auto; }
@media (max-width: 860px) { .main { grid-template-columns: minmax(0, 1fr); } }
form { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
label, .label { font-weight: 700; font-size: 14px; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.err { font-size: 13px; color: var(--pink); font-weight: 700; margin: 0; }
input[type=text] { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; width: 100%; }
input:focus-visible, button:focus-visible, a:focus-visible, .drop:focus-within, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.drop { display: flex; gap: 12px; align-items: center; border: 1.5px dashed var(--line); border-radius: 10px; padding: 10px; cursor: pointer; background: var(--bg); position: relative; }
.drop.over { border-color: var(--pink); background: var(--pink-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.thumb { width: 56px; height: 80px; border-radius: 3px; background: var(--sky); object-fit: cover; }
.drop-text { font-size: 13.5px; min-width: 0; overflow-wrap: anywhere; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode { display: grid; gap: 6px; padding: 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); text-align: center; font-size: 13.5px; }
.mode img { width: 100%; height: 92px; object-fit: contain; border-radius: 6px; background: #f3f6fa; }
.mode[aria-pressed="true"] { border-color: var(--pink); background: var(--pink-soft); color: var(--ink); }
.mode[aria-pressed="true"] .mode-label::before { content: "✓ "; color: var(--pink); }
.checks { display: grid; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--pink); flex: none; }
.check.oi input { accent-color: var(--oi); }
.badge { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--pink); color: #fff; font-size: 11px; font-weight: 900; flex: none; }
.oi-logo { height: 20px; width: auto; display: block; }
.promo { border: 1.5px solid var(--oi-line); background: var(--oi-soft); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: start; }
.promo img.m { width: 64px; height: auto; }
.promo .t { display: grid; gap: 6px; min-width: 0; font-size: 13px; line-height: 1.6; }
.promo .kicker { font-size: 11.5px; font-weight: 700; color: var(--oi); letter-spacing: .04em; }
.promo strong { font-size: 14.5px; line-height: 1.45; }
.promo .pill { display: inline-block; font-size: 11px; font-weight: 700; color: var(--pink); border: 1px solid var(--pink); border-radius: 999px; padding: 0 8px; }
.promo ul { margin: 0; padding-left: 1.1em; color: var(--muted); }
.promo a.cta { display: inline-flex; align-items: center; gap: 6px; background: var(--oi); color: #fff; font-weight: 700; text-decoration: none; border-radius: 999px; padding: 6px 14px; font-size: 13px; justify-self: start; }
.promo .mail { font-size: 12px; color: var(--muted); user-select: all; }
.promo.on { border-color: var(--oi); }
.promo .thanks { font-weight: 700; color: var(--oi); }
button { font: inherit; font-weight: 700; border-radius: 10px; padding: 11px 16px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
button.primary { background: var(--pink); border-color: var(--pink); color: #fff; width: 100%; font-size: 16px; }
button.small { padding: 6px 12px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.status { font-size: 13px; color: var(--muted); min-height: 1.4em; margin: 0; }
.howto { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.howto summary { cursor: pointer; font-weight: 700; color: var(--ink); font-size: 13px; }
.howto ol { margin: 8px 0 0; padding-left: 1.3em; display: grid; gap: 4px; }
.howto b { color: var(--ink); }
.howto.inapp { border-color: var(--orange); background: var(--pink-soft); }
.inapp-msg { margin: 6px 0 0; color: var(--ink); font-weight: 700; }
.preview { display: grid; gap: 10px; min-width: 0; }
@media (max-width: 860px) { .preview { position: static; } }
.preview-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.preview-head h2 { margin: 0; font-family: var(--f-display); font-size: 18px; }
.preview-head p { margin: 0; font-size: 12.5px; color: var(--muted); }
canvas, #out { width: 100%; max-width: 640px; height: auto; border-radius: 10px; border: 1px solid var(--line); display: block; background: var(--sky); }
.fallback { background: var(--sky); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; display: grid; gap: 8px; max-width: 640px; }
.note { font-size: 12.5px; color: var(--muted); margin: 0; max-width: 640px; }
@media (prefers-reduced-motion: no-preference) { button, a.cta { transition: filter .15s; } button:hover:not(:disabled), a.cta:hover { filter: brightness(1.06); } }

/* two-step flow: input -> preview & save */
body[data-step="input"] .preview { display: none; }
body[data-step="preview"] form { display: none; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; max-width: 680px; width: 100%; margin-inline: auto; }
.steps li { flex: 1; text-align: center; font-size: 13px; font-weight: 700; padding: 7px 0; border-radius: 999px; background: var(--sky); color: var(--muted); }
.steps li.on { background: var(--pink); color: #fff; }
.actions { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.dock { position: sticky; bottom: 0; z-index: 2; display: grid; gap: 8px; max-width: 640px; background: var(--bg); padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -10px 16px -12px rgba(30, 40, 60, .25); }
.dock .status:empty { display: none; }
body[data-step="preview"] .lead { display: none; }
.actions .back-btn { background: var(--surface); }
.unused-redirect { background: var(--sky); border-radius: 10px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; max-width: 640px; }
.redirect p { margin: 0; font-weight: 700; }
.foot { max-width: 680px; width: 100%; margin: 8px auto 0; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12.5px; color: var(--muted); display: grid; gap: 2px; }
.foot p { margin: 0; }

.restored { margin: 0; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--sky); border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 700; }
.restored button { padding: 4px 10px; font-size: 12.5px; }
.ios-hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.next-panel { background: var(--surface); border: 2px solid var(--pink); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; }
.next-panel h3 { margin: 0; font-size: 16px; font-family: var(--f-display); }
.next-panel p { margin: 0; font-size: 13.5px; }
.next-panel .np-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.next-panel a.np-other { display: inline-flex; align-items: center; background: var(--pink); color: #fff; font-weight: 900; text-decoration: none; border-radius: 10px; padding: 10px 14px; font-size: 14.5px; }
.next-panel a.np-top { display: inline-flex; align-items: center; border: 1px solid var(--line); color: var(--ink); background: var(--surface); font-weight: 700; text-decoration: none; border-radius: 10px; padding: 10px 14px; font-size: 14.5px; }
.next-panel .np-count { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.next-panel .np-count button { padding: 3px 10px; font-size: 12.5px; }
a.cta:focus-visible, .next-panel a:focus-visible, .back:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.post { display: grid; gap: 6px; border-top: 1px dashed var(--line); padding-top: 8px; }
.post label { font-size: 13px; }
.post textarea { font: inherit; font-size: 13px; line-height: 1.6; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; resize: vertical; min-height: 7.5em; }
.post .post-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.post .post-actions button { padding: 8px 14px; font-size: 14px; }
.post a.post-x { display: inline-flex; align-items: center; gap: 6px; background: #111; color: #fff; font-weight: 700; text-decoration: none; border-radius: 10px; padding: 8px 14px; font-size: 14px; }
.post .hint { margin: 0; }
.dock { max-height: 78vh; overflow-y: auto; }
.foot .contact a { color: inherit; font-weight: 700; }
