/* 무료 도장 만들기 — 화면 꾸밈 전체(설계서 9-4절).
   색은 홈페이지 색 체계(남색 글자 · 밝은 하늘 바탕 · 초록 강조)와 도장 카드의 인주 빨강을 쓴다.
   글꼴은 시스템 글꼴만 — 바깥 글꼴 서버 요청 0(설계서 9-7절). 도장 글꼴 7종은 캔버스에만 쓴다. */

:root {
  --paper: #EEF3FA;
  --card: #FFFFFF;
  --ink: #132135;
  --soft: #4A5D75;
  --hair: rgba(19, 33, 53, .12);
  --hair-strong: rgba(19, 33, 53, .28);
  --green: #0E6F52;
  --stamp: #C23A2E;          /* 홈페이지 도장 카드와 같은 색 — 흰 글자 대비 5.33 */
  --stamp-dark: #A32E23;
  --stamp-soft: rgba(194, 58, 46, .10);
  --warn: #8A5A00;
  --warn-bg: #FFF5DD;
  --error: #A1251B;
  --error-bg: #FDECEA;
  --info-bg: #EAF2FB;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', '맑은 고딕', 'Noto Sans KR', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--green); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.skip {
  position: absolute; left: 12px; top: -48px;
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 10px; z-index: 30;
}
.skip:focus { top: 10px; }

