/* QR Maker — 흑백(QR의 재료)을 기본으로, 초록은 '선택됨/정상' 표시에만 */
:root {
  --paper: #ffffff;
  --mist: #f3f4f2;
  --line: #e2e4e0;
  --ink: #15171a;
  --muted: #61666d;
  --go: #0e9f6e;
  --bad: #c0392b;
  --on-ink: #ffffff;
  --radius-lg: 20px;
  --radius: 12px;
  --radius-sm: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111315; --mist: #1b1e21; --line: #2d3136; --ink: #eef0f2; --muted: #9aa0a8;
    --go: #34c38f; --bad: #ff7b6b; --on-ink: #111315; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Hiragino Sans", "Noto Sans JP", sans-serif;
}
button, select, input { font: inherit; color: inherit; }
:lang(ko) body, body:lang(ko) { word-break: keep-all; overflow-wrap: anywhere; }   /* 한국어는 낱말 중간에서 줄바꿈하지 않음 */
a { color: inherit; }
:lang(ja) h1, :lang(ja) .sub { word-break: auto-phrase; }   /* 일본어 문절 단위 줄바꿈 (지원 브라우저) */
:focus-visible { outline: 2px solid var(--go); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- 머리 ---------- */
.top { max-width: 1120px; margin: 0 auto; padding: 18px 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 18px; letter-spacing: -0.01em; text-decoration: none; }
.top-right { display: flex; gap: 6px; align-items: center; }
.top select { border: 0; background: transparent; padding: 6px 4px; color: var(--muted); cursor: pointer; }
.quiet { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 7px 14px; font-size: 14px; cursor: pointer; }
.quiet:hover { border-color: var(--ink); }

/* ---------- 배치: 왼쪽(첫 화면+설정) / 오른쪽(미리보기 고정) ---------- */
.layout {
  max-width: 1120px; margin: 0 auto; padding: 24px 24px 0;
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; column-gap: 64px;
  grid-template-areas: "hero preview" "options preview";
  align-items: start;
}
.hero { grid-area: hero; padding-top: 24px; }
.options { grid-area: options; }
.preview { grid-area: preview; position: sticky; top: 20px; }

/* ---------- 첫 화면 ---------- */
h1 {
  font-size: clamp(34px, 5vw, 54px); line-height: 1.08; letter-spacing: -0.035em; font-weight: 800;
  margin: 0 0 16px; max-width: 13em; text-wrap: balance;
}
.sub { font-size: 18px; color: var(--muted); margin: 0 0 32px; max-width: 34em; }
.url-box {
  display: flex; align-items: center; gap: 6px; padding: 6px;
  border: 2px solid var(--ink); border-radius: 16px; background: var(--paper);
}
.url-box:focus-within { box-shadow: 0 0 0 4px color-mix(in srgb, var(--go) 25%, transparent); }
.url-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 18px; padding: 12px 12px; }
.url-btn { border: 0; background: var(--mist); border-radius: 11px; padding: 12px 16px; font-weight: 650; font-size: 15px; cursor: pointer; white-space: nowrap; }
.url-btn:hover { background: var(--line); }
.url-btn:disabled { opacity: .6; cursor: default; }
.url-meta { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.msg { margin: 12px 0 0; font-size: 15px; font-weight: 600; }
.msg.ok { color: var(--go); } .msg.bad { color: var(--bad); }
.text-btn { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }
.note { color: var(--muted); font-size: 13px; margin: 10px 0 0; max-width: 40em; }
.note:empty { display: none; }

.icon-group { margin-top: 28px; }

/* ---------- 설정 ---------- */
.options { padding: 40px 0 24px; }
.group { padding: 28px 0; border-top: 1px solid var(--line); }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 14px; letter-spacing: -0.01em; }
h3 { font-size: 14px; color: var(--muted); font-weight: 600; margin: 20px 0 8px; }
h3:first-child { margin-top: 4px; }

.icon-row { display: flex; gap: 8px; flex-wrap: wrap; }
select { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 11px 12px; cursor: pointer; }
.icon-row select { flex: 1; min-width: 200px; }
.seg { display: inline-flex; padding: 3px; background: var(--mist); border-radius: var(--radius); }
.seg button { border: 0; background: transparent; padding: 8px 16px; border-radius: 9px; cursor: pointer; font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--paper); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 650; }

/* 스타일 묶음: 내 링크로 그린 QR 견본 */
.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.preset { border: 0; background: none; padding: 0; cursor: pointer; text-align: center; }
.preset .thumb { display: block; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #fff; transition: transform .12s; }
.preset .thumb svg { display: block; width: 100%; height: 100%; }
.preset .name { display: block; font-size: 14px; margin-top: 6px; color: var(--muted); }
.preset:hover .thumb { transform: translateY(-2px); }
.preset[aria-pressed="true"] .thumb { border-color: var(--go); box-shadow: 0 0 0 2px var(--go); }
.preset[aria-pressed="true"] .name { color: var(--ink); font-weight: 650; }

/* 접는 칸 */
.fold summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after { content: "+"; font-size: 22px; font-weight: 400; color: var(--muted); line-height: 1; }
.fold[open] summary::after { content: "−"; }
.fold-body { padding-top: 8px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); cursor: pointer; font-size: 14px; }
.chip svg { border-radius: 6px; display: block; }
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--go); box-shadow: 0 0 0 1px var(--go) inset; font-weight: 650; }

