/* PDF Tools — 흰색 기반, 시스템 글꼴(웹폰트 없음 → 빠른 로딩) */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --line: #e3e6ea;
  --text: #1f2328;
  --muted: #5b636e;
  --brand: #d93025;
  --brand-dark: #b3261e;
  --brand-soft: #fdecea;
  --ok: #1e7e34;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo",
    "Hiragino Sans", "Yu Gothic UI", "Microsoft YaHei", "PingFang SC", "Noto Sans", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
img { max-width: 100%; }
a { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.3; }
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: #000; color: #fff; padding: 8px 12px; z-index: 10; border-radius: 6px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; }
[hidden] { display: none !important; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.header-nav { display: flex; gap: 6px; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; padding: 8px 12px; border-radius: 8px; font-size: .95rem; display: flex; align-items: center; gap: 6px; user-select: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); opacity: .6; }
.menu > summary:hover, .menu[open] > summary { background: var(--bg-soft); }
.menu ul { position: absolute; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 200px; }
.menu li a { display: block; padding: 9px 12px; border-radius: 6px; color: var(--text); text-decoration: none; white-space: nowrap; }
.menu li a:hover { background: var(--bg-soft); }
.menu li a[aria-current] { font-weight: 700; color: var(--brand-dark); }
.globe { width: 16px; height: 16px; border: 2px solid currentColor; border-radius: 50%; position: relative; display: inline-block; }
.globe::before { content: ""; position: absolute; inset: 0 4px; border: 2px solid currentColor; border-top: 0; border-bottom: 0; border-radius: 50%; }

/* Hero */
.home-hero, .tool-hero { text-align: center; padding-top: 40px; padding-bottom: 8px; }
.home-hero h1, .tool-hero h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 0 0 10px; }
.lead { color: var(--muted); font-size: 1.05rem; margin: 0 auto 24px; max-width: 680px; }

