.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; background: var(--panel); transition: background-color .4s var(--ease); }
.side-wrap { background: var(--side); transition: background-color .4s var(--ease); }
.side { position: sticky; top: 0; height: 100dvh; min-height: 440px; display: flex; flex-direction: column; gap: 30px; padding: 26px 18px; }
.side .brand { padding: 0 10px; }
.side nav { display: grid; gap: 4px; }
.link { display: flex; align-items: center; gap: 14px; min-height: 46px; padding: 0 14px; border-radius: 12px; font-weight: 500; color: var(--soft); width: 100%; text-align: start; transition: background-color .2s, color .2s; }
.link:hover { color: var(--ink); background: var(--wash); }
.link[aria-current] { color: var(--active-ink); background: var(--active); font-weight: 700; }
.side .foot { margin-top: auto; display: grid; gap: 4px; }
.who { display: flex; align-items: center; gap: 12px; padding: 8px 14px; min-width: 0; }
.who i { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-deep); color: var(--accent-ink); display: grid; place-items: center; font-style: normal; font-weight: 700; flex: none; }
.who span { overflow: hidden; text-overflow: ellipsis; }
.link.exit { color: var(--bad); }

.body { --side-gap: clamp(24px, 3.4vw, 72px); min-width: 0; min-height: 100dvh; display: flex; flex-direction: column; padding: 0 var(--side-gap) 26px; }
.top { position: sticky; top: 0; z-index: 20; margin: 0 calc(var(--side-gap) * -1); padding: 14px var(--side-gap); display: flex; align-items: center; gap: 14px; background: var(--panel); transition: background-color .4s var(--ease); }
.top .brand { display: none; }
.tabs { position: relative; min-width: 0; display: flex; gap: 2px; padding: 4px; border-radius: 14px; background: var(--raise); overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; scroll-behavior: smooth; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; z-index: 1; display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 16px; border-radius: 11px; white-space: nowrap; font-weight: 500; color: var(--soft); transition: color .25s; }
.tab::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--accent)); }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--active-ink); font-weight: 700; }
.tab[aria-selected="true"]::before { background: var(--active-ink); }
.glide { position: absolute; inset-block: 4px; left: 0; width: 0; border-radius: 11px; background: var(--active); transition: transform .5s var(--ease), width .5s var(--ease); will-change: transform; }
.acts { display: flex; gap: 2px; margin-inline-start: auto; align-items: center; }
.word { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--soft); font-weight: 500; transition: background-color .2s, color .2s; }
.word:hover { background: var(--wash); color: var(--ink); }
.word[aria-pressed="true"] { color: var(--accent); }
kbd { white-space: nowrap; font: 500 12px/1 Tajawal, sans-serif; padding: 5px 7px 3px; border-radius: 6px; background: var(--raise); color: var(--soft); direction: ltr; }
.bottom { display: none; }

#view { padding-top: 18px; outline: 0; }
#view { flex: 1; align-content: start; transition: opacity .15s linear; }
#view.leaving { opacity: 0; }
#view > * { animation: enter .6s var(--ease) both; }
#view > :nth-child(2) { animation-delay: .06s; }
#view > :nth-child(3) { animation-delay: .12s; }
#view > :nth-child(n + 4) { animation-delay: .18s; }
@keyframes enter { from { opacity: 0; transform: translate3d(0, 10px, 0); } }
@keyframes draw { from { transform: scaleX(0); } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .45s; animation-timing-function: ease; }

.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; }
.head { display: flex; align-items: center; gap: 22px; }
.head h1 { font-size: clamp(24px, 3vw, 32px); }
.head p { color: var(--soft); font-size: 17px; max-width: 46em; }
.dial { --tone: var(--accent); width: 116px; height: 116px; border-radius: 50%; border: 2px solid var(--tone); display: grid; place-content: center; text-align: center; flex: none; background: var(--card); }
.dial b { font-size: 25px; font-weight: 800; line-height: 1.1; }
.dial span { font-size: 12.5px; color: var(--soft); line-height: 1.25; }
.card, .fact:not(.mini), .tool, .layer, .atlas { border: 1px solid var(--edge); }
.card { background: var(--card); border-radius: var(--radius); padding: 24px; min-width: 0; transition: background-color .35s var(--ease); }
.card > h2 { font-size: 19px; color: var(--accent); }
.card > .sub { color: var(--soft); margin-top: 2px; }
.card > :is(h2, .sub) + :not(.sub) { margin-top: 18px; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.lead-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.spread { justify-content: space-between; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.fact { background: var(--card); border-radius: var(--radius); padding: 22px 24px; display: grid; gap: 4px; }
.fact > span { color: var(--soft); font-weight: 500; }
.fact b { font-size: clamp(26px, 3.6vw, 38px); font-weight: 800; line-height: 1.15; }
.fact small { font-size: 15px; color: var(--faint); }
.fact.mini { padding: 0; background: none; }
.fact.mini b { font-size: 25px; }
.minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 20px; }
.meter { height: 6px; border-radius: 3px; background: var(--raise); overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--tone, var(--accent)); transform-origin: left; animation: draw 1s var(--ease) both; }

