:root {
  --red: #e5322d;
  --red-dark: #c4211c;
  --ink: #1f2430;
  --muted: #5b6272;
  --line: #e3e6ec;
  --bg: #f5f6f8;
  --card: #ffffff;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--red); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 16px; }
.logo { font-weight: 800; font-size: 1.35rem; text-decoration: none; color: var(--ink); }
.logo span { color: var(--red); }
.nav { display: flex; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; }
.nav a:hover { color: var(--red); }

/* Hero */
.hero { text-align: center; padding: 48px 0 24px; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); margin: 0 0 8px; }
.hero p { color: var(--muted); font-size: 1.1rem; margin: 0 auto; max-width: 680px; }

/* Tool grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; padding: 24px 0 40px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; text-decoration: none; color: var(--ink); transition: transform .15s, box-shadow .15s; display: block; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.tile .ico { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .8rem; margin-bottom: 12px; }
.tile h2 { font-size: 1.1rem; margin: 0 0 6px; }
.tile p { margin: 0; color: var(--muted); font-size: .92rem; }

/* Tool page */
.tool-head { text-align: center; padding: 40px 0 16px; }
.tool-head h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 0 0 6px; }
.tool-head p { color: var(--muted); margin: 0; }

.workspace { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin: 16px 0 32px; }
.drop { border: 2px dashed #c9ced8; border-radius: var(--radius); padding: 40px 16px; text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.drop.over { background: #fff3f2; border-color: var(--red); }
.drop strong { display: block; font-size: 1.1rem; margin-bottom: 6px; }
.drop small { color: var(--muted); }

.btn { display: inline-block; background: var(--red); color: #fff; border: 0; border-radius: 10px; padding: 14px 28px; font-size: 1.05rem; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--red-dark); }
.btn:disabled { background: #e6a5a3; cursor: not-allowed; }
.btn.secondary { background: var(--ink); }

.files { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; }
.files li { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: #fafbfc; }
.files li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files li .size { color: var(--muted); font-size: .85rem; }
.files li button { background: none; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; padding: 2px 8px; font-size: .9rem; }

.options { display: grid; gap: 14px; margin: 20px 0 0; }
.options label { font-weight: 600; display: block; margin-bottom: 4px; }
.options input[type=text], .options input[type=number], .options select { width: 100%; max-width: 420px; padding: 10px; border: 1px solid #c9ced8; border-radius: 8px; font-size: 1rem; }
.options .hint { color: var(--muted); font-size: .88rem; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; }
.radio-row label { font-weight: 500; }

.actions { text-align: center; margin-top: 24px; }
.status { text-align: center; margin-top: 14px; color: var(--muted); min-height: 1.5em; }
.status.error { color: var(--red-dark); font-weight: 600; }
.result { text-align: center; margin-top: 16px; }
.result .btn { margin: 4px; }

/* Content */
.content { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; margin-bottom: 32px; }
.content h2 { margin-top: 0; }
.content h3 { margin-bottom: 4px; }
.page { padding: 40px 0; }
.page .content { max-width: 820px; margin: 0 auto 32px; }

/* Ads */
.ad-slot { margin: 16px auto; text-align: center; min-height: 0; }

/* Footer */
.site-footer { background: var(--ink); color: #c8ccd6; padding: 32px 0; margin-top: 24px; font-size: .92rem; }
.site-footer a { color: #fff; text-decoration: none; margin-right: 16px; }
.site-footer .links { margin-bottom: 10px; }

.privacy-note { text-align: center; color: var(--muted); font-size: .9rem; margin-top: 12px; }

@media (max-width: 640px) {
  .nav { display: none; }
  .workspace, .content { padding: 18px; }
}

/* Organize PDF */
.pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; }
.page-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center; background: #fafbfc; font-size: .85rem; }
.page-card .thumb { height: 150px; display: grid; place-items: center; overflow: hidden; }
.page-card canvas { max-width: 100%; max-height: 140px; box-shadow: 0 1px 4px rgba(0,0,0,.15); transition: transform .2s; }
.page-tools { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }
.page-tools button { background: #fff; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; padding: 2px 8px; }

/* Sign PDF */
.sign-pad { width: 100%; max-width: 500px; height: auto; aspect-ratio: 500 / 160; border: 2px dashed #c9ced8; border-radius: 8px; background: #fff; touch-action: none; display: block; }
.link-btn { background: none; border: 0; color: var(--red); cursor: pointer; font: inherit; padding: 4px 0; }

/* Crop PDF */
.row4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-width: 520px; }
@media (max-width: 640px) { .row4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Tool menu groups on the home page */
.group-title { margin: 28px 0 0; font-size: 1rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.grid.compact { padding-top: 12px; padding-bottom: 8px; }
