:root {
  --bg: #100e0c;
  --bg-2: #1a1612;
  --line: #2c261f;
  --ink: #f6f1e8;
  --muted: #b3a89a;
  --gold: #e8b86d;
  --gold-2: #c48a3a;
  --danger: #e25b4a;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Tajawal", "Geeza Pro", "Noto Naskh Arabic", sans-serif;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(16, 14, 12, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 0;
}
.brand {
  font-weight: 800;
  font-size: 30px;
  line-height: 1;
  color: var(--gold);
  letter-spacing: -0.03em;
}
.search {
  flex: 1;
  display: flex;
  gap: 6px;
  min-width: 0;
}
.search input {
  flex: 1;
  min-width: 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 16px;
  outline: none;
}
.search input:focus { border-color: var(--gold); }
.langs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.langs button {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 0;
}
.langs button.on {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--bg-2);
}
.btn.gold { background: var(--gold); color: #1a1208; font-weight: 800; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px 28px;
  color: var(--muted);
  font-size: 13px;
}
.foot p { margin: 0; }
.foot button {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 2px;
}

.cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 10px;
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
}
.cat.on { background: var(--gold); color: #1a1208; border-color: var(--gold); }

@media (max-width: 719px) {
  .top {
    position: static;
    background: transparent;
    border-bottom: 0;
    backdrop-filter: none;
    padding-top: 0;
  }
  .bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(16, 14, 12, 0.96);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-bottom: 8px;
  }
  .cats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
    gap: 6px;
    padding: 8px 10px 2px;
  }
  .cat {
    padding: 8px 6px;
    font-size: 13px;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
  }
  body.is-watch .cats { display: none; }
}

main { padding: 6px 10px 32px; }
body.is-watch main { padding: 0 0 28px; }
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 14px 2px 8px;
  font-size: 18px;
}
.section-title h2 { margin: 0; font-size: inherit; }
.section-title span { color: var(--muted); font-size: 13px; font-weight: 500; }
button, input { font-family: inherit; }

.rail, .grid {
  display: grid;
  gap: 10px;
}
.rail {
  grid-auto-flow: column;
  grid-auto-columns: 148px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(5, 1fr); } }

.card { cursor: pointer; min-width: 0; }
.card.in { animation: rise 0.45s ease; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card.in { animation: none; }
}
#sentinel { height: 1px; margin: 0; padding: 0; }
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #221c16 center / cover no-repeat;
  border-radius: 10px;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.len {
  position: absolute;
  bottom: 6px;
  inset-inline-start: 6px;
  background: rgba(0,0,0,.72);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 700;
}
.ttl {
  margin: 6px 2px 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
}
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  margin: 4px 2px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
}
.resume {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.resume::-webkit-scrollbar { display: none; }
.resume-item {
  position: relative;
  flex: 0 0 148px;
  background: var(--bg-2);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
}
.resume-item .ttl { margin: 6px 8px 8px; font-size: 12px; }
.x {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: rgba(0,0,0,.7);
  color: #fff;
  cursor: pointer;
  z-index: 2;
}
.linkish {
  background: none;
  border: 0;
  color: var(--gold);
  cursor: pointer;
  font-weight: 700;
  padding: 0;
}

.watch { display: block; }
.frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000 center / cover no-repeat;
  overflow: hidden;
}
.frame iframe {
  position: absolute;
  inset-inline: 0;
  top: -42px;
  width: 100%;
  height: calc(100% + 42px);
  border: 0;
  background: #000;
}
.watch-pad { padding: 10px 12px 0; }
.watch-pad .ttl { margin: 0; font-size: 17px; -webkit-line-clamp: 3; }
.watch-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}
.save {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
}
.save.on { border-color: var(--danger); color: var(--danger); }
.next { padding: 14px 10px 0; }
.next h2 { margin: 0 2px 8px; font-size: 16px; }
.toast {
  position: fixed;
  bottom: 16px;
  inset-inline: 16px;
  z-index: 30;
  background: #2a241c;
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
  font-weight: 700;
}

.more, .status {
  display: block;
  width: 100%;
  margin-top: 16px;
  text-align: center;
}
.status { color: var(--muted); padding: 28px 0; }
.more { background: var(--bg-2); border: 1px solid var(--line); }

.empty { color: var(--muted); padding: 40px 8px; text-align: center; }

.hello {
  position: fixed;
  z-index: 40;
  inset-inline: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.hello[hidden] { display: none; }
.hello-card {
  pointer-events: auto;
  width: min(420px, 100%);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border-radius: 16px;
  background: #1b2420;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  animation: chat-in 0.28s ease;
}
.hello-ava {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  object-fit: cover;
  flex: 0 0 auto;
}
.hello-body { min-width: 0; flex: 1; }
.hello-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hello-top strong { font-size: 15px; }
.hello-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #25d366;
}
.hello-top span:last-of-type { color: var(--muted); font-size: 12px; }
.hello-x {
  margin-inline-start: auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.hello-body p { margin: 2px 0 0; font-size: 15px; font-weight: 700; }
.hello-body p + p { font-size: 13px; font-weight: 500; color: var(--muted); }
@keyframes chat-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hello-card { animation: none; }
}