.seg { min-width: 0; display: inline-flex; position: relative; padding: 4px; border-radius: 13px; background: var(--raise); max-width: 100%; overflow-x: auto; scrollbar-width: none; justify-self: start; }
.seg button { position: relative; z-index: 1; min-height: 42px; padding: 0 20px; border-radius: 10px; font-weight: 500; color: var(--soft); white-space: nowrap; transition: color .25s; }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { color: var(--active-ink); font-weight: 700; }
.pane { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; animation: enter .5s var(--ease) both; }

.hero { display: grid; gap: 16px; padding: 14px 0 10px; max-width: 46em; }
.hero em { font-style: normal; color: var(--accent); font-weight: 700; }
.hero em { justify-self: start; padding: 4px 14px 2px; border-radius: 10px; background: var(--active); color: var(--active-ink) !important; font-size: 15px; }
.hero h1 { font-size: clamp(30px, 5vw, 50px); font-weight: 800; line-height: 1.22; }
.hero p { font-size: 18px; color: var(--soft); }
.meaning { display: flex; align-items: center; gap: 26px; }
.meaning b { color: var(--accent); font-size: 46px; font-weight: 800; line-height: 1.4; }
.meaning p { font-size: 18px; color: var(--soft); border-inline-start: 2px solid var(--accent-deep); padding-inline-start: 26px; }
.body > .credit b { color: var(--accent); }
.body > .credit { margin-top: 40px; border-top: 1px solid var(--line); }
.section-title { color: var(--accent); font-size: 22px; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.tool { background: var(--card); border-radius: 20px; padding: 26px; display: grid; gap: 18px; align-content: start; text-align: start; width: 100%; transition: background-color .35s var(--ease); }
.tool:hover { background: var(--raise); }
.tool header { display: flex; gap: 16px; align-items: center; }
.tool header .mark { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: var(--tone); background: color-mix(in srgb, var(--tone) 15%, transparent); flex: none; }
.tool h3 { font-size: 19px; }
.tool > p { font-size: 17px; line-height: 1.55; }
.tool dl { display: grid; gap: 9px; }
.tool dl div { display: grid; grid-template-columns: 92px 1fr; gap: 12px; }
.tool dt { color: var(--accent); font-weight: 500; }
.tool dd { color: var(--soft); }
.layers { display: grid; gap: 8px; }
.layer { display: grid; grid-template-columns: 12px 190px 1fr auto; gap: 18px; align-items: center; min-height: 72px; padding: 12px 22px 12px 18px; border-radius: 14px; background: var(--card); text-align: start; width: 100%; transition: background-color .35s var(--ease); }
.layer:hover { background: var(--raise); }
.layer::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--tone); }
.layer b { font-weight: 700; }
.layer span { color: var(--soft); }
.layer .num { color: var(--ink); font-weight: 700; }

.steps { display: grid; }
.step { border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step > button { width: 100%; min-height: 62px; display: flex; gap: 16px; align-items: center; text-align: start; font-weight: 700; font-size: 17px; }
.step i { font-style: normal; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--wash); color: var(--accent); flex: none; transition: background-color .3s, color .3s; font-size: 15px; }
.step[data-open] i { background: var(--tone); color: var(--panel); }
.step .ico { margin-inline-start: auto; color: var(--faint); transition: transform .35s var(--ease); }
.step[data-open] .ico { transform: rotate(180deg); }
.step .fold { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .5s var(--ease); }
.step[data-open] .fold { grid-template-rows: 1fr; }
.step .fold > div { overflow: hidden; visibility: hidden; transition: visibility .4s; }
.step[data-open] .fold > div { visibility: visible; }
.step p { padding-block: 0 20px; padding-inline: 50px 8px; color: var(--soft); font-size: 17px; max-width: 46em; }

