/* PDF Medic Online — the app's brand tokens, light and dark. */
:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef2f3;
  --ink: #17212b;
  --ink-2: #4a5866;
  --line: #d9e0e4;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e0f2ef;
  --brand: #d92d20;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --error: #b42318;
  --error-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 33, 43, 0.06), 0 4px 16px rgba(23, 33, 43, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f161c;
    --surface: #17212b;
    --surface-2: #1e2a35;
    --ink: #eef2f4;
    --ink-2: #a9b6c1;
    --line: #2c3a46;
    --accent: #2dd4bf;
    --accent-ink: #062b28;
    --accent-soft: #123a36;
    --brand: #f97066;
    --warn: #f5b546;
    --warn-soft: #3a2c10;
    --error: #ff8a80;
    --error-soft: #3d1a17;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
}
a { color: var(--accent); }
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; margin-top: 2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ header */
.site-head { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.logo img { width: 32px; height: 32px; border-radius: 8px; }
.site-head nav { margin-inline-start: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.site-head nav a { color: var(--ink); text-decoration: none; padding: 10px 12px; border-radius: 10px; min-height: 44px; display: inline-flex; align-items: center; }
.site-head nav a:hover { background: var(--surface-2); }

/* -------------------------------------------------------------------- hero */
.hero { padding: 28px 0 8px; }
.hero p.lead { font-size: 1.1rem; color: var(--ink-2); max-width: 60ch; }
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-soft); color: var(--ink); border-radius: 999px;
  padding: 6px 14px; font-size: 0.92rem; font-weight: 600; margin-bottom: 14px;
}
.badge svg { width: 18px; height: 18px; color: var(--accent); flex: none; }