/* Tool grid */
.tool-grid { list-style: none; padding: 0; margin: 8px 0 32px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tool-grid a { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); background: #fff; box-shadow: var(--shadow); transition: border-color .15s; }
.tool-grid a:hover { border-color: var(--brand); }
.tool-grid strong { font-size: 1.05rem; }
.tool-grid span { color: var(--muted); font-size: .92rem; }
.tool-grid.small { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tool-grid.small a { padding: 14px; box-shadow: none; }
.ti { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); position: relative; margin-bottom: 6px; }
.ti::before { content: ""; position: absolute; left: 12px; top: 9px; width: 16px; height: 21px; border: 2px solid var(--brand); border-radius: 3px; background: #fff; }
.ti-merge::after, .ti-split::after, .ti-compress::after, .ti-reorder::after, .ti-jpgToPdf::after, .ti-extract::after {
  position: absolute; right: 4px; bottom: 3px; font-size: 13px; font-weight: 800; color: var(--brand); line-height: 1; }
.ti-merge::after { content: "+"; } .ti-split::after { content: "÷"; } .ti-compress::after { content: "↓"; }
.ti-reorder::after { content: "⇅"; } .ti-jpgToPdf::after { content: "▣"; } .ti-extract::after { content: "↗"; }

/* Tool area */
.tool { max-width: 860px; }
.dropzone { border: 2px dashed #c9ced6; border-radius: 16px; background: var(--bg-soft); text-align: center; padding: 40px 20px; transition: background .15s, border-color .15s; }
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.compact { padding: 14px; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.dropzone.compact .dz-icon, .dropzone.compact .dz-limits { display: none; }
.dropzone.compact .dz-title { margin: 0; }
.dz-icon { width: 44px; height: 54px; margin: 0 auto 10px; border: 3px solid var(--brand); border-radius: 6px; position: relative; background: #fff; }
.dz-icon::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; font-weight: 700; color: var(--brand); }
.dz-title { font-size: 1.05rem; margin: 0 0 14px; }
.dz-limits { color: var(--muted); font-size: .85rem; margin: 14px 0 0; }
.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 10px; padding: 9px 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; min-height: 40px; }
.btn:hover:not(:disabled) { background: var(--bg-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-lg { padding: 13px 28px; font-size: 1.05rem; border-radius: 12px; min-height: 50px; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; border-radius: 8px; font-size: 1rem; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn-ok:hover:not(:disabled) { background: #176a2b; }

/* Workspace */
.ws-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.ws-toolbar .info { color: var(--muted); font-size: .92rem; }
.ws-toolbar .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.file-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fff; }
.file-list li:last-child { border-bottom: 0; }
.file-list li.dragging { opacity: .4; }
.file-list li.drop-before { box-shadow: inset 0 3px 0 var(--brand); }
.file-list li.drop-after { box-shadow: inset 0 -3px 0 var(--brand); }
.file-list .num { width: 28px; text-align: center; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.file-list .grip { cursor: grab; color: #9aa1ab; font-size: 18px; padding: 0 2px; user-select: none; flex-shrink: 0; }
.file-list .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); flex-shrink: 0; background: var(--bg-soft); }
.file-list .meta { flex: 1; min-width: 0; }
.file-list .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-list .sub { color: var(--muted); font-size: .85rem; }
.file-list .row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.single-file { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 18px; }
.single-file .meta { flex: 1; min-width: 0; }
.single-file .name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.single-file .sub { color: var(--muted); font-size: .88rem; }

.options { margin: 16px 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); display: grid; gap: 14px; }
.options fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.options legend, .options .label { font-weight: 600; margin-bottom: 6px; padding: 0; }
.choice { display: flex; flex-wrap: wrap; gap: 8px; }
.choice label { display: flex; gap: 8px; align-items: flex-start; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; flex: 1 1 200px; }
.choice label:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.choice small { display: block; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; }
input[type=text], input[type=number] { font: inherit; padding: 9px 12px; border: 1px solid #c9ced6; border-radius: 8px; width: 100%; max-width: 420px; background: #fff; }
.hint { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
.run-bar { display: flex; justify-content: center; margin: 18px 0 6px; }

/* Page grid (thumbnails) */
.page-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.page-grid li { position: relative; border: 2px solid var(--line); border-radius: 10px; background: #fff; padding: 8px 8px 6px; text-align: center; user-select: none; }
.page-grid li.selectable { cursor: pointer; }
.page-grid li.selected { border-color: var(--brand); background: var(--brand-soft); }
.page-grid li.selected::after { content: "✓"; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 13px; line-height: 22px; font-weight: 700; }
.page-grid li.dragging { opacity: .4; }
.page-grid li.drop-before { box-shadow: -4px 0 0 var(--brand); }
.page-grid li.drop-after { box-shadow: 4px 0 0 var(--brand); }
.page-grid .pthumb { width: 100%; aspect-ratio: 1 / 1.3; display: grid; place-items: center; background: var(--bg-soft); border-radius: 4px; overflow: hidden; }
.page-grid .pthumb canvas { max-width: 100%; max-height: 100%; box-shadow: 0 0 0 1px var(--line); }
.page-grid .pthumb .ph { color: #9aa1ab; font-size: 1.4rem; font-weight: 700; }
.page-grid .plabel { display: block; font-size: .85rem; color: var(--muted); margin-top: 4px; }
.page-grid .pmove { display: flex; justify-content: center; gap: 4px; margin-top: 4px; }
.page-grid li[draggable=true] { cursor: grab; }

/* Status / result */
.status { margin: 18px 0; text-align: center; }
.progress { height: 8px; background: var(--bg-soft); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress-bar { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
#status-text { color: var(--muted); margin: 8px 0 0; }
.alert { border-radius: 10px; padding: 12px 14px; margin: 16px 0; }
.alert-error { background: #fdecea; border: 1px solid #f5c2bd; color: #8a1c13; }
.alert-error ul { margin: 6px 0 0; padding-left: 20px; }
.alert-info { background: #eef4fd; border: 1px solid #c8daf7; color: #1a3d6e; }
.result { margin: 20px 0; padding: 24px; text-align: center; border: 1px solid #b7dfc1; background: #eef8f0; border-radius: 16px; }
.result h2 { margin: 0 0 6px; font-size: 1.3rem; }
.result p { margin: 4px 0 14px; color: var(--muted); }
.result .result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: .88rem; margin: 18px 0 0; text-align: center; }
.lock { width: 12px; height: 10px; border: 2px solid currentColor; border-radius: 2px; position: relative; margin-top: 4px; flex-shrink: 0; }
.lock::before { content: ""; position: absolute; left: 1px; top: -8px; width: 6px; height: 7px; border: 2px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; }

/* Content */
.content { max-width: 860px; padding-top: 24px; padding-bottom: 40px; }
.content h2 { font-size: 1.3rem; margin: 32px 0 10px; }
.steps, .notes { padding-left: 22px; }
.steps li, .notes li { margin: 6px 0; }
.features { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.features li { padding: 16px; border-radius: var(--radius); background: var(--bg-soft); }
.features strong { display: block; margin-bottom: 4px; }
.features span { color: var(--muted); font-size: .95rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-soft); padding: 24px 0; font-size: .9rem; color: var(--muted); }
.footer-tools { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.footer-tools a { color: var(--text); text-decoration: none; }
.footer-tools a:hover { text-decoration: underline; }
.copy { margin: 4px 0 0; }

/* Root language picker */
.lang-pick main { max-width: 480px; text-align: center; padding-top: 12vh; }
.lang-pick .logo { justify-content: center; font-size: 1.4rem; }
.lang-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.lang-list a { display: block; padding: 14px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); font-size: 1.05rem; }
.lang-list a:hover { border-color: var(--brand); }

@media (max-width: 600px) {
  .wrap { padding: 0 14px; }
  .home-hero, .tool-hero { padding-top: 24px; }
  .dropzone { padding: 28px 14px; }
  .logo span { font-size: 1rem; }
  .menu > summary { padding: 8px; }
  .menu ul { position: fixed; left: 10px; right: 10px; top: 64px; min-width: 0; }
  .file-list .grip { display: none; }
  .page-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .result { padding: 18px 12px; }
}

/* FAQ */
.faq { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.faq-item { border-bottom: 1px solid var(--line); background: #fff; }
.faq-item:last-child { border-bottom: 0; }
.faq-item summary { cursor: pointer; padding: 14px 44px 14px 16px; font-weight: 600; list-style: none; position: relative; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 1.3rem; color: var(--muted); }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { margin: 0; padding: 0 16px 16px; color: var(--muted); }

/* 정책 페이지 */
.policy h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); margin: 32px 0 6px; }
.policy h2 { font-size: 1.15rem; margin: 28px 0 8px; }
.policy p { margin: 6px 0; overflow-wrap: anywhere; }
.policy .updated { color: var(--muted); font-size: .9rem; }
.contact-mail { font-size: 1.1rem; padding: 14px 16px; background: var(--bg-soft); border-radius: var(--radius); }
.contact-mail a { margin-left: 6px; }
.footer-policy { margin-top: -2px; font-size: .85rem; }
.footer-policy a { color: var(--muted); }

/* 광고 자리 — 도구·다운로드 버튼과 떨어진 위치에만 둔다 */
.ad-slot { max-width: 860px; margin: 28px auto; text-align: center; }
.ad-slot.ad-live { min-height: 280px; }            /* 광고가 늦게 떠도 화면이 밀리지 않게 자리 확보 (CLS 방지) */
.ad-label { display: block; font-size: .75rem; color: var(--muted); margin-bottom: 4px; }
.adsbygoogle { display: block; }
.ad-dev { display: grid; place-items: center; min-height: 120px; border: 2px dashed #c9ced6; border-radius: var(--radius);
  color: var(--muted); font-size: .85rem; background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 10px, #f3f4f6 10px, #f3f4f6 20px); }