.colors { display: flex; gap: 20px; flex-wrap: wrap; }
.colors label { display: flex; align-items: center; gap: 8px; font-size: 15px; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); cursor: pointer; }
input[type=color]:disabled { opacity: .35; cursor: default; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.field { display: grid; gap: 6px; margin-top: 14px; font-size: 15px; max-width: 320px; }

/* ---------- 미리보기 ---------- */
.panel { background: var(--mist); border-radius: var(--radius-lg); padding: 20px; }
.qr { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: #fff; display: grid; place-items: center; }
.qr svg { display: block; width: 100%; height: 100%; }
.qr.is-empty svg { opacity: .12; }
.qr .empty { position: absolute; inset: auto 16px; margin: 0; padding: 10px 14px; text-align: center; background: rgba(255,255,255,.92); color: #3d4248; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; }
.grid { text-align: center; color: var(--muted); font-size: 14px; margin: 12px 0 0; min-height: 1.5em; }
.warns { color: var(--bad); font-size: 14px; padding-left: 18px; margin: 8px 0 0; }
.warns:empty { display: none; }
.btn-main { display: block; width: 100%; margin-top: 14px; border: 0; border-radius: var(--radius); padding: 15px; background: var(--ink); color: var(--on-ink); font-weight: 700; font-size: 16px; cursor: pointer; text-align: center; text-decoration: none; }
.btn-main:hover:not(:disabled) { opacity: .88; }
.btn-row { display: flex; gap: 8px; margin-top: 8px; }
.btn-sub { flex: 1; border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius); padding: 11px 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.btn-sub:hover:not(:disabled) { border-color: var(--ink); }
button:disabled { opacity: .4; cursor: default; }

/* 후원 넛지: 저장 직후 미리보기 아래에 조용히 등장 */
.nudge { margin-top: 14px; padding: 14px 16px; background: var(--paper); border-radius: var(--radius); border: 1px solid var(--line); animation: nudge-in .25s ease-out; }
.nudge-title { margin: 0; font-weight: 700; font-size: 15px; }
.nudge-body { margin: 4px 0 10px; font-size: 14px; color: var(--muted); }
.nudge-actions { display: flex; align-items: center; gap: 14px; }
.btn-coffee { border: 0; border-radius: 999px; padding: 9px 16px; background: #ffdd57; color: #1b1b1b; font-weight: 700; font-size: 14px; cursor: pointer; }
.btn-coffee:hover { background: #ffd333; }
@keyframes nudge-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .nudge { animation: none; } }

/* ---------- 광고 자리 ---------- */
.ad { margin-top: 20px; }
.ad:empty { display: none; }
.ad-wide { max-width: 1120px; margin: 32px auto 0; padding: 0 24px; }
.ad-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.ad-ph { border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; padding: 32px 8px; font-size: 13px; }
.small { font-size: 13px; color: var(--muted); }

/* ---------- 안내글 (검색엔진용 페이지에서 생성) ---------- */
.guide { max-width: 1120px; margin: 48px auto 0; padding: 8px 24px 0; }
.guide > * { max-width: 46em; }
.guide h2 { font-size: 22px; letter-spacing: -0.02em; margin: 40px 0 12px; }
.guide h2:first-child { margin-top: 0; }
.guide .lead { font-size: 18px; margin: 0 0 8px; }
.guide ol, .guide ul { padding-left: 1.3em; margin: 0; }
.guide li { margin: 6px 0; }
.guide code { font-size: .92em; background: var(--mist); padding: 1px 6px; border-radius: 5px; }
.guide details { border-top: 1px solid var(--line); padding: 14px 0; }
.guide details:last-of-type { border-bottom: 1px solid var(--line); }
.guide summary { cursor: pointer; font-weight: 650; }
.guide details p { margin: 8px 0 0; color: var(--muted); }

/* ---------- 바닥 ---------- */
footer { max-width: 1120px; margin: 48px auto 0; padding: 28px 24px 48px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
footer p { margin: 4px 0; max-width: 70em; }
footer a { text-decoration: underline; }
.sep::before { content: ""; display: inline-block; width: 1px; height: .9em; background: var(--line); margin: 0 10px; vertical-align: -1px; }

dialog { border: 0; border-radius: var(--radius-lg); background: var(--paper); color: var(--ink); max-width: 380px; width: calc(100% - 32px); padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { font-size: 20px; }
.donate-links { display: grid; gap: 8px; margin: 16px 0; }
.donate-links .btn-main { margin: 0; }
.donate-links .is-placeholder { opacity: .45; cursor: default; }
dialog form { display: flex; justify-content: flex-end; }
dialog form .btn-sub { flex: 0 0 auto; padding: 10px 18px; }

@media (prefers-reduced-motion: reduce) { .preset .thumb { transition: none; } .preset:hover .thumb { transform: none; } }

/* ---------- 태블릿·휴대폰: 링크 → 미리보기 → 설정 ---------- */
@media (max-width: 880px) {
  .top { padding: 14px 16px; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hero" "preview" "options"; padding: 8px 16px 0; }
  .hero { padding-top: 8px; }
  h1 { font-size: 32px; }
  .sub { font-size: 16px; margin-bottom: 20px; }
  .preview { position: static; margin-top: 24px; width: 100%; max-width: 420px; justify-self: center; }
  .qr { max-width: 320px; margin: 0 auto; }
  .options { padding-top: 24px; }
  .ad-wide { padding: 0 16px; }
  .guide { padding: 8px 16px 0; }
  footer { padding: 24px 16px 40px; }
}
@media (max-width: 480px) {
  .url-box { flex-wrap: wrap; }
  .url-box input { flex-basis: 100%; }
  .url-btn { flex: 1; }
  .presets { gap: 8px; }
  .preset .name { font-size: 12.5px; }
}
