/* ==========================================================================
   Saulx Outils — feuille de style
   ========================================================================== */
:root {
  --red: #e5322d;
  --red-dark: #c8211c;
  --red-soft: #fdecec;
  --ink: #2f2f37;
  --text: #47474f;
  --muted: #74747e;
  --line: #e3e3ec;
  --line-strong: #cfcfda;
  --bg: #f5f5fa;
  --card: #ffffff;
  --green: #2e9d52;
  --blue: #2b5db8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 30, 50, .05);
  --shadow-hover: 0 10px 28px rgba(30, 30, 60, .10);
  --topbar-h: 64px;
  --sidebar-w: 360px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: inherit; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
img, canvas { max-width: 100%; }
.ic { flex-shrink: 0; vertical-align: middle; }

/* ------------------------------------------------------------------ Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--line);
  height: var(--topbar-h);
}
.topbar-inner {
  height: 100%;
  max-width: 1560px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 28px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--red); color: #fff;
  display: grid; place-items: center;
}
.logo-text { font-weight: 800; font-size: 19px; letter-spacing: .5px; color: var(--ink); }
.logo-text b { color: var(--red); font-weight: 800; }

.mainnav { display: flex; align-items: center; gap: 4px; flex: 1; }
.mainnav > a, .mega-btn {
  text-decoration: none; font-weight: 600; font-size: 14px; color: var(--ink);
  padding: 8px 12px; border-radius: 8px; background: none; border: 0; cursor: pointer;
  text-transform: uppercase; letter-spacing: .2px;
}
.mainnav > a:hover, .mega-btn:hover { color: var(--red); }
.caret { font-size: 11px; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; cursor: pointer; padding: 8px; color: var(--ink); }

.mega { position: relative; }
.mega-panel {
  position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-40%);
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(20, 20, 40, .14);
  padding: 22px; display: none; gap: 26px;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  width: max-content; max-width: 92vw;
}
.mega:hover .mega-panel, .mega.open .mega-panel { display: grid; }
.mega-panel::before { content: ""; position: absolute; top: -14px; left: 0; right: 0; height: 14px; }
.mega-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 8px; }
.mega-col a {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin: 0 -8px;
  text-decoration: none; color: var(--ink); font-weight: 500; font-size: 14px; border-radius: 8px;
}
.mega-col a:hover { background: var(--bg); }

/* -------------------------------------------------------------------- Hero */
.hero {
  text-align: center; padding: 56px 24px 12px; max-width: 1120px; margin: 0 auto;
}
.hero h1 { font-size: clamp(28px, 3.4vw, 42px); font-weight: 700; letter-spacing: -.5px; }
.hero p { font-size: clamp(16px, 1.6vw, 20px); margin: 18px auto 0; max-width: 900px; color: var(--text); }
.page-home main {
  background:
    radial-gradient(900px 500px at 8% -10%, rgba(229, 50, 45, .06), transparent 60%),
    radial-gradient(800px 600px at 100% 10%, rgba(229, 50, 45, .05), transparent 60%);
}

/* ----------------------------------------------------------------- Filters */
.tools-section { max-width: 1560px; margin: 0 auto; padding: 24px 24px 40px; }
.filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 18px 0 34px; }
.pill {
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.pill:hover { border-color: var(--ink); }
.pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* -------------------------------------------------------------- Tool cards */
.tools-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.tool-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px 30px 28px; text-decoration: none; min-height: 250px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .2s, border-color .2s;
}
.tool-card:hover { box-shadow: var(--shadow-hover); border-color: var(--line-strong); transform: translateY(-2px); }
.tool-card h3 { font-size: 20px; font-weight: 600; margin: 22px 0 10px; }
.tool-card p { margin: 0; font-size: 14px; color: var(--text); line-height: 1.5; }
.tool-icon { display: block; }

