:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --text: #1d2321;
  --muted: #66706b;
  --line: #e3dfd6;
  --accent: #1f6b52;
  --accent-soft: #e2efe9;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121514;
    --card: #1b1f1e;
    --text: #e8ebe9;
    --muted: #98a29d;
    --line: #2b3130;
    --accent: #5fbf98;
    --accent-soft: #1f3129;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  line-height: 1.6;
}
button, select, input { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.logo { font-size: 26px; font-weight: 700; color: var(--accent); text-decoration: none; }
#q {
  flex: 1; min-width: 200px;
  padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card);
}
#q:focus { outline: 2px solid var(--accent); border-color: transparent; }
.tabs { display: flex; gap: 4px; }
.tabs button {
  border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted);
}
.tabs button.on { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.filters { padding: 12px 24px 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.chips button {
  flex: none;
  border: 1px solid var(--line); background: var(--card);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips.small button { padding: 4px 12px; font-size: 14px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
#sort { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 10px; }

main { padding: 8px 24px 32px; }
.count { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px 16px; }
.card { cursor: pointer; background: none; border: 0; padding: 0; text-align: right; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dur {
  position: absolute; bottom: 6px; left: 6px;
  background: rgba(0, 0, 0, .78); color: #fff;
  font-size: 12px; padding: 1px 6px; border-radius: 4px; direction: ltr;
}
.card h3 {
  margin: 8px 0 2px; font-size: 15px; font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card p { margin: 0; font-size: 13px; color: var(--muted); }
.card:hover h3 { color: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 48px 0; grid-column: 1 / -1; }
.more {
  display: block; margin: 28px auto 0;
  border: 1px solid var(--line); background: var(--card);
  padding: 10px 28px; border-radius: 999px; cursor: pointer;
}

dialog#player {
  width: min(960px, 96vw); padding: 0; border: 0; border-radius: 16px;
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .7); }
.frame { aspect-ratio: 16 / 9; background: #000; }
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.player-info { padding: 12px 20px 18px; }
.player-info h2 { margin: 0 0 4px; font-size: 18px; }
.player-info p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button, .actions a {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; font-size: 14px;
}
.actions button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; border-top: 1px solid var(--line); }

@media (max-width: 600px) {
  .top, .filters, main { padding-left: 16px; padding-right: 16px; }
  .top { gap: 10px; }
  .logo { font-size: 22px; }
  #q { order: 3; flex-basis: 100%; }
  .grid { grid-template-columns: 1fr; }
}
