:root {
  --accent: #2563eb;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ok: #16a34a;
  --err: #dc2626;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0f17; --card: #131a26; --text: #e5e7eb; --muted: #94a3b8; --border: #243042; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
}
main { max-width: 860px; margin: 0 auto; padding: 0 16px 48px; }
button, input { font: inherit; }

.topbar {
  max-width: 860px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-inline-end: 8px; }
.lang-btn { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 4px 14px; cursor: pointer; text-decoration: none; font-size: .95rem; }
.lang-btn:hover { border-color: var(--accent); }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .85rem; color: var(--muted); padding-top: 4px; }
.crumbs a { color: var(--muted); }

.hero { text-align: center; padding: 40px 0 24px; }
.hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); margin: 0 0 8px; line-height: 1.25; }
.sub { color: var(--muted); margin: 0 0 28px; }

.search {
  display: flex; gap: 8px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px; box-shadow: 0 6px 24px rgba(15, 23, 42, .06);
}
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text);
  padding: 10px 12px; font-size: 1rem; direction: ltr; text-align: start;
}
[dir="rtl"] .search input:placeholder-shown { direction: rtl; }
.search:focus-within { border-color: var(--accent); }

.primary, .ghost {
  border-radius: 10px; padding: 10px 20px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; transition: filter .15s, opacity .15s;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { filter: brightness(1.1); }
.primary:disabled { opacity: .55; cursor: wait; }
.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.wide { width: 100%; margin-top: 12px; }

.platforms { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 18px; }
.platforms span { font-size: .8rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; }

.status { text-align: center; padding: 14px; border-radius: var(--radius); margin: 8px 0 16px; }
.status.loading { color: var(--muted); }
.status.note { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text); }
.status.error { background: color-mix(in srgb, var(--err) 10%, transparent); color: var(--err); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-inline-end: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.result { display: grid; grid-template-columns: 280px 1fr; gap: 20px; padding: 16px; margin-bottom: 32px; }
.media { position: relative; }
.media img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; background: var(--border); display: block; }
.dur { position: absolute; bottom: 8px; inset-inline-end: 8px; background: rgba(0,0,0,.75); color: #fff; font-size: .8rem; padding: 1px 8px; border-radius: 6px; direction: ltr; }
.info h2 { font-size: 1.1rem; margin: 0 0 4px; line-height: 1.4; overflow-wrap: anywhere; }
.muted { color: var(--muted); margin: 0; font-size: .9rem; }

.tabs { display: flex; gap: 6px; margin: 16px 0 10px; background: var(--bg); padding: 4px; border-radius: 12px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 9px; cursor: pointer; font-weight: 600; }
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.qualities { display: flex; flex-wrap: wrap; gap: 6px; }
.qualities button {
  border: 1px solid var(--border); background: transparent; color: var(--text);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: .9rem;
}
.qualities button.active { border-color: var(--accent); color: var(--accent); font-weight: 700; }

.progress-box { margin-top: 14px; }
.progress { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
#bar { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s; }
#bar.indeterminate { width: 35% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { margin-inline-start: -35%; } 100% { margin-inline-start: 100%; } }
.progress-meta { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-top: 6px; }
.done-box .ok { color: var(--ok); font-weight: 700; margin: 14px 0 0; }

.how, .faq, .article, .related { margin-top: 40px; }
.how h2, .faq h2, .article h2, .related h2 { font-size: 1.3rem; line-height: 1.4; }
.article { max-width: 70ch; }
.article p { margin: 0 0 12px; }
.related ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.related a { display: block; height: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; color: var(--text); text-decoration: none; font-weight: 500; }
.related a:hover { border-color: var(--accent); color: var(--accent); }
.not-found { text-align: center; padding-top: 72px; }
.steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; counter-reset: s; }
.steps li { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; counter-increment: s; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; margin-bottom: 8px; }
.steps p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.faq details { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { color: var(--muted); margin: 8px 0 0; }

footer { text-align: center; padding: 24px 16px 40px; border-top: 1px solid var(--border); }
footer nav { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin-bottom: 8px; }
footer .muted { margin-top: 4px; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 0; font-size: .9rem; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); max-width: 560px; width: calc(100% - 32px); padding: 24px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog p { color: var(--muted); }

@media (max-width: 680px) {
  .result { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .search { flex-wrap: wrap; }
  .search input { flex-basis: 100%; }
  .search button { flex: 1; }
}
