/* CAS · Deep Dive: Attention — The Mathematics */
.topnav { position: fixed; top: 0; left: 0; right: 0; z-index: 130; display: flex; align-items: center; gap: 1.4rem; padding: 0.55rem clamp(1rem, 3vw, 2rem); background: rgba(5, 8, 14, 0.82); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topnav-brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--text); flex: none; }
.topnav-brand img { width: 2.1rem; height: 2.1rem; border-radius: 7px; }
.topnav-brand .tb-txt { display: flex; flex-direction: column; line-height: 1.1; }
.topnav-brand .tb-txt strong { font-family: var(--font-display); font-size: 0.85rem; letter-spacing: 0.05em; }
.topnav-brand .tb-txt small { font-family: var(--font-mono); font-size: 0.56rem; letter-spacing: 0.14em; color: var(--text-3); text-transform: uppercase; }
.topnav-links { display: flex; gap: 0.2rem; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.topnav-links::-webkit-scrollbar { display: none; }
.topnav-links a { font-size: 0.82rem; font-weight: 500; color: var(--text-2); text-decoration: none; padding: 0.35rem 0.65rem; border-radius: 7px; white-space: nowrap; transition: color 0.15s, background 0.15s; }
.topnav-links a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.topnav-links a.active { color: var(--teal); }
.topnav-back { flex: none; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; border: 1px solid var(--line-2); border-radius: 8px; padding: 0.4rem 0.8rem; color: var(--text); text-decoration: none; transition: border-color 0.2s, color 0.2s; }
.topnav-back:hover { border-color: var(--teal); color: var(--teal); text-decoration: none; }
@media (max-width: 900px) { .topnav-links { display: none; } }
main { padding-top: 3.2rem; }
.scroll-progress { top: 3.2rem; }
.rail-toggle { top: 4.4rem; }
.rail { padding-top: 4.6rem; }
.sec-hero { text-align: center; padding-top: clamp(3rem, 8vh, 5.5rem); }
.hero-badge { display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.06em; color: var(--teal); border: 1px solid rgba(94, 234, 212, 0.35); border-radius: 999px; padding: 0.42rem 1.1rem; background: rgba(94, 234, 212, 0.06); margin-bottom: 1.6rem; }
.sec-hero .hero-title { margin-inline: auto; }
.sec-hero .hero-sub { margin-inline: auto; text-align: center; }
.flow-strip { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.45rem; max-width: 1000px; margin: 2rem auto 1.6rem; }
.fs-step { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.1em; color: var(--text-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 0.42rem 0.8rem; background: rgba(8, 13, 24, 0.55); }
.fs-hl { color: var(--teal); border-color: rgba(94, 234, 212, 0.4); background: rgba(94, 234, 212, 0.06); }
.fs-model { color: #05231f; background: var(--teal); border-color: var(--teal); font-weight: 700; }
.fs-arw { color: var(--text-3); font-size: 0.8rem; }
.tok-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.5rem; }
.pn-presets { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.7rem; }
.pn-preset { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.06em; color: var(--text-2); border: 1px solid var(--line); border-radius: 999px; padding: 0.32rem 0.75rem; background: rgba(8, 13, 24, 0.45); cursor: pointer; transition: all 0.15s; }
.pn-preset:hover { color: var(--teal); border-color: rgba(94, 234, 212, 0.4); }
.pn-preset.on { color: #05231f; background: var(--teal); border-color: var(--teal); font-weight: 700; }
.range-wrap { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 1.1rem; }
.range-header { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.1em; color: var(--text-2); }
.range-val { color: var(--teal); font-weight: 700; }
.range-wrap input[type="range"] { width: 100%; accent-color: var(--teal); }
.tok-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 0.8rem; margin-top: 1.1rem; }
.qk-row { display: grid; grid-template-columns: minmax(5.4rem, 9rem) minmax(6rem, 1fr); gap: 0.8rem; align-items: center; padding: 0.26rem 0.5rem; border-bottom: 1px dashed var(--line); }
.qk-row:last-child { border-bottom: 0; }
.qk-row.win { background: rgba(94, 234, 212, 0.05); border-radius: 6px; }
.qk-tok { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text); }
.qk-w { display: flex; align-items: center; gap: 0.5rem; }
.qk-w i { display: block; height: 10px; border-radius: 5px; flex: 1; max-width: calc(100% - 7rem); min-width: 3px; background: linear-gradient(90deg, rgba(94, 234, 212, 0.4), rgba(94, 234, 212, 0.9)); }
.qk-w b { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text); min-width: 6.6rem; text-align: right; }
.math-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
@media (max-width: 880px) { .math-grid { grid-template-columns: 1fr; } }
.mv { font-family: var(--font-mono); font-size: 0.9rem; color: var(--text); background: rgba(8, 13, 24, 0.55); border: 1px solid var(--line); border-radius: 8px; padding: 0.35rem 0.6rem; display: inline-block; }
.mv b { font-weight: 500; }
.mv b.on { color: var(--amber); font-weight: 700; }
.mv-s { border-color: rgba(94, 234, 212, 0.45); }
.mv-h { border-color: rgba(56, 189, 248, 0.4); }
.mv-t { border-color: rgba(148, 163, 184, 0.4); }
.mv-a { border-color: rgba(251, 191, 36, 0.45); }
.mv-c { border-color: rgba(52, 211, 153, 0.45); }
.mv-line { margin: 0; }
.su-row { display: flex; gap: 0.7rem; align-items: center; margin-bottom: 0.45rem; }
.su-row .hl-mono { min-width: 6rem; }
.wa-table { display: flex; flex-direction: column; gap: 0.3rem; }
.wa-row { display: grid; grid-template-columns: minmax(8rem, 12rem) repeat(3, 1fr); gap: 0.6rem; align-items: center; border: 1px solid var(--line); border-radius: 7px; background: rgba(8, 13, 24, 0.45); padding: 0.35rem 0.7rem; }
.wa-row.head { background: none; border-color: transparent; }
.wa-row.head b { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.12em; color: var(--text-3); text-transform: uppercase; }
.wa-row span { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-2); }
.wa-row i { font-style: normal; font-family: var(--font-mono); font-size: 0.78rem; color: var(--text); }
.wa-row.sum { background: none; border-color: transparent; padding-bottom: 0; color: var(--text-3); font-size: 0.72rem; }
.tn-grid { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(300px, 1.1fr); gap: 1.4rem; align-items: start; }
@media (max-width: 880px) { .tn-grid { grid-template-columns: 1fr; } }
#tnCanvas { display: block; border: 1px solid var(--line); border-radius: var(--radius-s); background: rgba(5, 8, 14, 0.6); }
.cx-rows { display: flex; flex-direction: column; gap: 0.4rem; }
.cx-row { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 7px; background: rgba(8, 13, 24, 0.45); padding: 0.4rem 0.7rem; }
.cx-x { color: var(--text-3); font-family: var(--font-mono); }
.ms-stage { border: 1px solid var(--line); border-radius: var(--radius-s); background: rgba(5, 8, 14, 0.5); padding: 1.1rem 1.2rem; min-height: 9rem; }
.ms-stage p { line-height: 1.75; }
.recap-card { border: 1px solid rgba(94, 234, 212, 0.35); border-radius: var(--radius); background: rgba(94, 234, 212, 0.04); padding: 1.2rem 1.4rem; display: flex; flex-direction: column; gap: 0.65rem; }
.rc-row { display: flex; gap: 1rem; align-items: baseline; }
.rc-row b { flex: none; width: 1.9rem; height: 1.9rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 0.8rem; color: var(--teal); border: 1px solid rgba(94, 234, 212, 0.45); }
.rc-row p { margin: 0; font-size: 0.92rem; color: var(--text-2); line-height: 1.6; }
.rc-row p b { color: var(--teal); font-family: var(--font-mono); font-size: 0.84rem; }
.urdu-inline { font-family: 'Noto Nastaliq Urdu', serif; }
.cite-note { font-size: 0.8rem; color: var(--text-3); max-width: 70ch; line-height: 1.6; }
.sec-head .kicker { gap: 0.4rem; letter-spacing: 0.22em; }
.sec-head .kicker .knum { display: inline; border: 0; background: none; padding: 0; min-width: 0; height: auto; border-radius: 0; white-space: nowrap; }
.sec-head .kicker .knum::before { content: "— SECTION "; }
.sec-head .kicker .knum::after { content: " ·"; }
html.static .mv, html.static .wa-row { animation: none; transition: none; }

