/* ==========================================================================
   PDFmoor — shared design system
   ========================================================================== */

:root {
  --brand-50:  #eefcfa;
  --brand-100: #d4f5f0;
  --brand-200: #a9ebe1;
  --brand-300: #72dbcc;
  --brand-400: #3fc0b0;
  --brand-500: #1fa192;
  --brand-600: #147e74;
  --brand-700: #14655e;
  --brand-800: #14504b;
  --brand-900: #12433f;

  --accent-400: #ffb84d;
  --accent-500: #f79b1f;
  --accent-600: #e0810a;

  --ink-900: #0d1b1e;
  --ink-800: #16292c;
  --ink-700: #223a3e;
  --ink-600: #37545a;
  --ink-500: #57767c;
  --ink-400: #8aa3a7;
  --ink-300: #b8cbce;
  --ink-200: #dbe6e7;
  --ink-100: #eef4f4;
  --ink-50:  #f7fbfb;

  --white: #ffffff;
  --danger: #d64545;
  --danger-bg: #fdeceb;
  --success: #1f9d67;
  --success-bg: #e8f8f0;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(13, 27, 30, 0.06), 0 1px 1px rgba(13, 27, 30, 0.04);
  --shadow-md: 0 8px 24px rgba(13, 27, 30, 0.10), 0 2px 8px rgba(13, 27, 30, 0.06);
  --shadow-lg: 0 20px 48px rgba(13, 27, 30, 0.16), 0 6px 16px rgba(13, 27, 30, 0.08);

  --container: 1120px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;

  color-scheme: light;
}

* , *::before, *::after { box-sizing: border-box; }
html, body { padding: 0; margin: 0; }

body {
  font-family: var(--font-sans);
  background: var(--ink-50);
  color: var(--ink-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(247, 251, 251, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ink-200);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink-900);
}

.brand .mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-700));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
}

.brand .accent { color: var(--brand-600); }

.main-nav { display: flex; align-items: center; gap: 28px; }
.main-nav a {
  text-decoration: none;
  color: var(--ink-600);
  font-weight: 600;
  font-size: 15px;
}
.main-nav a:hover { color: var(--ink-900); }

.nav-toggle { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  border-radius: var(--radius-md);
  padding: 13px 24px;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, opacity .12s ease;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: white;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-lg); }

.btn-accent {
  background: linear-gradient(135deg, var(--accent-400), var(--accent-600));
  color: #241300;
  box-shadow: var(--shadow-md);
}
.btn-accent:hover:not(:disabled) { box-shadow: var(--shadow-lg); }

.btn-ghost {
  background: var(--white);
  color: var(--ink-700);
  border: 1.5px solid var(--ink-200);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--brand-400); color: var(--brand-700); }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: var(--radius-sm); }

