:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #161b26;
  --muted: #5d6576;
  --line: #e3e6ee;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --ok: #1a7f4b;
  --err: #c62828;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --card: #181c25;
    --text: #e8ebf2;
    --muted: #9aa3b5;
    --line: #2a303d;
    --accent: #4c8dff;
    --accent-soft: #1c2a44;
    --ok: #4cc38a;
    --err: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 19px; }
.brand svg { width: 30px; height: 30px; }
.brand b { color: var(--accent); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 15px; }
.top nav a:hover { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 560px) { .top nav a:not(:last-child) { display: none; } }

main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px 16px 56px; outline: none; }

.hero { text-align: center; margin: 12px auto 36px; max-width: 720px; }
.hero h1 { font-size: clamp(28px, 4.5vw, 44px); line-height: 1.15; margin: 0 0 12px; letter-spacing: -.02em; }
.hero p { color: var(--muted); font-size: 18px; margin: 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 4px 12px; font-size: 14px; margin-bottom: 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tool-card {
  display: flex; flex-direction: column; gap: 8px; padding: 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--text); box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.tool-card:hover { transform: translateY(-2px); border-color: var(--c); }
.tool-card h3 { margin: 4px 0 0; font-size: 18px; }
.tool-card p { margin: 0; color: var(--muted); font-size: 15px; }
.ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--c); color: #fff; flex: none; }
.ico svg { width: 24px; height: 24px; }

.tool-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.tool-head h1 { margin: 0; font-size: clamp(24px, 3.5vw, 34px); letter-spacing: -.01em; }
.tool-sub { color: var(--muted); margin: 0 0 24px; }
.back { display: inline-block; margin-bottom: 16px; color: var(--muted); text-decoration: none; font-size: 15px; }
.back:hover { color: var(--accent); }

.drop {
  border: 2px dashed var(--line); border-radius: 18px; background: var(--card);
  padding: 56px 20px; text-align: center; transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--c, var(--accent)); background: var(--accent-soft); }
.drop p { color: var(--muted); margin: 12px 0 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 12px 22px; cursor: pointer;
  background: var(--c, var(--accent)); color: #fff; font-weight: 600; font-size: 16px; text-decoration: none;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.big { padding: 16px 32px; font-size: 18px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { border-color: var(--c, var(--accent)); }
.btn svg { width: 20px; height: 20px; }

.work { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 820px) { .work { grid-template-columns: 1fr; } }
.work > *, .side > * { min-width: 0; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel h2 { font-size: 16px; margin: 0 0 12px; }
.side { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 820px) { .side { position: static; } }

.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.files li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.files li.dragging { opacity: .4; }
.files .thumb { width: 44px; height: 56px; object-fit: contain; border-radius: 4px; background: #fff; border: 1px solid var(--line); flex: none; }
.files .meta { flex: 1; min-width: 0; }
.files .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.files .info { color: var(--muted); font-size: 14px; }
.iconbtn { border: 1px solid var(--line); background: var(--card); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; flex: none; }
.iconbtn:hover { border-color: var(--c, var(--accent)); color: var(--c, var(--accent)); }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn:disabled { opacity: .35; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); }
.field input[type=text], .field input[type=number], .field select {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--bg); width: 100%;
}
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--c, var(--accent)); background: var(--accent-soft); }
.choice input { margin-top: 4px; accent-color: var(--c, var(--accent)); }
.choice b { display: block; font-size: 15px; }
.choice small { color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--c, var(--accent)); color: #fff; }
input[type=range] { width: 100%; accent-color: var(--c, var(--accent)); }
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; cursor: pointer; }
.check input { accent-color: var(--c, var(--accent)); width: 18px; height: 18px; }

.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.pg { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 10px 8px; text-align: center; cursor: grab; user-select: none; }
.pg.dragging { opacity: .35; }
.pg.drop-before { box-shadow: -4px 0 0 var(--c, var(--accent)); }
.pg .canvas-wrap { height: 150px; display: grid; place-items: center; }
.pg canvas, .pg img { max-width: 100%; max-height: 150px; box-shadow: 0 1px 4px rgba(0,0,0,.2); background: #fff; transition: transform .2s ease; }
.pg .num { font-size: 13px; color: var(--muted); margin-top: 6px; }
.pg .tools { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.pg .tools .iconbtn { width: 30px; height: 30px; }
.pg.removed { opacity: .35; }
.pg.removed canvas { filter: grayscale(1); }

.status { color: var(--muted); font-size: 15px; min-height: 22px; }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--c, var(--accent)); transition: width .2s; }
.err { color: var(--err); background: color-mix(in srgb, var(--err) 10%, transparent); border-radius: 10px; padding: 12px 14px; }
.note { color: var(--muted); font-size: 14px; }

.result { text-align: center; padding: 40px 20px; }
.result .done { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 0 auto 16px; }
.result .done svg { width: 34px; height: 34px; }
.result h2 { margin: 0 0 6px; font-size: 26px; }
.result .sizes { color: var(--muted); margin: 0 0 24px; font-size: 17px; }
.result .sizes b { color: var(--ok); }
.result .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.next { margin-top: 36px; }
.next h3 { font-size: 15px; color: var(--muted); font-weight: 500; margin: 0 0 12px; }
.next .row { justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 14px 6px 6px; cursor: pointer; font-size: 15px; }
.chip .ico { width: 28px; height: 28px; border-radius: 99px; }
.chip .ico svg { width: 16px; height: 16px; }
.chip:hover { border-color: var(--c); }

.foot { text-align: center; color: var(--muted); font-size: 14px; padding: 24px 16px 32px; border-top: 1px solid var(--line); }
.foot p { margin: 4px 0; display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.foot svg { width: 18px; height: 18px; color: var(--ok); }
.foot a { color: var(--muted); }

.sign-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.sp { position: relative; width: 100%; max-width: 760px; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.18); border-radius: 2px; overflow: hidden; }
.sp canvas.bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sp .pno { position: absolute; left: 8px; bottom: 6px; font-size: 12px; color: #888; }
.item { position: absolute; touch-action: none; cursor: move; outline: 1.5px dashed var(--c, var(--accent)); outline-offset: 2px; border-radius: 2px; }
.item.active { outline-style: solid; background: rgba(11, 114, 133, .06); }
.item img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.item .del { position: absolute; top: -14px; right: -14px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--err); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
.item .del svg { width: 14px; height: 14px; }
.item .rs { position: absolute; right: -8px; bottom: -8px; width: 18px; height: 18px; border-radius: 50%; background: var(--c, var(--accent)); border: 2px solid #fff; cursor: nwse-resize; }
.pad-wrap { position: relative; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.pad { display: block; width: 100%; max-width: 100%; aspect-ratio: 3 / 1; touch-action: none; cursor: crosshair; }
.pad-line { position: absolute; left: 12px; right: 12px; bottom: 18%; border-top: 1px solid #c9ced8; font-size: 11px; color: #9aa1ad; padding-top: 2px; pointer-events: none; }
.typed-prev { margin-top: 10px; padding: 10px 12px; min-height: 70px; background: #fff; border: 1px solid var(--line); border-radius: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #111; }
.seg.fonts button { padding: 4px 6px; }
.seg.fonts button.on span { color: #fff; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0 14px; }

.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 48px; }
.why div { padding: 4px 4px; }
.why h4 { margin: 0 0 4px; font-size: 16px; }
.why p { margin: 0; color: var(--muted); font-size: 15px; }
