:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --text: #1b1b1f;
  --muted: #6b6b75;
  --border: #e3e1da;
  --accent: #b4232a;
  --chip: #ecebe5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 14px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316;
    --surface: #1c1d22;
    --text: #ececef;
    --muted: #9a9aa5;
    --border: #2c2d33;
    --accent: #e25159;
    --chip: #26272d;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #121316;
  --surface: #1c1d22;
  --text: #ececef;
  --muted: #9a9aa5;
  --border: #2c2d33;
  --accent: #e25159;
  --chip: #26272d;
  --shadow: none;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif;
  line-height: 1.6;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* الرأس */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; }
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 1.9rem; font-weight: 800; color: var(--accent); }
.tagline { color: var(--muted); font-size: 0.95rem; }
.tools { display: flex; align-items: center; gap: 8px; }
.updated { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 1.1rem; cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }

.controls { padding-top: 12px; padding-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
#search {
  width: 100%; padding: 10px 14px; font: inherit;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
#search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.filters { display: flex; gap: 8px; min-width: 0; max-width: 100%; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid transparent;
  background: var(--chip); color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip .n { color: var(--muted); font-size: 0.8rem; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: 0.7; }
.chip.down { opacity: 0.55; }

/* الأخبار */
.status { color: var(--muted); text-align: center; margin: 24px 0; }
.status:empty { display: none; }
.grid {
  display: grid; gap: 16px; padding: 8px 0 24px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
  transition: transform 0.15s, border-color 0.15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.thumb { aspect-ratio: 16 / 9; background: var(--chip); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.meta { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--muted); }
.src { font-weight: 700; }
.card h2 { margin: 0; font-size: 1.08rem; line-height: 1.5; font-weight: 700; }
.card p {
  margin: 0; color: var(--muted); font-size: 0.92rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.foot { color: var(--muted); font-size: 0.82rem; text-align: center; padding-bottom: 28px; }

@media (max-width: 600px) {
  .tagline { display: none; }
  .updated { display: none; }
  .brand h1 { font-size: 1.6rem; }
  .grid { grid-template-columns: 1fr; }
}