.features {
  max-width: 1200px; margin: 20px auto 60px; padding: 0 24px;
  display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.feature { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.feature .ic { color: var(--red); }
.feature h3 { font-size: 17px; margin: 12px 0 6px; }
.feature p { margin: 0; font-size: 14px; }

/* ------------------------------------------------------------------ Footer */
.footer { background: #fff; border-top: 1px solid var(--line); }
.footer-inner {
  max-width: 1560px; margin: 0 auto; padding: 28px 24px;
  display: flex; flex-wrap: wrap; gap: 20px 40px; align-items: center; justify-content: space-between;
  font-size: 14px; color: var(--muted);
}
.footer-inner p { margin: 4px 0 0; }
.footer-note { display: flex; gap: 8px; align-items: center; max-width: 560px; }
.footer-note .ic { color: var(--green); }
.page-tool .footer { display: none; }

/* ----------------------------------------------------------------- Buttons */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--red); color: #fff; border: 0; border-radius: 10px;
  padding: 12px 22px; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none;
  transition: background .15s, transform .1s, opacity .15s;
}
.btn-primary:hover { background: var(--red-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-xl { font-size: 20px; padding: 16px 28px; border-radius: 12px; width: 100%; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: #fff; border: 1px solid var(--line-strong); color: var(--ink);
  border-radius: 9px; padding: 8px 14px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--ink); }
.btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-round {
  width: 44px; height: 44px; border-radius: 50%; background: var(--red); color: #fff;
  display: inline-grid; place-items: center; cursor: pointer; border: 0;
  box-shadow: 0 4px 14px rgba(229, 50, 45, .35); position: relative;
}
.btn-round:hover { background: var(--red-dark); }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: #fff; color: var(--ink); display: inline-grid; place-items: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.icon-btn:hover { color: var(--red); }

/* ------------------------------------------------------------- Tool views */
.upload-view { text-align: center; padding: 60px 24px 80px; max-width: 980px; margin: 0 auto; }
.upload-view h1 { font-size: clamp(30px, 3.6vw, 42px); font-weight: 700; }
.upload-view .lead { font-size: clamp(17px, 1.7vw, 21px); margin: 14px auto 36px; max-width: 760px; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px; border-radius: 20px; transition: background .2s; }
.btn-upload {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--red); color: #fff; font-weight: 700; font-size: clamp(18px, 2.2vw, 24px);
  padding: 26px 56px; min-width: min(420px, 100%); border-radius: 14px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(229, 50, 45, .30);
  transition: background .15s, transform .15s;
}
.btn-upload:hover { background: var(--red-dark); transform: translateY(-1px); }
.drop-hint { margin: 0; color: var(--muted); font-size: 15px; }
.privacy { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13.5px; margin-top: 30px; }
.privacy .ic { color: var(--green); }

body.dragging::after {
  content: "Déposez vos fichiers ici";
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: rgba(229, 50, 45, .88); color: #fff; font-size: 32px; font-weight: 700;
  border: 6px dashed rgba(255, 255, 255, .7);
}

/* Workspace */
.work-view {
  display: flex; min-height: calc(100vh - var(--topbar-h));
}
.work-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.work-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 24px 0; min-height: 60px;
}
.work-toolbar-left { font-size: 14px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.work-toolbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.work-area {
  flex: 1; padding: 20px 24px 40px;
  display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 22px;
}
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #fff; border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
}
.sidebar-head {
  font-size: 22px; font-weight: 700; color: var(--ink); text-align: center;
  padding: 22px 20px; border-bottom: 1px solid var(--line);
}
.sidebar-body { flex: 1; overflow-y: auto; padding: 20px; }
.sidebar-foot { padding: 18px 20px; border-top: 1px solid var(--line); }

