/* =============================================================
   PDF Tools — Shared Design System
   Dark-first, light via [data-theme="light"]. Vanilla CSS.
   ============================================================= */

:root {
  --bg: #0a0a0c;
  --surface: #141418;
  --surface-2: #1b1b21;
  --surface-3: #22222a;
  --border: #26262e;
  --border-soft: #1f1f26;
  --text: #ececf1;
  --text-dim: #a1a1ad;
  --text-faint: #6b6b78;
  --brand-1: #7c6cff;
  --brand-2: #22d3ee;
  --grad: linear-gradient(120deg, var(--brand-1), var(--brand-2));
  --grad-surface: linear-gradient(135deg, rgba(124, 108, 255, 0.08), rgba(34, 211, 238, 0.04));
  --ok: #4ade80;
  --err: #f87171;
  --ring: rgba(124, 108, 255, .4);
  --shadow: 0 10px 40px -14px rgba(0, 0, 0, .6);
  --radius: 14px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", var(--font-sans);
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f4f4f8;
  --surface-3: #eaeaf0;
  --border: #e2e2ea;
  --border-soft: #ececf1;
  --text: #16161a;
  --text-dim: #55555f;
  --text-faint: #8a8a95;
  --brand-2: #0ea5b7;
  --grad-surface: linear-gradient(135deg, rgba(124, 108, 255, 0.05), rgba(14, 165, 183, 0.03));
  --shadow: 0 12px 40px -18px rgba(20, 20, 40, .15);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

a { color: var(--brand-2); text-decoration: none; transition: color .15s; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
img { max-width: 100%; }

.wrap { max-width: 1080px; width: 100%; margin: 0 auto; padding: 0 24px; }
.wrap-sm { max-width: 740px; }
.gradient-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Header ---------- */
.pt-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.pt-header .wrap { position: relative; display: flex; align-items: center; gap: 16px; height: 58px; }
.pt-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--text); flex-shrink: 0; }
.pt-brand:hover { text-decoration: none; }
.pt-brand .mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--grad); display: grid; place-items: center;
  color: #fff; font-size: .8rem; font-weight: 800;
  box-shadow: 0 2px 8px rgba(124, 108, 255, .35);
}

/* ---- dynamic navbar ---- */
.pt-nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.pt-nav a {
  font-size: .88rem; font-weight: 500; color: var(--text-dim);
  padding: 7px 12px; border-radius: 8px; white-space: nowrap;
  transition: color .15s ease, background .15s ease;
}
.pt-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.pt-nav a.active { color: var(--text); background: var(--surface-2); font-weight: 600; }

.pt-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.pt-burger { display: none; }
.icon-btn {
  width: 36px; height: 36px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 9px; color: var(--text); display: grid; place-items: center;
  cursor: pointer; font-size: 1rem; transition: all .15s ease;
}
.icon-btn:hover { border-color: var(--brand-1); color: var(--brand-1); transform: scale(1.04); }

/* ---------- Page head ---------- */
.pt-hero { padding: 40px 0 16px; }
.pt-hero .kicker { font-family: var(--font-mono); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--brand-2); font-weight: 600; }
.pt-hero h1 { font-family: var(--font-display); font-size: clamp(1.8rem, 4vw, 2.5rem); letter-spacing: -.02em; margin: 8px 0 10px; font-weight: 700; }
.pt-hero p { color: var(--text-dim); max-width: 65ch; font-size: 1rem; }

/* ---------- Hub grid ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; padding: 24px 0 60px; }
.tool-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 18px; color: var(--text); box-shadow: var(--shadow);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  position: relative; overflow: hidden;
}
.tool-card::before {
  content: ""; position: absolute; inset: 0;
  background: var(--grad-surface); opacity: 0; transition: opacity .2s ease;
  pointer-events: none;
}
.tool-card:hover { text-decoration: none; transform: translateY(-4px); border-color: var(--brand-1); box-shadow: 0 16px 36px -12px rgba(124, 108, 255, .2); }
.tool-card .ic {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--brand-1);
  transition: all .18s ease;
}
.tool-card:hover .ic {
  background: var(--grad);
  color: #ffffff;
  border-color: transparent;
  transform: scale(1.05);
}
.tool-card h3 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; color: var(--text); }
.tool-card p { font-size: .88rem; color: var(--text-dim); line-height: 1.5; flex-grow: 1; }
.group-label { font-family: var(--font-mono); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); margin: 32px 0 -8px; font-weight: 600; }

/* ---------- Tool Shell & Detail Layout ---------- */
/* padding-block only — .tool-shell shares the element with .wrap, whose
   horizontal padding must be preserved. */
