:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev2: #1c2230;
  --border: #2b3340;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent2: #a371f7;
  --green: #3fb950;
  --gold: #e3b341;
  --radius: 14px;
  --font: "Vazirmatn", "Segoe UI", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 90% -10%, #1b2740 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,17,23,.6); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 34px; }
.brand h1 { margin: 0; font-size: 21px; }
.tag { margin: 0; color: var(--muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.last-run { color: var(--muted); font-size: 13px; }
.btn {
  background: linear-gradient(180deg, #21304d, #1a2438);
  color: var(--text); border: 1px solid var(--border);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-family: inherit;
  font-size: 14px; transition: .15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: progress; }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; padding: 22px 28px 6px;
}
.stat {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.stat .num { font-size: 28px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat .num.accent { color: var(--accent); }
.stat .num.green { color: var(--green); }
.stat .num.gold { color: var(--gold); }

.layout {
  display: grid; grid-template-columns: 270px 1fr;
  gap: 22px; padding: 18px 28px 40px; align-items: start;
}
@media (max-width: 880px) { .layout { grid-template-columns: 1fr; } }

.side {
  position: sticky; top: 86px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.side-title { font-size: 14px; color: var(--muted); margin: 4px 0 10px; }
.cats { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.cat {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 9px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; transition: .12s;
}
.cat:hover { background: var(--bg-elev2); }
.cat.active { background: var(--bg-elev2); border-color: var(--accent); }
.cat .c-name { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.cat .c-count {
  font-size: 12px; color: var(--muted); background: var(--bg);
  border-radius: 20px; padding: 1px 9px; min-width: 28px; text-align: center;
}
.langs { display: flex; flex-wrap: wrap; gap: 6px; }
.lang {
  font-size: 12px; padding: 4px 10px; border-radius: 20px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
}
.lang:hover, .lang.active { color: var(--text); border-color: var(--accent2); }

.content { display: flex; flex-direction: column; gap: 22px; }
.panel {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.panel-title { margin: 0 0 2px; font-size: 17px; }
.panel-sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

.cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg-elev2); border: 1px solid var(--border);
  border-radius: 22px; padding: 5px 12px; cursor: pointer; transition: .12s;
}
.chip:hover { border-color: var(--accent2); transform: translateY(-1px); }
.chip .t { font-size: 13px; }
.chip .n { font-size: 11px; color: var(--gold); }

.repo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.search, .select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 8px 12px; font-family: inherit; font-size: 13px;
}
.search { width: 230px; }
.search:focus, .select:focus { outline: none; border-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-elev2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; transition: .14s; min-height: 150px;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .repo-name { font-weight: 700; font-size: 15px; word-break: break-all; }
.card .repo-name .owner { color: var(--muted); font-weight: 400; }
.card .badge { font-size: 11px; color: var(--muted); white-space: nowrap; }
.card .desc { color: #c9d1d9; font-size: 13px; flex: 1; }
.card .meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.card .meta .dot::before { content: "●"; margin-inline-end: 5px; }
.card .topics { display: flex; flex-wrap: wrap; gap: 5px; }
.card .topic { font-size: 11px; background: var(--bg); border: 1px solid var(--border); color: var(--accent); border-radius: 20px; padding: 1px 8px; }
.lang-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--accent2); margin-inline-end: 5px; }

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

.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 18px 28px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px;
}

.skeleton { color: var(--muted); padding: 18px; }

/* ---- bell / alerts ---- */
.btn.icon { padding: 9px 12px; position: relative; }
.bell-wrap { position: relative; }
.badge-dot {
  position: absolute; top: 4px; left: 6px; min-width: 16px; height: 16px;
  background: #f85149; color: #fff; border-radius: 10px; font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.alerts-panel {
  position: absolute; top: 48px; left: 0; width: 320px; z-index: 30;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); overflow: hidden;
}
.alerts-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted);
}
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-family: inherit; font-size: 12px; }
.alerts-list { max-height: 320px; overflow-y: auto; }
.alert-item { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.alert-item:hover { background: var(--bg-elev2); }
.alert-item.unseen { border-inline-start: 3px solid var(--gold); }
.alert-item .a-time { color: var(--muted); font-size: 11px; }

/* ---- trend chart ---- */
.chart { width: 100%; overflow: hidden; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 10px; }
.legend .li { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.legend .li.off { opacity: .35; }
.legend .sw { width: 12px; height: 4px; border-radius: 3px; }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 20px; }
.modal-card {
  position: relative; width: min(860px, 100%); max-height: 88vh; overflow: hidden;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px;
  display: flex; flex-direction: column;
}
.modal-close { position: absolute; top: 12px; left: 12px; z-index: 2;
  background: var(--bg-elev2); border: 1px solid var(--border); color: var(--text);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.modal-body { overflow-y: auto; padding: 24px; }
.modal-title { font-size: 20px; margin: 0 0 4px; word-break: break-all; }
.modal-title .owner { color: var(--muted); font-weight: 400; }
.modal-meta { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 13px; margin: 8px 0 14px; }
.modal-actions { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.readme {
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; line-height: 1.8; direction: ltr; text-align: left; overflow-x: auto;
}
.readme img { max-width: 100%; height: auto; }
.readme pre { background: #0a0e14; padding: 12px; border-radius: 8px; overflow-x: auto; }
.readme code { background: #0a0e14; padding: 1px 5px; border-radius: 5px; font-size: 90%; }
.readme h1, .readme h2 { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.readme a { color: var(--accent); }
.readme table { border-collapse: collapse; }
.readme td, .readme th { border: 1px solid var(--border); padding: 6px 10px; }
.modal-loading { color: var(--muted); padding: 30px; text-align: center; }

/* ---- translation ---- */
.desc-fa {
  background: rgba(88,166,255,.08); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; color: #d6e4ff;
  margin-top: 4px; line-height: 1.8;
}
.mini-translate {
  align-self: flex-start; background: none; border: 1px solid var(--border);
  color: var(--accent); font-family: inherit; font-size: 11px; cursor: pointer;
  border-radius: 16px; padding: 2px 10px; margin-top: 2px;
}
.mini-translate:hover { border-color: var(--accent); background: var(--bg-elev); }
.readme-fa { line-height: 2; white-space: pre-wrap; }
.muted-inline { color: var(--muted); font-size: 13px; font-weight: 400; }
#repoTitle .link-btn { font-size: 13px; }
