:root {
  --brand: #e5484d;
  --brand-d: #c93a3f;
  --ink: #1b1d24;
  --ink-2: #4a4f5c;
  --muted: #737a89;
  --line: #e6e8ee;
  --bg: #f6f7fb;
  --card: #fff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
img, canvas { max-width: 100%; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* Header */
.site-header { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.header-in { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.logo b { color: var(--brand); font-weight: 800; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 17px; }
.logo-tag { font-size: 11px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; text-transform: uppercase; letter-spacing: .04em; }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a { color: var(--ink-2); font-weight: 600; font-size: 14px; padding: 8px 12px; border-radius: 8px; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav .nav-all { background: var(--ink); color: #fff; }
.nav .nav-all:hover { background: #000; color: #fff; }
.menu-btn { display: none; background: none; border: 0; padding: 8px; cursor: pointer; }
.menu-btn span { display: block; width: 22px; height: 2px; background: var(--ink); margin: 5px 0; border-radius: 2px; }

/* Hero */
.hero { padding: 64px 0 36px; text-align: center; }
.hero h1 { font-size: clamp(30px, 5vw, 50px); line-height: 1.1; margin: 0 0 14px; letter-spacing: -.03em; }
.hero h1 span { color: var(--brand); }
.lead { font-size: 18px; color: var(--ink-2); max-width: 680px; margin: 0 auto; }
.search { max-width: 520px; margin: 28px auto 0; }
.search input { width: 100%; padding: 15px 20px; font-size: 16px; border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); outline: none; }
.search input:focus { border-color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 26px; }
.chip { border: 1px solid var(--line); background: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.chip.active, .chip:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Tool grid */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tool-grid.small { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tool-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 8px; color: var(--ink); transition: transform .15s, box-shadow .15s, border-color .15s; }
.tool-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: transparent; }
.tool-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); }
.tool-icon.big { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 12px; }
.tool-name { font-weight: 700; font-size: 17px; }
.tool-desc { color: var(--muted); font-size: 14px; }
.no-results { text-align: center; color: var(--muted); }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-top: 60px; margin-bottom: 40px; }
.feature { background: #fff; border-radius: var(--radius); padding: 26px; border: 1px solid var(--line); }
.feature h3 { margin: 0 0 6px; }
.feature p { margin: 0; color: var(--ink-2); }

/* Tool page */
.tool-hero { text-align: center; padding: 44px 0 24px; }
.tool-hero .tool-icon { margin: 0 auto 12px; }
.tool-hero h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.02em; }
.tool-app { margin-bottom: 30px; }
.dropzone { background: #fff; border: 2px dashed #d3d7e0; border-radius: 20px; padding: 56px 20px; text-align: center; transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--brand); background: #fff5f5; }
.privacy-note { font-size: 13px; color: var(--ink-2); margin: 14px 0 0; }

.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--brand); color: #fff; border: 0; border-radius: 12px; padding: 12px 22px; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; }
.btn-primary:hover { background: var(--brand-d); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-big { font-size: 19px; padding: 17px 40px; border-radius: 14px; box-shadow: 0 6px 20px rgba(229, 72, 77, .3); }
.btn-block { width: 100%; margin-top: 14px; padding: 15px; font-size: 17px; }
.btn-sec { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; color: var(--ink); }
.btn-sec:hover { border-color: #c5cad4; }
.btn-link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; margin-top: 10px; text-decoration: underline; }

.panel { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.panel-main, .panel-side { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel-side { position: sticky; top: 84px; }
.panel-side h3 { margin: 0 0 12px; }
.file-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-item { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fafbfc; }
.file-item.dragging { opacity: .4; }
.file-item .handle { cursor: grab; color: var(--muted); font-size: 18px; user-select: none; }
.file-item .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-item .fsize { color: var(--muted); font-size: 13px; }
.file-item .rm { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; }
.file-item .rm:hover { color: var(--brand); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field input[type=text], .field input[type=number], .field input[type=password], .field select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; background: #fff; color: var(--ink); width: 100%; }
.field input[type=color] { width: 60px; height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }

.status, .error, .result { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 40px 20px; text-align: center; margin-top: 16px; }
.error { color: #b42318; background: #fff6f5; border-color: #fecdca; padding: 18px; font-weight: 600; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid #f1d0d1; border-top-color: var(--brand); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; background: var(--bg); border-radius: 6px; max-width: 360px; margin: 10px auto 0; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.result h2 { margin: 0 0 6px; }
.result .btn-big { margin-top: 14px; }
.result textarea { width: 100%; min-height: 240px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: 14px/1.5 ui-monospace, Menlo, Consolas, monospace; margin-top: 10px; }

/* Organize pages */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; margin-top: 12px; }
.page-thumb { background: #fafbfc; border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; cursor: grab; position: relative; }
.page-thumb.dragging { opacity: .4; }
.page-thumb.over { outline: 2px solid var(--brand); }
.page-thumb .thumb-wrap { height: 150px; display: grid; place-items: center; overflow: hidden; }
.page-thumb canvas { max-height: 150px; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); transition: transform .2s; background: #fff; }
.page-thumb .pnum { font-size: 12px; color: var(--muted); margin-top: 6px; font-weight: 600; }
.page-thumb .acts { position: absolute; top: 6px; right: 6px; z-index: 2; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.page-thumb:hover .acts { opacity: 1; }
.page-thumb .acts button { width: 28px; height: 28px; border-radius: 8px; border: 0; background: var(--ink); color: #fff; cursor: pointer; font-size: 14px; }
.ws-bar { margin-top: 6px; }

/* Place (sign/edit) */
.place-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; margin-top: 10px; }
.place-side { border-right: 1px solid var(--line); padding-right: 16px; }
.place-stage { background: #eef0f4; border-radius: 12px; padding: 16px; overflow: auto; max-height: 80vh; display: flex; justify-content: center; }
.stage-inner { position: relative; display: inline-block; cursor: crosshair; box-shadow: 0 2px 10px rgba(0, 0, 0, .15); background: #fff; line-height: 0; }
.stage-inner canvas { display: block; max-width: none; }
.placed { position: absolute; border: 1px dashed var(--brand); cursor: pointer; line-height: 1.1; white-space: pre; transform-origin: top left; }
.placed:hover { background: rgba(229, 72, 77, .1); }
.placed img { display: block; width: 100%; pointer-events: none; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 10px; font-weight: 600; font-size: 14px; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tab { flex: 1; padding: 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-weight: 600; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
#sigPad { width: 100%; height: 100px; border: 1px solid var(--line); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
#sigText { width: 100%; padding: 10px; font: italic 26px "Segoe Script", "Brush Script MT", cursive; border: 1px solid var(--line); border-radius: 10px; }

/* Content */
.howto, .related { margin-top: 40px; }
.howto ol { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 22px 22px 44px; margin: 0; }
.howto li { margin: 6px 0; color: var(--ink-2); }
.prose { max-width: 800px; padding-top: 40px; padding-bottom: 60px; }
.prose h2 { margin-top: 30px; }
.prose p { color: var(--ink-2); }
.center { text-align: center; }
.ad { margin: 24px auto; max-width: 1180px; padding: 0 20px; min-height: 90px; text-align: center; }

/* Footer */
.site-footer { background: #fff; border-top: 1px solid var(--line); margin-top: 60px; padding: 44px 0 20px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 24px; }
.footer-grid h4 { margin: 0 0 10px; font-size: 14px; }
.footer-grid a:not(.logo) { display: block; color: var(--ink-2); font-size: 14px; margin: 5px 0; }
.footer-grid a:not(.logo):hover { color: var(--brand); }
.footer-grid p { font-size: 14px; }
.logo-footer { font-size: 18px; }
.copyright { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); margin-top: 26px; padding-top: 18px; }

@media (max-width: 900px) {
  .panel { grid-template-columns: 1fr; }
  .panel-side { position: static; }
  .place-layout { grid-template-columns: 1fr; }
  .place-side { border-right: 0; padding-right: 0; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .menu-btn { display: block; }
  .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: #fff; flex-direction: column; align-items: stretch; padding: 10px 20px 16px; border-bottom: 1px solid var(--line); }
  .nav-open .nav { display: flex; }
  .logo-tag { display: none; }
  .hero { padding: 40px 0 24px; }
  .tool-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tool-card { padding: 16px; }
  .tool-desc { display: none; }
}
@media (hover: none) { .page-thumb .acts { opacity: 1; } }