.tool-shell { padding-top: 24px; padding-bottom: 60px; flex: 1; }
.tool-shell .pt-hero {
  padding: 0 0 20px;
  text-align: left;
}
.tool-shell .pt-hero h1 {
  font-size: clamp(1.6rem, 3.2vw, 2.1rem);
  margin: 6px 0 8px;
  line-height: 1.25;
}
.tool-shell .pt-hero p {
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 0;
  max-width: none;
}

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 20px;
}
.panel h2, .panel h3 {
  font-family: var(--font-display); font-size: 1.12rem; font-weight: 600;
  margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel > .actions:first-child { margin-top: 0; }

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--border); border-radius: 12px; background: var(--surface-2);
  padding: 34px 20px; text-align: center; cursor: pointer; transition: all .16s ease;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--brand-1);
  background: color-mix(in srgb, var(--brand-1) 8%, var(--surface-2));
}
.dropzone .dz-icon {
  color: var(--brand-1);
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}
.dropzone p { margin-top: 8px; color: var(--text); font-size: .94rem; }
.dropzone .hint { font-size: .82rem; color: var(--text-faint); margin-top: 4px; }

/* File Chips */
.filechips { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.filechip {
  display: flex; align-items: center; gap: 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: .88rem;
  transition: border-color .15s ease;
}
.filechip:hover { border-color: var(--border-soft); }
.filechip .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); color: var(--text); }
.filechip .sz { color: var(--text-faint); font-size: .78rem; font-family: var(--font-mono); white-space: nowrap; }
.filechip button {
  background: none; border: 0; color: var(--text-faint); cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 4px 6px; border-radius: 6px; transition: all .15s ease;
}
.filechip button:hover { color: var(--err); background: rgba(248, 113, 113, 0.12); }
.filechip .ord { display: flex; flex-direction: column; gap: 2px; }
.filechip .ord button { font-size: .75rem; padding: 2px 4px; }

/* Controls */
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .84rem; font-weight: 600; color: var(--text-dim); }
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; font-family: var(--font-sans); font-size: .92rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px;
  transition: border-color .15s, outline .15s;
}
textarea { font-family: var(--font-mono); font-size: .86rem; min-height: 120px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-1); outline-offset: -1px; border-color: var(--brand-1); }
input[type="range"] { width: 100%; accent-color: var(--brand-1); height: 6px; background: var(--surface-3); border-radius: 4px; cursor: pointer; }
input[type="color"] { width: 48px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--text); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--brand-1); }
.radio-row { display: flex; flex-wrap: wrap; gap: 14px; margin: 4px 0 12px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: .92rem; padding: 11px 20px; min-height: 42px;
  border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  transition: all .15s ease; line-height: 1;
}
.btn-primary { background: var(--grad); color: #ffffff; box-shadow: 0 4px 16px -2px rgba(124, 108, 255, .4); }
.btn-primary:hover:not(:disabled) { opacity: .95; transform: translateY(-1px); box-shadow: 0 6px 20px -2px rgba(124, 108, 255, .5); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand-1); color: var(--brand-1); background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  color: #0a0a0c; animation: pt-spin .7s linear infinite;
}
@keyframes pt-spin { to { transform: rotate(360deg); } }

