:root {
  --bg: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #1a56db;
  --accent-dark: #0f3fa8;
  --accent-ink: #ffffff;
  --chip: #f2f4f7;
  --drop: #f8f9fc;
  --res: #475467;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --ink: #f2f4f7;
    --muted: #98a2b3;
    --line: #1f2937;
    --chip: #16213b;
    --drop: #101a30;
  }
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Arabic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

/* ---------- header / footer ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.9rem 1rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.logo span { color: var(--accent); }

.site-nav {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-nav a:hover { color: var(--ink); }

#lang-switch {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  color: var(--accent) !important;
  font-weight: 600;
}

.site-main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.5rem 1rem 2.5rem;
}

.site-footer {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin-bottom: 0.6rem;
}

.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--ink); }

/* ---------- home ---------- */

.hero { padding: 2.2rem 0 1.6rem; text-align: center; }

.hero h1 {
  font-size: 1.9rem;
  line-height: 1.25;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.hero-sub { color: var(--muted); margin: 0 0 1rem; font-size: 1.05rem; }

.hero-privacy {
  display: inline-block;
  background: var(--chip);
  color: var(--res);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  margin: 0;
}

.tool-grid-section { margin: 1.2rem 0 2rem; }

.section-title {
  font-size: 1.15rem;
  margin: 1.4rem 0 0.8rem;
  letter-spacing: -0.01em;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.8rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.tool-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--ink);
  background: var(--drop);
}

.tool-card:hover { border-color: var(--accent); }

.tool-card strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.tool-card span { color: var(--muted); font-size: 0.88rem; }

/* ---------- tool page ---------- */

.tool-header h1, .legal-header h1 {
  font-size: 1.6rem;
  line-height: 1.3;
  margin: 1.6rem 0 0.6rem;
  letter-spacing: -0.02em;
}

.tool-intro { color: var(--muted); margin: 0 0 1.4rem; }

.tool-page h2, .tool-widget h2, .legal-page h2 { font-size: 1.2rem; letter-spacing: -0.01em; }

/* ---------- widget ---------- */

.widget {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--drop);
  padding: 1.1rem;
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1rem;
  text-align: center;
  background: var(--bg);
  transition: border-color 0.15s ease;
}

.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dropzone.dragover { border-color: var(--accent); background: var(--chip); }

.drop-hint { display: block; color: var(--muted); margin-bottom: 0.8rem; }

.file-list {
  list-style: none;
  padding: 0;
  margin: 0.9rem 0 0;
}

.file-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  margin-bottom: 0.4rem;
  font-size: 0.92rem;
}

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 0.85rem;
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink);
}

.icon-btn:disabled { opacity: 0.35; cursor: default; }

.file-meta { color: var(--muted); font-size: 0.9rem; margin: 0.9rem 0 0; }

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  align-items: center;
  margin-top: 0.9rem;
  font-size: 0.95rem;
}

.quality-row { display: inline-flex; gap: 0.4rem; align-items: center; }

.quality-row select {
  font: inherit;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.8rem;
  align-items: center;
  margin-top: 0.9rem;
  font-size: 0.95rem;
}

.field-row input {
  flex: 1;
  min-width: 12rem;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}

.field-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.widget-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-reset { border-color: transparent; background: transparent; color: var(--muted); }

.size-compare {
  margin: 0.9rem 0 0;
  font-variant-numeric: tabular-nums;
  color: var(--res);
  font-size: 0.95rem;
}

.status {
  margin: 0.7rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.3em;
}

.status.error { color: #b42318; }

/* ---------- howto / why / faq / related ---------- */

.tool-howto, .tool-why, .tool-faq, .tool-related { margin-top: 2.2rem; }

.tool-howto ol { padding-inline-start: 1.3rem; margin: 0.6rem 0 0; }
.tool-howto li { margin-bottom: 0.35rem; }

.tool-why p, .tool-faq p { color: var(--res); margin: 0.5rem 0 0; }

.faq-item { border-top: 1px solid var(--line); padding: 0.8rem 0; }
.faq-item:last-child { border-bottom: 1px solid var(--line); }

.faq-item h3 {
  font-size: 1rem;
  margin: 0 0 0.35rem;
  letter-spacing: -0.01em;
}

.related-list {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.related-list a { text-decoration: none; font-weight: 600; }

/* ---------- legal ---------- */

.legal-updated { color: var(--muted); font-size: 0.9rem; margin: 0 0 1.5rem; }

.legal-page h2 { margin: 1.6rem 0 0.4rem; }

.legal-page p { color: var(--res); margin: 0.4rem 0 0; }

/* ---------- RTL ---------- */

[dir="rtl"] { text-align: right; }

[dir="rtl"] .file-list li { flex-direction: row-reverse; }

/* ---------- small screens upgrade ---------- */

@media (min-width: 40rem) {
  .hero h1 { font-size: 2.4rem; }
  .tool-header h1, .legal-header h1 { font-size: 1.9rem; }
}

@media print {
  .site-header, .site-footer, .tool-related, .status { display: none; }
}

/* ---------- text tools ---------- */

.text-widget textarea {
  width: 100%;
  min-height: 9rem;
  resize: vertical;
  font: inherit;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}

.text-widget textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.text-widget textarea[readonly] { background: var(--drop); color: var(--ink); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.5rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
}

.stats li {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  text-align: center;
}

.stats b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.stats span { color: var(--muted); font-size: 0.8rem; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.9rem; }

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.88rem; font-weight: 600; }

.copy-note { color: var(--accent); font-size: 0.85rem; min-height: 1.2em; margin: 0.5rem 0 0; }

/* ---------- password ---------- */

.pw-out {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-top: 0.9rem;
}

.pw-out output {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  padding: 0.55rem 0.7rem;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  display: block;
}

.opt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.4rem 0.9rem;
  margin-top: 0.9rem;
  font-size: 0.95rem;
}

.opt-grid label { display: flex; gap: 0.4rem; align-items: center; }

.len-row {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin-top: 0.9rem;
  font-size: 0.95rem;
}

.len-row input[type="range"] { flex: 1; accent-color: var(--accent); }

.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  margin-top: 0.8rem;
  overflow: hidden;
}

.meter i { display: block; height: 100%; width: 0; background: #d92d20; transition: width .2s ease, background .2s ease; }

/* ---------- pdf-to-jpg thumbs ---------- */

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.6rem;
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
}

.thumbs li { text-align: center; }

.thumbs img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: block;
}

.thumbs .page-n {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0.25rem 0;
}

.thumbs .btn { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
