/* ==========================================================
   DeviTest — أنماط الصفحات الفرعية (نفس هوية الصفحة الرئيسية)
   ========================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg-dark: #070a12; --bg-panel: #0f1624; --glass: rgba(15,22,36,0.75); --tile: rgba(0,0,0,0.3);
  --border: #1e293b; --border-light: #2d3b52; --text: #e2e8f0; --text-strong: #fff;
  --text-dim: #94a3b8; --text-dimmer: #8392aa; /* FIX: AA contrast */ --primary: #2563eb; /* FIX: AA contrast for white button text */ --primary-2: #1d4ed8;
  --accent: #06b6d4; --warning: #f59e0b; --purple: #8b5cf6;
  --glow-a: rgba(59,130,246,0.07); --glow-b: rgba(139,92,246,0.06);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg-dark: #eef2f7; --bg-panel: #fff; --glass: rgba(255,255,255,0.9); --tile: #f1f5f9;
  --border: #d6dee9; --border-light: #c3cede; --text: #0f172a; --text-strong: #0b1220;
  --text-dim: #475569; --text-dimmer: #526074; /* FIX: AA contrast */ --accent: #0e7490;
  --glow-a: rgba(59,130,246,0.1); --glow-b: rgba(139,92,246,0.08);
  color-scheme: light;
}
html, body { background: var(--bg-dark); color: var(--text); font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Arabic', Tahoma, 'Helvetica Neue', Arial, sans-serif; line-height: 1.8; }
body { isolation: isolate; min-height: 100vh; }
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(circle at 15% 20%, var(--glow-a), transparent 45%), radial-gradient(circle at 85% 80%, var(--glow-b), transparent 45%);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 820px; margin: 0 auto; padding: 20px; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 20px; background: var(--glass);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-strong); text-decoration: none; font-weight: 700; }
.brand img { width: 38px; height: 38px; border-radius: 10px; }
.top a.back { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 600; display: inline-block; padding: 4px 0; }
.calib-bars { direction: ltr; display: grid; grid-template-columns: repeat(8, 1fr); height: 6px; border-radius: 3px; overflow: hidden; margin-bottom: 22px; }
.calib-bars span:nth-child(1){background:#c0c0c0} .calib-bars span:nth-child(2){background:#c0c000}
.calib-bars span:nth-child(3){background:#00c0c0} .calib-bars span:nth-child(4){background:#00c000}
.calib-bars span:nth-child(5){background:#c000c0} .calib-bars span:nth-child(6){background:#c00000}
.calib-bars span:nth-child(7){background:#0000c0} .calib-bars span:nth-child(8){background:#131313}
article { background: var(--glass); border: 1px solid var(--border); border-radius: 20px; padding: 28px; }
article h1 { font-size: 26px; line-height: 1.4; color: var(--text-strong); margin-bottom: 10px; }
article .lead { color: var(--text-dim); font-size: 16px; margin-bottom: 20px; }
article h2 { font-size: 19px; margin: 26px 0 10px; color: var(--text-strong); }
article p, article li { color: var(--text-dim); font-size: 15px; }
article p + p { margin-top: 10px; }
article ol, article ul { padding-inline-start: 22px; display: grid; gap: 8px; }
article a { color: var(--accent); }
article b { color: var(--text); }
.note { margin: 18px 0; padding: 14px 16px; border-radius: 14px; background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25); font-size: 14px; color: var(--text-dim); }
.cta {
  display: inline-flex; align-items: center; gap: 10px; margin: 8px 0 4px;
  padding: 13px 22px; border-radius: 12px; text-decoration: none; font-weight: 600; font-size: 15px;
  color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 4px 15px rgba(59,130,246,0.3);
}
.cta.secondary { background: var(--tile); color: var(--text); border: 1px solid var(--border-light); box-shadow: none; }
.cta-row { display: flex; gap: 10px; flex-wrap: wrap; }
.related { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.related a { display: block; padding: 14px; border-radius: 12px; border: 1px solid var(--border-light); background: var(--tile); color: var(--text); text-decoration: none; font-weight: 600; }
.related a:hover { border-color: var(--primary); }
form { display: grid; gap: 12px; margin-top: 10px; }
label { font-size: 14px; color: var(--text-dim); display: grid; gap: 6px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--tile);
  border: 1px solid var(--border-light); border-radius: 10px; padding: 10px 12px; width: 100%;
}
textarea { min-height: 140px; resize: vertical; }
button.cta { border: none; cursor: pointer; font-family: inherit; }
footer { text-align: center; color: var(--text-dimmer); font-size: 12px; padding: 26px 10px; }
footer nav { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; }
footer a { color: var(--text-dim); text-decoration: none; display: inline-block; padding: 4px 2px; }
footer a:hover { color: var(--accent); }
@media (max-width: 600px) { .wrap { padding: 12px; } article { padding: 20px; } article h1 { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
/* روابط أعلى الصفحة: العودة + تبديل اللغة */
.top-links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.top a.lang {
  color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 4px 12px; border-radius: 20px; border: 1px solid rgba(59,130,246,0.3); background: rgba(59,130,246,0.1);
}

/* ================= أدوات تفاعلية (حاسبة PPI، فحص الجوال، اختبار التباين) ================= */
.tool { margin: 18px 0 6px; padding: 18px; border-radius: 16px; border: 1px solid var(--border-light); background: var(--tile); }
.tool h3 { font-size: 16px; color: var(--text-strong); margin-bottom: 6px; }
.tool p.hint { font-size: 14px; margin-bottom: 12px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tool .cta { margin: 0; padding: 10px 16px; font-size: 14px; }
.out { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.out div { padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-panel); }
.out small { display: block; color: var(--text-dimmer); font-size: 12px; }
.out strong { display: block; color: var(--text-strong); font-size: 20px; direction: ltr; unicode-bidi: plaintext; }
.status { margin-top: 10px; font-size: 14px; color: var(--text-dim); min-height: 1.5em; }
.status.ok { color: #22c55e; } .status.bad { color: var(--warning); }
.meter { height: 14px; border-radius: 7px; background: var(--bg-panel); border: 1px solid var(--border); overflow: hidden; margin-top: 12px; }
.meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, var(--warning)); transition: width .08s linear; }
.touch-pad { margin-top: 12px; height: 200px; border-radius: 12px; border: 1px dashed var(--border-light); background: var(--bg-panel);
  display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; text-align: center; font-size: 15px; color: var(--text-dim); }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 14px; border-radius: 12px; margin-top: 12px; direction: ltr; }
.levels div { aspect-ratio: 1; border-radius: 4px; display: grid; place-items: end center; font-size: 11px; padding-bottom: 4px; }
.levels:fullscreen { border-radius: 0; align-content: center; padding: 4vmin; gap: 1.2vmin; }

/* ================= الدفعة 5.7: كيبورد، ماوس، صوت، كاميرا، محدد البكسل، Gamma، مسطرة ================= */
select { width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-light); background: var(--bg-panel); color: var(--text); font: inherit; }
.kb { direction: ltr; overflow-x: auto; padding: 10px; border-radius: 12px; background: var(--bg-panel); border: 1px solid var(--border); margin-top: 12px; }
.kb-row { display: flex; gap: 4px; margin-bottom: 4px; min-width: 640px; }
.kb-row:last-child { margin-bottom: 0; }
.key { flex: 1 0 0; height: 40px; display: grid; place-items: center; border-radius: 6px; font-size: 11px; font-weight: 600;
  color: var(--text-dim); background: var(--tile); border: 1px solid var(--border-light); transition: background .1s; user-select: none; }
.key.done { background: rgba(34,197,94,.22); border-color: #22c55e; color: var(--text-strong); }
.key.down { background: var(--primary, #3b82f6); border-color: var(--primary, #3b82f6); color: #fff; }
.kb-gap { flex: .4 0 0; }
.click-area { margin-top: 12px; min-height: 220px; border-radius: 12px; border: 1px dashed var(--border-light); background: var(--bg-panel);
  display: grid; place-items: center; text-align: center; font-size: 15px; color: var(--text-dim); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.mbtns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; direction: ltr; }
.mbtn { padding: 12px 6px; border-radius: 10px; text-align: center; border: 1px solid var(--border-light); background: var(--tile); font-size: 13px; color: var(--text-dim); }
.mbtn.down { background: var(--primary, #3b82f6); color: #fff; border-color: transparent; }
.mbtn b { display: block; font-size: 22px; color: var(--text-strong); }
.mbtn.down b { color: #fff; }
.mbtn.warn { border-color: var(--warning); }
.cam-wrap { margin-top: 12px; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 16/9; display: grid; place-items: center; }
.cam-wrap video { width: 100%; height: 100%; object-fit: contain; }
.cam-wrap.mirror video { transform: scaleX(-1); }
.cam-wrap span { color: #888; font-size: 14px; padding: 20px; text-align: center; }
.fs-layer { position: fixed; inset: 0; z-index: 9999; cursor: crosshair; touch-action: none; }
.fs-bar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 10000; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
  padding: 8px; border-radius: 14px; background: rgba(20,24,36,.88); border: 1px solid rgba(255,255,255,.15); max-width: calc(100% - 20px); }
.fs-bar button { border: 0; border-radius: 9px; padding: 9px 12px; font: 600 13px inherit; cursor: pointer; color: #fff; background: rgba(255,255,255,.12); }
.fs-bar .sw { width: 34px; padding: 0; border: 2px solid rgba(255,255,255,.4); }
.fs-mark { position: fixed; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 2px solid #f0f; box-shadow: 0 0 0 2px #0ff; pointer-events: none; z-index: 9999; }
.fs-mark i { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font: 700 11px sans-serif; color: #f0f; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.plist { margin-top: 12px; font-size: 14px; direction: ltr; text-align: start; }
.plist li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.gamma-wrap { margin-top: 12px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; direction: ltr; }
.gamma-wrap figure { margin: 0; text-align: center; }
.gamma-wrap canvas { width: 100%; aspect-ratio: 1; border-radius: 8px; display: block; background: #000; }
.gamma-wrap figcaption { font-size: 13px; color: var(--text-strong); margin-top: 6px; font-weight: 600; }
.ruler-box { margin-top: 12px; overflow: hidden; border-radius: 12px; background: #f5f0e1; direction: ltr; }
.ruler-box canvas { display: block; width: 100%; }
.card-cal { margin-top: 12px; direction: ltr; display: flex; justify-content: center; }
.card-cal div { flex: 0 0 auto; max-width: calc(100vw - 8px); }
.card-cal div { height: 120px; box-sizing: border-box; border-radius: 10px; border: 2px solid var(--primary, #3b82f6); background: linear-gradient(135deg, rgba(59,130,246,.25), rgba(139,92,246,.25)); display: grid; place-items: center; font-size: 13px; color: var(--text-strong); }
input[type=range] { width: 100%; margin-top: 10px; }
[hidden] { display: none !important; }

/* ================= الدفعة 5.8: شاشات ملونة، يد تحكم، ميكروفون، CPS، رد الفعل ================= */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.color-btn { aspect-ratio: 1.3; border-radius: 12px; border: 1px solid var(--border-light); cursor: pointer; display: grid; place-items: end center; padding: 0 0 8px; }
.color-btn span { font: 600 12px inherit; padding: 2px 8px; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; }
input[type=color] { width: 56px; height: 44px; padding: 2px; border-radius: 10px; border: 1px solid var(--border-light); background: var(--bg-panel); cursor: pointer; }
.pad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 12px; direction: ltr; }
.pbtn { position: relative; overflow: hidden; padding: 10px 6px; border-radius: 10px; text-align: center; font-size: 12px; font-weight: 600; border: 1px solid var(--border-light); background: var(--tile); color: var(--text-dim); }
.pbtn i { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--accent); }
.pbtn.done { border-color: #22c55e; color: var(--text-strong); }
.pbtn.down { background: var(--primary); color: #fff; }
.sticks { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; margin-top: 14px; direction: ltr; }
.sticks figure { margin: 0; text-align: center; font-size: 12px; color: var(--text-dim); }
.stick { width: 110px; height: 110px; border-radius: 50%; border: 2px solid var(--border-light); background: radial-gradient(circle, var(--tile) 0 8%, var(--bg-panel) 9%); display: grid; place-items: center; margin-bottom: 6px; }
.stick b { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.stick.drift { border-color: var(--warning); }
.stick + figcaption { font-family: ui-monospace, monospace; }
.react-area { margin-top: 12px; min-height: 260px; border-radius: 14px; display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; cursor: pointer;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; font-size: 22px; font-weight: 700; color: #fff; padding: 20px; }
.react-area small { display: block; font-size: 14px; font-weight: 500; opacity: .9; }
.react-area b { font-size: 44px; }
.r-idle { background: #1e3a8a; } .r-wait { background: #b91c1c; } .r-go { background: #16a34a; } .r-early { background: #b45309; }
.cps-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; direction: ltr; text-align: center; }
.cps-stats div { padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-panel); }
.cps-stats b { display: block; font-size: 26px; color: var(--text-strong); }
.cps-stats small { color: var(--text-dimmer); font-size: 12px; }

/* FIX: accessibility — skip link and clear keyboard focus */
.skip-link { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 10001; padding: 10px 16px; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 12px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto !important; } .fs-bar { transition: none !important; } }
/* v6.5: FAQ on tool pages */
article h3.faq-q { font-size: 16px; line-height: 1.5; margin: 16px 0 4px; color: var(--text-strong); }

/* Ads (v7.0.3): no empty boxes — the label shows only once Google fills the slot;
   unfilled or blocked slots take no space */
.ad-slot { margin: 24px 0; clear: both; }
.ad-slot ins { width: 100%; }
.ad-slot::before { content: none; }
.ad-slot:has(ins[data-ad-status="filled"])::before { content: attr(data-label); display: block; font-size: 11px; color: var(--text-dimmer, var(--text-dim)); margin-bottom: 4px; letter-spacing: .02em; }
.ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad-slot:has(ins:empty) { margin: 0; }
@media print { .ad-slot { display: none !important; } }

/* Ruler fine-tune (v7.0.3) */
.rs-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; direction: ltr; }
.rs-row input { flex: 1; min-width: 0; }
.rs-step { min-width: 44px; padding: 8px 0; font-size: 18px; line-height: 1; }
.status.warn { color: var(--warning, #f59e0b); }
