:root {
  --bg: #0a0b0f;
  --bg-2: #101219;
  --surface: #161923;
  --surface-2: #1d212c;
  --line: #262b38;
  --text: #eceef4;
  --muted: #969db0;
  --gold: #f3c264;
  --gold-dim: #a8863c;
  --good: #5fcf8e;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f3ef;
    --bg-2: #ffffff;
    --surface: #ffffff;
    --surface-2: #f2f1ec;
    --line: #e2e0d8;
    --text: #16181f;
    --muted: #6c7180;
    --gold: #a9791a;
    --gold-dim: #d8b978;
    --good: #2f9c66;
    --shadow: 0 8px 24px rgba(20, 20, 30, 0.09);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(1200px 600px at 80% -10%, var(--bg-2), var(--bg)) fixed;
  color: var(--text);
  font-family: 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 18px 90px;
}

/* ---------- الهيدر ---------- */
header.top {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}

.top-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.2px;
}

.brand .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px var(--gold);
}

nav.tabs {
  display: flex;
  gap: 4px;
  margin-inline-start: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: 999px;
}

nav.tabs a {
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  transition: 0.18s;
}

nav.tabs a:hover {
  color: var(--text);
}

nav.tabs a.active {
  background: var(--gold);
  color: #14110a;
}

/* ---------- أزرار ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: 0.16s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn:hover {
  border-color: var(--gold-dim);
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #14110a;
}

.btn.primary:hover {
  filter: brightness(1.07);
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: #e2706b;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* ---------- الهيرو والإحصائيات ---------- */
.hero {
  padding: 34px 0 22px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 800;
  letter-spacing: -0.5px;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 15.5px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 22px 0 8px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}

.stat b {
  display: block;
  font-size: 23px;
  font-weight: 800;
  line-height: 1.2;
}

.stat span {
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- شريط الأدوات ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 18px 0 20px;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.16s;
}

.chip.on {
  color: var(--text);
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 14%, transparent);
}

input,
select,
textarea {
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  outline: none;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold-dim);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

.filter-search {
  flex: 1 1 190px;
  min-width: 150px;
}

select.sort {
  width: auto;
  cursor: pointer;
}

/* ---------- الشبكة ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 18px 14px;
}

.card {
  display: block;
  cursor: pointer;
}

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(150deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: 0.22s;
}

.card:hover .poster {
  transform: translateY(-4px);
  border-color: var(--gold-dim);
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster .noimg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 40px;
  font-weight: 800;
  color: var(--gold-dim);
  opacity: 0.75;
  padding: 10px;
  text-align: center;
}

.badge {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  background: rgba(8, 9, 12, 0.82);
  color: var(--gold);
  border: 1px solid rgba(243, 194, 100, 0.35);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}

.fav-mark {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  font-size: 15px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
}

.tag-status {
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  padding: 22px 10px 8px;
  background: linear-gradient(to top, rgba(6, 7, 10, 0.9), transparent);
  color: #e9ebf1;
  font-size: 12px;
  font-weight: 600;
}

.card h3 {
  margin: 10px 2px 2px;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .sub {
  margin: 0 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty h3 {
  color: var(--text);
  margin: 0 0 8px;
  font-size: 18px;
}

/* ---------- النجوم ---------- */
.stars {
  display: inline-flex;
  flex-direction: row-reverse;
  gap: 2px;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 1px;
}

.stars.big {
  font-size: 27px;
  gap: 3px;
}

.star-pick {
  display: flex;
  flex-direction: row-reverse;
  gap: 4px;
  align-items: center;
}

.star-pick button {
  background: none;
  border: 0;
  padding: 0 1px;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  color: var(--line);
  transition: 0.12s;
}

.star-pick button.on {
  color: var(--gold);
}

.star-pick button:hover {
  transform: scale(1.12);
}

/* ---------- النافذة المنبثقة ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 8, 0.72);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: none;
  overflow-y: auto;
  padding: 26px 14px 60px;
}

.overlay.open {
  display: block;
}

.modal {
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  padding: 22px;
}

.modal h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.modal .hint {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 16px;
}

.row {
  display: flex;
  gap: 10px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--muted);
}

.results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 6px;
}

.result {
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  transition: 0.14s;
}

.result:hover {
  border-color: var(--gold-dim);
}

.result b {
  font-size: 15px;
}

.result span {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.preview {
  display: flex;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 16px;
}

.preview img,
.preview .ph {
  width: 78px;
  height: 117px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
  background: var(--surface-2);
}

.preview h4 {
  margin: 0 0 4px;
  font-size: 16px;
}

.preview p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.msg {
  font-size: 13.5px;
  color: var(--muted);
  padding: 10px 0;
}

.msg.err {
  color: #e2706b;
}

/* ---------- صفحة العمل ---------- */
.detail {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 30px;
  padding: 30px 0 10px;
}

.detail .poster-lg {
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  aspect-ratio: 2/3;
  background: var(--surface);
}

.detail .poster-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail h1 {
  margin: 0 0 6px;
  font-size: clamp(24px, 4.5vw, 34px);
  font-weight: 800;
  letter-spacing: -0.4px;
}

.detail .alt {
  color: var(--muted);
  font-size: 15px;
  margin: 0 0 14px;
  direction: ltr;
  text-align: start;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.pill {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--muted);
}

.pill.score {
  color: var(--gold);
  border-color: var(--gold-dim);
}

.overview {
  line-height: 1.95;
  font-size: 15.5px;
  color: #d3d7e2;
  margin-bottom: 22px;
}

@media (prefers-color-scheme: light) {
  .overview {
    color: #33363f;
  }
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.fact {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px 14px;
}

.fact span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.fact b {
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.6;
}

.mycard {
  background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 10%, var(--surface)), var(--surface));
  border: 1px solid var(--gold-dim);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 22px;
}

.mycard h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.mycard .note-view {
  white-space: pre-wrap;
  line-height: 1.8;
  font-size: 14.5px;
  margin-top: 12px;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  margin-top: 18px;
}

.back:hover {
  color: var(--gold);
}

@media (max-width: 720px) {
  .detail {
    grid-template-columns: 1fr;
    gap: 20px;
    padding-top: 18px;
  }

  .detail .poster-lg {
    width: 165px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px 11px;
  }

  .top-inner {
    flex-wrap: wrap;
    gap: 10px;
  }

  nav.tabs {
    margin-inline-start: 0;
    width: 100%;
    justify-content: center;
  }
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 30px 0 10px;
}

.fab {
  position: fixed;
  inset-inline-end: 20px;
  bottom: 20px;
  z-index: 25;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
  padding: 14px 20px;
  border-radius: 999px;
  font-size: 15px;
}
