:root {
  --bg: #e8e0d2;
  --ink: #172033;
  --muted: #5e564c;
  --navy: #10283d;
  --navy-2: #1a4060;
  --copper: #a56a34;
  --copper-deep: #7c4a1e;
  --teal: #0d6a62;
  --teal-soft: #e6f4f2;
  --rose: #8d3c3c;
  --rose-soft: #f8eeee;
  --gold: #c6a36a;
  --line: #ddd3c3;
  --card: #fffdf8;
  --shadow: 0 18px 40px rgba(16, 40, 61, 0.08);
  --side: 292px;
  --bar: 64px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --en: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(165, 106, 52, 0.16), transparent 55%),
    radial-gradient(700px 380px at 0% 0%, rgba(13, 106, 98, 0.08), transparent 50%),
    var(--bg);
  line-height: 1.75;
}
img, svg { max-width: 100%; }
button, input { font-family: inherit; }
a { color: var(--teal); }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

.en, .term .en, bdi { font-family: var(--en); direction: ltr; unicode-bidi: isolate; }

.app { min-height: 100vh; }
.side {
  position: fixed;
  inset: 0 0 0 auto;
  width: var(--side);
  background:
    linear-gradient(180deg, rgba(198, 163, 106, 0.16), transparent 180px),
    var(--navy);
  color: #f4efe6;
  overflow: auto;
  z-index: 20;
  padding: 18px 14px 28px;
}
.brand-block { padding: 8px 10px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 12px; }
.brand-block a { color: inherit; text-decoration: none; }
.brand-k { color: var(--gold); font-size: 12px; letter-spacing: 0.08em; }
.brand-block strong { display: block; font-size: 18px; line-height: 1.45; margin-top: 4px; }
.brand-block span { display: block; color: #c9d0d8; font-size: 12.5px; }
.brand-block .rights { margin-top: 8px; color: #e7d3b0; font-size: 12px; line-height: 1.45; }
.side h2 {
  margin: 16px 10px 6px;
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
}
.side a.item {
  display: block;
  color: #e7eef5;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.45;
}
.side a.item:hover, .side a.item.active { background: rgba(255,255,255,0.08); }
.side a.item.active { box-shadow: inset -3px 0 0 var(--gold); }

.main {
  margin-right: var(--side);
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.bar {
  position: relative;
  flex: none;
  z-index: 15;
  height: var(--bar);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  background: rgba(247, 243, 234, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick a {
  text-decoration: none;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}
.quick a[aria-current="page"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.tools { margin-right: auto; display: flex; gap: 8px; }
.tools button, .present-bar button, .builder button, .menu-btn {
  background: var(--navy);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13.5px;
}
.tools button.ghost, .present-bar button.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.menu-btn { display: none; }

.deck {
  flex: 1;
  min-height: 0;
  width: min(1080px, calc(100% - 28px));
  margin: 12px auto 0;
  padding-bottom: 96px;
  overflow: hidden;
}
.deck > .trail { display: none; }
.slide {
  display: none;
  height: 100%;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 28px 22px;
  box-shadow: var(--shadow);
}
.slide.on { display: block; }
.slide.hero {
  background:
    radial-gradient(500px 180px at 0% 0%, rgba(198, 163, 106, 0.25), transparent 60%),
    linear-gradient(160deg, #10283d, #1b4a68 70%, #0d6a62);
  color: #f7f3ea;
  border: 0;
}
.slide.hero .lead, .slide.hero .muted { color: #e4d8c6; }
.slide.hero .page-links a,
.slide.hero .card,
.slide.hero .lab,
.slide.hero .impact,
.slide.hero .story,
.slide.hero .think,
.slide.hero .def { color: var(--ink); }
.diagram text {
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  direction: rtl;
  unicode-bidi: isolate;
}
.kicker {
  margin: 0 0 6px;
  color: var(--copper-deep);
  font-weight: 700;
  font-size: 13px;
}
.hero .kicker { color: var(--gold); }
h1, h2, h3 { line-height: 1.35; margin: 0 0 8px; }
h1 { font-size: 40px; }
h2 { font-size: 28px; }
h3 { font-size: 18px; }
.lead { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.hero .muted { color: #d9d0c4; }

.grid-2, .grid-3 { display: grid; gap: 12px; margin: 12px 0; }
.grid-2 { grid-template-columns: 1.15fr 0.85fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.card, .impact, .story, .lab, .think, .def {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}
.card h3, .impact h3, .story h3, .lab h3, .think h3 { font-size: 16px; }
.card ul, .impact ul, .story ul, .lab ol, .lab ul { margin: 6px 0 0; padding: 0 18px 0 0; }
.card li + li, .impact li + li { margin-top: 4px; }
.impact.good { background: var(--teal-soft); border-color: #b7ddd8; }
.impact.risk { background: var(--rose-soft); border-color: #ecd0d0; }
.story { background: #fbf6ec; border-color: #ead9bc; }
.lab { background: #f3f7fb; border-color: #d3e0ea; }
.think { background: #f7f4ff; border-color: #ddd6f3; }
.def { background: #f6f8f7; }
.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--copper-deep);
  background: #f6eadb;
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 6px;
}
.story .tag { background: #f0e0c4; }
.lab .tag { background: #d9e8f5; color: #18486a; }
.think .tag { background: #e6e0f8; color: #43386a; }

.term {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: #f4efe6;
  border: 1px solid #e4d8c4;
  border-radius: 999px;
  padding: 2px 8px 2px 4px;
  margin: 2px 2px;
  vertical-align: middle;
}
.hero .term { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.16); color: #fff; }
.term .ar { font-weight: 600; }
.term .en {
  font-weight: 600;
  font-size: 13px;
  background: var(--navy);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
}
.hero .term .en { background: #c6a36a; color: #1b140c; }
.term .phon { color: var(--muted); font-size: 12px; }
.hero .term .phon { color: #eadfce; }
.say {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--teal);
  color: #fff;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.say svg { width: 15px; height: 15px; display: block; }
.say.on { background: var(--copper); animation: pulse 0.9s ease infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) {
  .say.on { animation: none; }
  html { scroll-behavior: auto; }
}

.table-wrap { overflow-x: auto; margin: 10px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; background: #fff; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: right; vertical-align: top; }
th { background: var(--navy); color: #fff; font-weight: 600; }
tr:nth-child(even) td { background: #faf7f2; }

.diagram {
  width: 100%;
  height: auto;
  background: linear-gradient(180deg, #fbf8f2, #fff);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.cap { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.cols-diagram { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.builder { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 12px; align-items: start; }
.builder .g { opacity: 0.18; }
.builder.show-server .g-server,
.builder.show-wan .g-wan,
.builder.show-wifi .g-wifi { opacity: 1; }
.builder-controls { display: flex; flex-direction: column; gap: 8px; }
.builder button { text-align: right; }
.builder button.on { background: var(--teal); }
#builderNote { min-height: 4.5em; }

.checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.check a { display: block; color: inherit; text-decoration: none; padding: 4px 0; }
.check a:hover { color: var(--teal); }
.check h3 { margin-bottom: 8px; }
.page-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.page-links a {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  min-height: 140px;
}
.page-links a strong { display: block; font-size: 20px; margin: 6px 0; }
.page-links a span { color: var(--muted); }

.glossary-tools { display: flex; gap: 8px; margin: 8px 0 12px; }
.glossary-tools input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
  background: #fff;
}
.gloss {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.gloss article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.steps { counter-reset: step; padding: 0; margin: 8px 0 0; list-style: none; }
.steps li {
  counter-increment: step;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 44px 10px 12px;
  margin: 0 0 8px;
  position: relative;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  right: 10px;
  top: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
}

.toast {
  display: none;
  position: fixed;
  bottom: 18px;
  left: 18px;
  background: var(--navy);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  z-index: 40;
}
.figure {
  margin: 12px 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.figure img {
  width: 100%;
  display: block;
  height: 320px;
  object-fit: cover;
}
.figure figcaption {
  padding: 8px 12px 12px;
  color: var(--muted);
  font-size: 14px;
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.atlas {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  min-height: 460px;
  background: #10283d;
}
.atlas > img {
  width: 100%;
  height: 460px;
  object-fit: cover;
  display: block;
  filter: saturate(0.9);
}
.pin {
  position: absolute;
  max-width: 230px;
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 10px 24px rgba(16, 40, 61, 0.18);
  font-size: 14px;
}
.pin strong { display: block; color: var(--copper-deep); }
.pin.a { top: 18px; right: 18px; }
.pin.b { top: 18px; left: 18px; }
.pin.c { bottom: 18px; right: 18px; }
.trail {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 28px;
}
.trail a {
  text-decoration: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
}
.trail .back { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.trail .go { background: var(--navy); color: #fff; }
.deck-bar {
  position: fixed;
  z-index: 25;
  left: 0;
  right: var(--side);
  bottom: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 8px 18px 12px;
  background: #10283d;
  color: #fff;
}
.deck-bar .rights {
  flex: 1 0 100%;
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: #e7d3b0;
}
.deck-bar button {
  font-family: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  background: #fff;
  color: var(--navy);
}
.deck-bar button.go { background: #c6a36a; color: #1b140c; }
.deck-bar .count { min-width: 5.2em; text-align: center; font-size: 14px; }
.deck-bar .track {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: rgba(255,255,255,0.18);
  overflow: hidden;
}
.deck-bar .track span { display: block; height: 100%; width: 0; background: #c6a36a; }
.footer-note { color: var(--muted); font-size: 13px; padding: 0 8px 20px; }

@media (max-width: 980px) {
  .side { transform: translateX(105%); transition: transform 0.2s ease; }
  body.nav-open .side { transform: none; }
  .main { margin-right: 0; height: 100vh; }
  .deck-bar { right: 0; }
  .menu-btn { display: inline-grid; place-items: center; }
  .grid-2, .grid-3, .checks, .page-links, .cols-diagram, .builder, .gloss, .pair { grid-template-columns: 1fr; }
  h1 { font-size: 32px; }
  .bar { height: auto; flex-wrap: wrap; padding: 8px; }
  .pair, .atlas { min-height: 0; }
  .pin { position: static; max-width: none; margin: 8px; }
  .atlas { display: flex; flex-direction: column; }
  .figure img, .atlas > img { height: 220px; }
}
@media print {
  .side, .bar, .say, .toast, .menu-btn, .trail, .deck-bar { display: none !important; }
  body { overflow: auto; height: auto; }
  .main { margin: 0; height: auto; display: block; }
  .deck { overflow: visible; height: auto; padding: 0; }
  .slide, .slide.on { display: block !important; height: auto; overflow: visible; break-inside: avoid; box-shadow: none; margin: 0 0 16px; }
  body { background: #fff; }
}
}
