/* ========== FreePDF – freepdfservice.com ========== */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", Roboto, "Noto Sans KR", "Malgun Gothic", "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #111a2b; --surface-2: #172238; --text: #e5edf7; --muted: #94a3b8;
    --border: #243049; --primary: #3b82f6; --primary-600: #2563eb; --primary-soft: #1e3a8a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, canvas, svg { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
.container { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }
html[lang="ko"] [data-lang="en"] { display: none !important; }
html[lang="en"] [data-lang="ko"] { display: none !important; }

/* ----- header ----- */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 1.25rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.brand b { color: var(--primary); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 20px; margin-left: auto; }
.nav a { color: var(--muted); font-weight: 600; font-size: .95rem; }
.nav a:hover { color: var(--text); text-decoration: none; }
.lang-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.lang-btn:hover { border-color: var(--primary); color: var(--primary); }
@media (max-width: 640px) { .nav { display: none; } .lang-btn { margin-left: auto; } }

/* ----- hero / home ----- */
.hero { text-align: center; padding: 56px 0 32px; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); margin-bottom: .4em; }
.hero .lead { font-size: 1.15rem; color: var(--muted); max-width: 680px; margin: 0 auto 1.5em; }
.badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 8px; }
.badge { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin: 24px 0 40px; }
.tool-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 20px; color: var(--text); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary); text-decoration: none; }
.tool-card h3 { font-size: 1.1rem; margin: 14px 0 6px; }
.tool-card p { color: var(--muted); font-size: .9rem; margin: 0; }
.tool-card-icon { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 14%, transparent); }
.tool-card.small { display: flex; gap: 12px; align-items: center; padding: 14px 16px; }
.tool-card.small strong { display: block; font-size: .95rem; }
.tool-card.small span { color: var(--muted); font-size: .8rem; }
.tool-card.small .tool-icon { flex: none; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 24px 0 48px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.feature h3 { font-size: 1.05rem; margin-bottom: .3em; }
.feature p { color: var(--muted); font-size: .92rem; margin: 0; }

/* ----- tool page layout ----- */
.tool-head { text-align: center; padding: 36px 0 20px; }
.tool-head h1 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); }
.tool-head .lead { color: var(--muted); max-width: 640px; margin: 0 auto; font-size: 1.05rem; }
.tool-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
@media (min-width: 1080px) { .tool-layout.has-sidebar { grid-template-columns: minmax(0, 1fr) 350px; } }
.sidebar { position: sticky; top: 76px; }
.section { margin: 40px 0; }
.section h2 { font-size: 1.4rem; margin-bottom: .8em; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); counter-reset: step; }
.steps li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 18px 58px; position: relative; color: var(--muted); font-size: .95rem; }
.steps li::before { counter-increment: step; content: counter(step); position: absolute; left: 16px; top: 16px; width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 800; display: grid; place-items: center; }
.steps li strong { display: block; color: var(--text); margin-bottom: 2px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px 18px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 600; padding: 10px 0; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq summary::after { content: "+"; color: var(--muted); font-size: 1.2rem; }
.faq details[open] summary::after { content: "−"; }
.faq summary::-webkit-details-marker { display: none; }
.faq details p { color: var(--muted); margin: 0 0 14px; font-size: .95rem; }
.other-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.prose { max-width: 760px; }
.prose h1 { font-size: 2rem; margin-top: 32px; }
.prose h2 { font-size: 1.3rem; margin-top: 1.8em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .3em; }

/* ----- dropzone ----- */
.dropzone { background: var(--surface); border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--border)); border-radius: 20px; padding: 56px 24px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s, transform .15s; color: var(--primary); }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 4%, var(--surface)); outline: none; }
.dropzone.dragover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); transform: scale(1.01); }
.dropzone h2 { color: var(--text); font-size: 1.35rem; margin: 12px 0 4px; }
.dropzone .hint { color: var(--muted); font-size: .85rem; margin: 16px 0 0; }
.tool-work.dragover { outline: 2px dashed var(--primary); outline-offset: 6px; border-radius: 12px; }

