/* =========================================================
   KidsPrint · 어린이 무료 색칠도안 & 프린터블 게임
   정적 사이트 스타일 (인쇄 최적화 포함)
   ========================================================= */
:root {
  --ink: #24313d;
  --ink-soft: #5b6b78;
  --paper: #fffdf8;
  --bg: #fff8ef;
  --coral: #ff6b6b;
  --coral-dark: #e9554f;
  --mint: #35bfb1;
  --sun: #ffd23f;
  --sky: #6fb7f5;
  --line: #ffe2cc;
  --line-strong: #ffd0ae;
  --radius: 20px;
  --shadow: 0 10px 24px rgba(126, 96, 66, .10);
  --shadow-sm: 0 4px 10px rgba(126, 96, 66, .08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  word-break: keep-all;
  overflow-wrap: break-word;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

img, svg { max-width: 100%; }
img { height: auto; }

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: "Jua", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  line-height: 1.25;
  letter-spacing: -.01em;
  margin: 0 0 .5em;
  font-weight: 400;
}

h1 { font-size: clamp(1.9rem, 4.2vw, 2.9rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }

.wrap { width: min(1160px, 92vw); margin: 0 auto; }

/* ---------------- header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 253, 248, .96);
  border-bottom: 3px solid var(--line);
  backdrop-filter: blur(6px);
}
.header-in {
  display: flex; align-items: center; gap: 18px;
  height: 74px;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-family: "Jua", system-ui, sans-serif;
  font-size: 1.5rem; white-space: nowrap;
}
.logo .mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--coral); color: #fff;
  display: grid; place-items: center; font-size: 20px;
  box-shadow: var(--shadow-sm);
}
.logo small { display: block; font-family: "Pretendard", sans-serif; font-size: .62rem; color: var(--ink-soft); letter-spacing: .04em; }

.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  padding: 9px 13px; border-radius: 999px;
  font-size: .95rem; font-weight: 600; color: var(--ink-soft);
}
.nav a:hover { background: #fff1e4; color: var(--ink); }
.nav a.on { background: var(--ink); color: #fff; }
.lang-switch {
  margin-left: 6px; padding: 8px 12px; border-radius: 999px;
  border: 2px solid var(--line-strong); font-size: .82rem; font-weight: 700; color: var(--ink-soft);
}
.lang-switch:hover { border-color: var(--coral); color: var(--coral-dark); }

/* ---------------- hero ---------------- */
.hero {
  position: relative; overflow: hidden;
  padding: 56px 0 44px;
  background:
    radial-gradient(circle at 12% 20%, #ffe9d6 0 3px, transparent 3px) 0 0/26px 26px,
    linear-gradient(180deg, #fff6ea, #fffdf8);
  border-bottom: 1px solid var(--line);
}
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 40px; align-items: center; }
.hero h1 { margin-bottom: 14px; }
.hero h1 em { font-style: normal; color: var(--coral-dark); }
.hero .lead { font-size: 1.05rem; color: var(--ink-soft); max-width: 34em; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 22px; border-radius: 999px;
  font-weight: 700; font-size: 1rem; border: 0; cursor: pointer;
  background: #fff; color: var(--ink);
  border: 2px solid var(--line-strong);
  transition: transform .12s ease, box-shadow .12s ease;
  font-family: inherit;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-primary:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.btn-ghost { background: #fff; }
.btn-sm { padding: 9px 16px; font-size: .9rem; }
.btn-block { width: 100%; justify-content: center; }

.hero-art { position: relative; height: 340px; }
.hero-art figure {
  position: absolute; margin: 0; background: #fff;
  border: 3px solid var(--line-strong); border-radius: 18px;
  box-shadow: var(--shadow); overflow: hidden;
  width: 178px;
}
.hero-art img { display: block; width: 100%; }
.hero-art .c1 { left: 4%;  top: 26px;  transform: rotate(-7deg); }
.hero-art .c2 { left: 33%; top: 0;     transform: rotate(2deg); width: 200px; }
.hero-art .c3 { right: 2%; top: 44px;  transform: rotate(8deg); }
.hero-art .badge {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; white-space: nowrap;
}

/* ---------------- sections ---------------- */
.section { padding: 52px 0; }
.section.alt { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-head p { margin: 0; color: var(--ink-soft); }
.section-head h2 { margin-bottom: 4px; }
.more { font-weight: 700; color: var(--coral-dark); white-space: nowrap; font-size: .95rem; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.cat {
  background: #fff; border: 2px solid var(--line); border-radius: 16px;
  padding: 14px 12px; text-align: center; transition: .15s;
}
.cat:hover { border-color: var(--coral); transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.cat .emoji { font-size: 26px; display: block; line-height: 1.2; }
.cat b { display: block; font-size: .95rem; margin-top: 4px; }
.cat span { font-size: .74rem; color: var(--ink-soft); }
.cat.soon { opacity: .55; }

.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.design-card {
  background: #fff; border: 2px solid var(--line); border-radius: 16px; overflow: hidden;
  transition: .15s; display: flex; flex-direction: column;
}
.design-card:hover { border-color: var(--coral); transform: translateY(-3px); box-shadow: var(--shadow); }
.design-card .thumb { aspect-ratio: 1/1.414; background: #fff; overflow: hidden; border-bottom: 2px solid var(--line); }
.design-card .thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.design-card .body { padding: 10px 12px 12px; }
.design-card b { display: block; font-size: 1rem; }
.design-card small { color: var(--ink-soft); font-size: .78rem; }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .7rem; font-weight: 700;
  background: #fff1e4; color: #b4582f; margin: 4px 4px 0 0;
}

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.game-card {
  background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 20px;
  display: flex; flex-direction: column; gap: 6px; transition: .15s;
}
.game-card:hover { border-color: var(--mint); transform: translateY(-3px); box-shadow: var(--shadow); }
.game-card .ico { font-size: 30px; }
.game-card b { font-size: 1.1rem; }
.game-card p { font-size: .86rem; color: var(--ink-soft); margin: 0; }
.game-card .go { margin-top: auto; font-size: .85rem; font-weight: 700; color: var(--mint); }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.step { background: #fff; border: 2px dashed var(--line-strong); border-radius: 18px; padding: 20px; }
.step b { display: block; margin-bottom: 4px; }
.step .num {
  width: 30px; height: 30px; border-radius: 50%; background: var(--sun);
  display: grid; place-items: center; font-weight: 800; margin-bottom: 10px;
}

/* ---------------- ad slot ---------------- */
.ad-slot {
  min-height: 110px; border: 2px dashed var(--line-strong); border-radius: 16px;
  display: grid; place-items: center; color: #b99b83; font-size: .8rem;
  background: #fffdfa; margin: 26px 0; text-align: center; padding: 12px;
}

/* ---------------- footer ---------------- */
.site-footer { background: #2c3a46; color: #dfe6ea; padding: 40px 0 28px; margin-top: 20px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 28px; }
.site-footer a { color: #cfd8de; }
.site-footer a:hover { color: #fff; }
.site-footer h4 { color: #fff; font-size: .95rem; margin-bottom: 8px; }
.site-footer p { font-size: .84rem; color: #adbcc6; }
.site-footer ul { list-style: none; padding: 0; margin: 0; font-size: .88rem; line-height: 2; }
.copy { border-top: 1px solid #3d4d5a; margin-top: 26px; padding-top: 16px; font-size: .78rem; color: #93a4b0; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------------- page layout ---------------- */
.page { padding: 30px 0 60px; }
.crumbs { font-size: .84rem; color: var(--ink-soft); margin-bottom: 14px; }
.crumbs a:hover { color: var(--coral-dark); }
.page-head { margin-bottom: 24px; }
.page-head .lead { color: var(--ink-soft); max-width: 46em; }

.tool-layout { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.panel {
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.tool-controls { position: sticky; top: 92px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: .82rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
select, input[type="text"], input[type="number"] {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line);
  font-family: inherit; font-size: .95rem; background: #fffdf8; color: var(--ink);
}
select:focus, input:focus { outline: none; border-color: var(--coral); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 54px; padding: 9px 4px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--line); background: #fff; font-family: inherit; font-weight: 700;
  font-size: .86rem; color: var(--ink-soft);
}
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.hint { font-size: .76rem; color: var(--ink-soft); line-height: 1.5; }
.control-actions { display: grid; gap: 8px; margin-top: 16px; }

/* ---------------- paper / print page ---------------- */
.stage { display: flex; flex-direction: column; gap: 18px; }
.paper {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow);
  border: 1px solid #efe6dc; padding: 22px;
  margin: 0 auto; width: 100%; max-width: 820px;
}
.paper-head {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 2px solid #f1e7dc; padding-bottom: 8px; margin-bottom: 14px;
  font-size: .85rem; color: #7c8a95;
}
.paper-head b { color: var(--ink); font-size: .95rem; }
.paper-foot {
  border-top: 2px solid #f1e7dc; margin-top: 14px; padding-top: 8px;
  font-size: .72rem; color: #9aa7b1; display: flex; justify-content: space-between;
}
.art svg { display: block; width: 100%; height: auto; }
.sudoku-wrap { display: grid; place-items: center; }
table.sudoku { border-collapse: collapse; margin: 0 auto; border: 4px solid #1b2733; }
table.sudoku td {
  width: 46px; height: 46px; text-align: center; vertical-align: middle;
  font-size: 26px; font-weight: 600; border: 1px solid #b9c2ca; color: var(--ink);
}
table.sudoku td.bt { border-top: 4px solid #1b2733; }
table.sudoku td.bb { border-bottom: 4px solid #1b2733; }
table.sudoku td.bl { border-left: 4px solid #1b2733; }
table.sudoku td.br { border-right: 4px solid #1b2733; }
table.sudoku td.given { color: #1b2733; }
table.sudoku td.empty { color: #b9c2ca; }
.sudoku-cap { text-align: center; font-size: .8rem; color: #7c8a95; margin-top: 8px; }

.answer-page { display: none; }
body.show-answers .answer-page { display: block; }

/* ---------------- design detail ---------------- */
.design-layout { display: grid; grid-template-columns: 1fr 330px; gap: 26px; align-items: start; }
.design-side .panel { position: sticky; top: 92px; }
.design-side h1 { font-size: 1.7rem; }
.meta-list { list-style: none; padding: 0; margin: 12px 0 18px; font-size: .88rem; display: grid; gap: 6px; }
.meta-list li { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.meta-list span { color: var(--ink-soft); }

/* ---------------- guide text ---------------- */
.guide { margin-top: 46px; }
.guide .panel { padding: 26px 28px; }
.guide h2 { font-size: 1.3rem; }
.guide h3 { margin-top: 1.4em; }
.guide ul, .guide ol { padding-left: 1.2em; }
.guide li { margin-bottom: .35em; }
.faq details { border-bottom: 1px dashed var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq p { margin: 8px 0 0; color: var(--ink-soft); font-size: .92rem; }

/* ---------------- filters ---------------- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 2px solid var(--line);
  background: #fff; font-size: .86rem; font-weight: 700; color: var(--ink-soft); cursor: pointer;
  font-family: inherit;
}
.chip:hover { border-color: var(--coral); }
.chip.on { background: var(--coral); border-color: var(--coral); color: #fff; }
.search { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search input { width: 220px; }
.empty-note { color: var(--ink-soft); padding: 30px 0; text-align: center; grid-column: 1/-1; }

/* ---------------- policy pages ---------------- */
.prose { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 30px 34px; }
.prose h2 { margin-top: 1.6em; font-size: 1.25rem; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { font-size: .95rem; color: #33424f; }
.prose table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .88rem; }
.prose th, .prose td { border: 1px solid var(--line-strong); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: #fff6ec; }

/* ---------------- misc ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: .88rem; opacity: 0; pointer-events: none; transition: .2s; z-index: 90;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .tool-layout, .design-layout { grid-template-columns: 1fr; }
  .tool-controls, .design-side .panel { position: static; }
  .steps { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .nav { display: none; }
  .search { margin-left: 0; width: 100%; }
  .search input { width: 100%; }
}

/* =========================================================
   PRINT  ·  A4 세로/가로 자동, 네비·광고·버튼 숨김
   ========================================================= */
@media print {
  @page { size: A4 portrait; margin: 10mm; }

  html, body { background: #fff !important; }
  body { font-size: 11pt; }

  .no-print, .site-header, .site-footer, .ad-slot, .crumbs, .page-head,
  .tool-controls, .design-side, .filter-bar, .toast, .more { display: none !important; }

  .page { padding: 0 !important; }
  .wrap { width: 100% !important; }
  .tool-layout, .design-layout { display: block !important; }
  .stage { display: block !important; gap: 0 !important; }

  .paper {
    border: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    padding: 0 !important; max-width: none !important; width: 100% !important;
    page-break-inside: avoid;
  }
  .print-page + .print-page { page-break-before: always; }

  .paper-head { font-size: 9pt; color: #666; border-bottom: 1px solid #ddd; padding-bottom: 4px; margin-bottom: 5mm; }
  .paper-foot { font-size: 7.5pt; color: #999; border-top: 1px solid #ddd; padding-top: 4px; margin-top: 4mm; }

  .answer-page { display: none !important; }
  body.printing-answers .answer-page { display: block !important; }

  /* 그림·문제 영역이 A4 한 장을 넘지 않도록 고정 */
  .art svg { width: 100% !important; height: 232mm !important; display: block; }
  .design-art { width: 100% !important; height: 232mm !important; object-fit: contain; }

  .guide, .section { display: none !important; }
  .sol { stroke: #555 !important; }

  table.sudoku td { width: 14mm; height: 14mm; font-size: 13pt; }
  .sudoku-cap { font-size: 8pt; }
  .math-head { margin-bottom: 6mm; }
  .math-head i { width: 55mm; }
  .math-grid { gap: 7mm 14mm; }
  .math-item { font-size: 14pt; }
  .word-list { margin-top: 4mm; }
  .tag { font-size: 9pt; }

  svg { break-inside: avoid; }
}

/* ---------------- 연산 학습지 ---------------- */
.math-sheet { width: 100%; }
.math-head {
  display: flex; gap: 40px; font-size: .9rem; color: var(--ink-soft);
  border-bottom: 1px dashed #e6dccf; padding-bottom: 10px; margin-bottom: 22px;
}
.math-head span { display: inline-flex; align-items: baseline; gap: 8px; }
.math-head i {
  display: inline-block; width: 130px; border-bottom: 1px solid #b9c2ca; height: 1.1em;
}
.math-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 34px; }
.math-item { display: flex; align-items: baseline; gap: 8px; font-size: 1.32rem; font-weight: 600; }
.math-item .no { color: #9aa7b1; font-size: .8rem; width: 1.8em; font-weight: 500; }
.math-item .expr { white-space: nowrap; }
.math-item .blank {
  flex: 1; border-bottom: 2px solid #c9d3db; min-height: 1.5em;
  text-align: center; font-weight: 700; color: #e9554f;
}

/* 스도쿠 크기별 */
table.sudoku.s4 td { width: 74px; height: 74px; font-size: 40px; }
table.sudoku.s6 td { width: 62px; height: 62px; font-size: 34px; }
table.sudoku.s9 td { width: 54px; height: 54px; font-size: 28px; }

@media print {
  .math-head { gap: 24mm; font-size: 10pt; }
  .math-head i { width: 45mm; }
  .math-grid { gap: 9mm 16mm; }
  .math-item { font-size: 15pt; }
  table.sudoku.s4 td { width: 30mm; height: 30mm; font-size: 22pt; }
  table.sudoku.s6 td { width: 22mm; height: 22mm; font-size: 17pt; }
  table.sudoku.s9 td { width: 17mm; height: 17mm; font-size: 15pt; }
  .word-list .tag { font-size: 10pt; padding: 3px 10px; }
}

/* 단어찾기: 종이 위 단어 목록 */
.word-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.word-list .tag { font-size: .9rem; padding: 4px 12px; }
@media print {
  .ws .art svg { height: 196mm !important; }
  .word-list { margin-bottom: 4mm; }
}