/* -------------------------------------------------------------- tool grid */
.cat { margin: 24px 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
:lang(ar) .cat { text-transform: none; letter-spacing: 0; font-size: 0.95rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px; min-height: 92px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card strong { display: block; margin-bottom: 2px; }
.card span { color: var(--ink-2); font-size: 0.9rem; line-height: 1.4; }
.icon {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.icon svg { width: 24px; height: 24px; }

/* -------------------------------------------------------------- tool page */
.tool-head { display: flex; gap: 14px; align-items: center; margin: 24px 0 6px; }
.tool-head .icon { width: 52px; height: 52px; }
.tool-head h1 { margin: 0; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin: 16px 0;
}
.tool-body > * + * { margin-top: 16px; }
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 40px 16px;
  text-align: center; background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop p { margin: 10px 0 0; }
.drop-small { padding: 14px; }
.drop-small .btn-big { min-height: 44px; font-size: 1rem; padding: 8px 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-big { min-height: 56px; padding: 14px 28px; font-size: 1.1rem; }
.btn-link { background: none; border: none; color: var(--accent); padding: 8px 4px; min-height: 44px; font-weight: 600; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; flex: none;
}
.icon-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.file {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface-2); border-radius: 12px;
}
.file-icon {
  flex: none; width: 40px; height: 48px; border-radius: 6px; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-size: 0.7rem; font-weight: 800;
}
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files.small { font-size: 0.92rem; }

fieldset.choice { border: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
fieldset.choice legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.field { display: grid; gap: 6px; }
.field-label { font-weight: 600; }
input[type="text"], input[type="password"], input[type="number"], select {
  font: inherit; color: var(--ink); background: var(--surface); min-height: 48px;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; max-width: 420px;
}
input[type="range"] { width: 100%; max-width: 420px; accent-color: var(--accent); }
input[type="color"] { width: 56px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.check.warn { background: var(--warn-soft); padding: 12px; border-radius: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }

.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress .bar { height: 100%; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 0.2s; }
[dir="rtl"] .progress .bar { transform-origin: right; }
.error { color: var(--error); background: var(--error-soft); padding: 12px 14px; border-radius: 12px; }
[hidden] { display: none !important; }
.note { background: var(--warn-soft); padding: 10px 14px; border-radius: 12px; }
.result { text-align: center; }
.result-msg { font-size: 1.2rem; font-weight: 700; }
.result .btn-big { margin: 8px 0; }
.loading::before {
  content: ""; display: inline-block; width: 16px; height: 16px; margin-inline-end: 8px; vertical-align: -3px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; inset-inline: 16px; bottom: 16px; margin: 0 auto; max-width: 420px; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; text-align: center;
}

/* page previews (rotate, crop, redact, watermark) */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.thumb { display: grid; gap: 6px; justify-items: center; font-size: 0.85rem; color: var(--ink-2); }
.thumb button { padding: 0; border: 2px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; overflow: hidden; line-height: 0; }
.thumb button[aria-pressed="true"] { border-color: var(--accent); }
.thumb img { transition: transform 0.2s; max-height: 160px; }
.stage { position: relative; display: inline-block; max-width: 100%; line-height: 0; background: #fff; border: 1px solid var(--line); touch-action: none; user-select: none; -webkit-user-select: none; }
.stage img { display: block; width: 560px; max-width: 100%; height: auto; aspect-ratio: auto 595 / 842; }
.stage-wrap { text-align: center; }
.crop-box { position: absolute; border: 2px solid var(--accent); box-shadow: 0 0 0 9999px rgba(23, 33, 43, 0.45); cursor: move; }
.crop-box i { position: absolute; width: 22px; height: 22px; background: var(--accent); border-radius: 50%; }
.redact-box { position: absolute; background: rgba(0, 0, 0, 0.82); border: 1px solid #000; cursor: pointer; }
.redact-box.off { background: rgba(217, 45, 32, 0.12); border: 1px dashed var(--brand); }
.stage-clip { overflow: hidden; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; }
.finds { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 280px; overflow: auto; }
.finds label { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); min-height: 44px; }
.finds span[dir] { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.finds .btn-link { min-height: 32px; padding: 4px; white-space: nowrap; font-size: 0.85rem; }
.finds .kind { font-size: 0.8rem; color: var(--ink-2); white-space: nowrap; }
.row .field { flex: 1; min-width: 200px; }

/* signature preview: squares show see-through areas */
.checker {
  display: inline-block; max-width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px;
  background-color: #fff; background-image: linear-gradient(45deg, #e6e9ec 25%, transparent 25%, transparent 75%, #e6e9ec 75%), linear-gradient(45deg, #e6e9ec 25%, transparent 25%, transparent 75%, #e6e9ec 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.sig-preview { display: block; max-width: 100%; max-height: 320px; }

/* links to a tool's preset pages */
.sizes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 8px; }
.chip-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 0.92rem;
}
.chip-link:hover { border-color: var(--accent); }

/* ------------------------------------------------------------- ad slots */
.ad {
  margin: 24px auto; min-height: 120px; display: grid; place-items: center; text-align: center;
  border-radius: var(--radius); background: var(--surface-2); color: var(--ink-2); font-size: 0.75rem;
}
.ad:empty::before, .ad[data-empty]::before { content: attr(data-label); }

/* ----------------------------------------------------------- content */
.steps { padding-inline-start: 1.3em; }
.steps li { margin-bottom: 0.5em; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; margin-bottom: 8px; }
summary { cursor: pointer; font-weight: 600; padding: 14px 0; min-height: 44px; }
details p { margin-top: 0; }
.app-promo { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.app-promo img { width: 64px; height: 64px; border-radius: 14px; }
.app-promo div { flex: 1; min-width: 220px; }

.site-foot { margin-top: 48px; padding: 24px 0 40px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 0.9rem; }
.site-foot .wrap { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-foot a { color: var(--ink-2); padding: 10px 0; }
.site-foot .spacer { flex: 1; }

@media (max-width: 560px) {
  .panel { padding: 14px; }
  .drop { padding: 28px 12px; }
  .site-head nav a { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