.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn-label { opacity: 0.85; }

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: white;
  animation: spin 0.7s linear infinite;
}
.btn-ghost .spinner { border-color: var(--ink-200); border-top-color: var(--brand-600); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Hero ---------- */
.hero {
  padding: 76px 0 56px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
  color: var(--ink-900);
  font-weight: 800;
}
.hero h1 .hl { color: var(--brand-600); }
.hero p.lead {
  max-width: 640px;
  margin: 0 auto;
  font-size: 18px;
  color: var(--ink-600);
}
.pill-row {
  margin-top: 26px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  border: 1px solid var(--ink-200);
  color: var(--ink-600);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.pill svg { width: 14px; height: 14px; color: var(--brand-600); }

/* ---------- Tool grid ---------- */
.section-title {
  text-align: center;
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  color: var(--ink-900);
  letter-spacing: -0.02em;
}
.section-sub {
  text-align: center;
  color: var(--ink-500);
  margin: 0 0 40px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  padding: 8px 0 64px;
}

.tool-card {
  background: var(--white);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
.tool-card .icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.tool-card .icon svg { width: 24px; height: 24px; }
.tool-card h3 { margin: 0; font-size: 17px; color: var(--ink-900); font-weight: 700; }
.tool-card p { margin: 0; font-size: 13.5px; color: var(--ink-500); line-height: 1.45; }
.tool-card .badge {
  position: absolute; top: 16px; right: 16px;
  font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--brand-100); color: var(--brand-700);
  padding: 3px 8px; border-radius: 999px;
}

/* icon color variants */
.icon-teal   { background: linear-gradient(135deg, #3fc0b0, #147e74); }
.icon-amber  { background: linear-gradient(135deg, #ffcf7a, #e0810a); }
.icon-blue   { background: linear-gradient(135deg, #6fb6ff, #2563eb); }
.icon-violet { background: linear-gradient(135deg, #b79bff, #6d28d9); }
.icon-rose   { background: linear-gradient(135deg, #ff9bb0, #d6336c); }
.icon-slate  { background: linear-gradient(135deg, #94a7ad, #37545a); }

/* ---------- Trust / how-it-works ---------- */
.strip {
  background: var(--white);
  border-top: 1px solid var(--ink-200);
  border-bottom: 1px solid var(--ink-200);
  padding: 56px 0;
}
.trust-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
.trust-item { text-align: center; padding: 0 12px; }
.trust-item .icon {
  width: 48px; height: 48px; margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--brand-100); color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
}
.trust-item .icon svg { width: 24px; height: 24px; }
.trust-item h4 { margin: 0 0 6px; font-size: 16px; color: var(--ink-900); }
.trust-item p { margin: 0; color: var(--ink-500); font-size: 14px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--ink-200);
  padding: 44px 0 30px;
  color: var(--ink-500);
  font-size: 13.5px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1fr 1fr 1fr;
  gap: 18px;
  margin-bottom: 30px;
}
.footer-grid h5 {
  color: var(--ink-800);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 14px;
}
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.footer-grid a { text-decoration: none; color: var(--ink-500); }
.footer-grid a:hover { color: var(--brand-700); }
.footer-bottom {
  border-top: 1px solid var(--ink-200);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

/* ==========================================================================
   Tool page layout
   ========================================================================== */

.tool-page-header {
  padding: 40px 0 8px;
  text-align: center;
}
.tool-page-header .icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center; color: white;
  box-shadow: var(--shadow-md);
}
.tool-page-header .icon svg { width: 28px; height: 28px; }
.tool-page-header h1 { margin: 0 0 10px; font-size: 30px; letter-spacing: -0.02em; color: var(--ink-900); }
.tool-page-header p { max-width: 560px; margin: 0 auto; color: var(--ink-500); }

.crumbs {
  padding: 20px 0 0;
  font-size: 13px;
  color: var(--ink-400);
}
.crumbs a { text-decoration: none; color: var(--ink-500); }
.crumbs a:hover { color: var(--brand-700); }

.workspace {
  max-width: 760px;
  margin: 32px auto 80px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 32px;
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--ink-300);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: var(--brand-50);
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--brand-500);
  background: var(--brand-100);
}
.dropzone .dz-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  color: var(--brand-600);
}
.dropzone .dz-icon svg { width: 100%; height: 100%; }
.dropzone strong { color: var(--ink-900); font-size: 16px; }
.dropzone p { margin: 6px 0 0; color: var(--ink-500); font-size: 13.5px; }
.dropzone input[type="file"] { display: none; }

/* File list */
.file-list { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.file-item.dragging { opacity: 0.4; }
.file-item .grip { color: var(--ink-300); cursor: grab; font-size: 16px; line-height: 1; user-select: none; }
.file-item .thumb {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--brand-100); color: var(--brand-700);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  overflow: hidden;
}
.file-item .thumb svg { width: 18px; height: 18px; }
.file-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-item .meta { flex: 1; min-width: 0; }
.file-item .name { font-size: 14px; font-weight: 600; color: var(--ink-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item .size { font-size: 12px; color: var(--ink-400); }
.file-item .remove {
  background: none; border: none; cursor: pointer; color: var(--ink-400);
  font-size: 18px; line-height: 1; padding: 4px;
}
.file-item .remove:hover { color: var(--danger); }
.file-item .order-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand-600); color: white;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.add-more { margin-top: 14px; }

/* Options */
.options { margin-top: 26px; display: flex; flex-direction: column; gap: 18px; }
.field label.field-label { display: block; font-size: 13.5px; font-weight: 700; color: var(--ink-800); margin-bottom: 8px; }
.field .hint { font-size: 12.5px; color: var(--ink-400); margin-top: 6px; }

.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.radio-card {
  border: 1.5px solid var(--ink-200);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-600);
  background: var(--white);
}
.radio-card input { display: none; }
.radio-card.is-active {
  border-color: var(--brand-500);
  background: var(--brand-50);
  color: var(--brand-700);
}
.radio-card small { display: block; font-weight: 400; color: var(--ink-400); margin-top: 2px; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  border: 1.5px solid var(--ink-200);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink-800);
  background: var(--white);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}

.row { display: flex; gap: 14px; }
.row > * { flex: 1; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--ink-200);
  border-radius: 999px; cursor: pointer; transition: background 0.15s;
}
.switch .track::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: white; border-radius: 50%; transition: transform 0.15s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .track { background: var(--brand-500); }
.switch input:checked + .track::before { transform: translateX(18px); }

.slider-row { display: flex; align-items: center; gap: 14px; }
input[type="range"] { flex: 1; accent-color: var(--brand-600); }

/* Actions / status */
.actions { margin-top: 28px; display: flex; flex-direction: column; gap: 12px; }
.status-box {
  display: none;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13.5px;
  align-items: center;
  gap: 10px;
}
.status-box.is-visible { display: flex; }
.status-box.error { background: var(--danger-bg); color: var(--danger); }
.status-box.success { background: var(--success-bg); color: var(--success); }
.status-box.info { background: var(--brand-50); color: var(--brand-700); }

.progress-wrap {
  display: none;
  margin-top: 4px;
}
.progress-wrap.is-visible { display: block; }
.progress-bar-track {
  height: 8px; border-radius: 999px; background: var(--ink-100); overflow: hidden;
}
.progress-bar-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-400), var(--brand-600));
  transition: width 0.2s ease;
}
.progress-label { font-size: 12.5px; color: var(--ink-500); margin-top: 6px; text-align: center; }

.result-box {
  display: none;
  text-align: center;
  padding: 28px 20px;
  background: var(--success-bg);
  border-radius: var(--radius-lg);
  margin-top: 22px;
}
.result-box.is-visible { display: block; }
.result-box .icon { width: 48px; height: 48px; margin: 0 auto 12px; color: var(--success); }
.result-box h3 { margin: 0 0 4px; color: var(--ink-900); }
.result-box p { margin: 0 0 18px; color: var(--ink-500); font-size: 13.5px; }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.note-box {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--ink-500);
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
}
.note-box svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--brand-600); }

/* Rotate page thumbs */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px; margin-top: 20px; }
.page-thumb { position: relative; border: 1.5px solid var(--ink-200); border-radius: var(--radius-md); padding: 8px; text-align: center; background: var(--ink-50); }
.page-thumb canvas, .page-thumb img { max-width: 100%; max-height: 100%; border-radius: 6px; transition: transform 0.2s ease; background: white; box-shadow: var(--shadow-sm); }
.thumb-canvas-wrap { display: flex; align-items: center; justify-content: center; height: 120px; overflow: hidden; }
.page-thumb .num { font-size: 11px; color: var(--ink-400); margin-top: 6px; }
.page-thumb .rot-btns { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.page-thumb .rot-btns button { border: 1px solid var(--ink-200); background: white; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; font-size: 13px; }
.page-thumb .rot-btns button:hover { border-color: var(--brand-500); }

/* Page pick/mark states — shared by Delete Pages & Extract Pages */
.page-thumb.is-pickable { cursor: pointer; user-select: none; transition: border-color .15s, box-shadow .15s, background .15s; }
.page-thumb.is-pickable:hover { border-color: var(--ink-300); }
.page-thumb .pick-badge {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--white); border: 1.5px solid var(--ink-200); display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: transparent; z-index: 2; line-height: 1;
}
.page-thumb.is-marked-delete { border-color: var(--danger); background: var(--danger-bg); }
.page-thumb.is-marked-delete canvas, .page-thumb.is-marked-delete img { opacity: 0.32; }
.page-thumb.is-marked-delete .num { color: var(--danger); font-weight: 700; }
.page-thumb.is-marked-delete .pick-badge { color: var(--white); background: var(--danger); border-color: var(--danger); }
.page-thumb.is-selected { border-color: var(--brand-500); background: var(--brand-50); box-shadow: 0 0 0 3px var(--brand-100); }
.page-thumb.is-selected .num { color: var(--brand-700); font-weight: 700; }
.page-thumb.is-selected .pick-badge { color: var(--white); background: var(--brand-500); border-color: var(--brand-500); }

/* Utility */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }

@media (max-width: 1080px) and (min-width: 761px) {
  .footer-grid { grid-template-columns: 1.3fr 1fr 1fr; grid-row-gap: 24px; }
}
@media (max-width: 760px) {
  .main-nav { display: none; }
  .trust-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-grid { grid-template-columns: 1fr 1fr; grid-column-gap: 28px; }
  .radio-cards { grid-template-columns: 1fr; }
  .row { flex-direction: column; }
  .panel { padding: 22px; }
}