.wa-mat { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-2); word-break: break-all; }

/* why-cards: intuition before arithmetic */
.why-card {
  border: 1px solid rgba(94, 234, 212, 0.4); border-left: 3px solid var(--teal);
  border-radius: var(--radius-s); background: rgba(94, 234, 212, 0.05);
  padding: 1rem 1.2rem 0.9rem; margin-bottom: 1.1rem;
}
.why-card .mini { color: var(--teal); letter-spacing: 0.16em; }
.why-card p { margin: 0.45rem 0 0; font-size: 0.94rem; color: var(--text-2); line-height: 1.7; }
.why-card p strong, .why-card p b { color: var(--text); }
.why-card p.micro { font-size: 0.8rem; color: var(--text-3); }
.ms-why {
  font-size: 0.98rem; color: var(--teal); font-style: italic;
  border-left: 2px solid rgba(94, 234, 212, 0.5); padding-left: 0.8rem;
  margin: 0.6rem 0 0;
}

/* ================= math-first teaching system ================= */
.mf-hero-eqs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 1rem; max-width: 1080px; margin: 1.8rem auto 0.6rem; }
.mf-eq { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1rem 0.4rem; text-align: center; overflow-x: auto; }
.mf-eq-lab { margin: 0 0 0.4rem; font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.14em; color: var(--teal); }
.mf-block {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem 1.7rem; margin-bottom: 1.2rem;
}
.mf-formula {
  background: rgba(5, 8, 14, 0.55); border: 1px solid rgba(94, 234, 212, 0.35);
  border-radius: var(--radius-s); padding: 1.1rem 1rem 0.4rem; margin-bottom: 1.3rem; overflow-x: auto;
}
.mf-h {
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--teal); margin: 1.4rem 0 0.6rem;
  border-top: 1px dashed var(--line); padding-top: 1.1rem;
}
.mf-h:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.mf-sym { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.mf-sym td { padding: 0.5rem 0.7rem; border-bottom: 1px dashed var(--line); vertical-align: top; color: var(--text-2); line-height: 1.55; }
.mf-sym td:first-child { font-family: var(--font-mono); color: var(--text); white-space: nowrap; width: 8.5rem; }
.mf-sym td:last-child { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-3); white-space: nowrap; }
.mf-sym strong { color: var(--text); }
.mf-note { font-size: 0.82rem; color: var(--text-3); line-height: 1.6; margin: 0.7rem 0 0; }
.mf-read {
  font-size: 1.02rem; color: var(--text); font-style: italic; line-height: 1.75;
  border-left: 3px solid var(--teal); padding: 0.2rem 0 0.2rem 1rem; margin: 0;
}
.mf-why { font-size: 0.92rem; color: var(--text-2); line-height: 1.7; margin: 0.45rem 0 0; }
.mf-why strong { color: var(--text); }
.mf-expand { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-s); background: rgba(5, 8, 14, 0.5); padding: 0.6rem 0.4rem 0.2rem; }
.mf-expand p, .mf-numnote { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-2); margin: 0.2rem 0; }
.mf-shapes { overflow-x: auto; }
.mf-nums { border: 1px solid var(--line); border-radius: var(--radius-s); background: rgba(5, 8, 14, 0.5); padding: 0.9rem 1rem; overflow-x: auto; }
.mf-step { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-2); margin: 0.45rem 0; line-height: 1.6; }
.mf-step b { color: var(--teal); }
.mf-numnote { font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-3); margin: 0.7rem 0 0; line-height: 1.6; }
.mf-numnote b { color: var(--teal); }
.mf-int {
  font-size: 0.96rem; color: var(--text-2); line-height: 1.7; font-style: italic;
  border-left: 3px solid var(--amber); padding: 0.15rem 0 0.15rem 1rem; margin: 0;
}
.mf-arrow { overflow-x: auto; text-align: center; }
.mf-check {
  margin-top: 1.3rem; border: 1px dashed rgba(251, 191, 36, 0.45); border-radius: var(--radius-s);
  background: rgba(251, 191, 36, 0.05); padding: 0.85rem 1rem; font-size: 0.9rem; color: var(--text-2); line-height: 1.6;
}
.mf-check b { color: var(--amber); }
.mf-check-btn {
  display: block; margin-top: 0.6rem; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.12em;
  color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.5); background: none; border-radius: 999px;
  padding: 0.35rem 0.9rem; cursor: pointer; transition: all 0.15s;
}
.mf-check-btn:hover { background: var(--amber); color: #241a02; }
.mf-check-ans { margin: 0.7rem 0 0; color: var(--text); font-size: 0.88rem; line-height: 1.65; }
/* indexing map + symbol color coding */
.idx-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.5rem; }
.idx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 0.9rem; }
.idx-item { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0.9rem 1rem; background: rgba(8, 13, 24, 0.45); }
.idx-item b { font-family: var(--font-mono); font-size: 1.5rem; display: block; margin-bottom: 0.3rem; }
.idx-item p { margin: 0; font-size: 0.84rem; color: var(--text-2); line-height: 1.55; }
.sym-i-c b, .sym-i-c { color: var(--violet); }
.sym-j-c b, .sym-j-c { color: var(--sky); }
.sym-k-c b, .sym-k-c { color: var(--amber); }
.sym-tx-c b, .sym-tx-c { color: var(--green); }
.idx-example { border-top: 1px dashed var(--line); margin-top: 1.1rem; padding-top: 1rem; }
.idx-toks { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.4rem 0 0.5rem; }
.idx-toks span { font-family: var(--font-mono); font-size: 0.8rem; color: var(--sky); border: 1px solid rgba(56, 189, 248, 0.4); border-radius: 7px; padding: 0.25rem 0.55rem; background: rgba(56, 189, 248, 0.06); }
.pipe-chain { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-s); background: rgba(5, 8, 14, 0.5); padding: 0.7rem 0.4rem 0.3rem; }
.pipe-rows { display: flex; flex-direction: column; gap: 0.55rem; }
.pipe-row { display: grid; grid-template-columns: minmax(7rem, 9rem) 1fr; gap: 1rem; align-items: baseline; border-bottom: 1px dashed var(--line); padding-bottom: 0.55rem; }
.pipe-row:last-child { border-bottom: 0; padding-bottom: 0; }
.pipe-row b { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.1em; color: var(--teal); }
.pipe-row p { margin: 0; font-size: 0.9rem; color: var(--text-2); line-height: 1.6; }
.pipe-row p b { color: var(--teal); font-family: var(--font-mono); font-size: 0.82rem; }
@media (max-width: 700px) { .pipe-row { grid-template-columns: 1fr; gap: 0.2rem; } }
html.static .mf-eq, html.static .mf-block { animation: none; transition: none; }