/* ----- buttons ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer; transition: background .15s, transform .05s, box-shadow .15s; line-height: 1.2; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary) 60%, transparent); }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-block { width: 100%; margin-top: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.btn-row .btn { flex: 1; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--muted); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 1rem; display: grid; place-items: center; }
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.link-btn { background: none; border: 0; color: var(--primary); font: inherit; font-size: .9rem; cursor: pointer; margin-left: auto; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ----- workspace ----- */
.tool-work { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .tool-work { grid-template-columns: 1fr; } }
.tool-files { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-height: 240px; }
.tool-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: sticky; top: 76px; }
.files-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: .9rem; margin-bottom: 12px; font-weight: 600; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); cursor: grab; }
.file-item.sortable-ghost { opacity: .4; }
.file-icon { flex: none; font-size: .65rem; font-weight: 800; color: #fff; background: var(--danger); border-radius: 6px; padding: 6px 7px; letter-spacing: .03em; }
.file-icon.img { background: #0ea5e9; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .95rem; }
.file-meta { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.tool-options { display: grid; gap: 14px; margin-bottom: 6px; }
.field { display: grid; gap: 5px; }
.field-label { font-size: .85rem; font-weight: 700; color: var(--muted); }
.field-hint { color: var(--muted); font-size: .78rem; }
.field input[type="text"], .field input[type="number"], .field select { width: 100%; font: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.field input:focus, .field select:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
.field input[type="color"] { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 2px; }
.field input[type="range"] { width: 100%; accent-color: var(--primary); }

/* ----- page grid ----- */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.page-cell { position: relative; border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--surface-2); text-align: center; cursor: grab; transition: opacity .15s; }
.page-cell.deleted { opacity: .35; }
.page-cell.deleted .thumb-wrap::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top right, transparent 48%, var(--danger) 49%, var(--danger) 51%, transparent 52%); }
.page-cell.sortable-ghost { opacity: .3; border-color: var(--primary); }
.thumb-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden; }
.thumb-img { display: grid; place-items: center; width: 100%; height: 100%; transition: transform .2s; }
.thumb-img > * { max-width: 100%; max-height: 100%; }
.thumb-img canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; box-shadow: 0 1px 4px rgba(0,0,0,.25); background: #fff; }
.thumb-skeleton { width: 70%; height: 90%; background: linear-gradient(90deg, var(--border), var(--surface), var(--border)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 4px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.page-num { display: block; margin-top: 8px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.page-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.page-cell:hover .page-actions, .page-cell:focus-within .page-actions { opacity: 1; }
@media (hover: none) { .page-actions { opacity: 1; } }
.grid-loading { display: grid; place-items: center; min-height: 200px; }

/* ----- status ----- */
.status-box { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 48px 24px; text-align: center; display: grid; justify-items: center; gap: 10px; }
.status-box h2 { margin: 6px 0 0; }
.status-box .btn + .btn { margin-top: 4px; }
.spinner { width: 44px; height: 44px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar { width: min(420px, 100%); height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--primary); transition: width .2s; }
.check { width: 60px; height: 60px; border-radius: 50%; background: var(--success); color: #fff; font-size: 2rem; font-weight: 800; display: grid; place-items: center; }
.status-box.error .check { background: var(--danger); }
.file-name-big { font-weight: 700; word-break: break-all; margin: 0; }
.size-compare { color: var(--muted); font-size: .95rem; }
.size-compare strong { color: var(--success); }

/* ----- ads ----- */
.ad-slot { margin: 24px auto; text-align: center; overflow: hidden; }
.ad-slot iframe { max-width: 100%; border: 0; display: block; margin: 0 auto; }
.ad-slot--placeholder { border: 2px dashed var(--border); border-radius: 12px; min-height: 120px; display: grid; place-items: center; align-content: center; color: var(--muted); font-size: .85rem; background: var(--surface); }
.ad-slot--placeholder small { opacity: .6; }
.ad-slot[data-ad="sidebar"].ad-slot--placeholder { min-height: 600px; }

/* ----- footer ----- */
.site-footer { margin-top: 64px; border-top: 1px solid var(--border); background: var(--surface); padding: 40px 0 24px; font-size: .9rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr; gap: 20px; } }
.site-footer h4 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .8em; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.site-footer a { color: var(--text); }
.footer-brand p { color: var(--muted); margin-top: 10px; max-width: 360px; }
.footer-bottom { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; }
.footer-bottom p { margin: 0 0 6px; }
.disclosure { font-style: italic; }

/* ----- toast ----- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ----- integrated editor ----- */
.ed-app { position: relative; }
.ed-topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; position: sticky; top: 64px; z-index: 20; }
.ed-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ed-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-meta { font-size: .8rem; }
.ed-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-actions .btn { padding: 9px 14px; font-size: .9rem; }
.ed-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .ed-body { grid-template-columns: 1fr; } .ed-topbar { top: 60px; } }
.ed-pages { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-height: 320px; }
.ed-grid .page-cell { cursor: pointer; }
.ed-grid .page-cell.selected { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); background: color-mix(in srgb, var(--primary) 6%, var(--surface-2)); }
.page-check { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: .8rem; font-weight: 800; display: none; place-items: center; }
.page-cell.selected .page-check { display: grid; }
.ed-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; position: sticky; top: 140px; }
@media (max-width: 900px) { .ed-side { position: static; } }
.ed-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ed-tab { border: 0; background: none; padding: 10px 4px; font: inherit; font-size: .78rem; font-weight: 600; color: var(--muted); cursor: pointer; display: grid; justify-items: center; gap: 2px; border-bottom: 2px solid transparent; }
.ed-tab-icon { font-size: 1.1rem; }
.ed-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--surface); }
.ed-tab:hover { color: var(--text); }
.ed-panel { padding: 16px; display: grid; gap: 12px; }
.ed-panel h4 { margin: 0; font-size: .9rem; }
.ed-panel .btn-row { margin: 0; }
.ed-export { display: grid; gap: 8px; }
.ed-export .btn-block { margin-top: 0; }
.ed-overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(3px); z-index: 90; display: grid; place-items: center; padding: 16px; }
.ed-overlay .status-box { width: min(420px, 100%); padding: 32px 24px; }
.ed-modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 95; display: none; flex-direction: column; align-items: center; padding: 16px; overflow: auto; }
.ed-modal.open { display: flex; }
.ed-modal-bar { display: flex; align-items: center; gap: 8px; color: #fff; margin-bottom: 12px; }
.ed-modal-bar .btn { color: #fff; background: rgba(255,255,255,.12); border-color: transparent; }
.ed-modal-title { min-width: 80px; text-align: center; font-weight: 600; }
.ed-modal-body { display: grid; place-items: center; }
.ed-modal-body canvas { height: auto; box-shadow: 0 10px 40px rgba(0,0,0,.5); background: #fff; transition: transform .2s; }
.tool-card.featured { grid-column: 1 / -1; display: flex; align-items: center; gap: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), var(--surface)); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.tool-card.featured h3 { margin: 0 0 4px; font-size: 1.25rem; }
.tool-card.featured .tool-card-icon { flex: none; }
.tool-card.featured .cta { margin-left: auto; white-space: nowrap; }
@media (max-width: 640px) { .tool-card.featured { flex-wrap: wrap; } .tool-card.featured .cta { margin-left: 0; width: 100%; } }
.hero-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 18px 0 8px; }

/* ----- guides ----- */
.guide-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.guide-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; color: var(--text); transition: transform .15s, box-shadow .15s, border-color .15s; }
.guide-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); text-decoration: none; }
.guide-card h3 { font-size: 1.02rem; margin: 0 0 6px; }
.guide-card p { color: var(--muted); font-size: .88rem; margin: 0; }
.guide-card .tag { display: inline-block; font-size: .72rem; font-weight: 700; color: var(--primary); background: var(--primary-soft); border-radius: 999px; padding: 2px 9px; margin-bottom: 8px; }
article.guide { max-width: 760px; }
article.guide h1 { font-size: clamp(1.6rem, 3.2vw, 2.1rem); margin-top: 28px; }
article.guide .byline { color: var(--muted); font-size: .85rem; margin-bottom: 24px; }
article.guide h2 { font-size: 1.25rem; margin-top: 1.8em; }
article.guide p, article.guide li { font-size: 1.02rem; line-height: 1.8; }
article.guide code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: .9em; }
.related-tools { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin: 32px 0; }
.related-tools h3 { font-size: 1rem; margin-bottom: 10px; }
.related-tools .other-tools { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.guide-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