.bars { display: grid; gap: 15px; }
.bar { display: grid; gap: 6px; }
.bar .lab { display: flex; justify-content: space-between; gap: 14px; }
.bar .lab span:last-child { color: var(--soft); white-space: nowrap; }
.track { height: 12px; border-radius: 4px; background: var(--raise); overflow: hidden; display: flex; gap: 2px; }
.track i { height: 100%; border-radius: 4px; transform-origin: left; animation: draw 1s var(--ease) both; background: var(--tone, var(--accent)); }
[dir="rtl"] :is(.meter, .track) i { transform-origin: right; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--soft); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; background: var(--tone); }
.scroll { overflow-x: auto; overscroll-behavior-x: contain; margin-inline: -24px; padding-inline: 24px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { font-weight: 700; color: var(--accent); }
td:first-child, th:first-child { padding-inline-start: 0; }
.lead-row > .seg { max-width: 100%; }
.tag { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.tag::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--tone, var(--faint)); }
.reasons { display: grid; gap: 12px; counter-reset: r; }
.reasons li { display: flex; gap: 12px; align-items: baseline; counter-increment: r; }
.reasons li::before { content: counter(r); color: var(--accent); font-weight: 700; min-width: 1em; }
.reasons code { display: block; font: 13px/1.5 ui-monospace, Consolas, monospace; color: var(--faint); direction: ltr; text-align: start; unicode-bidi: plaintext; }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.controls select { flex: 1 1 260px; min-width: 0; appearance: none; padding-inline-end: 40px; background-image: url(caret.svg); background-repeat: no-repeat; background-position: right 14px center; }
.card > .controls + div:not(.hint) { margin-top: 14px; }
.hint { color: var(--faint); }
.strip { width: 100%; height: 150px; touch-action: pan-y; cursor: pointer; }
.strip rect { transition: opacity .2s; }
.strip .on { stroke: var(--ink); stroke-width: 2; }
.plot { width: 100%; overflow: visible; }
.plot text { fill: var(--faint); font: 14px Tajawal, sans-serif; }
.plot .grid { stroke: var(--line); }
.tip { position: fixed; z-index: 60; pointer-events: none; padding: 8px 12px; border-radius: 10px; background: var(--ink); color: var(--panel); font-size: 14px; line-height: 1.45; opacity: 0; transition: opacity .15s; max-width: 260px; top: 0; left: 0; }
.tip.on { opacity: 1; }
input[type="range"] { accent-color: var(--accent-deep); width: 170px; height: 32px; }

.atlas { background: var(--card); border-radius: 22px; padding: 10px 14px; }
.atlas svg { width: 100%; }
.atlas .wide { height: calc(100dvh - 286px); min-height: 400px; max-height: 760px; }
.atlas .tall { display: none; }
.atlas text { fill: var(--ink); font-family: Tajawal, sans-serif; }
.atlas .dim { fill: var(--soft); }
.atlas .cap { fill: var(--faint); font-weight: 500; }
.atlas .box { fill: var(--raise); }
.atlas .wire { fill: none; stroke: var(--tone); stroke-width: 1.6; opacity: .75; }
.atlas .dash { stroke-dasharray: 3 6; }
.atlas .ring { fill: var(--panel); stroke: var(--tone); stroke-width: 2; transition: stroke-width .3s; }
.atlas .go { cursor: pointer; outline: 0; }
.atlas .go .grow { transition: transform .4s var(--ease); transform-box: fill-box; transform-origin: center; }
.atlas .go:hover .grow, .atlas .go:focus-visible .grow { transform: scale(1.035); }
.atlas .go:focus-visible .ring, .atlas .go:focus-visible .box { stroke: var(--ink); stroke-width: 2.5; }
.atlas .dot { fill: var(--ink); opacity: 0; transition: opacity .3s; }
.atlas.live .dot { opacity: 1; }

.map { position: relative; }
.map > svg { width: 100%; height: clamp(300px, calc(100dvh - 475px), 500px); touch-action: pan-y; }
.map .node { cursor: grab; outline: 0; transition: opacity .3s; touch-action: none; }
.map .node circle:not(.hit) { stroke: var(--card); stroke-width: 3; transition: r .3s var(--ease); }
.map .node:focus-visible circle:not(.hit), .map .node.on circle:not(.hit) { stroke: var(--ink); }
.map .edge { stroke: var(--faint); opacity: .5; transition: opacity .3s, stroke .3s; }
.map .edge.hot { stroke: var(--bad); opacity: .75; }
.map .off { opacity: .12 !important; }
.map text { paint-order: stroke; stroke: var(--card); stroke-width: 5px; stroke-linejoin: round; fill: var(--ink); font: 500 13px Tajawal, sans-serif; text-anchor: middle; pointer-events: none; }