/* ---- 머리 ---- */
.top { max-width: 1120px; margin: 0 auto; padding: 16px 20px 6px; }
.top-in { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* 집 모양 단추 — 다른 무료 도구와 같은 모양(34px 둥근 네모 · D231 ①) */
.home-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 11px; color: var(--soft); background: var(--card); border: 1.5px solid var(--hair);
  transition: color .25s, border-color .25s, background .25s;
}
.home-btn:hover { color: #C98A1F; border-color: #F5B841; background: #FFF9EA; }   /* 다른 무료 도구와 같은 금색(분리 감수 L6) */
.home-btn:focus-visible { outline: 3px solid #7FB2F0; outline-offset: 2px; }
.top h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.01em; }
.lock { margin: 6px 0 0; font-size: .92rem; color: var(--green); font-weight: 600; }
.lock-ico { width: 18px; height: 18px; display: inline-block; vertical-align: -3px; margin-right: 4px; }

/* ---- 본 화면: 데스크톱 두 칸 ---- */
.app {
  max-width: 1120px; margin: 0 auto; padding: 10px 20px 24px;
  display: grid; grid-template-columns: 404px minmax(0, 1fr); gap: 22px; align-items: start;
}
.stage, .controls {
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(19, 33, 53, .06);
}
.stage { padding: 18px; }
.controls { padding: 18px 22px 16px; }

/* 미리보기 */
.preview-wrap {
  width: 366px; max-width: 100%; margin: 0 auto; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--hair); overflow: hidden; min-height: 366px; padding: 3px;
}
.preview-box { width: 360px; height: 360px; max-width: 100%; aspect-ratio: 1 / 1; }
.preview-box canvas { display: block; width: 100%; height: 100%; }
.preview-wrap[data-backdrop="grid"] {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #E3E8EF 25%, transparent 25%), linear-gradient(-45deg, #E3E8EF 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #E3E8EF 75%), linear-gradient(-45deg, transparent 75%, #E3E8EF 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.preview-wrap[data-backdrop="paper"] {
  background: #fff repeating-linear-gradient(to bottom, transparent 0 27px, rgba(19, 33, 53, .07) 27px 28px);
}
.preview-wrap[data-backdrop="real"] { background: #fff; gap: 10px; }
.ruler { color: var(--ink); line-height: 0; }
.real-note { margin: 0 12px 4px; font-size: .78rem; color: var(--soft); text-align: center; }

/* 바탕 고르기 · 칩 공통(라디오는 눈에 안 보이게 두고 글자 칩을 누른다 — 키보드로도 움직인다) */
.seg, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.seg { justify-content: center; margin: 12px 0 4px; }
.seg label, .chips label { position: relative; cursor: pointer; }
.seg input, .chips input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.seg span, .chips label > span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 13px; border-radius: 999px; border: 1px solid var(--hair-strong);
  background: #fff; font-size: .9rem; line-height: 1.5; user-select: none;
}
.chips small { color: var(--soft); font-size: .78rem; }
.seg input:checked + span, .chips input:checked + span {
  background: var(--ink); border-color: var(--ink); color: #fff;
}
.chips input:checked + span small { color: #DCE5F0; }
.seg input:focus-visible + span, .chips input:focus-visible + span { outline: 3px solid #7FB2F0; outline-offset: 2px; }
.chips .check input:checked + span { background: var(--green); border-color: var(--green); }

/* 저장 */
.save-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; }
.size-lbl { font-weight: 700; font-size: .92rem; }
select {
  padding: 7px 12px; border-radius: 10px; border: 1px solid var(--hair-strong); background: #fff; min-width: 170px;
}
select:focus-visible, .text-row input:focus-visible, .btn:focus-visible, .btn-mini:focus-visible, summary:focus-visible {
  outline: 3px solid #7FB2F0; outline-offset: 2px;
}
.actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--hair-strong); background: #fff;
  font-weight: 700; font-size: .98rem;
}
.btn svg { width: 19px; height: 19px; }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn-main { background: var(--stamp); border-color: var(--stamp); color: #fff; padding: 10px 24px; }
.btn-main:hover:not(:disabled) { background: var(--stamp-dark); border-color: var(--stamp-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.is-hint { box-shadow: 0 0 0 4px rgba(194, 58, 46, .28); }
.action-status { min-height: 1.5em; margin: 8px 0 0; text-align: center; font-size: .86rem; color: var(--green); }
.action-status.is-error { color: var(--error); }

/* 오른쪽: 고르기 */
.field { margin: 0 0 14px; }
.lbl { display: block; font-weight: 800; font-size: 1rem; margin: 0 0 6px; }
.lbl-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.lbl-row .lbl { margin-bottom: 6px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }
.text-row { display: flex; align-items: center; gap: 10px; }
.text-row input {
  flex: 1; min-width: 0; width: 100%; font-size: 1.4rem; font-weight: 700; letter-spacing: .02em;
  padding: 9px 14px; border-radius: 12px; border: 2px solid var(--hair-strong); background: #fff;
}
.text-row input:focus { border-color: var(--ink); }
.count { font-size: .9rem; color: var(--soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.count.over { color: var(--error); font-weight: 700; }
.messages { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.msg { font-size: .88rem; padding: 4px 10px; border-radius: 8px; }
.msg-info { background: var(--info-bg); color: var(--ink); }
.msg-warn { background: var(--warn-bg); color: var(--warn); }
.msg-error { background: var(--error-bg); color: var(--error); font-weight: 700; }

/* 글씨체 견본판 */
.font-status { font-size: .82rem; color: var(--soft); font-variant-numeric: tabular-nums; }
.font-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.font-opt {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 4px 6px; border: 1.5px solid var(--hair); border-radius: 12px; background: #fff; cursor: pointer;
  text-align: center; min-width: 0;
}
.font-opt:hover { border-color: var(--hair-strong); }
.font-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.font-opt:focus-within { outline: 3px solid #7FB2F0; outline-offset: 1px; }
.font-canvas { width: 84px; height: 84px; display: block; }
.font-name { font-size: .8rem; font-weight: 700; line-height: 1.3; }
.font-note { font-size: .72rem; color: var(--error); line-height: 1.25; min-height: 1.25em; }
.font-opt.is-selected { border-color: var(--stamp); box-shadow: 0 0 0 2px var(--stamp-soft); background: #FFFBFA; }
.font-opt.is-disabled .font-canvas, .font-opt.is-disabled .font-name { opacity: .38; }
.font-opt.is-disabled { cursor: not-allowed; }

/* 추가 기능 — 노란 단추(대표 지시 D232) */
.more { border-top: 1px solid var(--hair); padding-top: 12px; }
.more summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.more summary::-webkit-details-marker { display: none; }
.more summary::marker { content: ''; }
.more-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px 8px 18px; border-radius: 999px;
  background: #FFD54F; color: var(--ink); border: 1px solid #F2B705;
  font-weight: 800; font-size: .98rem; letter-spacing: -.01em;
  box-shadow: 0 3px 10px rgba(242, 183, 5, .32);
  transition: background .2s, box-shadow .2s, transform .2s;
}
.more summary:hover .more-pill { background: #FFC928; box-shadow: 0 4px 14px rgba(242, 183, 5, .45); transform: translateY(-1px); }
.more-pill .chev { width: 18px; height: 18px; transition: transform .25s; }
.more[open] .more-pill .chev { transform: rotate(180deg); }
.more-sub { font-weight: 500; color: var(--soft); font-size: .86rem; }
.more-grid { display: grid; gap: 10px; margin-top: 12px; }
.more-grid legend { font-weight: 700; font-size: .88rem; margin-bottom: 4px; width: 100%; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 1px solid rgba(255, 255, 255, .7); }
.dot-red { background: #D0312D; }
.dot-darkred { background: #9E1B1B; }
.dot-navy { background: #1F3A8A; }
.dot-black { background: #1B1B1B; }
.btn-mini {
  padding: 5px 12px; border-radius: 999px; border: 1px dashed var(--hair-strong); background: #fff;
  font-size: .86rem; cursor: pointer;
}
.hint { font-size: .82rem; color: var(--soft); align-self: center; }

/* ---- 아래: 쓰는 법 · 고지 · 확인법 · 글꼴 출처 ---- */
.info { padding: 6px 20px 10px; }
.info-in { max-width: 1120px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; align-items: start; }
.info .card {
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--radius); padding: 18px 22px;
}
.info h2 { margin: 0 0 8px; font-size: 1.05rem; }

/* 접는 안내 칸 — 제목만 보이고 누르면 스르륵 열림(대표 지시 D231 ⑤) */
.info .fold { padding: 0; }
.fold > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-radius: var(--radius);
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::marker { content: ''; }
.fold > summary h2 { margin: 0; font-size: 1rem; }
.fold > summary::after {
  content: ''; flex: none; width: 10px; height: 10px; margin-right: 4px;
  border-right: 2.4px solid var(--soft); border-bottom: 2.4px solid var(--soft);
  transform: rotate(45deg) translateY(-3px); transition: transform .25s;
}
.fold[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.fold > summary:hover { background: #F6F9FD; }
.fold[open] > summary { border-bottom: 1px solid var(--hair); border-radius: var(--radius) var(--radius) 0 0; }
.fold-body { padding: 14px 22px 16px; }
.card-notice.fold { border-left: 5px solid var(--stamp); }

/* 스르륵 — 높이가 자라는 움직임(되는 브라우저) + 글이 살짝 내려오며 나타남(모든 브라우저) */
:root { interpolate-size: allow-keywords; }
/* 높이 움직임은 안내 칸에만(추가 기능 칸은 칩 가장자리 초점 테두리가 잘리지 않게 나타남 움직임만) */
.fold::details-content {
  block-size: 0; overflow: hidden;
  transition: block-size .32s ease, content-visibility .32s allow-discrete;
}
.fold[open]::details-content { block-size: auto; }
.fold[open] > .fold-body, .more[open] > .more-grid { animation: fold-in .32s ease both; }
@keyframes fold-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.info p { margin: 0 0 8px; }
.card-notice { border-left: 5px solid var(--stamp); }
#verify, #fonts-credit { grid-column: 1 / -1; }
.steps { margin: 0 0 8px; padding-left: 1.3em; }
.steps li { margin: 2px 0; }
.small { font-size: .88rem; color: var(--soft); }
.table-wrap { overflow-x: auto; }
.credit { width: 100%; border-collapse: collapse; font-size: .86rem; }
.credit th, .credit td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--hair); vertical-align: top; }
.credit th { color: var(--soft); font-weight: 700; white-space: nowrap; }
/* 슬라이드 메이커 안내 한 줄 — 파란 굵은 글씨로 눈에 띄게(대표 지시 2026-10-14) */
.next-line { grid-column: 1 / -1; margin: 4px 0 0; text-align: center; font-size: .98rem; color: #1D4ED8; font-weight: 800; }
.next-line a { font-weight: 800; color: #1D4ED8; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.next-line a:hover { color: #1E3A8A; }
.foot {
  max-width: 1120px; margin: 0 auto; padding: 14px 20px 40px; display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; font-size: .86rem; color: var(--soft);
}
.foot a { color: var(--soft); }
/* 누르는 링크의 높이를 24px 이상으로(분리 감수 L5 — 손가락으로 누르기 쉽게) */
.foot a, .next-line a, .lock a, .credit a { display: inline-block; min-height: 24px; line-height: 24px; padding: 0 2px; }
.fatal, .fatal-static {
  max-width: 640px; margin: 24px auto; padding: 16px 20px; border-radius: 14px;
  background: var(--error-bg); color: var(--error); font-weight: 700; text-align: center;
}

/* ---- 모바일(가로 900px 미만) — 한 칸, 미리보기는 위에 붙어 따라오고 저장 단추는 맨 아래 띠 ---- */
@media (max-width: 899px) {
  /* minmax(0,1fr) — 글자 칸(input)의 기본 폭이 칸을 밀어 화면이 옆으로 넘치던 것(실측 420px)을 막는다 */
  .app { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 6px 16px 96px; }
  .top { padding: 12px 16px 4px; }
  .top h1 { font-size: 1.25rem; }
  .lock { font-size: .84rem; }
  .stage {
    position: sticky; top: 0; z-index: 10; padding: 10px 12px 8px;
    border-radius: 0 0 var(--radius) var(--radius); margin: 0 -16px;
  }
  .preview-wrap { width: 206px; min-height: 206px; }
  .preview-box { width: 200px; height: 200px; }
  .preview-wrap[data-backdrop="real"] { width: 100%; }
  .seg { margin: 6px 0 0; gap: 4px; }
  .seg span { padding: 2px 10px; font-size: .82rem; }
  .save-row { margin-top: 5px; }
  .size-lbl { font-size: .84rem; }
  select { padding: 4px 10px; min-width: 150px; font-size: .9rem; }
  .action-status { margin: 4px 0 0; min-height: 0; }
  .actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96); border-top: 1px solid var(--hair);
    box-shadow: 0 -6px 18px rgba(19, 33, 53, .08);
  }
  .actions .btn { flex: 1; justify-content: center; }
  .controls { padding: 14px 14px 12px; }
  .font-board { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .font-canvas { width: 64px; height: 64px; }
  .info { padding: 6px 16px 10px; }
  /* minmax(0,1fr) — 안내 칸 안의 표·긴 낱말이 칸을 밀어 360px 에서 16px · 320px 에서 56px 옆으로 넘치던 것(분리 감수 M1) */
  .info-in { grid-template-columns: minmax(0, 1fr); }
  .info .card { padding: 16px; min-width: 0; }
  .info .fold { padding: 0; }
  .fold > summary { padding: 12px 16px; }
  .fold-body { padding: 12px 16px 14px; }
  /* 아래 단추 띠(약 68px)가 맨 아래 바닥글·처리방침 링크를 덮지 않게 그만큼 여백(분리 감수 M3) */
  .foot { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .font-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app { padding-left: 12px; padding-right: 12px; }
  .stage { margin: 0 -12px; }
  .info { padding-left: 12px; padding-right: 12px; }
  .info .card { padding: 14px 12px; }
  .info .fold { padding: 0; }
  .fold > summary { padding: 12px 12px; }
  .fold-body { padding: 12px 12px 14px; }
  select { min-width: 0; }
}
/* 화면 높이가 낮을 때(휴대폰을 가로로 눕힘 · 667×375 등) — 미리보기를 위에 붙이지 않는다.
   붙이면 미리보기와 아래 단추 띠가 화면을 다 차지해 글자 칸·모양 단추를 누를 수 없었다(분리 감수 M2). */
.mini-preview { display: none; width: 56px; height: 56px; flex: none; border: 1px solid var(--hair); border-radius: 8px; background: #fff; }
@media (max-width: 899px) and (max-height: 599px) {
  .stage { position: static; }
  .app { padding-bottom: 16px; }
  /* 대신 글자 칸 옆에 작은 미리보기를 보인다 — 글자를 칠 때 큰 미리보기가 위로 밀려 안 보이던 것(재감수 L-a) */
  .mini-preview { display: block; }
}
/* 움직임 줄이기 — 가짜 요소(::details-content · ::after)까지(분리 감수 M1 · 종전 `*` 만으로는 칸 높이가 0.3초 자랐다) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, .fold::details-content { transition: none !important; animation: none !important; }
}