.status { font-size: .88rem; margin-top: 12px; min-height: 1.2em; font-family: var(--font-mono); font-weight: 500; }
.status:empty { display: none; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.note { font-size: .82rem; color: var(--text-faint); margin-top: 10px; }

.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 14px; }
.preview-grid figure { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.preview-grid figcaption { font-size: .74rem; color: var(--text-faint); text-align: center; padding: 5px; font-family: var(--font-mono); }

/* ---- live page preview ---- */
.pv-wrap { display: flex; justify-content: center; padding: 8px 0; }
.pv-rot { position: relative; display: inline-block; line-height: 0; transition: transform .18s ease; }
.pv-rot canvas { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.pv-overlay { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pv-loading { padding: 26px; text-align: center; color: var(--text-faint); font-size: .85rem; }

/* ---- thumbnail grid ---- */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 14px; }
.thumb-grid figure { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); transition: border-color .12s ease, box-shadow .12s ease; cursor: pointer; }
.thumb-grid figure.sel { border-color: var(--brand-1); box-shadow: 0 0 0 2px var(--ring); }
.thumb-grid figure canvas, .thumb-grid figure img { display: block; width: 100%; height: auto; background: #fff; }
.thumb-grid figcaption { font: .72rem/1.7 var(--font-mono); text-align: center; color: var(--text-faint); }
.thumb-grid .note { grid-column: 1 / -1; margin-top: 0; }
canvas.sigpad { width: 100%; height: 190px; background: #fff; border: 1px solid var(--border); border-radius: 8px; touch-action: none; cursor: crosshair; }

.pt-footer {
  margin-top: auto; border-top: 1px solid var(--border-soft); padding: 28px 0;
  text-align: center; color: var(--text-faint); font-size: .84rem; font-family: var(--font-mono);
}
.pt-footer a { color: var(--text-dim); }
.pt-footer a:hover { color: var(--text); }

#pt-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(16px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: .86rem; font-weight: 600; opacity: 0; pointer-events: none; z-index: 100;
  transition: opacity .18s ease, transform .18s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
#pt-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Privacy & Trust Guarantee Card ---------- */
.privacy-banner {
  background: color-mix(in srgb, var(--brand-1) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand-1) 25%, var(--border));
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 24px 0 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.privacy-icon {
  color: var(--brand-2);
  flex-shrink: 0;
  margin-top: 2px;
}
.privacy-content strong {
  display: block;
  font-family: var(--font-display);
  font-size: .96rem;
  color: var(--text);
  margin-bottom: 3px;
}
.privacy-content p {
  font-size: .84rem;
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0;
}

/* ---------- SEO Guide & FAQ Section ---------- */
.seo-section {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--border-soft);
}
.seo-section h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 12px;
  letter-spacing: -.01em;
  color: var(--text);
}
.seo-section h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 18px 0 6px;
  color: var(--text);
}
.seo-section p {
  color: var(--text-dim);
  font-size: .9rem;
  line-height: 1.65;
  margin-bottom: 12px;
}
.seo-section ul, .seo-section ol {
  color: var(--text-dim);
  font-size: .9rem;
  line-height: 1.65;
  padding-left: 20px;
  margin-bottom: 16px;
}
.seo-section li { margin-bottom: 6px; }
.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.faq-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.faq-card h4 {
  font-family: var(--font-display);
  font-size: .96rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.faq-card p {
  font-size: .86rem;
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0;
}

/* ---------- Responsive Breakpoints ---------- */
@media (max-width: 900px) {
  .wrap { padding: 0 20px; }
}

@media (max-width: 760px) {
  .pt-burger { display: grid; }
  .pt-nav {
    position: absolute; top: calc(100% + 8px); right: 0; left: auto;
    min-width: 180px;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 8px; box-shadow: var(--shadow);
    margin-left: 0;
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
  }
  .pt-nav.open { transform: none; opacity: 1; pointer-events: auto; }
  .pt-nav a { padding: 10px 12px; font-size: .92rem; }
  .pt-header-actions { margin-left: auto; }
}

@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .pt-header .wrap { height: 54px; }
  .pt-nav { left: 12px; right: 12px; min-width: 0; }
  .pt-hero { padding: 28px 0 12px; }
  .tool-shell { padding-top: 18px; padding-bottom: 50px; }
  .tool-shell .pt-hero { padding: 0 0 16px; }
  .tool-shell .pt-hero h1 { font-size: 1.6rem; }
  .panel { padding: 18px 16px; margin-bottom: 16px; border-radius: 12px; }
  .panel h2, .panel h3 { font-size: 1.05rem; margin-bottom: 14px; }
  .dropzone { padding: 26px 16px; }
  .controls { gap: 12px; }
  .actions { gap: 10px; }
  .actions .btn { flex: 1; justify-content: center; }
  .privacy-banner { padding: 14px 16px; margin: 20px 0 16px; }
  .seo-section { margin-top: 28px; padding-top: 22px; }
  .faq-grid { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .pt-brand span:not(.mark) { display: none; }
}