.veil { position: fixed; inset: 0; z-index: 70; background: var(--veil); display: grid; justify-items: center; align-items: start; padding: 12vh 16px 16px; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.finder { width: min(580px, 100%); background: var(--panel); border-radius: 20px; overflow: hidden; box-shadow: var(--lift); animation: enter .3s var(--ease) both; }
.finder input { width: 100%; min-height: 62px; padding: 0 22px; border: 0; background: none; font-size: 18px; outline: 0; border-bottom: 1px solid var(--line); }
.finder ul { max-height: 46vh; overflow-y: auto; padding: 8px; overscroll-behavior: contain; }
.finder li { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: 12px; cursor: pointer; }
.finder li[aria-selected="true"] { background: var(--wash); }
.finder li span:last-child { margin-inline-start: auto; color: var(--faint); }
.finder p { padding: 18px 22px; color: var(--soft); }
.stage { position: fixed; z-index: 50; inset-inline: 16px; bottom: 20px; margin: auto; width: min(760px, calc(100% - 32px)); background: var(--ink); color: var(--panel); border-radius: 20px; padding: 18px 22px; display: grid; gap: 12px; box-shadow: var(--lift); animation: enter .4s var(--ease) both; }
.stage h2 { font-size: 18px; }
.stage p { line-height: 1.6; }
.stage footer { display: flex; align-items: center; gap: 10px; }
.fact .tag { font-weight: inherit; }
.stage footer span { white-space: nowrap;  margin-inline-end: auto; opacity: .75; }
.stage .btn { min-height: 44px; background: transparent; color: inherit; border-color: color-mix(in srgb, currentColor 35%, transparent); }
.stage .btn.main { background: var(--accent-deep); color: #fff; border-color: transparent; }
.presenting .body { padding-bottom: 240px; }
.wait { min-height: 46vh; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--soft); }
.skip { position: fixed; top: 8px; inset-inline-start: 8px; z-index: 90; transform: translateY(-200%); }
.skip:focus { transform: none; }
.list { display: grid; }
.list li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border: 0; }
.list span:last-child { color: var(--faint); }
.form { display: grid; gap: 16px; max-width: 420px; }

@media (min-width: 1700px) {
  .tools { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1480px) {
  .word span, kbd { display: none; }
}
@media (max-width: 1280px) {
  .shell { grid-template-columns: 84px minmax(0, 1fr); }
  .side { padding: 22px 14px; align-items: center; }
  .side .brand b, .side .link span, .side .who span { display: none; }
  .side .brand, .who { padding: 0; }
  .side .link { width: 56px; justify-content: center; padding: 0; }
  .side .foot { justify-items: center; }
}
@media (max-width: 960px) {
  .shell { display: block; }
  .side-wrap { display: none; }
  .body { --side-gap: 16px; padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .top { padding-block: 8px 10px; flex-wrap: wrap; gap: 8px; }
  .top .brand { display: inline-flex; }
  .top .brand img { width: 30px; height: 30px; }
  .top .brand b { font-size: 21px; }
  .tabs { order: 3; width: calc(100% + 32px); margin: 0 -16px; border-radius: 0; background: none; padding: 2px 16px; scroll-padding: 16px; }
  .tab { min-height: 44px; padding: 0 14px; }
  .tabs .glide { inset-block: 2px; }
  .acts .word { display: none; }
  .bottom { position: fixed; z-index: 40; inset-inline: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--side); border-top: 1px solid var(--line); }
  .bottom button { display: grid; justify-items: center; gap: 2px; padding: 7px 2px; min-height: 54px; border-radius: 12px; color: var(--faint); font-size: 12.5px; font-weight: 500; line-height: 1.3; transition: color .2s; }
  .bottom button[aria-current] { color: var(--accent); }
  .stage { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .map > svg { height: auto; max-height: calc(100dvh - 400px); min-height: 290px; }
  .tools { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .tool { padding: 20px; }
  .head { gap: 16px; align-items: flex-start; }
  .head p { font-size: 16px; }
  .dial { width: 88px; height: 88px; }
  .dial b { font-size: 19px; }
  .dial span { font-size: 11.5px; max-width: 7em; }
  .pair { gap: 12px; }
  .fact { padding: 16px; }
  .fact.mini { padding: 0; }
  .card { padding: 18px; }
  .scroll { margin-inline: -18px; padding-inline: 18px; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 10px; }
  .layer { grid-template-columns: 12px 1fr auto; padding-inline: 14px; }
  .layer span:not(.num) { grid-column: 2 / -1; grid-row: 2; }
  .step p { padding-inline-start: 50px; font-size: 16px; }
  .atlas { padding: 10px 6px; }
  .atlas .wide { display: none; }
  .atlas .tall { display: block; height: auto; max-height: calc(100dvh - 244px - env(safe-area-inset-bottom)); min-height: 380px; }
  .atlas-head .hint { display: none; }
  #view:has(.atlas) { gap: 10px; padding-top: 6px; }
  #view:has(.atlas) + .credit { margin-top: 14px; }
  .controls .btn { flex: 1 1 130px; }
  .controls select { flex-basis: 100%; }
  .stage { padding: 16px; }
  .stage .btn { padding-inline: 14px; }
}
@media print { .side-wrap, .top, .bottom { display: none; } }
