/* Savenz PDF: one stylesheet for every page. Light and dark follow the device unless the visitor picks one. */
:root {
  --sky: #2fa6ff;
  --fill: #1463f3;
  --ok: #10a36a;
  --warn: #c77a05;
  --bad: #e23b42;
  --bg: #f2f6fc;
  --bg2: #e7eff9;
  --card: #ffffff;
  --card2: #f6f9fe;
  --line: #dbe5f2;
  --line2: #c9d7ea;
  --text: #0c1830;
  --muted: #4f6080;
  --dim: #7a8aa6;
  --glow: rgba(47, 166, 255, .22);
  --shadow: 0 1px 2px rgba(12, 30, 70, .06), 0 8px 24px -12px rgba(12, 30, 70, .18);
  --shadow2: 0 2px 4px rgba(12, 30, 70, .06), 0 22px 40px -18px rgba(20, 99, 243, .35);
  --page: #ffffff;
  --checker: #e9eef6;
  --fb: "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  --fd: "Kanit", "IBM Plex Sans Thai", system-ui, sans-serif;
  --r: 16px;
  --spring: cubic-bezier(.2, .9, .3, 1.2);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #050a16; --bg2: #0a1325; --card: #0c1529; --card2: #101b33; --line: #1a2945; --line2: #253859;
    --text: #e8f0ff; --muted: #a1b2cf; --dim: #7486a6; --glow: rgba(47, 166, 255, .16);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .7);
    --shadow2: 0 2px 4px rgba(0, 0, 0, .3), 0 24px 44px -18px rgba(20, 99, 243, .45);
    --checker: #172036; --ok: #2fd08f; --warn: #ffb547; --bad: #ff6066;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #050a16; --bg2: #0a1325; --card: #0c1529; --card2: #101b33; --line: #1a2945; --line2: #253859;
  --text: #e8f0ff; --muted: #a1b2cf; --dim: #7486a6; --glow: rgba(47, 166, 255, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .7);
  --shadow2: 0 2px 4px rgba(0, 0, 0, .3), 0 24px 44px -18px rgba(20, 99, 243, .45);
  --checker: #172036; --ok: #2fd08f; --warn: #ffb547; --bad: #ff6066;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: var(--fb); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
body::before {
  content: ""; position: fixed; inset: -20vh -10vw auto; height: 70vh; z-index: -1; pointer-events: none;
  background: radial-gradient(40% 60% at 20% 30%, var(--glow), transparent 70%), radial-gradient(35% 50% at 85% 10%, rgba(20, 99, 243, .14), transparent 70%);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(4vw, 3vh, 0) scale(1.08); } }
