:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #1c2321;
  --muted: #5d6764;
  --border: #dfe3e1;
  --accent: #0f6e56;
  --accent-text: #ffffff;
  --accent-soft: #e3f1ec;
  --notice-bg: #fff6e0;
  --notice-text: #6b4e00;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --surface: #1b211f;
    --text: #e8ecea;
    --muted: #9aa5a1;
    --border: #2d3532;
    --accent: #3fb58f;
    --accent-text: #08130f;
    --accent-soft: #1d332b;
    --notice-bg: #3a2f12;
    --notice-text: #f3dc9b;
  }
}

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

body {
  margin: 0;
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}
.logo {
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--accent);
  text-decoration: none;
}
.badge {
  font-size: 0.85rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
}

.hero { text-align: center; padding: 32px 0 16px; }
.hero h1 { font-size: clamp(1.5rem, 5vw, 2.2rem); margin: 0 0 8px; line-height: 1.4; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 600px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { font-size: 2.5rem; }

.spinner {
  width: 40px; height: 40px;
  margin: 8px auto 12px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.editor {
  display: grid;
  gap: 16px;
  margin: 16px 0;
}
@media (min-width: 760px) {
  .editor { grid-template-columns: 1fr 1fr; align-items: start; }
}

.preview-frame {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: repeating-conic-gradient(var(--border) 0% 25%, transparent 0% 50%) 50% / 20px 20px;
  border-radius: var(--radius);
}
#preview {
  /* عرض ثابت للمعاينة، عشان المقاسات الصغيرة (200×200) ما تطلع صغيرة كثير */
  width: 320px;
  max-width: 100%;
  height: auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  touch-action: none;
  cursor: grab;
}
#preview:active { cursor: grabbing; }

.notice {
  background: var(--notice-bg);
  color: var(--notice-text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.controls { margin: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; margin-bottom: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit;
  font-size: 0.9rem;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.swatch { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border); }

input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 18px; height: 18px; }

.actions { display: flex; flex-direction: column; gap: 10px; }
.sheet-row { display: flex; gap: 8px; }
.sheet-row select { flex: 1; }
.sheet-row .btn { flex: 1; }

.btn, select {
  font: inherit;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.info h2 { font-size: 1.2rem; margin-top: 0; }
.info ol { padding-inline-start: 20px; }
details { border-top: 1px solid var(--border); padding: 10px 0; }
summary { cursor: pointer; font-weight: 600; }

/* ---------- قائمة الأدوات ---------- */
.tools-nav { border-top: 1px solid var(--border); }
.tools-nav .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-block: 6px;
}
.tools-nav a {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  white-space: nowrap;
}
.tools-nav a:hover { color: var(--text); background: var(--bg); }
.tools-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---------- عناصر الأدوات ---------- */
.field-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.field-row label { display: flex; align-items: center; gap: 6px; }
input[type="number"] {
  font: inherit;
  width: 110px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 0 0; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-weight: 700; font-size: 1.15rem; }
.stat.good { border-color: var(--accent); background: var(--accent-soft); }
.stat.good .value { color: var(--accent); }

.result-img {
  display: block;
  max-width: 100%;
  max-height: 50vh;
  margin: 0 auto;
  border-radius: 10px;
  background: var(--bg);
}

.file-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}
.file-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; background: var(--bg); }
.file-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.file-item .num { color: var(--muted); font-weight: 600; width: 1.5em; text-align: center; }
.icon-btn {
  font: inherit;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex: none;
}
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.progress-text { color: var(--muted); text-align: center; margin: 12px 0 0; }

/* ---------- صفحات الدول ---------- */
.spec-table { width: 100%; border-collapse: collapse; }
.spec-table th, .spec-table td {
  text-align: start;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.spec-table tbody th { font-weight: 600; white-space: nowrap; width: 1%; }
.table-scroll { overflow-x: auto; }
.sizes-table thead th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.sizes-table tbody th { white-space: normal; width: auto; }
.sizes-table td:last-child { white-space: nowrap; }

.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}
.country-card {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}
.country-card:hover { border-color: var(--accent); background: var(--accent-soft); }

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

/* ---------- صفحات المعلومات (من نحن، الخصوصية...) ---------- */
.prose { max-width: 760px; margin-inline: auto; }
.prose h2 { font-size: 1.2rem; margin: 24px 0 8px; }
.prose h2:first-child { margin-top: 0; }
.prose ul { padding-inline-start: 20px; }
.contact-email { font-size: 1.2rem; font-weight: 700; }
.footer-legal { margin-top: 4px; }

.site-footer { padding: 24px 0 40px; text-align: center; }
.footer-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-bottom: 8px; }
.footer-tools a { color: var(--muted); }
