:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #003566;
  --accent-dark: #001d3d;
  --border: #e2e8f0;
  --toc-bg: #f1f5f9;
  --radius: 12px;
  --shadow: 0 1px 3px rgb(15 23 42 / 8%);
  --font-en: "Inter", system-ui, -apple-system, sans-serif;
  --font-ar: "Noto Sans Arabic", "Inter", system-ui, sans-serif;
  --content-max: 720px;
  --page-max: 1100px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-en);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

html[lang="ar"] body {
  font-family: var(--font-ar);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-dark);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: #fff;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.updated {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.lang-switch a {
  padding: 0.35rem 0.85rem;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--text-muted);
}

.lang-switch a.active,
.lang-switch a:hover {
  color: var(--accent);
  background: var(--toc-bg);
}

.hero {
  background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}

.hero-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 2rem;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  max-width: 42rem;
  color: var(--text-muted);
  font-size: 1.0625rem;
}

.layout {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  display: grid;
  gap: 2rem;
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: start;
  }
}

.toc {
  position: sticky;
  top: 5.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.toc h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li + li {
  margin-top: 0.35rem;
}

.toc a {
  display: block;
  padding: 0.25rem 0;
  font-size: 0.9375rem;
  text-decoration: none;
  color: var(--text);
}

.toc a:hover {
  color: var(--accent);
}

.content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  box-shadow: var(--shadow);
}

.content section + section {
  margin-top: 2.25rem;
  padding-top: 2.25rem;
  border-top: 1px solid var(--border);
}

.content h2 {
  margin: 0 0 0.75rem;
  font-size: 1.375rem;
  line-height: 1.3;
  color: var(--accent-dark);
}

.content h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.0625rem;
}

.content p,
.content li {
  color: var(--text);
}

.content ul {
  margin: 0.5rem 0 0;
  padding-inline-start: 1.25rem;
}

.content li + li {
  margin-top: 0.35rem;
}

.content .note {
  margin-top: 1rem;
  padding: 1rem 1.125rem;
  background: var(--toc-bg);
  border-radius: 8px;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--text-muted);
}

html[dir="rtl"] .toc ol {
  padding-inline-start: 0;
}

html[dir="rtl"] .content ul {
  padding-inline-start: 1.25rem;
}

@media (max-width: 959px) {
  .toc {
    position: static;
  }
}
