:root {
  --bg: #f4f5f7;
  --white: #fff;
  --ink: #14181f;
  --muted: #6b7280;
  --border: #e6e8ec;
  --primary: #ee384e;
  --primary-soft: rgba(238, 56, 78, 0.1);
  --secondary: #00a651;
  --side: #111;
  --side-text: rgba(255,255,255,.78);
  --radius: 16px;
  --shadow: 0 10px 30px rgba(17,17,17,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  background: #f0f1f3;
  padding: 1px 6px;
  border-radius: 6px;
  direction: ltr;
  display: inline-block;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--side);
  color: #fff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none !important;
  padding: 4px 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--primary);
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.2rem;
}
.brand strong { display: block; font-size: 1rem; }
.brand small { color: rgba(255,255,255,.5); font-size: .75rem; }

.search-wrap { padding: 0 2px; }
.search {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: #fff;
  border-radius: 12px;
  padding: 11px 14px;
  outline: none;
}
.search::placeholder { color: rgba(255,255,255,.4); }
.search:focus { border-color: rgba(238,56,78,.55); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-section { margin-top: 8px; }
.nav-section-title {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  background: transparent; border: 0; color: rgba(255,255,255,.45);
  font: inherit; font-size: .78rem; font-weight: 700;
  padding: 10px 10px 6px; cursor: pointer; text-align: right;
}
.nav-section-title:hover { color: rgba(255,255,255,.8); }
.nav-items { display: none; flex-direction: column; gap: 2px; padding-bottom: 6px; }
.nav-section.open .nav-items { display: flex; }
.nav a {
  display: block;
  color: var(--side-text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none !important;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--primary-soft); color: #fff; }

.side-foot {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08);
}
.side-foot a {
  color: rgba(255,255,255,.65);
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none !important;
}
.side-foot a:hover { color: #fff; }

.main-wrap { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(244,245,247,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; gap: 14px;
}
.menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  width: 40px; height: 40px;
  cursor: pointer; font-size: 1.1rem;
}
.crumbs { flex: 1; color: var(--muted); font-size: .9rem; }
.crumbs strong { color: var(--ink); }
.top-link {
  background: var(--primary); color: #fff !important;
  padding: 9px 16px; border-radius: 999px;
  font-weight: 700; font-size: .88rem;
  text-decoration: none !important;
}

.content {
  padding: 28px;
  max-width: 920px;
  width: 100%;
}
.article {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 32px;
  box-shadow: var(--shadow);
}
.article h1 {
  font-size: 1.85rem;
  line-height: 1.35;
  margin-bottom: 8px;
}
.article .lead {
  color: var(--muted);
  margin-bottom: 22px;
  font-size: 1.02rem;
}
.article h2 {
  font-size: 1.25rem;
  margin: 28px 0 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.article h2:first-of-type { border-top: 0; padding-top: 0; }
.article h3 { font-size: 1.05rem; margin: 18px 0 8px; }
.article p { margin-bottom: 12px; }
.article ul, .article ol {
  margin: 0 0 14px 0;
  padding-right: 22px;
}
.article li { margin-bottom: 7px; }
.article pre {
  direction: ltr;
  text-align: left;
  background: #111;
  color: #e8ffe8;
  border-radius: 14px;
  padding: 14px 16px;
  overflow: auto;
  margin: 0 0 16px;
  font-size: .84rem;
  white-space: pre-wrap;
}
.article pre code { background: transparent; color: inherit; padding: 0; }
.note, .warn {
  border-radius: 14px;
  padding: 14px 16px;
  margin: 14px 0;
  font-size: .95rem;
}
.note { background: #eefaf3; border: 1px solid #cdeedc; }
.warn { background: #fff4f6; border: 1px solid #ffd0d7; }
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 18px 0 8px;
}
.card-link {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  color: inherit !important;
  text-decoration: none !important;
  transition: .15s border-color, .15s transform;
}
.card-link:hover { border-color: var(--primary); transform: translateY(-1px); }
.card-link strong { display: block; margin-bottom: 4px; }
.card-link span { color: var(--muted); font-size: .88rem; }

.pager {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 22px; flex-wrap: wrap;
}
.pager a {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--ink) !important;
  text-decoration: none !important;
  font-weight: 700;
  font-size: .9rem;
}
.pager a:hover { border-color: var(--primary); color: var(--primary) !important; }

.site-foot {
  padding: 8px 28px 28px;
  color: var(--muted);
  font-size: .85rem;
  max-width: 920px;
}
.site-foot .muted { margin-top: 4px; opacity: .85; }

.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 30;
}

.hidden-nav { display: none !important; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    transform: translateX(-110%);
    transition: transform .2s ease;
  }
  body.rtl-side .sidebar { inset: 0 0 0 auto; transform: translateX(110%); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .content, .topbar, .site-foot { padding-left: 16px; padding-right: 16px; }
  .article { padding: 20px; }
  .cards { grid-template-columns: 1fr; }
}
