/* NearPDF — tokens and layout carried over from the approved wireframe. */
:root{
  --bg:#fafafa;
  --surface:#ffffff;
  --ink:#14171a;
  --ink-soft:#5b6470;
  --line:#e3e6ea;
  --accent:#1f3a5f;
  --accent-soft:#eaf0f7;
  --ok:#2f7a55;
  --ad:#f4f5f7;
  --ad-line:#c9ced6;
}
*{box-sizing:border-box;}
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:'Inter',system-ui,-apple-system,sans-serif;
  -webkit-font-smoothing:antialiased;
}
.mono{
  font-family:'IBM Plex Mono','SFMono-Regular',Consolas,monospace;
  letter-spacing:-0.01em;
}
/* Korean must never break mid-word (브라우저 → 브라/우저) — wrap on spaces only */
:lang(ko){word-break:keep-all; overflow-wrap:break-word;}
[hidden]{display:none !important;}
.visually-hidden{
  position:absolute; width:1px; height:1px; margin:-1px; padding:0;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* ================= SCREEN 1: LANDING ================= */
.page{max-width:1000px; margin:0 auto; padding:0 24px;}
/* Sticky global header — brand + language stay pinned while the page scrolls */
.site-head{
  position:sticky; top:0; z-index:45;
  background:rgba(250,250,250,.9);
  backdrop-filter:saturate(150%) blur(10px);
  -webkit-backdrop-filter:saturate(150%) blur(10px);
  border-bottom:1px solid var(--line);
}
.head-inner{
  display:flex; align-items:center; justify-content:space-between;
  padding-top:13px; padding-bottom:13px;
}
.wordmark{font-weight:700; font-size:16px; letter-spacing:-0.02em;}
.wordmark a{color:inherit; text-decoration:none;}
.head-right{display:flex; align-items:center; gap:14px;}
@media (max-width:520px){ .head-right .mono{display:none;} }

/* Header language dropdown */
.lang-menu{position:relative;}
.lang-menu summary{
  list-style:none; cursor:pointer; user-select:none;
  font-size:12.5px; color:var(--ink);
  border:1px solid var(--line); border-radius:6px;
  padding:6px 26px 6px 12px; background:var(--surface);
  position:relative;
}
.lang-menu summary::-webkit-details-marker{display:none;}
.lang-menu summary::after{
  content:""; position:absolute; right:11px; top:50%;
  width:6px; height:6px;
  border-right:1.5px solid var(--ink-soft); border-bottom:1.5px solid var(--ink-soft);
  transform:translateY(-70%) rotate(45deg);
}
.lang-menu[open] summary{border-color:var(--accent);}
.lang-menu nav{
  position:absolute; right:0; top:calc(100% + 6px); z-index:55;
  display:flex; flex-direction:column; min-width:150px;
  background:var(--surface); border:1px solid var(--line); border-radius:8px;
  box-shadow:0 8px 24px rgba(20,23,26,.12); padding:6px;
}
.lang-menu nav a{
  padding:7px 10px; font-size:13px; color:var(--ink);
  text-decoration:none; border-radius:5px;
}
.lang-menu nav a:hover{background:var(--accent-soft); color:var(--accent);}
.site-head .mono{font-size:12px; color:var(--ink-soft);}

.hero{padding:64px 0 20px; text-align:center;}
.hero h1{
  font-size:clamp(32px,5vw,52px);
  line-height:1.08;
  letter-spacing:-0.03em;
  font-weight:700;
  margin:0 0 18px;
  text-wrap:balance;
}
.hero p{
  font-size:17px; color:var(--ink-soft); max-width:520px;
  margin:0 auto 40px; line-height:1.55;
  text-wrap:pretty;
}

.dropzone{
  max-width:640px; margin:0 auto;
  border:1.5px dashed var(--line);
  border-radius:12px;
  padding:56px 24px;
  text-align:center;
  background:var(--surface);
  transition:border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-within{border-color:var(--accent); background:var(--accent-soft);}
/* Whole screen highlights while a file is dragged over it */
.screen.dragover .dropzone{border-color:var(--accent); background:var(--accent-soft);}
.screen.dragover{outline:2px dashed var(--accent); outline-offset:-10px;}
.dropzone .glyph{
  width:34px; height:34px; margin:0 auto 18px;
  border:1.5px solid var(--ink); border-radius:4px;
  position:relative;
}
.dropzone .glyph::after{
  content:""; position:absolute; left:50%; top:50%;
  width:12px; height:12px; border-left:1.5px solid var(--ink); border-bottom:1.5px solid var(--ink);
  transform:translate(-50%,-65%) rotate(-45deg); /* ∨ (drop-in arrow) — 45deg rendered as "<" */
}
.dropzone .primary{font-size:16px; font-weight:600; margin-bottom:6px;}
.dropzone .secondary{font-size:13px; color:var(--ink-soft); margin-bottom:18px;}
.browse-btn{
  background:var(--ink); color:#fff; border:none;
  padding:11px 22px; border-radius:6px; font-size:14px; font-weight:600;
  font-family:inherit; cursor:pointer;
}
.browse-btn:focus-visible{outline:2px solid var(--accent); outline-offset:2px;}

.trust-line{
  text-align:center; margin:18px 0 0;
  font-size:12.5px; color:var(--ink-soft);
}
.trust-line .mono{color:var(--ok);}

.tool-nav{
  display:flex; gap:8px; justify-content:center; flex-wrap:wrap;
  margin:26px auto 0; max-width:640px;
}
.tool-nav a, .tool-nav .active{
  font-size:13px; text-decoration:none; padding:7px 14px; border-radius:999px;
  border:1px solid var(--line); color:var(--ink-soft); background:var(--surface);
}
.tool-nav a:hover{border-color:var(--accent); color:var(--accent);}
.tool-nav .active{background:var(--accent-soft); border-color:var(--accent); color:var(--accent); font-weight:600;}

.ad-native{
  max-width:640px; margin:44px auto; padding:16px 18px;
  background:var(--ad); border:1px solid var(--ad-line); border-radius:8px;
  display:flex; align-items:center; gap:14px;
}
.ad-native .tag, .ad-below .tag{
  font-size:10px; text-transform:uppercase; letter-spacing:.08em;
  color:var(--ink-soft); border:1px solid var(--ad-line);
  padding:2px 6px; border-radius:3px; flex-shrink:0;
}
.ad-native .body{font-size:13px; color:var(--ink-soft);}

.seo-block{
  border-top:1px solid var(--line);
  margin-top:56px; padding:44px 0;
}
.seo-block h2{font-size:20px; margin:0 0 14px; text-wrap:balance;}
.seo-block p{font-size:14.5px; color:var(--ink-soft); line-height:1.7; max-width:680px; text-wrap:pretty;}
.faq-item{padding:16px 0; border-top:1px solid var(--line);}
.faq-item summary{font-size:14.5px; font-weight:600; cursor:pointer;}
.faq-item p{margin:10px 0 0;}

.site-foot{
  border-top:1px solid var(--line);
  padding:28px 0 100px;
  display:flex; justify-content:space-between; gap:20px; flex-wrap:wrap;
  font-size:12.5px; color:var(--ink-soft);
}
.site-foot a{color:var(--ink-soft);}
.foot-links{display:flex; gap:16px; flex-wrap:wrap;}

.lang-suggest{
  display:flex; align-items:center; justify-content:center; gap:14px;
  background:var(--accent-soft); border-bottom:1px solid var(--line);
  padding:9px 16px; font-size:13px;
}
.lang-suggest a{color:var(--accent); font-weight:600; text-decoration:none;}
.lang-suggest button{
  background:none; border:none; color:var(--ink-soft);
  font-size:13px; cursor:pointer; padding:2px 6px;
}

/* While the workspace action bar is visible, the banner sits above it (never covers Merge) */
body:has(#screen-workspace:not([hidden])) .cookie-banner{
  bottom:calc(80px + env(safe-area-inset-bottom));
}
.cookie-banner{
  position:fixed; left:0; right:0; bottom:0; z-index:60;
  background:var(--ink); color:#fff;
  padding:14px 24px;
  display:flex; align-items:center; gap:18px; flex-wrap:wrap;
  font-size:13px;
}
.cookie-banner p{margin:0; flex:1; min-width:220px; opacity:.85;}
.cookie-banner a{color:#fff;}
.cookie-dismiss{
  flex-shrink:0; background:transparent; border:1px solid rgba(255,255,255,.35);
  color:#fff; width:30px; height:30px; border-radius:50%;
  font-family:inherit; font-size:13px; cursor:pointer;
}
.cookie-dismiss:hover{background:rgba(255,255,255,.12);}

/* ================= SCREEN 2: WORKSPACE ================= */
.ws-shell{max-width:1100px; margin:0 auto; padding:0 24px 120px;}
.ws-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:24px 0; border-bottom:1px solid var(--line);
}
.ws-head .left{display:flex; align-items:center; gap:14px;}
.ws-head-actions{display:flex; gap:8px;}
.back{font-size:13px; color:var(--ink-soft); text-decoration:none;}
.filecount{font-size:13px; font-weight:600;}
.skip-btn{
  background:transparent; border:1px solid var(--line); color:var(--ink);
  padding:9px 16px; border-radius:6px; font-family:inherit; font-size:13px; cursor:pointer;
}

.ws-layout{
  display:grid; grid-template-columns:1fr 220px; gap:28px; padding-top:28px;
}
.thumb-grid{
  display:grid; grid-template-columns:repeat(auto-fill,minmax(110px,1fr)); gap:16px;
}
.thumb{
  aspect-ratio:3/4; background:var(--surface); border:1px solid var(--line);
  border-radius:6px; position:relative; cursor:grab;
  display:flex; align-items:flex-end; justify-content:center;
  padding-bottom:10px;
}
.thumb::before{
  content:""; position:absolute; top:10px; left:10px; right:10px; bottom:24px;
  background:repeating-linear-gradient(180deg, var(--line) 0 2px, transparent 2px 8px);
  border-radius:2px;
}
.thumb canvas{
  position:absolute; top:10px; left:10px; right:10px; bottom:24px;
  width:calc(100% - 20px); height:calc(100% - 34px);
  object-fit:contain; background:var(--surface); z-index:1;
}
.thumb .pagenum{
  font-size:11px; color:var(--ink-soft); z-index:1;
  max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding:0 6px;
}
.thumb.dragging{opacity:.35; cursor:grabbing;}
.thumb:active{cursor:grabbing;}

/* Click-to-zoom lightbox */
.zoom-overlay{
  position:fixed; inset:0; z-index:70;
  background:rgba(20,23,26,.78);
  display:flex; align-items:center; justify-content:center;
  cursor:zoom-out;
}
.zoom-overlay canvas{
  max-width:92vw; max-height:86vh; width:auto; height:auto;
  background:var(--surface); border-radius:4px;
  box-shadow:0 10px 40px rgba(0,0,0,.45);
}
.zoom-close{
  position:fixed; top:14px; right:16px;
  width:36px; height:36px; border-radius:50%;
  background:rgba(255,255,255,.12); border:1px solid rgba(255,255,255,.35);
  color:#fff; font-size:15px; cursor:pointer;
}
.zoom-nav{
  position:fixed; top:50%; transform:translateY(-50%);
  width:44px; height:44px; border-radius:50%;
  background:rgba(255,255,255,.12); border:1px solid rgba(255,255,255,.35);
  color:#fff; font-size:24px; line-height:1; cursor:pointer;
}
.zoom-nav:disabled{opacity:.25; cursor:default;}
.zoom-prev{left:16px;}
.zoom-next{right:16px;}
.zoom-counter{
  position:fixed; bottom:18px; left:50%; transform:translateX(-50%);
  color:#fff; font-size:13px; opacity:.85;
  background:rgba(20,23,26,.6); padding:5px 12px; border-radius:999px;
}
.thumb:focus-visible{outline:2px solid var(--accent); outline-offset:2px;}
.thumb-controls{
  position:absolute; top:4px; right:4px; z-index:2;
  display:none; gap:2px;
}
.thumb:hover .thumb-controls, .thumb:focus-within .thumb-controls{display:flex;}
.thumb-controls button{
  font-family:inherit; font-size:11px; line-height:1;
  width:22px; height:22px; padding:0;
  background:var(--surface); border:1px solid var(--line); border-radius:4px;
  color:var(--ink); cursor:pointer;
}
.thumb-controls button:hover{border-color:var(--accent); color:var(--accent);}
@media (hover:none){ .thumb-controls{display:flex;} }

/* Desktop sticky side ad — fixed 220×600 reservation prevents CLS */
.ad-side{
  position:sticky; top:24px; align-self:start;
  width:220px; height:600px;
  background:var(--ad); border:1px solid var(--ad-line); border-radius:8px;
}

.ws-actionbar{
  position:fixed; left:0; right:0; bottom:0;
  background:var(--surface); border-top:1px solid var(--line);
  padding:16px 24px; display:flex; justify-content:center; z-index:40;
}
.merge-btn{
  background:var(--accent); color:#fff; border:none;
  padding:13px 34px; border-radius:7px; font-size:15px; font-weight:600;
  font-family:inherit; cursor:pointer;
}
.merge-btn:disabled{opacity:.55; cursor:progress;}
.wm-input{
  font-family:inherit; font-size:14px; padding:12px 16px; border-radius:7px;
  border:1px solid var(--line); background:var(--surface); color:var(--ink);
  min-width:min(260px,50vw); margin-right:12px;
}
.wm-input:focus{outline:2px solid var(--accent); outline-offset:1px;}
/* Watermark text box shows only on the watermark tool */
html:not([data-tool="watermark"]) #watermark-input{display:none;}
/* Grid layout controls show only on the receipt-grid tool */
html:not([data-tool="grid"]) .grid-select{display:none;}
.grid-check{display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--ink); cursor:pointer;}
.grid-check input{width:16px; height:16px; accent-color:var(--accent);}

/* Mobile anchor ad — replaces the side ad below the breakpoint */
.ad-anchor{
  position:fixed; left:0; right:0; bottom:64px; z-index:39;
  background:var(--ad); border-top:1px solid var(--ad-line);
  min-height:50px;
}
@media (min-width:761px){ .ad-anchor{display:none !important;} }

/* ================= SCREEN 3: DOWNLOAD ================= */
.dl-shell{max-width:640px; margin:0 auto; padding:80px 24px 60px; text-align:center;}
.dl-check{
  width:46px; height:46px; margin:0 auto 22px;
  border:1.5px solid var(--ok); border-radius:50%;
  position:relative;
}
.dl-check::after{
  content:""; position:absolute; left:32%; top:48%;
  width:6px; height:12px; border-right:2px solid var(--ok); border-bottom:2px solid var(--ok);
  transform:translate(-50%,-60%) rotate(45deg);
}
.dl-shell h1{font-size:26px; margin:0 0 10px; letter-spacing:-0.02em;}
.dl-stats{
  font-size:13px; color:var(--ink-soft); margin-bottom:36px;
}

.download-btn{
  background:var(--ink); color:#fff; border:none;
  padding:15px 40px; border-radius:7px; font-size:16px; font-weight:600;
  font-family:inherit; cursor:pointer; margin-bottom:8px;
}
.dl-filesize{font-size:12px; color:var(--ink-soft); margin-bottom:56px;}

.other-tools{
  border-top:1px solid var(--line); padding-top:28px; margin-bottom:40px;
}
.other-tools p{font-size:12px; color:var(--ink-soft); margin:0 0 14px; text-transform:uppercase; letter-spacing:.06em;}
.tool-links{display:flex; gap:10px; justify-content:center; flex-wrap:wrap;}
.tool-links a{
  font-size:13px; color:var(--ink); text-decoration:none;
  border:1px solid var(--line); padding:8px 14px; border-radius:6px;
}

/* Ad zone below the fold, well clear of the Download button (mis-click safe) */
.ad-below{
  margin:0 auto 36px; max-width:560px; min-height:120px;
  background:var(--ad); border:1px solid var(--ad-line); border-radius:8px;
  padding:22px; font-size:12px; color:var(--ink-soft);
}

/* ================= DESIGNER (free-form layout editor) ================= */
.design-toolbar{
  position:sticky; top:0; z-index:44;
  background:var(--surface); border-bottom:1px solid var(--line); padding:10px 0;
}
.dz-tools{display:flex; gap:8px; flex-wrap:wrap; align-items:center;}
.dz-btn{
  font-family:inherit; font-size:13px; padding:8px 14px; border-radius:6px;
  border:1px solid var(--line); background:var(--surface); color:var(--ink); cursor:pointer;
}
.dz-btn:hover:not(:disabled){border-color:var(--accent); color:var(--accent);}
.dz-btn:disabled{opacity:.45; cursor:default;}
.dz-primary{background:var(--accent); color:#fff; border-color:var(--accent); font-weight:600; margin-left:auto;}
.dz-primary:hover:not(:disabled){color:#fff;}
.design-canvas-wrap{
  display:flex; justify-content:center; padding:28px 20px;
  background:var(--bg); min-height:60vh;
}
.design-stage{
  position:relative; background:#fff;
  box-shadow:0 4px 24px rgba(20,23,26,.14); border:1px solid var(--line);
  overflow:hidden; touch-action:none;
}
.dz-obj{position:absolute; cursor:move; outline:1px dashed transparent;}
.dz-obj.selected{outline:1.5px solid var(--accent);}
.dz-obj img{width:100%; height:100%; display:block; pointer-events:none; user-select:none;}
.dz-text{width:100%; height:100%; outline:none; color:var(--ink); line-height:1.1; overflow:hidden;}
.dz-resize{
  position:absolute; right:-6px; bottom:-6px; width:14px; height:14px;
  background:var(--accent); border:2px solid #fff; border-radius:50%; cursor:nwse-resize;
  opacity:0;
}
.dz-obj.selected .dz-resize{opacity:1;}
.design-hint{text-align:center; color:var(--ink-soft); font-size:12.5px; padding:0 24px 40px;}
@media (max-width:520px){ .dz-primary{margin-left:0;} }

/* ================= RESPONSIVE ================= */
@media (max-width:760px){
  .ws-layout{grid-template-columns:1fr;}
  .ad-side{display:none !important;}
  .ws-actionbar{padding-bottom:calc(16px + env(safe-area-inset-bottom));}
}
@media (max-width:520px){
  .cookie-banner{padding:12px 16px;}
}
@media (prefers-reduced-motion:reduce){
  *{transition:none !important;}
}
