
:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --text: #e8eefc;
  --muted: #9aa8c7;
  --accent: #3dbbff;
  --border: #243047;
  --active: #1a2740;
  --link: #7dd3fc;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Segoe UI", "Tahoma", "Arial", "Noto Naskh Arabic", "Amiri", "Traditional Arabic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 16px;
}
.top {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  padding: .75rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { color: var(--accent); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.crumb { color: var(--muted); font-size: .9rem; }
.layout { display: grid; grid-template-columns: 280px 1fr; min-height: calc(100vh - 100px); }
.sidebar {
  background: var(--panel); border-left: 1px solid var(--border);
  padding: 1rem; overflow: auto; max-height: calc(100vh - 60px); position: sticky; top: 56px;
}
.sidebar .ch { font-weight: 700; color: var(--accent); margin: .8rem 0 .3rem; font-size: .92rem; }
.sidebar ul { list-style: none; padding: 0; margin: 0 0 .6rem; }
.sidebar li a { display: block; padding: .25rem .5rem; color: var(--text); text-decoration: none; border-radius: 6px; font-size: .9rem; }
.sidebar li.active a, .sidebar li a:hover { background: var(--active); color: var(--link); }
.content { padding: 1.5rem 2rem 3rem; max-width: 920px; }
.content h1 { font-size: 1.8rem; border-bottom: 1px solid var(--border); padding-bottom: .4rem; }
.content h2 { margin-top: 1.8rem; color: #c7e6ff; }
.content h3 { margin-top: 1.2rem; }
.content a { color: var(--link); }
.content table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: .92rem; }
.content th, .content td { border: 1px solid var(--border); padding: .45rem .6rem; vertical-align: top; }
.content th { background: var(--active); }
.content code { font-family: Consolas, "Courier New", monospace; background: #0f172a; padding: .1rem .35rem; border-radius: 4px; font-size: .88em; direction: ltr; display: inline-block; }
.content pre { background: #0f172a; padding: 1rem; overflow: auto; border-radius: 8px; border: 1px solid var(--border); direction: ltr; text-align: left; }
.content pre code { background: transparent; padding: 0; }
.content img { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #020617; }
.math-display { margin: 1rem 0; overflow-x: auto; text-align: center; direction: ltr; unicode-bidi: isolate; }
.math-inline, bdi.math-inline {
  display: inline-block;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  text-align: left;
}
/* KaTeX may split one formula into several .katex-base siblings; force LTR box order in RTL pages */
.math-inline .katex,
.math-display .katex {
  direction: ltr !important;
  unicode-bidi: isolate !important;
}
.math-inline .katex-html,
.math-display .katex-html {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: baseline !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
}
.f1-anchor[hidden] { display: none !important; }
.topic-ids { margin: 0 0 1rem; padding: .6rem .8rem; background: var(--active); border-radius: 8px; border: 1px dashed var(--border); }
.topic-ids a { margin-left: .5rem; color: var(--muted); text-decoration: none; }
.topic-ids a:target, .content span:target, .content a:target { outline: 2px solid var(--accent); background: #16324d; }
.f1-note { color: var(--muted); font-size: .9rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.pager a { color: var(--link); text-decoration: none; }
.foot { padding: .75rem 1.25rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); }
.index-list ul { margin: .3rem 0 .8rem; }
.math-note { color: var(--muted); }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: 0; max-height: none; border-left: none; border-bottom: 1px solid var(--border); }
}

.topic-ids, .topic-ids-hidden, .f1-note { display:none !important; }
.edition-banner.user { background:#14532d; color:#dcfce7; padding:.5rem .8rem; border-radius:8px; margin-bottom:1rem; }
.dev-note { display:none !important; }
