:root {
  --accent: #dc2626;
  --accent-dark: #b91c1c;
  --accent-soft: rgba(220, 38, 38, 0.1);
  --bg-grad-1: #0f172a;
  --bg-grad-2: #1e293b;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --input-bg: #f8fafc;
  --shadow: 0 20px 60px -15px rgba(2, 6, 23, 0.55);
  --radius: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 40px 18px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 15% -10%, #334155 0%, transparent 55%),
              radial-gradient(1000px 700px at 110% 10%, #991b1b 0%, transparent 45%),
              linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Card ---------- */
.card {
  width: 100%;
  max-width: 560px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 28px 26px;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.card__header { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.card__heading { flex: 1; min-width: 0; }
.logo {
  width: 48px; height: 48px; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 14px; box-shadow: 0 8px 20px -6px var(--accent-dark);
}
.logo svg { width: 24px; height: 24px; }
.card__header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.subtitle { color: var(--text-muted); font-size: 0.88rem; margin-top: 3px; }

/* ---------- Hub tool cards ---------- */
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.tool-card {
  display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--text);
  background: var(--input-bg); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.tool-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.tool-card:active { transform: scale(0.99); }
.tool-card__icon {
  width: 46px; height: 46px; flex: 0 0 auto; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 12px;
}
.tool-card__icon svg { width: 24px; height: 24px; }
.tool-card__meta { flex: 1; min-width: 0; }
.tool-card__title { display: block; font-size: 1.05rem; font-weight: 700; }
.tool-card__desc { display: block; font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; line-height: 1.45; }
.tool-card__go { flex: 0 0 auto; color: var(--accent-dark); font-weight: 800; font-size: 1.15rem; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  background: var(--input-bg);
  padding: 38px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.01); }
.dz-icon { width: 42px; height: 42px; color: var(--accent); margin-bottom: 10px; }
.dz-title { font-size: 1.05rem; font-weight: 700; }
.dz-sub { color: var(--text-muted); font-size: 0.86rem; margin-top: 4px; }
.dz-browse { color: var(--accent-dark); font-weight: 600; text-decoration: underline; }
.dz-notice { margin-top: 12px; text-align: center; font-size: 0.85rem; font-weight: 600; color: #dc2626; }

/* ---------- File list (merge: sortable) ---------- */
.files { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.file-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
}
.file-badge {
  width: 40px; height: 46px; flex: 0 0 auto; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  color: var(--accent); font-weight: 800; font-size: 0.6rem; letter-spacing: 0.03em;
}
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.file-info .arrow { color: var(--accent-dark); font-weight: 700; }
.file-info .saved { color: #16a34a; font-weight: 600; }
.file-info .grew { color: #ea580c; font-weight: 600; }
.file-fail { color: #dc2626; font-weight: 600; font-size: 0.8rem; }
.order-btns { display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto; }
.order-btn {
  width: 26px; height: 22px; border: 1px solid var(--border); background: #fff; border-radius: 6px;
  cursor: pointer; color: var(--text-muted); font-size: 0.7rem; line-height: 1; font-family: inherit;
  display: grid; place-items: center;
}
.order-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.order-btn:disabled { opacity: 0.35; cursor: default; }
.remove-btn {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer;
  background: transparent; color: var(--text-muted); font-size: 1.1rem; line-height: 1; font-family: inherit;
}
.remove-btn:hover { background: #fee2e2; color: #dc2626; }

/* ---------- Page thumbnails (split) ---------- */
.pages-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 10px; }
.pages-title { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); }
.select-links { display: flex; gap: 12px; }
.select-links button {
  background: none; border: none; color: var(--accent-dark); font-weight: 700; font-size: 0.8rem;
  cursor: pointer; font-family: inherit; padding: 0;
}
.select-links button:hover { text-decoration: underline; }
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; }
.page-tile {
  position: relative; border: 2px solid var(--border); border-radius: 10px; background: #fff;
  cursor: pointer; overflow: hidden; padding: 0; font-family: inherit;
  transition: border-color 0.12s ease, transform 0.08s ease;
}
.page-tile:hover { border-color: var(--accent); }
.page-tile:active { transform: scale(0.97); }
.page-tile canvas, .page-tile img { display: block; width: 100%; height: auto; background: #f1f5f9; }
.page-tile .pg-num {
  display: block; text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  padding: 4px 0; background: var(--input-bg); border-top: 1px solid var(--border);
}
.page-tile.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.page-tile.selected .pg-num { background: var(--accent); color: #fff; }
.page-tile .check {
  position: absolute; top: 5px; right: 5px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff; display: none; place-items: center; font-size: 0.7rem; font-weight: 800;
}
.page-tile.selected .check { display: grid; }

/* ---------- Controls ---------- */
.controls { margin-top: 20px; }
.field { margin-bottom: 18px; }
.field > label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 10px;
}
.field > label span { color: var(--accent-dark); font-weight: 700; }
.text-input {
  width: 100%; border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--input-bg);
  padding: 12px 14px; font-size: 1rem; font-weight: 600; color: var(--text); font-family: inherit; outline: none;
  min-width: 0;
}
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: #fff; }
.hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 7px; line-height: 1.5; }

.seg { display: flex; background: var(--input-bg); border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg button {
  flex: 1; padding: 10px 0; border: none; border-radius: 9px; background: transparent; cursor: pointer;
  font-size: 0.88rem; font-weight: 700; color: var(--text-muted); font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease;
}
.seg button.active { background: #fff; color: var(--accent-dark); box-shadow: 0 1px 4px rgba(2,6,23,.12); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  background: var(--border); border-radius: 999px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(2,6,23,.3);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 3px solid #fff;
}

.primary-btn {
  width: 100%; padding: 14px 0; font-size: 1rem; font-weight: 700; letter-spacing: 0.02em;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  transition: filter 0.15s ease, transform 0.08s ease; font-family: inherit;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: scale(0.99); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Progress ---------- */
.progress { margin-top: 14px; }
.progress-bar { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border-radius: 999px; transition: width 0.2s ease; }
.progress-label { text-align: center; font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; font-weight: 600; }

/* ---------- Result ---------- */
.result {
  margin-top: 18px; display: flex; align-items: center; gap: 12px;
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--radius-sm); padding: 14px 16px;
}
.result__icon { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; background: #16a34a; color: #fff; border-radius: 50%; }
.result__icon svg { width: 18px; height: 18px; }
.result__meta { flex: 1; min-width: 0; }
.result__title { font-size: 0.92rem; font-weight: 700; }
.result__info { font-size: 0.8rem; color: var(--text-muted); margin-top: 1px; }
.dl-btn {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  padding: 10px 18px; font-size: 0.86rem; font-weight: 700; border-radius: 999px;
  background: #16a34a; color: #fff; border: 1px solid transparent; cursor: pointer;
  font-family: inherit; flex: 0 0 auto;
}
.dl-btn:hover { filter: brightness(1.08); }
.dl-btn svg { width: 14px; height: 14px; }

.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Privacy note ---------- */
.privacy-note {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  margin-top: 18px; color: var(--text-muted); font-size: 0.82rem;
}
.privacy-note svg { width: 15px; height: 15px; color: #16a34a; flex: 0 0 auto; }

/* ---------- Tool cross-links ---------- */
.other-tools { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.other-tools span { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.other-tools a {
  font-size: 0.8rem; font-weight: 700; color: var(--accent-dark); text-decoration: none;
  background: var(--accent-soft); padding: 6px 12px; border-radius: 999px;
}
.other-tools a:hover { background: var(--accent); color: #fff; }

/* ---------- Ad slot ---------- */
.adslot {
  width: 100%; max-width: 560px; min-height: 100px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04); border: 1px dashed rgba(148,163,184,0.35);
  border-radius: var(--radius-sm); color: rgba(148,163,184,0.7); font-size: 0.8rem;
}

/* ---------- Footer ---------- */
.site-footer {
  width: 100%; max-width: 560px; display: flex; justify-content: flex-end; align-items: center; gap: 18px;
  padding: 4px 6px 0; color: rgba(148,163,184,0.75); font-size: 0.8rem; flex-wrap: wrap;
}
.site-footer .copy { margin-right: auto; }
.site-footer a { color: rgba(203,213,225,0.85); text-decoration: none; font-weight: 500; }
.site-footer a:hover { color: #fff; text-decoration: underline; }

/* ---------- Document pages (About / Privacy / guides) ---------- */
.doc {
  width: 100%; max-width: 720px; background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 34px 34px 30px; border: 1px solid rgba(255,255,255,0.6);
}
.doc__brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); margin-bottom: 22px; }
.doc__brand .logo { width: 40px; height: 40px; }
.doc__brand .logo svg { width: 20px; height: 20px; }
.doc__brand span { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.doc h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 6px; }
.doc .updated { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 20px; }
.doc .lead { font-size: 1.06rem; color: #475569; line-height: 1.7; }
.doc h2 { font-size: 1.1rem; font-weight: 700; margin: 24px 0 8px; }
.doc h3 { font-size: 1rem; font-weight: 600; margin: 18px 0 4px; }
.doc p, .doc li { color: #334155; font-size: 0.96rem; line-height: 1.7; }
.doc p { margin-bottom: 12px; }
.doc ul, .doc ol { margin: 0 0 12px 20px; }
.doc li { margin-bottom: 6px; }
.doc a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.doc a:hover { text-decoration: underline; }
.doc .callout { background: var(--accent-soft); border: 1px solid rgba(220,38,38,.25); border-left: 4px solid var(--accent); border-radius: 12px; padding: 16px 18px; margin: 20px 0; }
.doc .callout p { margin: 0; color: var(--accent-dark); font-weight: 500; }
.doc .faq h3 { font-size: 1.02rem; font-weight: 700; margin: 20px 0 4px; color: var(--text); }
.doc .table-wrap { overflow-x: auto; margin: 14px 0 20px; }
.doc table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 360px; }
.doc th, .doc td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc th { color: var(--text); font-weight: 700; background: var(--input-bg); }
.doc td { color: #334155; }
.doc .back {
  display: inline-block; margin-top: 24px; padding: 11px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
  border-radius: var(--radius-sm); font-weight: 700; font-size: 0.9rem;
}
.doc .back:hover { filter: brightness(1.08); text-decoration: none; }

@media (max-width: 440px) {
  .card { padding: 24px 20px 22px; }
  .doc { padding: 24px 20px 22px; }
  .card__header h1 { font-size: 1.25rem; }
  .site-footer { justify-content: center; flex-wrap: wrap; gap: 12px; }
  .site-footer .copy { margin-right: 0; width: 100%; text-align: center; }
  .file-name { max-width: 40vw; }
  .page-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
}