a { color: var(--fill); text-decoration: none; }
:root[data-theme="dark"] a { color: var(--sky); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) a { color: var(--sky); } }
h1, h2, h3 { font-family: var(--fd); font-weight: 600; line-height: 1.25; margin: 0; letter-spacing: .1px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, canvas, svg { display: block; max-width: 100%; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Header */
.top { position: sticky; top: 0; z-index: 40; backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.top .wrap { display: flex; align-items: center; gap: 12px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text) !important; font-family: var(--fd); font-size: 21px; font-weight: 600; }
.brand img { width: 34px; height: 34px; transition: transform .5s var(--spring); }
.brand:hover img { transform: rotate(-8deg) scale(1.06); }
.brand b { font-weight: 600; }
.brand span { margin-left: 1px; padding: 0 7px; border-radius: 7px; font-size: 15px; color: #fff; background: linear-gradient(135deg, var(--sky), var(--fill)); }
.top .grow { flex: 1; }
.iconbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--muted); transition: .2s; }
.iconbtn:hover { color: var(--text); border-color: var(--line2); }
.iconbtn svg { width: 20px; height: 20px; }
.toplink { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 12px; color: var(--muted) !important; font-size: 15px; }
.toplink:hover { color: var(--text) !important; background: var(--card); }

/* Home */
.hero { padding: 46px 0 18px; text-align: center; }
.hero h1 { font-size: clamp(27px, 5.4vw, 52px); font-weight: 700; text-wrap: balance; }
.hero h1 em { font-style: normal; background: linear-gradient(100deg, var(--sky), var(--fill) 70%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 12px auto 0; max-width: 620px; color: var(--muted); font-size: 17px; }
.trust { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.trust span { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; font-size: 14px; color: var(--muted); background: var(--card); border: 1px solid var(--line); }
.trust svg { width: 16px; height: 16px; color: var(--ok); }
.finder { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 26px 0 8px; }
.search { position: relative; flex: 1 1 280px; max-width: 420px; }
.search input { width: 100%; height: 46px; padding: 0 16px 0 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); outline: none; transition: .2s; }
.search input:focus { border-color: var(--sky); box-shadow: 0 0 0 4px var(--glow); }
.search svg { position: absolute; left: 14px; top: 13px; width: 20px; height: 20px; color: var(--dim); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 14.5px; transition: .2s; }
.chip:hover { color: var(--text); }
.chip.on { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--sky), var(--fill)); box-shadow: 0 6px 16px -8px var(--fill); }
.group { margin-top: 26px; }
.group h2 { display: flex; align-items: center; gap: 10px; font-size: 18px; color: var(--muted); font-weight: 500; margin-bottom: 12px; }
.group h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tool {
  --c: var(--fill); position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: var(--r); overflow: hidden;
  background: var(--card); border: 1px solid var(--line); color: var(--text) !important; box-shadow: var(--shadow);
  transition: translate .45s var(--spring), border-color .25s, box-shadow .35s;
  animation: rise .6s var(--spring) both; animation-delay: calc(var(--i, 0) * 28ms);
}
.tool::after { content: ""; position: absolute; inset: auto -30% -60% auto; width: 160px; height: 160px; border-radius: 50%; background: var(--c); opacity: 0; filter: blur(40px); transition: opacity .35s; }
.tool:hover { translate: 0 -4px; border-color: color-mix(in srgb, var(--c) 55%, var(--line)); box-shadow: 0 2px 4px rgba(0,0,0,.05), 0 20px 36px -20px var(--c); }
.tool:hover::after { opacity: .18; }
.tool:active { translate: 0 -1px; }
.tool .ic { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: #fff;
  background: linear-gradient(140deg, color-mix(in srgb, var(--c) 70%, #fff) -20%, var(--c) 60%, color-mix(in srgb, var(--c) 80%, #000)); box-shadow: 0 8px 18px -10px var(--c), inset 0 1px 0 rgba(255,255,255,.35); transition: transform .45s var(--spring); }
.tool:hover .ic { transform: scale(1.08) rotate(-4deg); }
.tool .ic svg { width: 25px; height: 25px; }
.tool h3 { font-size: 17.5px; font-weight: 500; }
.tool p { margin: 3px 0 0; font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.tool .tag { position: absolute; top: 10px; right: 10px; padding: 1px 8px; border-radius: 999px; font-size: 12px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
@keyframes rise { from { opacity: 0; translate: 0 14px; } }
.empty { padding: 40px 0; text-align: center; color: var(--dim); }
.soon { margin-top: 28px; padding: 16px 18px; border-radius: var(--r); border: 1px dashed var(--line2); color: var(--muted); font-size: 15px; display: flex; gap: 12px; align-items: center; }
.soon svg { flex: none; width: 22px; height: 22px; color: var(--sky); }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 48px; }
.how div { padding: 18px; border-radius: var(--r); background: var(--card2); border: 1px solid var(--line); }
.how b { display: block; font-family: var(--fd); font-weight: 500; font-size: 17px; margin-bottom: 4px; }
.how p { margin: 0; font-size: 14.5px; color: var(--muted); }
.foot { margin-top: 56px; padding: 26px 0 40px; border-top: 1px solid var(--line); color: var(--dim); font-size: 14px; }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: space-between; }
.foot a { color: var(--dim) !important; }
.foot a:hover { color: var(--text) !important; }

/* Tool page */
.tp { padding: 22px 0 120px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted) !important; font-size: 15px; padding: 4px 0; }
.back:hover { color: var(--text) !important; }
.back svg { width: 18px; height: 18px; }
.tphead { display: flex; gap: 16px; align-items: center; margin: 12px 0 20px; }
.tphead .ic { flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 17px; color: #fff;
  background: linear-gradient(140deg, color-mix(in srgb, var(--c) 70%, #fff) -20%, var(--c) 60%, color-mix(in srgb, var(--c) 80%, #000)); box-shadow: 0 10px 24px -12px var(--c); }
.tphead .ic svg { width: 29px; height: 29px; }
.tphead h1 { font-size: clamp(24px, 4vw, 32px); }
.tphead p { margin: 2px 0 0; color: var(--muted); }

.drop {
  position: relative; display: grid; place-items: center; gap: 10px; padding: 46px 20px; border-radius: 22px; text-align: center;
  border: 2px dashed color-mix(in srgb, var(--c, var(--sky)) 45%, var(--line)); background: color-mix(in srgb, var(--c, var(--sky)) 5%, var(--card)); transition: .25s;
}
.drop.over { border-color: var(--c, var(--sky)); background: color-mix(in srgb, var(--c, var(--sky)) 12%, var(--card)); transform: scale(1.01); }
.drop .big { display: grid; place-items: center; width: 74px; height: 74px; border-radius: 22px; color: var(--c, var(--sky)); background: color-mix(in srgb, var(--c, var(--sky)) 14%, transparent); animation: bob 3.2s ease-in-out infinite; }
.drop .big svg { width: 38px; height: 38px; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.drop .hint { color: var(--muted); font-size: 15px; }
.drop .btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.privacy { display: inline-flex; gap: 7px; align-items: center; margin-top: 6px; font-size: 13.5px; color: var(--dim); }
.privacy svg { width: 15px; height: 15px; color: var(--ok); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 13px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 500; font-size: 15.5px; white-space: nowrap;
  transition: transform .2s var(--spring), box-shadow .2s, background .2s, border-color .2s, opacity .2s;
}
.btn:hover { border-color: var(--line2); }
.btn:active { transform: scale(.97); }
.btn svg { width: 19px; height: 19px; flex: none; }
.btn.pri { color: #fff; border: 0; background: linear-gradient(135deg, var(--sky), var(--fill)); box-shadow: 0 10px 22px -12px var(--fill), inset 0 1px 0 rgba(255,255,255,.25); }
.btn.pri:hover { box-shadow: 0 14px 28px -12px var(--fill), inset 0 1px 0 rgba(255,255,255,.25); filter: brightness(1.05); }
.btn.big { min-height: 54px; padding: 12px 26px; font-size: 17px; border-radius: 15px; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--card2); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.work { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.work.single { grid-template-columns: minmax(0, 1fr); }
.main { min-width: 0; }
.side { position: sticky; top: 78px; display: grid; gap: 14px; padding: 18px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.side h3 { font-size: 16px; font-weight: 500; }
.side .sub { font-size: 13.5px; color: var(--dim); margin-top: -8px; }
.field { display: grid; gap: 7px; }
.field > label, .field > .lbl { font-size: 14px; color: var(--muted); }
.field .note { font-size: 13px; color: var(--dim); }
.warn { font-size: 13.5px; color: var(--warn); display: flex; gap: 6px; align-items: flex-start; }
.warn svg { flex: none; width: 16px; height: 16px; margin-top: 3px; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 9px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); outline: none; transition: .2s; }
.input:focus { border-color: var(--sky); box-shadow: 0 0 0 4px var(--glow); }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.6; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 13px; background: var(--card2); border: 1px solid var(--line); }
.seg button { flex: 1 1 auto; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 14px; transition: .2s; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.1), 0 4px 12px -6px rgba(20, 99, 243, .5); }
:root[data-theme="dark"] .seg button.on { background: #1a2a48; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button.on { background: #1a2a48; } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.range { display: flex; gap: 10px; align-items: center; }
.range input { flex: 1; accent-color: var(--fill); }
.range output { min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; cursor: pointer; user-select: none; }
.check input { width: 20px; height: 20px; accent-color: var(--fill); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line2); }
.swatches button.on { box-shadow: 0 0 0 2px var(--sky); }
.posgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 150px; padding: 8px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); aspect-ratio: 3 / 3.6; }
.posgrid button { border: 0; border-radius: 8px; background: transparent; position: relative; }
.posgrid button::after { content: ""; position: absolute; inset: 35%; border-radius: 4px; background: var(--line2); transition: .2s; }
.posgrid button.on::after { inset: 25%; background: linear-gradient(135deg, var(--sky), var(--fill)); }
.posgrid button:hover::after { background: var(--sky); }
.posgrid .mid { pointer-events: none; }
.posgrid .mid::after { display: none; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.bar .grow { flex: 1; }
.bar .count { color: var(--muted); font-size: 14.5px; }

/* Thumbnail grid */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; user-select: none; -webkit-user-select: none; }
.pg { position: relative; display: grid; gap: 6px; padding: 10px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .3s var(--spring), border-color .2s, box-shadow .2s, opacity .2s; touch-action: manipulation; }
.pg .sheet { position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1.3; border-radius: 8px; background: var(--checker); overflow: hidden; }
.pg canvas, .pg img.thumb { max-width: 100%; max-height: 100%; width: auto; height: auto; background: var(--page); box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: transform .35s var(--spring); }
.pg .num { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); min-height: 22px; }
.pg .num .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg .acts { position: absolute; top: 14px; right: 14px; display: flex; gap: 4px; opacity: 0; transition: opacity .2s; }
.pg:hover .acts, .pg:focus-within .acts { opacity: 1; }
@media (hover: none) { .pg .acts { opacity: 1; } }
.pg .acts button { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--muted); box-shadow: var(--shadow); }
.pg .acts button:hover { color: var(--text); }
.pg .acts button.del:hover { color: var(--bad); }
.pg .acts svg { width: 17px; height: 17px; }
.pg.sel { border-color: var(--sky); box-shadow: 0 0 0 3px var(--glow), var(--shadow); }
.pg .tick { position: absolute; top: 14px; left: 14px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line2); background: var(--card); color: transparent; transition: .2s; }
.pg .tick svg { width: 15px; height: 15px; }
.pg.sel .tick { border-color: transparent; background: linear-gradient(135deg, var(--sky), var(--fill)); color: #fff; }
.pg.gone { opacity: .5; }
.pg.gone .sheet::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--bad) 18%, transparent); }
.pg.gone .tick { border-color: transparent; background: var(--bad); color: #fff; }
.pg.drag { z-index: 30; box-shadow: 0 26px 50px -16px rgba(0,0,0,.45); transform: scale(1.04) rotate(1.5deg); transition: none; pointer-events: none; }
.pg.ph { opacity: .25; border-style: dashed; }
.pg .badge { position: absolute; left: 14px; bottom: 44px; padding: 1px 7px; border-radius: 6px; font-size: 12px; color: #fff; background: var(--c, var(--fill)); }
.pg.blank .sheet::before { content: "หน้าว่าง"; position: absolute; color: var(--dim); font-size: 13px; }
.pg .spin { position: absolute; width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line2); border-top-color: var(--sky); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.addtile { display: grid; place-items: center; gap: 6px; align-content: center; min-height: 200px; border-radius: 14px; border: 2px dashed var(--line2); background: transparent; color: var(--muted); transition: .2s; }
.addtile:hover { border-color: var(--sky); color: var(--sky); }
.addtile svg { width: 30px; height: 30px; }

/* File rows */
.files { display: grid; gap: 10px; }
.frow { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.frow .fi { flex: none; width: 46px; height: 58px; display: grid; place-items: center; border-radius: 8px; background: var(--checker); overflow: hidden; }
.frow .fi canvas, .frow .fi img { max-width: 100%; max-height: 100%; }
.frow .meta { flex: 1; min-width: 0; }
.frow .meta b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .meta span { font-size: 13.5px; color: var(--muted); }
.frow .meta .good { color: var(--ok); }
.frow .meta .bad { color: var(--bad); }

/* Big page view (crop, sign, text) */
.viewer { display: grid; gap: 40px; justify-items: center; padding-top: 22px; }
.vpage { position: relative; max-width: 100%; box-shadow: 0 2px 6px rgba(0,0,0,.12), 0 20px 50px -24px rgba(0,0,0,.4); background: var(--page); touch-action: pan-x pan-y pinch-zoom; }
.vpage > canvas { width: 100%; height: auto; }
.vpage .pno { position: absolute; left: 0; top: -24px; font-size: 13px; color: var(--dim); }
.ann { position: absolute; border: 1.5px dashed transparent; cursor: move; touch-action: none; }
.ann.on { border-color: var(--sky); }
.ann img { width: 100%; height: 100%; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.ann .h { position: absolute; right: -11px; bottom: -11px; width: 22px; height: 22px; border-radius: 50%; background: var(--fill); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); cursor: nwse-resize; display: none; }
.ann .x { position: absolute; right: -12px; top: -12px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; display: none; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.ann .x svg { width: 14px; height: 14px; }
.ann.on .h { display: block; }
.ann.on .x { display: grid; }
.ann .txt { white-space: pre; line-height: 1.25; pointer-events: none; }
.crop { position: absolute; border: 2px solid var(--sky); cursor: move; touch-action: none; }
.cropclip { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.cropshade { position: absolute; box-shadow: 0 0 0 9999px rgba(5, 12, 28, .55); }
.crop i { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--fill); box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.crop i[data-h="nw"] { left: -12px; top: -12px; cursor: nwse-resize; }
.crop i[data-h="ne"] { right: -12px; top: -12px; cursor: nesw-resize; }
.crop i[data-h="sw"] { left: -12px; bottom: -12px; cursor: nesw-resize; }
.crop i[data-h="se"] { right: -12px; bottom: -12px; cursor: nwse-resize; }
.vpagewrap { position: relative; width: 100%; display: grid; justify-items: center; }
.vpage.pick { cursor: crosshair; }
.overlay-wm { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* Editor toolbar (sign, text) */
.tbar { position: sticky; top: 70px; z-index: 20; display: grid; gap: 8px; padding: 8px; margin: 0 0 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.tbar .trow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tbar .trow .seg { flex: 1 1 260px; }

/* Signature pad */
.pad { position: relative; border-radius: 14px; border: 1px solid var(--line); background: #fff; overflow: hidden; touch-action: none; }
.pad canvas { width: 100%; height: 170px; cursor: crosshair; }
.pad .line { position: absolute; left: 18px; right: 18px; bottom: 40px; border-top: 1.5px dashed #c9d4e5; pointer-events: none; }
.pad .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa8bf; pointer-events: none; font-size: 15px; }
.sigs { display: flex; gap: 8px; flex-wrap: wrap; }
.sigs button { position: relative; width: 120px; height: 56px; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 4px; }
.sigs button img { width: 100%; height: 100%; object-fit: contain; }
.sigs button.on { border-color: var(--sky); box-shadow: 0 0 0 3px var(--glow); }
.sigs .rm { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; background: var(--bad); color: #fff; display: grid; place-items: center; font-size: 13px; line-height: 1; }

/* Result */
.result { display: grid; justify-items: center; gap: 14px; padding: 40px 20px; border-radius: 24px; text-align: center; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); animation: rise .6s var(--spring) both; }
.result .okmark { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; color: #fff; background: linear-gradient(135deg, #2fd08f, #10a36a); box-shadow: 0 14px 30px -14px #10a36a; animation: pop .6s var(--spring) both .1s; }
.result .okmark svg { width: 40px; height: 40px; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .5s ease forwards .35s; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.result h2 { font-size: 26px; }
.result .stat { color: var(--muted); }
.result .stat b { color: var(--ok); font-weight: 600; }
.result .btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.result .outs { width: min(560px, 100%); display: grid; gap: 8px; text-align: left; max-height: 340px; overflow: auto; }
.result .next { margin-top: 10px; width: min(720px, 100%); }
.result .next p { color: var(--dim); font-size: 14px; margin: 0 0 8px; }
.result .next .chips { justify-content: center; flex-wrap: wrap; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; width: 100%; }
.gallery a { display: grid; gap: 4px; padding: 8px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); color: var(--muted) !important; font-size: 13px; text-align: center; }
.gallery img { width: 100%; aspect-ratio: 1 / 1.3; object-fit: contain; background: var(--checker); border-radius: 6px; }

/* Busy overlay, toast, modal */
.busy { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
.busy .box { width: min(380px, 100% - 40px); padding: 26px; border-radius: 22px; text-align: center; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow2); }
.busy .ring { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--sky); border-right-color: var(--fill); animation: spin .9s linear infinite; }
.busy .msg { font-weight: 500; }
.busy .sub { margin-top: 2px; font-size: 14px; color: var(--muted); min-height: 22px; }
.meter { height: 8px; margin-top: 14px; border-radius: 99px; background: var(--card2); overflow: hidden; border: 1px solid var(--line); }
.meter i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--sky), var(--fill)); transition: width .25s; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 95; translate: -50% 0; display: flex; gap: 10px; align-items: center; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; color: #fff; background: #12203d; box-shadow: 0 16px 40px -14px rgba(0,0,0,.6); animation: toast .35s var(--spring) both; font-size: 15px; }
.toast.bad { background: #8f1f26; }
.toast svg { width: 19px; height: 19px; flex: none; }
@keyframes toast { from { opacity: 0; translate: -50% 16px; } }
.modal { position: fixed; inset: 0; z-index: 92; display: grid; place-items: center; padding: 16px; background: rgba(3, 8, 20, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .2s both; }
.modal .box { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; border-radius: 22px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow2); display: grid; gap: 14px; animation: rise .4s var(--spring) both; }
.modal h3 { font-size: 19px; }
.modal p { margin: 0; color: var(--muted); font-size: 15px; }
.modal .btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Scan */
.scanedit { position: relative; display: block; width: fit-content; margin-inline: auto; touch-action: none; user-select: none; max-width: 100%; }
.scanedit canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 72vh; border-radius: 10px; }
.scanedit svg.quad { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.scanedit .cn { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 3px solid #fff; background: rgba(20, 99, 243, .55); box-shadow: 0 2px 8px rgba(0,0,0,.4); touch-action: none; cursor: grab; }
.scanedit .cn::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: #fff; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.filters button { display: grid; gap: 4px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); font-size: 13px; color: var(--muted); }
.filters button.on { border-color: var(--sky); color: var(--text); box-shadow: 0 0 0 3px var(--glow); }
.filters canvas { width: 100%; aspect-ratio: 1 / 1.25; object-fit: cover; border-radius: 8px; background: var(--checker); }

/* OCR */
.ocrout { display: grid; gap: 14px; }
.ocrpage { display: grid; gap: 8px; }
.ocrpage .hd { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 14px; }
.ocrpage textarea { min-height: 220px; font-family: "Sarabun", var(--fb); font-size: 16px; }

/* Compare slider for images */
.cmp { position: relative; overflow: hidden; border-radius: 14px; background: var(--checker); touch-action: none; user-select: none; }
.cmp img { width: 100%; height: auto; max-height: 62vh; object-fit: contain; }
.cmp .after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--x, 50%)); }
.cmp .after img { width: 100%; height: 100%; object-fit: contain; }
.cmp .knob { position: absolute; top: 0; bottom: 0; left: var(--x, 50%); width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 8px rgba(0,0,0,.4); }
.cmp .knob::after { content: "⇆"; position: absolute; top: 50%; left: 50%; translate: -50% -50%; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #fff; color: var(--fill); font-size: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.cmp .lb { position: absolute; top: 10px; padding: 2px 9px; border-radius: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 12.5px; }

/* Phone */
@media (max-width: 900px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .side .act { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .wrap { width: calc(100% - 32px); }
  .hero { padding: 22px 0 4px; }
  .hero p { font-size: 15px; margin-top: 8px; }
  .trust { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin: 14px -16px 0; padding: 0 16px 2px; }
  .trust::-webkit-scrollbar { display: none; }
  .trust span { flex: none; font-size: 13px; padding: 5px 10px; }
  .finder { margin-top: 16px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tool { flex-direction: column; gap: 10px; padding: 14px; }
  .tool .ic { width: 42px; height: 42px; border-radius: 12px; }
  .tool .ic svg { width: 22px; height: 22px; }
  .tool h3 { font-size: 16px; }
  .tool p { font-size: 13px; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
  .pg { padding: 7px; }
  .pg .acts { position: static; opacity: 1; justify-content: space-between; gap: 2px; }
  .pg .acts button { flex: 1; height: 30px; width: auto; box-shadow: none; }
  .pg .acts:empty { display: none; }
  .pg .tick { top: 10px; left: 10px; }
  .drop { padding: 34px 16px; }
  .toplink span { display: none; }
  .tphead .ic { width: 48px; height: 48px; }
  .result { padding: 30px 16px; }
}
@media (max-width: 640px) {
  .tbar { top: 64px; margin-inline: -8px; padding: 6px; border-radius: 14px; }
  .tbar .trow { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tbar .trow::-webkit-scrollbar { display: none; }
  .tbar .btn, .tbar .swatches { flex: none; }
  .tbar .trow .seg { flex: none; flex-wrap: nowrap; }
  .tbar .seg button { flex: none; }
}
@media (max-width: 360px) { .grid { grid-template-columns: 1fr; } }

/* Preview canvases (page numbers, watermark) */
.pv { display: block; width: auto; height: auto; max-width: 100%; max-height: 78vh; border-radius: 4px; box-shadow: 0 10px 40px -20px rgba(0,0,0,.5); }

/* Office previews (Word, PowerPoint, Excel to PDF) */
.docpv { position: relative; overflow: hidden; border-radius: 14px; background: var(--checker); padding: 12px 0; }
.docpv-in { transform-origin: 0 0; padding: 0 12px; }
.docpv .docx-wrapper { background: transparent !important; padding: 0 !important; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.docpv .docx-wrapper > section.docx { margin: 0 !important; box-shadow: 0 2px 10px rgba(0,0,0,.18) !important; }
.docpv .pptx-preview-wrapper, .docpv [class*="pptx-preview-wrapper"] { background: transparent !important; height: auto !important; overflow: visible !important; }
.docpv [class*="slide-wrapper"] { margin: 0 auto 16px !important; box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.xpage { background: #fff; color: #000; margin: 0 auto 16px; box-shadow: 0 2px 10px rgba(0,0,0,.18); font-family: SvzSarabun, sans-serif; }
.xhead { height: 22px; font-size: 11px; color: #777; }
.xsheet { border-collapse: collapse; table-layout: fixed; font-family: SvzSarabun, "Leelawadee UI", sans-serif; font-size: 14.6px; color: #000; background: #fff; }
.xsheet td { padding: 1px 4px; overflow: hidden; line-height: 1.25; }
.xsheet.xgrid td { box-shadow: inset -1px -1px 0 #d4d8de; }
@media print {
  body.printing > *:not(#svz-print) { display: none !important; }
  body.printing { background: #fff !important; }
  body.printing::before { display: none; }
  #svz-print .docx-wrapper { background: none !important; padding: 0 !important; display: block; }
  #svz-print section.docx { box-shadow: none !important; margin: 0 !important; page-break-after: always; break-after: page; }
  @page { margin: 0; }
}