/* Sidebar form controls */
.field { margin-bottom: 18px; }
.field > label, .field-label { display: block; font-weight: 600; color: var(--ink); font-size: 14px; margin-bottom: 7px; }
.field small, .hint { display: block; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.input, .select, textarea.input {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff;
  padding: 9px 12px; font-size: 14.5px; outline: none;
}
.input:focus, .select:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.row .unit { flex: 0 0 auto; color: var(--muted); font-size: 13px; }
.row > .btn, .row > button, .row > input[type=color] { flex: 0 0 auto; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14.5px; color: var(--ink); margin: 9px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--red); margin: 2px 0 0; flex-shrink: 0; }
input[type=range] { width: 100%; accent-color: var(--red); }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row output { min-width: 44px; text-align: right; font-weight: 700; color: var(--ink); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.info-box {
  background: #f1f6ff; border: 1px solid #d6e4ff; color: #294a86; border-radius: 10px;
  padding: 11px 13px; font-size: 13px; margin-bottom: 16px;
}
.warn-box { background: #fff7e6; border-color: #ffe1a6; color: #7a5200; }
.ok-box { background: #edf8f0; border-color: #c6ead1; color: #1f6b39; }

.opt-cards { display: grid; gap: 10px; }
.opt-card { cursor: pointer; display: block; }
.opt-card input { position: absolute; opacity: 0; pointer-events: none; }
.opt-card-body {
  display: block; border: 2px solid var(--line); border-radius: 11px; padding: 11px 14px; transition: border-color .15s, background .15s;
}
.opt-card-body strong { display: block; color: var(--ink); font-size: 14.5px; }
.opt-card-body small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.opt-card input:checked + .opt-card-body { border-color: var(--red); background: var(--red-soft); }
.opt-card input:focus-visible + .opt-card-body { outline: 2px solid var(--red); outline-offset: 2px; }
.opt-card-body:hover { border-color: var(--line-strong); }

.segmented { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; gap: 4px; }
.segmented label { flex: 1; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; padding: 7px 8px; border-radius: 7px; font-weight: 600; font-size: 13.5px; color: var(--muted);
}
.segmented input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* File cards (miniatures) */
.file-card {
  position: relative; width: 190px; background: #fff; border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .10), 0 0 0 1px var(--line);
  padding: 14px 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: grab; transition: box-shadow .15s;
}
.file-card:hover { box-shadow: 0 8px 24px rgba(0, 0, 0, .12), 0 0 0 1px var(--line-strong); }
.file-card .thumb {
  width: 160px; height: 200px; display: grid; place-items: center; overflow: hidden;
  background: repeating-conic-gradient(#f0f0f5 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  border-radius: 6px;
}
.file-card .thumb img, .file-card .thumb canvas {
  max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); background: #fff;
}
.file-card .name {
  font-size: 12.5px; font-weight: 600; color: var(--ink); width: 100%;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-card .meta { font-size: 12px; color: var(--muted); text-align: center; }
.file-card .actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 6px; opacity: 0; transition: opacity .15s;
}
.file-card:hover .actions, .file-card:focus-within .actions { opacity: 1; }
.file-card .badge {
  position: absolute; top: 8px; left: 8px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 6px; padding: 2px 7px;
}
.file-card.selected { box-shadow: 0 0 0 3px var(--red); }
.file-card.sortable-ghost { opacity: .35; }
.file-card.removed .thumb { opacity: .25; }
.page-card { width: 150px; cursor: grab; }
.page-card .thumb { width: 124px; height: 160px; }
.page-card.blank .thumb::after { content: "Page blanche"; color: var(--muted); font-size: 12px; }
.save-tag { font-size: 12px; font-weight: 700; color: var(--green); }
.save-tag.neg { color: var(--red); }

/* Results */
.result-view { text-align: center; padding: 50px 24px 80px; max-width: 1100px; margin: 0 auto; }
.result-view h1 { font-size: clamp(28px, 3.2vw, 38px); }
.result-view .lead { font-size: 17px; margin: 10px 0 26px; }
.result-actions { display: flex; gap: 14px; justify-content: center; align-items: center; }
.result-actions .btn-xl { width: auto; min-width: min(420px, 70vw); padding: 22px 36px; font-size: 22px; }
.btn-back {
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
}
.btn-back:hover { background: #000; }
.result-body { margin-top: 36px; }
.result-list { display: grid; gap: 10px; text-align: left; max-width: 760px; margin: 0 auto; }
.result-item {
  display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
.result-item .rthumb {
  width: 54px; height: 54px; border-radius: 8px; overflow: hidden; flex-shrink: 0; display: grid; place-items: center;
  background: repeating-conic-gradient(#f0f0f5 0% 25%, #fff 0% 50%) 50% / 12px 12px;
}
.result-item .rthumb img { width: 100%; height: 100%; object-fit: contain; }
.result-item .rinfo { flex: 1; min-width: 0; }
.result-item .rname { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-item .rmeta { font-size: 13px; color: var(--muted); }
.stat-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 22px; min-width: 150px;
}
.stat b { display: block; font-size: 24px; color: var(--ink); }
.stat span { font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------ Loader/toast */
.loader {
  position: fixed; inset: 0; z-index: 100; background: rgba(245, 245, 250, .86); backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
.loader-box { text-align: center; width: min(420px, 86vw); }
.spinner {
  width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 50%;
  border: 5px solid var(--red-soft); border-top-color: var(--red); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-msg { font-size: 18px; font-weight: 600; color: var(--ink); margin: 0 0 14px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--red); transition: width .2s; }
.progress.indeterminate .progress-bar { width: 35%; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 120; display: grid; gap: 8px; width: min(520px, 92vw); }
.toast {
  background: var(--ink); color: #fff; border-radius: 10px; padding: 12px 16px; font-size: 14.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: toast-in .2s ease-out;
}
.toast.error { background: #b3261e; }
.toast.success { background: #1f7a3e; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------- Image editors */
.canvas-stage {
  width: 100%; display: grid; place-items: center; position: relative;
}
.checker {
  background-color: #fff;
  background-image: repeating-conic-gradient(#e9e9ef 0% 25%, #fff 0% 50%);
  background-size: 20px 20px;
}
.stage-wrap { position: relative; display: inline-block; line-height: 0; box-shadow: 0 4px 20px rgba(0, 0, 0, .12); border-radius: 4px; }
.stage-wrap canvas { display: block; max-height: calc(100vh - var(--topbar-h) - 140px); max-width: 100%; }
.compare-slider { position: relative; display: inline-block; line-height: 0; overflow: hidden; border-radius: 6px; box-shadow: 0 4px 20px rgba(0, 0, 0, .12); }
.compare-slider img { display: block; max-height: calc(100vh - var(--topbar-h) - 150px); max-width: 100%; user-select: none; -webkit-user-drag: none; }
.compare-slider .after { position: absolute; inset: 0; clip-path: inset(0 0 0 50%); }
.compare-slider .after img { width: 100%; height: 100%; max-height: none; }
.compare-handle { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; left: 50%; transform: translateX(-50%); box-shadow: 0 0 6px rgba(0, 0, 0, .4); pointer-events: none; }
.compare-handle::after {
  content: "⟷"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 38px; height: 38px; border-radius: 50%; background: #fff; color: var(--ink); display: grid; place-items: center; font-size: 18px; line-height: 38px; text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
.compare-slider input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--line); cursor: pointer; padding: 0;
}
.swatch.active { border-color: var(--red); box-shadow: 0 0 0 2px #fff inset; }
.swatch.transparent { background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 50% / 10px 10px; }
input[type=color] { width: 32px; height: 32px; padding: 0; border: 2px solid var(--line); border-radius: 8px; cursor: pointer; background: none; }

.crop-box {
  position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5); cursor: move; touch-action: none;
}
.crop-box::before, .crop-box::after { content: ""; position: absolute; border: 1px dashed rgba(255, 255, 255, .5); pointer-events: none; }
.crop-box::before { left: 33.33%; right: 33.33%; top: 0; bottom: 0; border-top: 0; border-bottom: 0; }
.crop-box::after { top: 33.33%; bottom: 33.33%; left: 0; right: 0; border-left: 0; border-right: 0; }
.crop-handle { position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0, 0, 0, .5); touch-action: none; }
.crop-handle[data-h=nw] { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-handle[data-h=ne] { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-handle[data-h=sw] { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-handle[data-h=se] { right: -8px; bottom: -8px; cursor: nwse-resize; }
.stage-wrap.crop-mode { overflow: hidden; }

.tool-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------ PDF viewers */
.pdf-pages { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 24px; }
.pdf-page { position: relative; box-shadow: 0 2px 12px rgba(0, 0, 0, .14); background: #fff; line-height: 0; }
.pdf-page canvas { display: block; }
.pdf-page .overlay { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.pdf-page .page-num { position: absolute; top: -20px; left: 0; font-size: 12px; color: var(--muted); line-height: 1; }
.redact-box { position: absolute; background: rgba(0, 0, 0, .78); outline: 2px solid var(--red); cursor: pointer; }
.redact-box.white { background: rgba(255, 255, 255, .85); outline-color: var(--red); }
.redact-box:hover::after {
  content: "✕"; position: absolute; top: -10px; right: -10px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--red); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}
.redact-draft { position: absolute; border: 2px dashed var(--red); background: rgba(229, 50, 45, .15); pointer-events: none; }

/* Compare */
.cmp-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; width: 100%; max-width: 980px; margin: 0 auto; }
.cmp-slot {
  border: 2px dashed var(--line-strong); border-radius: 16px; padding: 30px 20px; text-align: center; background: #fff; cursor: pointer;
  min-height: 220px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px; transition: border-color .15s, background .15s;
}
.cmp-slot:hover, .cmp-slot.over { border-color: var(--red); background: var(--red-soft); }
.cmp-slot.filled { border-style: solid; border-color: var(--green); background: #f3fbf5; }
.cmp-slot h3 { font-size: 18px; }
.cmp-slot .slot-file { font-weight: 600; color: var(--ink); word-break: break-all; }
.cmp-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.diff-text {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 24px 28px; width: 100%; max-width: 1000px;
  white-space: pre-wrap; font-size: 14.5px; line-height: 1.7; color: var(--ink); text-align: left;
}
.diff-text ins { background: #d7f5dd; color: #145a25; text-decoration: none; border-radius: 3px; padding: 0 1px; }
.diff-text del { background: #fde0de; color: #9b1c16; border-radius: 3px; padding: 0 1px; }
.diff-text .pmark { display: block; margin: 18px 0 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--line); }
.visual-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; width: 100%; }
.visual-grid figure { margin: 0; text-align: center; }
.visual-grid figcaption { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.visual-grid canvas { width: 100%; height: auto; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); background: #fff; }
.legend { display: inline-flex; gap: 14px; font-size: 13px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ------------------------------------------------------ Password generator */
.pw-page { max-width: 1100px; margin: 0 auto; padding: 44px 24px 70px; }
.pw-page > h1 { text-align: center; font-size: clamp(28px, 3.4vw, 40px); }
.pw-page > .lead { text-align: center; font-size: 18px; margin: 12px auto 34px; max-width: 720px; }
.pw-layout { display: grid; grid-template-columns: 400px 1fr; gap: 28px; align-items: start; }
.pw-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 24px 26px; box-shadow: var(--shadow); }
.pw-title { color: #e30613; font-size: 22px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.pw-mode { margin-bottom: 14px; }
.pw-form .check { font-size: 16px; margin: 11px 0; }
.pw-form .check input { accent-color: #e30613; width: 20px; height: 20px; }
.pw-form code { font-family: "Courier New", monospace; font-size: 14px; color: var(--muted); letter-spacing: 1px; }
.pw-select-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; font-size: 16px; color: var(--ink); }
.pw-select-row select { width: 76px; padding: 7px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; }
.pw-select-row input.input { width: 120px; }
.btn-pw {
  width: 100%; margin-top: 18px; border: 0; border-radius: 8px; background: #e30613; color: #fff;
  font-size: 20px; font-weight: 700; padding: 14px; cursor: pointer;
}
.btn-pw:hover { background: #c00510; }
.pw-results { display: grid; gap: 12px; }
.pw-item { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.pw-line { display: flex; gap: 12px; align-items: center; }
.pw-value {
  flex: 1; min-width: 0; font-family: "JetBrains Mono", "Consolas", "Courier New", monospace; font-size: 19px; color: var(--ink);
  word-break: break-all; letter-spacing: .5px;
}
.pw-value .d { color: #2b5db8; }
.pw-value .s { color: #e30613; }
.pw-meter { height: 6px; border-radius: 99px; background: var(--line); margin-top: 12px; overflow: hidden; }
.pw-meter span { display: block; height: 100%; border-radius: 99px; }
.pw-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.pw-empty { text-align: center; color: var(--muted); padding: 50px 20px; border: 2px dashed var(--line-strong); border-radius: 16px; }
.pw-tester { margin-top: 28px; }
.pw-tester h2 { font-size: 20px; margin-bottom: 12px; }
.pw-tips { margin: 12px 0 0; padding-left: 20px; font-size: 14px; }
.pw-tips li { margin: 4px 0; }
.pw-actions { display: flex; gap: 10px; justify-content: flex-end; margin-bottom: 4px; }

/* ------------------------------------------------------------- Responsive */
@media (max-width: 1100px) {
  :root { --sidebar-w: 320px; }
  .visual-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 960px) {
  .nav-toggle { display: block; }
  .mainnav {
    display: none; position: absolute; top: var(--topbar-h); left: 0; right: 0; background: #fff;
    flex-direction: column; align-items: stretch; padding: 10px 16px 18px; border-bottom: 1px solid var(--line);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .1); max-height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  }
  .mainnav.open { display: flex; }
  .mega-panel { position: static; transform: none; box-shadow: none; border: 0; padding: 8px 0; grid-template-columns: 1fr 1fr; width: auto; }
  .mega-btn { width: 100%; text-align: left; }
  .work-view { flex-direction: column; }
  .sidebar { width: 100%; position: static; height: auto; border-left: 0; border-top: 1px solid var(--line); }
  .sidebar-body { overflow: visible; }
  .sidebar-foot { position: sticky; bottom: 0; background: #fff; }
  .pw-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 0 16px; }
  .tools-section, .hero { padding-left: 16px; padding-right: 16px; }
  .tools-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tool-card { padding: 18px; min-height: 0; }
  .tool-card h3 { font-size: 16px; margin-top: 14px; }
  .tool-card p { font-size: 13px; }
  .mega-panel { grid-template-columns: 1fr; }
  .file-card { width: calc(50% - 8px); }
  .file-card .thumb { width: 100%; height: 160px; }
  .page-card { width: calc(33% - 10px); }
  .page-card .thumb { height: 120px; }
  .work-area { padding: 14px 16px 30px; gap: 12px; }
  .work-toolbar { padding: 12px 16px 0; }
  .cmp-slots { grid-template-columns: 1fr; }
  .visual-grid { grid-template-columns: 1fr; }
  .result-actions .btn-xl { min-width: 0; padding: 18px 20px; font-size: 18px; }
  .btn-upload { padding: 22px 26px; }
  .pw-page { padding: 28px 16px 50px; }
  .pw-value { font-size: 16px; }
}
@media (max-width: 400px) {
  .tools-grid { grid-template-columns: 1fr; }
}