/* ================= luong-specific ================= */
.lo-barr { display: flex; align-items: flex-end; gap: 10px; height: 70px; }
.lo-pos { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; height: 100%; }
.lo-pos i { display: block; width: 70%; max-width: 40px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, rgba(94,234,212,0.9), rgba(94,234,212,0.3)); }
.lo-pos.center i { background: linear-gradient(180deg, var(--amber), rgba(251,191,36,0.4)); }
.lo-pos b { font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-3); }
.lo-pos em { font-style: normal; font-family: var(--font-mono); font-size: 0.56rem; color: var(--text-3); }
.rs-row2 { display: grid; grid-template-columns: minmax(11rem, 15rem) minmax(8rem, 1fr) 1fr; gap: 0.9rem; align-items: center; padding: 0.34rem 0; border-bottom: 1px dashed var(--line); }
.rs-row2:last-child { border-bottom: 0; }
.rs-m { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text); }
.rs-barwrap { height: 16px; border-radius: 8px; background: rgba(148,163,184,0.1); overflow: hidden; position: relative; }
.rs-barwrap i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, rgba(94,234,212,0.45), var(--teal)); transition: width 0.3s; }
.rs-barwrap i.base { background: linear-gradient(90deg, rgba(251,113,133,0.45), var(--rose)); }
.rs-barwrap i.top { background: linear-gradient(90deg, rgba(251,191,36,0.5), var(--amber)); }
.rs-barwrap b { position: absolute; right: 8px; top: 0; line-height: 16px; font-family: var(--font-mono); font-size: 0.68rem; color: #04231f; font-weight: 700; }
.rs-note { font-size: 0.78rem; color: var(--text-3); }
.qk-w i.g { background: linear-gradient(90deg, rgba(148,163,184,0.4), #94a3b8); }
.qk-w i.l { background: linear-gradient(90deg, rgba(251,191,36,0.5), var(--amber)); }

/* ================= machine block diagram ================= */
.lgb-wrap { width: 100%; }
.lgb-svg { width: 100%; max-width: 860px; height: auto; display: block; margin: 0 auto; font-family: var(--font-mono); }
.lgb-r { fill: rgba(8, 13, 24, 0.6); stroke: var(--line-2); stroke-width: 1.3; transition: fill 0.15s, stroke 0.15s; }
.lgb-t { font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em; fill: var(--text); }
.lgb-s { font-size: 8.5px; fill: var(--text-3); }
.lgb-a { stroke: #5b7290; stroke-width: 1.5; fill: none; transition: opacity 0.15s, stroke 0.15s; }
.lgb-lab { font-size: 9.5px; fill: var(--text-3); }
.lgb-cap { font-size: 10.5px; letter-spacing: 0.16em; fill: var(--text-3); }
.lgb-plus-c { fill: rgba(5, 8, 14, 0.85); stroke: #878d93; stroke-width: 1.5; }
.lgb-plus { stroke: #9aa4ad; stroke-width: 1.5; }
.lgb-wline { stroke: var(--teal); transition: opacity 0.15s; }
.lgb-loop { stroke: var(--amber); stroke-width: 2.1; }
.lgb-looplab { font-size: 11px; font-weight: 700; fill: var(--amber); }
.lgb-flow { stroke: var(--teal); stroke-width: 2.3; stroke-dasharray: 2 12; stroke-linecap: round; fill: none; opacity: 0.75; animation: lgbFlow 1.25s linear infinite; pointer-events: none; }
@keyframes lgbFlow { to { stroke-dashoffset: -14; } }
@media (prefers-reduced-motion: reduce) { .lgb-flow { animation: none; opacity: 0; } }
html.static .lgb-flow { animation: none; opacity: 0; }
.lgb-blk { cursor: pointer; outline: none; transition: opacity 0.15s; }
.lgb-blk.enc .lgb-r { stroke: rgba(167, 139, 250, 0.5); fill: rgba(167, 139, 250, 0.06); }
.lgb-blk.enc .lgb-t { fill: var(--violet); }
.lgb-blk.mem .lgb-r { stroke: rgba(56, 189, 248, 0.5); fill: rgba(56, 189, 248, 0.06); }
.lgb-blk.mem .lgb-t { fill: var(--sky); }
.lgb-blk.att .lgb-r { stroke: rgba(94, 234, 212, 0.55); fill: rgba(94, 234, 212, 0.07); }
.lgb-blk.att .lgb-t { fill: var(--teal); }
.lgb-blk.dec .lgb-r { stroke: rgba(167, 139, 250, 0.5); fill: rgba(167, 139, 250, 0.06); }
.lgb-blk.dec .lgb-t { fill: var(--violet); }
.lgb-blk.out .lgb-r { stroke: rgba(52, 211, 153, 0.5); fill: rgba(52, 211, 153, 0.05); }
.lgb-blk.out .lgb-t { fill: var(--green); }
.lgb-blk.io .lgb-r { fill: rgba(5, 8, 14, 0.6); }
.lgb-win { fill: rgba(251, 191, 36, 0.09); stroke: rgba(251, 191, 36, 0.55); stroke-dasharray: 6 5; display: none; }
.lgb-winlab { fill: var(--amber); font-size: 10px; display: none; }
.lgb-svg.trace .lgb-blk { opacity: 0.38; }
.lgb-svg.trace .lgb-blk.hot, .lgb-svg.trace .lgb-blk:hover { opacity: 1; }
.lgb-svg.trace .lgb-a { opacity: 0.12; }
.lgb-svg.trace .lgb-a.hot { opacity: 1; stroke: var(--teal); }
.lgb-svg.trace .lgb-wline { opacity: 0.04 !important; }
.lgb-svg.trace .lgb-flow { opacity: 0.12; }
.lgb-svg.local .lgb-wline { transition: opacity 0.3s; }
.lgb-svg.local .lgb-blk[data-id="ann"] { transition: opacity 0.3s; }
