/* App-only styles. Tokens and components come from the design session (tokens.css, components.css). */

/* Persian strings inside an English UI (model titles) and the other way round */
[lang="fa"] { font-family: "Vazirmatn", var(--font-ui); }
:root:lang(en) [lang="fa"] .slide__label, :root:lang(en) .slide__label[lang="fa"] { font-family: "Aref Ruqaa", var(--font-label); }

a.row, a.slide, .tab { -webkit-tap-highlight-color: transparent; }
.stack { display: grid; gap: var(--s3); }
.grid-slides { display: grid; gap: var(--s3); }
@media (min-width: 700px) { .grid-slides { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Your path (Home): the map band ---------- */
.band { position: relative; overflow: hidden; border-radius: 26px; padding: var(--s5) clamp(var(--s4), 3vw, var(--s6)) var(--s5);
  background: var(--slide); box-shadow: 0 14px 34px -18px var(--shadow); margin-bottom: var(--s2); isolation: isolate; }
.band__art { position: absolute; inset: 0; z-index: -1; }
.band__art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 58%; display: block; }
.band__art::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--halo) 0%, var(--halo) 12%, transparent 42%, transparent 72%, var(--halo) 100%); } /* the map shows through the middle, where the trail runs */
.band { --halo: rgba(244, 234, 210, .8); }
:root[data-theme="dark"] .band { --halo: rgba(12, 14, 32, .78); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .band { --halo: rgba(12, 14, 32, .78); } }
.band__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s2); }
.band .brand { font-size: var(--fs-lg); }
.band__hello { font: 800 var(--fs-xl)/1.2 var(--font-head); margin-top: var(--s3); text-shadow: 0 0 8px var(--halo), 0 0 2px var(--halo); }
:root:lang(fa) .band__hello { font-weight: 900; }
.band time { display: block; font-size: var(--fs-sm); color: var(--ink-2); margin-top: var(--s1); font-weight: 600; }
.band .search { max-width: 560px; box-shadow: 0 8px 20px -14px var(--shadow); }
@media (min-width: 900px) { .band { padding-top: var(--s6); padding-bottom: var(--s7); } .band .brand { display: none; } .band__hello { font-size: var(--fs-2xl); margin-top: 0; } }

.clues-link { margin-bottom: var(--s2); }
.clues-link .disc { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none; background: #1d2348; box-shadow: inset 0 0 0 2px #b48a33; color: #f1e7d0; }
.clues-link .disc .i { width: 20px; height: 20px; }

/* ---------- The guide (H1 to H4) ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(12, 14, 32, .55); }
.guide { width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 22px; background: var(--paper); overflow: auto;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .6); }
.guide__stage { position: relative; aspect-ratio: 3 / 2; overflow: hidden; }
.guide__pic, .guide__pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
[dir="rtl"] .guide__pic img { transform: scaleX(-1); } /* the calm side follows the reading start */
.guide__stage::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(247, 239, 220, .95) 0%, rgba(247, 239, 220, .6) 32%, transparent 48%); }
[dir="rtl"] .guide__stage::after { background: linear-gradient(270deg, rgba(247, 239, 220, .95) 0%, rgba(247, 239, 220, .6) 32%, transparent 48%); }
.guide__say { position: absolute; z-index: 1; inset-inline-start: 5%; top: 9%; width: 33%; color: #1d2348; }
.guide__say h2 { font: 800 clamp(18px, 2.6vw, 26px)/1.2 var(--font-head); outline: none; }
:root:lang(fa) .guide__say h2 { font-weight: 900; }
.guide__say p { margin-top: var(--s2); font-size: clamp(13px, 1.7vw, 15.5px); line-height: 1.55; color: #5a4a35; font-weight: 500; }
.guide__dots { display: flex; gap: 6px; margin-top: var(--s4); }
.guide__dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(29, 35, 72, .25); }
.guide__dots i.on { width: 22px; border-radius: 4px; background: #855a10; }
@media (max-width: 600px) { .guide__dots i { background: var(--line-strong); } .guide__dots i.on { background: var(--haem); } }
.guide__bar { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); background: var(--slide); }
@media (max-width: 600px) { /* phones: the words under the picture */
  .guide__stage { aspect-ratio: auto; display: grid; }
  .guide__pic { position: relative; aspect-ratio: 3 / 2; }
  .guide__stage::after { display: none; }
  .guide__say { position: static; width: auto; padding: var(--s4); color: var(--ink); }
  .guide__say p { color: var(--ink-2); }
}

/* ---------- The partner: the robot button and its sheet ---------- */
.partner { position: fixed; z-index: 25; inset-inline-end: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  width: 58px; height: 58px; padding: 4px; border: 0; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 50% 88%, rgba(224, 179, 87, .45), transparent 60%), #161a3a;
  box-shadow: inset 0 0 0 2px #e0b357, 0 10px 24px -10px rgba(0, 0, 0, .7); transition: transform .2s var(--ease-out); }
.partner:hover { transform: translateY(-2px); }
.partner img { width: 100%; height: 100%; object-fit: contain; display: block; }
@media (min-width: 900px) { .partner { width: 72px; height: 72px; bottom: 24px; inset-inline-end: 28px; } }
body.is-reader .partner, body.is-model .partner { display: none; }
/* The main column fills its grid track (it shrank to its content on wide screens: QA major bug 2) */
.app > .main { width: 100%; min-width: 0; }
/* A model opens above the shell too: no rail; its bar is the navy spine */
body.is-model .rail { display: none; }
body.is-model .app { display: block; }
.viewer__bar { background: #161a3a !important; color: #f1e7d0; border-bottom: 1px solid #343b6b !important; }
.viewer__bar .t small { color: #cfc3a6 !important; }
.viewer__bar .back, .viewer__bar .icon-btn { color: #f3cf7e; }

/* Loading: skeleton lines, and the thinking robot if it takes a while */
.loading__robot { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); color: var(--ink-2); font-weight: 600; font-size: var(--fs-sm);
  opacity: 0; animation: fade-in .3s ease-out .9s forwards; }
.loading__robot img { width: 56px; height: 56px; object-fit: contain; }
@media (prefers-reduced-motion: reduce) { .loading__robot { opacity: 1; } }

/* Pages ease in (no motion for people who turn it off: components.css removes animations) */
.main > * { animation: page-in .28s var(--ease-out) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { to { opacity: 1; } }
.partner-bubble { display: none; }
@media (min-width: 900px) {
  .partner-bubble { display: block; position: fixed; z-index: 25; inset-inline-end: 112px; bottom: 34px; max-width: 270px; padding: 12px 44px 12px 14px;
    border-radius: 16px; border-end-end-radius: 4px; background: var(--paper); color: var(--ink); border: 1px solid var(--line);
    box-shadow: 0 12px 28px -14px var(--shadow); font: 600 14px/1.5 var(--font-ui); animation: bubble-in .35s var(--ease-out); }
  [dir="rtl"] .partner-bubble { border-end-end-radius: 16px; border-end-start-radius: 4px; padding: 12px 14px 12px 44px; }
  .partner-bubble a { display: inline-block; margin-top: 6px; font-weight: 700; color: var(--haem); }
  .partner-bubble__x { position: absolute; top: 0; inset-inline-end: 0; width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer; }
  .partner-bubble__x:hover { background: var(--haem-wash); }
}
@keyframes bubble-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
body.is-reader .partner-bubble, body.is-model .partner-bubble { display: none; }
/* The reader opens above the shell: no rail, no tab bar (docs/DESIGN.md → Layout → Reader) */
body.is-reader .rail, body.is-reader .tabbar { display: none; }
body.is-reader .app { display: block; }
body.is-reader .main { padding-bottom: calc(var(--modebar-h, 80px) + env(safe-area-inset-bottom) + var(--s6)); }
/* Making highlights: the mode bar (components.css) in the spine's paper; marks are buttons */
.modebar { background: var(--slide) !important; }
.modebar .hint:empty { display: none; }
mark.hl[data-id] { cursor: pointer; border-radius: 2px; }
mark.hl[data-id]:focus-visible { outline: 2px solid var(--haem); outline-offset: 1px; }
.hl-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); }
.hl-sheet__head h2 { font: 800 var(--fs-lg)/1.25 var(--font-head); outline: none; }
.hl-sheet .paper { margin-bottom: var(--s4); max-height: 30vh; overflow: auto; }
.hl-sheet .kinds { margin-bottom: var(--s4); }
.hl-sheet__acts { display: flex; justify-content: space-between; gap: var(--s2); margin-top: var(--s4); }
@media (min-width: 900px) { .toast { bottom: calc(var(--modebar-h, 80px) + var(--s6)); } }
dialog.sheet { margin: 0; border: 0; max-width: none; color: var(--ink); top: auto; }
@media (max-width: 899px) { dialog.sheet { width: 100%; } }
.partner-sheet { text-align: center; }
.partner-sheet__pic { width: 160px; height: 160px; object-fit: contain; display: block; margin: 0 auto var(--s3); }
.partner-sheet h2 { font: 800 var(--fs-lg)/1.25 var(--font-head); outline: none; }
.partner-sheet p { margin: var(--s2) 0 var(--s4); color: var(--ink-2); line-height: 1.55; }


/* Your clues: each highlight is a paper note pinned to the board */
.clues { display: grid; gap: var(--s4); padding-top: var(--s2); }
@media (min-width: 700px) { .clues { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.clues .hl-row.clue { position: relative; border: 1px solid var(--line); border-radius: 6px; background: var(--paper);
  padding: var(--s5) var(--s4) var(--s4); box-shadow: 0 8px 18px -12px var(--shadow), 0 1px 3px -1px var(--shadow); }
.hl-row.clue:nth-child(odd) { transform: rotate(-.5deg); }
.hl-row.clue:nth-child(even) { transform: rotate(.45deg); }
.hl-row.clue::before { content: ""; position: absolute; top: 8px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f3cf7e, #9a6a17 60%, #5c3f0a); box-shadow: 0 2px 3px rgba(0, 0, 0, .35); }
a.hl-row.clue:hover { background: var(--paper); transform: rotate(0) translateY(-2px); }
.hl-row.clue .paper { border: 0; padding: 0; background: none; }
.hl-row.clue .cap { flex-wrap: wrap; }
.hl-row.clue .cap .from { flex-basis: 100%; order: 3; font-size: 11.5px; line-height: 1.4; }
@media (prefers-reduced-motion: reduce) { .hl-row.clue, .hl-row.clue:nth-child(n) { transform: none; } }

/* Books: blank leather covers (B3) with the title in code */
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s5) var(--s4); }
.book-card { display: grid; gap: 4px; color: inherit; text-decoration: none; }
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 4px 9px 9px 4px; overflow: hidden; background: #1d2348;
  box-shadow: 0 14px 24px -12px rgba(30, 18, 2, .7), 0 2px 4px -2px rgba(0, 0, 0, .4); transition: transform .2s var(--ease-out); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover__t { position: absolute; inset: 18% 15% auto; text-align: center; font: 800 15px/1.25 var(--font-book); color: #f0d58f;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .6); display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; }
.cover__t small { display: block; margin-top: 8px; font: 600 11px/1.3 var(--font-book); color: #e9d6a6; }
a.book-card:hover .cover { transform: translateY(-3px) rotate(-.6deg); }
.book-card__t { margin-top: var(--s2); font: 700 var(--fs-sm)/1.3 var(--font-book); }
.book-card__m { display: grid; font-size: var(--fs-xs); color: var(--ink-2); }
.page-head--book { align-items: center; }
.cover--mini { width: 56px; flex: none; }
.cover--mini .cover__t { display: none; }
@media (min-width: 700px) { .cover--mini { width: 72px; } }

/* Phones: the More button and its sheet */
.tabbar .tab--more { border: 0; background: none; cursor: pointer; font: inherit; font-size: var(--fs-xs); }
.rail .tab--more { display: none; }
.more-sheet h2 { font: 800 var(--fs-lg)/1.25 var(--font-head); margin-bottom: var(--s3); outline: none; }
.more-row { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 52px; padding: var(--s2) var(--s2); border: 0; border-top: 1px solid var(--line);
  background: none; color: var(--ink); font: 600 var(--fs-md) var(--font-ui); text-decoration: none; text-align: start; cursor: pointer; }
.more-row:first-child { border-top: 0; }
.more-row .emblem { width: 34px; height: 34px; object-fit: contain; }
.more-row .disc { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none; background: #1d2348; box-shadow: inset 0 0 0 2px #b48a33; color: #f1e7d0; }
.more-row .disc .i { width: 18px; height: 18px; }

/* ---------- Your detective ---------- */
.idcard { display: grid; grid-template-columns: auto 1fr; gap: var(--s5); align-items: center; padding: var(--s5); border-radius: var(--r-card, 18px);
  background: var(--paper); border: 1px solid var(--line); box-shadow: 0 14px 30px -18px var(--shadow); }
.idcard__fig img { height: clamp(200px, 30vw, 280px); width: auto; display: block; }
.idcard__kicker { font: 600 var(--fs-xs)/1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.idcard h2 { font: 800 var(--fs-2xl)/1.1 var(--font-head); margin: var(--s2) 0; }
:root:lang(fa) .idcard h2 { font-weight: 900; }
:root:lang(fa) .idcard__kicker { letter-spacing: 0; }
.idcard__rank { display: flex; align-items: center; gap: var(--s2); font-weight: 800; margin-bottom: var(--s2); }
.idcard__rank img { width: 36px; height: 36px; }
.idcard__acts { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
@media (max-width: 600px) { .idcard { grid-template-columns: 1fr; justify-items: center; text-align: center; } .idcard__rank, .idcard__acts { justify-content: center; } }
.ranks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); position: relative; }
.ranks::before { content: ""; position: absolute; inset-inline: 12%; top: 44px; height: 3px; border-radius: 3px; background: var(--line-strong); }
.ranks .rank { position: relative; display: grid; justify-items: center; gap: 4px; text-align: center; }
.ranks .rank img { width: 88px; height: 88px; object-fit: contain; }
.ranks .rank b { font: 800 var(--fs-sm)/1.25 var(--font-head); }
.ranks .rank small { font-size: var(--fs-xs); color: var(--ink-2); min-height: 1.3em; }
.ranks .is-current small { color: var(--haem); font-weight: 700; }
.ranks .is-ahead img { filter: grayscale(.85) brightness(.9); opacity: .55; }
@media (max-width: 600px) { .ranks { grid-template-columns: 1fr 1fr; row-gap: var(--s5); } .ranks::before { display: none; } }
.record { display: grid; grid-template-columns: 1.3fr repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.record > * { display: grid; gap: 4px; justify-items: center; align-content: center; padding: var(--s3) var(--s2); border-radius: var(--r-md); background: var(--slide); border: 1px solid var(--line); color: inherit; text-decoration: none; text-align: center; }
.record b { font: 800 var(--fs-xl)/1 var(--font-book); font-variant-numeric: tabular-nums; }
.record span { font-size: var(--fs-xs); color: var(--ink-2); }
a.record__kind:hover { border-color: var(--haem); }
@media (max-width: 600px) { .record { grid-template-columns: repeat(4, minmax(0, 1fr)); } .record__total { grid-column: 1 / -1; } }
.band__rank { display: inline-flex; align-items: center; gap: 6px; margin-top: var(--s2); font: 700 var(--fs-sm) var(--font-ui); color: var(--ink); text-decoration: none; }
.band__rank img { width: 28px; height: 28px; }
.avatar--row { width: 34px; height: 34px; flex: none; box-shadow: 0 0 0 2px #b48a33; }

/* The lab: "more models on the way" slot */
.slot { display: flex; align-items: center; gap: var(--s4); padding: var(--s3) var(--s4); border: 1.5px dashed var(--line-strong); border-radius: var(--r-card, 18px); color: var(--ink-2); font-weight: 600; }
.slot .pic { width: 96px; height: 96px; object-fit: contain; flex: none; }

/* Settings: the detective picker */
.detective-pick { display: flex; align-items: center; gap: var(--s4); }
.detective-pick .seg { flex: 1; }

/* ---------- Home ---------- */
.search-link { text-decoration: none; }
.continue .slide__spec { display: grid; gap: var(--s3); }
.continue__foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.continue__foot .progress { flex: 1 1 100%; }
.continue__foot small { flex: 1; }
.continue__foot small { color: var(--ink-2); font-size: var(--fs-xs); white-space: nowrap; }
@media (min-width: 900px) { .continue { --label-w: 120px; } .continue .slide__spec { grid-template-columns: 1fr minmax(0, 340px); align-items: start; } .continue .paper { grid-row: span 2; } }
.review { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.review a { display: grid; gap: 6px; justify-items: center; padding: var(--s3) var(--s1); border-radius: var(--r-md); background: var(--slide); border: 1px solid var(--line); color: inherit; text-decoration: none; text-align: center; }
.review a:hover { border-color: var(--haem); }
.review b { font: 600 var(--fs-xl)/1 var(--font-book); font-variant-numeric: tabular-nums; }
.review span { font-size: var(--fs-xs); color: var(--ink-2); }

/* ---------- Table of contents ---------- */
.toc-ch { border-top: 1px solid var(--line); }
.toc-ch:first-child { border-top: 0; }
.toc-ch summary { display: flex; gap: var(--s3); align-items: baseline; min-height: 52px; padding: var(--s3) var(--s4); cursor: pointer; list-style: none; }
.toc-ch summary::-webkit-details-marker { display: none; }
.toc-ch summary::before { content: ""; flex: none; align-self: center; width: 7px; height: 7px; border: solid var(--ink-2); border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform .15s; } /* folds open: a chevron */
.toc-ch[open] summary::before { transform: rotate(45deg); }
.toc-ch summary .num { color: var(--ink-2); min-width: 2.5ch; }
.toc-ch summary span:nth-child(2) { flex: 1; font-weight: 550; }
.toc-ch ul { padding: 0 var(--s4) var(--s3) calc(var(--s4) + 7px + 2.5ch + 2 * var(--s3)); }
.toc-ch li a { display: flex; align-items: center; min-height: 44px; padding: 4px 0; text-decoration: none; color: var(--ink); }
.toc-ch li a:hover { color: var(--haem); }
.toc-part { font: 600 var(--fs-xs)/1.3 var(--font-ui); color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; padding: var(--s4) var(--s4) var(--s1); }

/* ---------- Reader: book text on paper, always LTR ---------- */
.reader { max-width: calc(var(--measure) + 2 * var(--s5)); margin-inline: auto; }
.reader__bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: var(--s2); margin: calc(-1 * var(--s5)) calc(-1 * var(--gutter)) var(--s4); padding: var(--s2) var(--gutter);
  background: color-mix(in srgb, var(--tray) 88%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
@media (min-width: 900px) { .reader__bar { margin-top: calc(-1 * var(--s6)); margin-inline: calc(-1 * var(--s6)); padding-inline: var(--s6); } }
.reader__bar .t { flex: 1; min-width: 0; }
.reader__bar .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader__bar .t small { display: block; color: var(--ink-2); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader__progress { position: absolute; inset-inline: 0; bottom: -1px; height: 2px; }
.reader__progress > i { display: block; height: 100%; width: var(--p, 0%); background: var(--eosin); }
.page { background: var(--paper); color: var(--paper-ink); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s5) clamp(var(--s4), 4vw, var(--s6));
  font: 400 calc(var(--reader-size) * var(--scale, 1))/var(--reader-lh) var(--font-book); text-align: left; }
.page h1 { font: 600 var(--fs-2xl)/1.15 var(--font-book); margin-bottom: var(--s5); }
.page h1 small { display: block; font: 600 var(--fs-sm)/1.3 var(--font-ui); color: var(--ink-2); margin-bottom: var(--s2); }
.page section + section { margin-top: var(--s6); }
.page h2 { font: 600 1.2em/1.3 var(--font-book); margin-bottom: var(--s3); scroll-margin-top: 72px; }
.page p, .page .blk { margin: 0 0 .75em; white-space: pre-wrap; }
.page { overflow-wrap: anywhere; }
.page .blk-ref { font-size: .82em; line-height: 1.45; color: var(--ink-2); margin-bottom: .5em; padding-inline-start: 1.2em; text-indent: -1.2em; } /* a reference list: quiet, one entry per line */ /* long reference URLs wrap inside the paper, never widen the page */
.page .flash { animation: flash 2.4s ease-out; border-radius: 4px; } /* the passage opened from Your clues */
@keyframes flash { 0%, 35% { background: var(--select); box-shadow: 0 0 0 6px var(--select); } 100% { background: transparent; box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { .page .flash { animation: none; outline: 2px solid var(--haem); outline-offset: 4px; } }
.page .blk-h3 { font-weight: 700; margin-top: 1em; margin-bottom: .25em; }
.page .blk-li { padding-inline-start: 1.2em; position: relative; }
.page .blk-li::before { content: "•"; position: absolute; inset-inline-start: .2em; }
.page .blk-table { font-size: .82em; line-height: 1.45; font-variant-numeric: tabular-nums; background: color-mix(in srgb, var(--frost) 55%, transparent); border-radius: var(--r-sm); padding: var(--s2) var(--s3); overflow-x: auto; }
.page .blk-caption { font-size: .88em; font-style: italic; font-weight: 600; }
.page figure { margin: var(--s4) 0; }
.page figure .fig { width: 100%; background: var(--frost); border-radius: var(--r-sm); overflow: hidden; display: grid; place-items: center; }
.page figure img { width: 100%; height: 100%; object-fit: contain; display: block; }
.page figure figcaption { font: 600 var(--fs-sm)/1.4 var(--font-ui); color: var(--ink-2); margin-top: var(--s2); }
.reader__nav { display: flex; justify-content: space-between; gap: var(--s3); margin-top: var(--s5); }
.reader__nav a { flex: 1; max-width: 48%; }
.reader__nav a:only-child { margin-inline-start: auto; }

/* ---------- Search and highlight lists ---------- */
.hit .paper { margin-top: var(--s2); font-size: var(--fs-sm); }
.hl-row { display: grid; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.hl-row:first-child { border-top: 0; }
a.hl-row:hover { background: var(--haem-wash); }
.hl-row .cap { display: flex; gap: var(--s2); align-items: center; font-size: var(--fs-xs); color: var(--ink-2); }
.hl-row .note-text { font-size: var(--fs-sm); color: var(--ink); }

/* ---------- Educational models ---------- */
.model-card .slide__label { font-size: 18px; display: grid; place-items: center; text-align: center; }
.model-card .slide__title[lang="fa"] { font-family: "Vazirmatn", var(--font-ui); font-weight: 700; }
.model-card .slide__meta { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.tag { display: inline-flex; align-items: center; min-height: 22px; padding: 0 var(--s2); border-radius: var(--r-pill); background: var(--frost); font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
body.is-model .tabbar { display: none; }
body.is-model .main { max-width: none; width: 100%; margin-inline: 0; padding: 0; } /* auto margins would shrink a grid item to its content */
@media (min-width: 900px) { body.is-model .main { padding: 0; } }
.viewer { display: flex; flex-direction: column; height: 100dvh; }
.viewer__bar { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--gutter); padding-top: max(var(--s2), env(safe-area-inset-top)); background: var(--slide); border-bottom: 1px solid var(--line); }
.viewer__bar .t { flex: 1; min-width: 0; }
.viewer__bar .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer__bar .t small { display: block; font-size: var(--fs-xs); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer iframe { flex: 1; width: 100%; border: 0; background: var(--paper); }
.credits { font-size: var(--fs-sm); line-height: 1.55; }
.credits p + p { margin-top: var(--s2); }

/* ---------- Settings ---------- */
.settings { display: grid; gap: 0; max-width: 560px; padding: var(--s2) var(--s5); border-radius: var(--r-card, 18px);
  background: var(--paper); border: 1px solid var(--line); box-shadow: 0 12px 28px -18px var(--shadow); }
.settings > .field { padding: var(--s4) 0; }
.settings > .field + .field { border-top: 1px dashed var(--line-strong); }
.settings > .note { margin: var(--s2) 0 var(--s4); }

/* QA fixes (docs/qa-review-web-app.md) */
#main:focus { outline: none; } /* focus moves here after navigation; the page itself needs no ring */
.section-head a { min-width: var(--tap); justify-content: flex-end; }
:root[dir="rtl"] .hl-row .cap .from { text-align: right; } /* English caption, but on the Persian side */

/* ---------- Your path: the trail across the map (docs/mockups/redesign/home.html) ---------- */
.trail-wrap { margin: 0 calc(-1 * clamp(var(--s2), 1.5vw, var(--s4))) var(--s3); }
.trail-scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding-top: 34px; }
.trail-scroll::-webkit-scrollbar { display: none; }
.trail { position: relative; min-width: 640px; aspect-ratio: 1000 / 260; }
.trail__line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
[dir="rtl"] .trail__line { transform: scaleX(-1); }
.trail__done { stroke: var(--eosin); stroke-width: 4; fill: none; stroke-linecap: round; filter: drop-shadow(0 0 5px color-mix(in srgb, var(--eosin) 60%, transparent)); }
.trail__ahead { stroke: var(--eosin); stroke-width: 3; fill: none; stroke-linecap: round; stroke-dasharray: 2 11; opacity: .9; }
.trail__under { stroke: var(--halo); stroke-width: 8; fill: none; opacity: .75; }
.stn { position: absolute; width: 0; height: 0; transform: translate(-50%, -50%); color: var(--ink); text-decoration: none; }
[dir="rtl"] .stn { transform: translate(50%, -50%); }
.stn__dot { position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 18px; height: 18px; border-radius: 50%; }
.stn.is-done .stn__dot { background: var(--eosin); box-shadow: 0 0 0 5px color-mix(in srgb, var(--eosin) 22%, transparent); }
.stn.is-ahead .stn__dot { background: var(--paper); border: 3px solid var(--eosin); width: 20px; height: 20px; }
.stn.is-now .stn__dot { background: var(--haem); box-shadow: 0 0 0 6px color-mix(in srgb, var(--haem) 28%, transparent); }
.stn.is-now .stn__dot::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 2px solid var(--haem); animation: ping 2.4s cubic-bezier(.16, 1, .3, 1) infinite; }
@keyframes ping { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(2.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .stn.is-now .stn__dot::after { animation: none; } }
.stn__pin { position: absolute; left: 50%; bottom: 4px; translate: -50% 0; width: 40px; height: 52px; object-fit: contain; object-position: 50% 100%; z-index: 2; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .35)); }
.stn__lbl { position: absolute; left: 50%; translate: -50% 0; top: 18px; width: 112px; text-align: center; font: 600 12.5px/1.3 var(--font-ui);
  text-shadow: 0 0 6px var(--halo), 0 0 3px var(--halo), 0 0 1px var(--halo); }
.stn.up .stn__lbl { top: auto; bottom: 18px; }
.stn__lbl b { display: block; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stn__lbl small { display: block; font-size: 11.5px; color: var(--ink-2); font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stn.is-now .stn__lbl b { color: var(--haem); font-weight: 800; }
.stn:hover .stn__lbl b, .stn:focus-visible .stn__lbl b { text-decoration: underline; }
.stn:focus-visible { outline: none; }
.stn:focus-visible .stn__dot { outline: 3px solid var(--haem); outline-offset: 4px; }
.trail-legend { display: flex; justify-content: space-between; gap: var(--s3); padding: 0 clamp(var(--s2), 1.5vw, var(--s4)); font: 700 13px/1.2 var(--font-ui);
  text-shadow: 0 0 6px var(--halo), 0 0 2px var(--halo); }
.trail-legend__item { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 999px; background: var(--halo); } /* readable over the busy edge of the map */
.trail-legend i { width: 26px; border-top: 4px solid var(--eosin); border-radius: 4px; }
.trail-legend .is-ahead i { border-top: 3px dotted var(--eosin); }

/* ---------- Finding your way: contents finder, "in this chapter", library search ---------- */
.library-search { margin-bottom: var(--s4); }
.toc-find { margin-bottom: var(--s3); }
.toc-none { padding: var(--s3) var(--s1); }
.toc-continue { display: flex; width: 100%; justify-content: flex-start; gap: 10px; margin-bottom: var(--s3); min-height: 48px; text-align: start; overflow: hidden; }
.toc-continue__k { flex: none; white-space: nowrap; }
.toc-continue bdi { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; opacity: .85; }
.toc-now { display: inline-block; margin-inline-start: 8px; padding: 1px 8px; border-radius: 999px; vertical-align: 2px;
  font: 700 var(--fs-xs)/1.5 var(--font-ui); color: var(--haem); background: var(--haem-wash); }
.sec-sheet h2 { outline: none; }
.sec-list { list-style: none; margin: 0; padding: 0; }
.sec-row { display: flex; align-items: center; width: 100%; min-height: 48px; padding: var(--s2) var(--s2) var(--s2) var(--s3); border: 0; border-top: 1px solid var(--line);
  background: none; color: var(--ink); font: 500 var(--fs-md)/1.35 var(--font-book); text-align: left; cursor: pointer; border-radius: 0; }
.sec-list li:first-child .sec-row { border-top: 0; }
.sec-row:hover { background: var(--haem-wash); }
.sec-row[aria-current="true"] { color: var(--haem); font-weight: 700; box-shadow: inset 3px 0 0 var(--haem); }
.sec-row:focus-visible { outline: 2px solid var(--haem); outline-offset: -2px; }

/* ---------- Home, uncluttered: "see all" links, the lab row, shelf slides ---------- */
.see-all { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); padding-inline: 6px; margin-inline-end: -6px;
  font: 700 var(--fs-sm)/1.2 var(--font-ui); color: var(--haem); text-decoration: none; border-radius: 8px; }
.see-all .i { width: 16px; height: 16px; }
.see-all:hover { text-decoration: underline; text-underline-offset: 3px; }
.lab-link { margin-top: var(--s5); }
.lab-link__mark { flex: none; width: 40px; height: 40px; }
.lab-link__mark .emblem { width: 40px; height: 40px; object-fit: contain; }
.spec-slide .slide__label { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2px; }
.spec-slide .slide__label b { font: 400 26px/1 var(--font-label); font-variant-numeric: tabular-nums; }
.spec-slide .slide__label small { font-size: 13px; color: var(--ink-2); }

/* ---------- The admin area (/admin) ---------- */
body.is-admin .partner, body.is-admin .partner-bubble { display: none; }
.adm-narrow { max-width: 460px; margin: var(--s5) auto; }
.adm-card { background: var(--slide); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s5); margin-bottom: var(--s4); box-shadow: 0 10px 26px -18px var(--shadow); }
.adm-form { display: grid; gap: var(--s4); }
.adm-form h1 { font: 800 var(--fs-xl)/1.2 var(--font-head); }
.adm-form h2 { font: 700 var(--fs-md)/1.3 var(--font-head); margin-top: var(--s2); }
.adm-form .muted { margin-top: calc(-1 * var(--s3)); }
.adm-form > .btn { justify-self: start; }
.adm-narrow .adm-form > .btn { justify-self: stretch; }
.adm-code { font: 700 24px/1 var(--font-ui); letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.adm-error { color: var(--danger); font-weight: 600; }
.adm-who { font-weight: 700; }
.adm-key { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); }
.adm-key code { font: 600 15px/1.6 ui-monospace, Menlo, monospace; padding: 4px 10px; border-radius: 8px; background: var(--frost); word-break: break-all; user-select: all; }
.adm-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.adm-me { display: flex; align-items: center; gap: var(--s3); }
.adm-me > span { display: grid; text-align: end; }
.adm-me small { color: var(--ink-2); font-size: var(--fs-xs); }
.adm-tabs { margin: var(--s2) 0 var(--s3); max-width: 720px; grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); border-radius: 24px; }
.adm-tabs a { display: grid; place-items: center; min-height: var(--tap); border-radius: var(--r-pill); color: var(--ink-2); font-weight: 600; font-size: var(--fs-sm); text-decoration: none; }
.adm-tabs a[aria-current="page"] { background: var(--slide); color: var(--haem); box-shadow: 0 1px 3px var(--shadow); }
.adm-note { margin-bottom: var(--s4); font-size: var(--fs-sm); }
.adm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s3); }
.adm-tile { display: grid; gap: 4px; padding: var(--s4); border-radius: var(--r-md); border: 1px dashed var(--line-strong); }
.adm-tile small { color: var(--ink-2); font-size: var(--fs-xs); }
a.adm-tile { text-decoration: none; color: inherit; }
.adm-log, .adm-person { list-style: none; }
.adm-entry, .adm-person { align-items: center; }
.adm-entry .row__title { font-weight: 400; }
.adm-actions { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: flex-end; }
.adm-row2 { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: start; }
.adm-copy { display: flex; gap: var(--s2); }
.adm-copy .input { flex: 1; min-width: 0; font-size: var(--fs-sm); }
.adm-link { border-color: var(--haem); }

/* ---------- Cases (docs/mockups/redesign/case.html) ---------- */
.inv { margin-bottom: var(--s5); }
.inv-list { list-style: none; }
.inv-num { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; font-weight: 700; font-variant-numeric: tabular-nums;
  border: 2px solid var(--eosin); color: var(--ink); }
.inv-num.ok { background: var(--eosin); color: var(--paper); }
.case-sub { margin: -8px 0 var(--s3); }
.case-steps { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 var(--s4); }
.case-steps a { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--eosin); color: var(--ink); font-weight: 700; text-decoration: none; }
.case-steps a.ok { background: var(--eosin); color: var(--paper); }
.case-steps a.now { box-shadow: 0 0 0 4px color-mix(in srgb, var(--haem) 30%, transparent); border-color: var(--haem); }
.case { display: grid; gap: var(--s4); }
.case-file, .case-debrief, .case-board { position: relative; background: var(--paper); color: var(--paper-ink); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: var(--s5); box-shadow: 0 12px 28px -18px var(--shadow); }
.case-tab { display: inline-block; margin-bottom: var(--s2); font: 700 var(--fs-xs)/1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.case-stamp { position: absolute; top: 20px; inset-inline-end: 22px; transform: rotate(-8deg); padding: 4px 12px; border: 2px solid var(--danger); border-radius: 8px;
  color: var(--danger); font: 800 14px/1.2 var(--font-ui); text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.case-file h2 { font: 800 var(--fs-xl)/1.2 var(--font-head); margin-bottom: var(--s3); padding-inline-end: 90px; }
.case-vignette { font: 400 var(--fs-md)/1.65 var(--font-book); white-space: pre-wrap; }
.case-exhibit { display: flex; align-items: center; gap: var(--s3); margin: var(--s4) 0 0; padding: var(--s3); border: 1.5px dashed var(--line-strong); border-radius: 14px; font-size: var(--fs-sm); white-space: pre-wrap; }
.case-exhibit__frame { flex: none; width: 88px; }
.case-exhibit__frame img { width: 100%; display: block; }
.case-q { margin-top: var(--s5); }
.case-q h3 { font: 700 var(--fs-lg)/1.35 var(--font-head); margin-bottom: var(--s3); }
.case-opts { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s2); }
.case-opt { display: flex; width: 100%; min-height: 52px; align-items: center; padding: var(--s3) var(--s4); border-radius: 14px; border: 1.5px solid var(--control-edge);
  background: var(--slide); color: var(--ink); font: 500 var(--fs-md)/1.4 var(--font-ui); text-align: start; cursor: pointer; }
.case-opt:hover:not([disabled]) { border-color: var(--haem); background: var(--haem-wash); }
.case-opt[disabled] { cursor: default; opacity: .75; }
.case-opts .is-right .case-opt { opacity: 1; border-color: #2e7d4f; background: color-mix(in srgb, #2e7d4f 12%, var(--slide)); box-shadow: inset 4px 0 0 #2e7d4f; }
.case-opts .is-picked:not(.is-right) .case-opt { opacity: 1; border-color: var(--danger); box-shadow: inset 4px 0 0 var(--danger); }
.case-why { margin: 6px var(--s4) 0; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.5; }
.case-verdict { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s4); padding: var(--s3); border-radius: 14px; background: var(--haem-wash); }
.case-bot { width: 64px; height: 64px; object-fit: contain; flex: none; }
.case-debrief__art { margin: calc(-1 * var(--s5)) calc(-1 * var(--s5)) var(--s4); border-radius: var(--r-card) var(--r-card) 0 0; overflow: hidden; aspect-ratio: 16 / 6; }
.case-debrief__art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.case-debrief h2 { font: 800 var(--fs-xl)/1.2 var(--font-head); }
.case-lead { margin: var(--s2) 0 var(--s3); font-weight: 600; }
.case-points { padding-inline-start: 1.4em; display: grid; gap: var(--s3); list-style: decimal; }
.case-points li::marker { font-weight: 800; color: var(--haem); }
.case-points p { margin-top: 4px; line-height: 1.6; }
.case-links { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-top: var(--s4); }
.case-links a { color: var(--haem); font-weight: 600; }
.case-next { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s5); }
/* The Vault (views/vault.js, question-view.js): drawers, cold cases, one question at a time */
.vault-drawers { list-style: none; display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.vault-drawer { display: grid; gap: 4px; height: 100%; padding: var(--s4); border-radius: var(--r-card); border: 1px solid var(--line); background: var(--slide); color: inherit; text-decoration: none; box-shadow: 0 10px 26px -18px var(--shadow); }
.vault-drawer:hover { border-color: var(--haem); }
.vault-drawer__name { font: 800 var(--fs-lg)/1.25 var(--font-head); }
.vault-drawer__go { margin-top: var(--s2); font-weight: 700; color: var(--haem); }
.vault-due { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-md); border: 1.5px dashed var(--haem); color: inherit; text-decoration: none; }
.q-card .q-stem { font: 700 var(--fs-lg)/1.45 var(--font-head); padding-inline-end: 0; }
.q-run { padding-bottom: 88px; } /* the last button stays clear of the partner button */
.q-after { margin-top: var(--s4); display: grid; gap: var(--s4); }
.q-done { display: grid; justify-items: center; gap: var(--s3); text-align: center; }
.case-board { background: var(--paper) url("../img/C8-L-800.webp") center / cover; }
:root[data-theme="dark"] .case-board { background-image: url("../img/C8-D-800.webp"); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .case-board { background-image: url("../img/C8-D-800.webp"); } }
.case-board h3 { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--paper); box-shadow: 0 4px 10px -6px var(--shadow); font: 800 var(--fs-md)/1.3 var(--font-head); margin-bottom: var(--s3); }
.case-clue { background: var(--paper); border-radius: 10px; padding: var(--s3); margin-top: var(--s2); box-shadow: 0 6px 14px -8px var(--shadow); }
.case-clue__kind { display: flex; align-items: center; gap: 6px; font: 700 var(--fs-xs)/1.2 var(--font-ui); color: var(--ink-2); margin-bottom: 4px; }
.case-clue q { quotes: none; line-height: 1.5; }
.case-after { display: grid; gap: var(--s4); }
@media (min-width: 1000px) { .case-after:not([hidden]) { grid-template-columns: 1fr 300px; align-items: start; } .case-after > .case-debrief:only-child { grid-column: 1 / -1; } }

/* admin: case editor */
.adm-bar { margin-bottom: var(--s3); }
.adm-back { margin-bottom: var(--s2); }
.tag--live { background: color-mix(in srgb, #2e7d4f 16%, transparent); color: #2e7d4f; }
.adm-tile--live { text-decoration: none; color: inherit; border-style: solid; border-color: var(--haem); }
.adm-tile--live:hover { background: var(--haem-wash); }
.adm-rows { display: grid; gap: var(--s2); }
.adm-rowcard { display: grid; gap: var(--s2); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); background: color-mix(in srgb, var(--frost) 40%, transparent); }
.adm-remove { justify-self: end; color: var(--danger); }
.adm-add { justify-self: start; }
.adm-check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--fs-sm); }
.adm-check input { width: 20px; height: 20px; accent-color: var(--haem); }
.adm-case-actions { position: sticky; bottom: 0; z-index: 4; justify-content: flex-start; padding: var(--s3) 0; background: linear-gradient(transparent, var(--bg, var(--tray)) 30%); }
.adm-saved { color: #2e7d4f; font-weight: 600; min-height: 1.4em; }
.adm-preview { margin-top: var(--s4); padding-top: var(--s4); border-top: 2px dashed var(--line-strong); }
/* booklet PDF -> drafts (on the Cases page) */
.adm-booklet summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; }
.adm-booklet[open] summary { margin-bottom: var(--s3); }
.adm-booklet .adm-saved, .adm-booklet .adm-error { overflow-wrap: anywhere; }
.adm-booklet progress { width: 100%; accent-color: var(--haem); }
.adm-model { width: 100%; height: min(70vh, 640px); border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; }
.adm-licences { display: grid; gap: var(--s2); }
.adm-licence { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; }
.adm-licence input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--haem); }
.adm-licence span { display: grid; gap: 2px; }
.adm-licence small { color: var(--ink-2); font-size: var(--fs-xs); }
.adm-licence.is-off { cursor: not-allowed; opacity: .75; }
/* Files and images */
.adm-upload { display: grid; gap: var(--s3); }
.adm-upload .help { margin: 0; }
.adm-drop { display: grid; place-items: center; min-height: 112px; padding: var(--s4); border: 2px dashed var(--line-strong); border-radius: var(--r-md); background: transparent; color: var(--ink); font: inherit; cursor: pointer; text-align: center; }
.adm-drop:hover, .adm-drop.is-over { border-color: var(--haem); background: var(--haem-wash); }
.adm-queue { list-style: none; display: grid; gap: var(--s2); }
.adm-queue:empty { display: none; }
.adm-q { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--s3); align-items: center; font-size: var(--fs-sm); }
.adm-q__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.adm-q progress { width: 120px; accent-color: var(--haem); }
.adm-q .row__sub { grid-column: 1 / -1; }
.adm-filter { display: flex; flex-wrap: wrap; border-radius: var(--r-md); margin-bottom: var(--s3); }
.adm-filter button { flex: 1 0 auto; padding: 0 var(--s3); }
.adm-files { list-style: none; display: grid; gap: var(--s3); }
.adm-file { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--s2) var(--s3); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--slide); }
.adm-file__thumb { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--frost); color: var(--ink-2); font: 800 var(--fs-xs)/1 var(--font-ui); text-decoration: none; }
.adm-file__thumb img { width: 100%; height: 100%; object-fit: cover; }
.adm-file__main { display: grid; gap: 2px; min-width: 0; align-content: center; }
.adm-file__title { overflow-wrap: anywhere; }
.adm-file__actions { grid-column: 1 / -1; justify-content: flex-start; }
.adm-picker { max-width: 360px; margin-top: calc(-1 * var(--s2)); }
.bk-media audio, .bk-media video { width: 100%; display: block; border-radius: 12px; }
.bk-file a { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; font-weight: 700; color: var(--haem); }
.bk-file__kind { padding: 2px 8px; border-radius: 6px; background: var(--frost); color: var(--ink-2); font: 800 var(--fs-xs)/1.4 var(--font-ui); }

/* ---------- The road: an investigation as a board game on our map (views/road.js) ---------- */
.road { position: relative; border-radius: 26px; border: 1px solid var(--line); margin-bottom: var(--s5); overflow: hidden;
  box-shadow: 0 14px 30px -20px var(--shadow); background: var(--paper);
  --bead: #f7efdc; --bead-rim: #6b5233; --walked: var(--eosin); --enamel: #1d2348; --brass: #b48a33; --brass-hi: #e4c47a; --enamel-ink: #f1e7d0; }
:root[data-theme="dark"] .road { --bead: #1b2040; --bead-rim: #c9c3e6; --enamel: #141833; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .road { --bead: #1b2040; --bead-rim: #c9c3e6; --enamel: #141833; } }
.road-scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.road-map { position: relative; min-width: 760px; aspect-ratio: 1000 / 860; isolation: isolate; }
.road__art { position: absolute; inset: 0; z-index: -1; }
.road__art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.road.is-rtl .road__art img { transform: scaleX(-1); } /* the walk starts on the right in Persian */
.road-board { position: absolute; inset: 0; }
.road__line { position: absolute; inset: 0; width: 100%; height: 100%; }
.road__guide { fill: none; stroke: var(--bead-rim); stroke-width: 2.5; opacity: .45; }
.bead { fill: var(--bead); stroke: var(--bead-rim); stroke-width: 2.5; }
.bead.is-walked { fill: var(--walked); stroke: color-mix(in srgb, var(--walked) 55%, #000); }
.road-stop { position: absolute; width: 0; height: 0; text-decoration: none; color: var(--ink); z-index: 1; }
.road-stop:hover, .road-stop:focus-visible { z-index: 2; }
.road-stop__token { position: absolute; left: 0; top: 0; translate: -50% -50%; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, color-mix(in srgb, var(--enamel) 75%, #fff), var(--enamel) 70%); color: var(--enamel-ink);
  box-shadow: inset 0 0 0 3px var(--brass), inset 0 0 0 5px var(--brass-hi), 0 0 0 2px color-mix(in srgb, var(--brass) 60%, #000), 0 8px 14px -6px rgba(0, 0, 0, .5);
  font: 800 19px/1 var(--font-head); font-variant-numeric: tabular-nums; transition: transform .15s; }
.road-stop.is-done .road-stop__token { background: radial-gradient(circle at 35% 30%, var(--brass-hi), var(--brass) 65%, #7a5a1c); color: var(--enamel); }
.road-stop.is-next .road-stop__token::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 2px solid var(--haem); animation: ping 2.4s cubic-bezier(.16, 1, .3, 1) infinite; }
@media (prefers-reduced-motion: reduce) { .road-stop.is-next .road-stop__token::after { animation: none; } }
.road-stop[aria-current="step"] .road-stop__token { outline: 3px dashed var(--haem); outline-offset: 5px; }
.road-stop.is-draft .road-stop__token { outline: 2px dashed var(--brass); outline-offset: 4px; }
.road-stop:hover .road-stop__token, .road-stop:focus-visible .road-stop__token { transform: translateY(-3px); }
.road-stop:focus-visible { outline: none; }
.road-stop:focus-visible .road-stop__token { outline: 3px solid var(--haem); outline-offset: 5px; }
.road-stop__lbl { position: absolute; left: 0; top: 30px; translate: calc(-50% + var(--dx, 0px)) 0; width: 124px; padding: 3px 7px; border-radius: 8px; text-align: center;
  background: color-mix(in srgb, var(--paper) 94%, transparent); color: var(--ink); font: 700 12px/1.35 var(--font-ui);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brass) 45%, transparent), 0 4px 10px -6px rgba(0, 0, 0, .45);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.road-stop.up .road-stop__lbl { top: auto; bottom: 30px; }
.road-flag { position: absolute; translate: -50% -50%; padding: 4px 12px; border-radius: 999px; background: var(--enamel); color: var(--enamel-ink); z-index: 1;
  box-shadow: inset 0 0 0 2px var(--brass), 0 6px 12px -6px rgba(0, 0, 0, .5); font: 800 13px/1.3 var(--font-ui); white-space: nowrap; }
.road-flag--end { background: var(--brass); color: var(--enamel); }
.case-road-h { font: 800 var(--fs-lg)/1.2 var(--font-head); margin: var(--s6) 0 var(--s3); }
.case-written { margin-top: var(--s2); }
.case-reveal { width: 100%; }
.case-answer { padding: var(--s4); border-radius: 14px; background: color-mix(in srgb, #2e7d4f 10%, var(--slide)); border: 1.5px solid #2e7d4f; }
.case-answer b { display: block; margin-bottom: var(--s2); color: #2e7d4f; }
.case-answer p { white-space: pre-wrap; line-height: 1.7; }
.adm-preview-note { margin-bottom: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-md); border: 1.5px dashed var(--brass, #b48a33); background: var(--haem-wash); font-size: var(--fs-sm); }
.adm-preview-note a { font-weight: 700; color: var(--haem); }

/* ---------- A booklet step: case → Continue → explanation → Case answer (case-view.js, booklet-text.js) ---------- */
.case-cover { margin: calc(-1 * var(--s5)) calc(-1 * var(--s5)) var(--s4); border-radius: var(--r-card) var(--r-card) 0 0; overflow: hidden; aspect-ratio: 3 / 2; max-height: 340px; }
.case-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.case-intro { margin: 0 0 var(--s3); padding: var(--s3); border-radius: 12px; background: var(--haem-wash); white-space: pre-wrap; }
.case-written { margin-top: var(--s4); display: grid; gap: var(--s4); }
.case-reveal { width: 100%; min-height: 52px; font-size: var(--fs-md); }
.case-expl > h3, .case-answer > h3 { font: 800 var(--fs-lg)/1.3 var(--font-head); margin-bottom: var(--s3); }
.case-answer { padding: var(--s4); border-radius: 14px; background: color-mix(in srgb, #2e7d4f 9%, var(--paper)); border: 1.5px solid #2e7d4f; }
.case-answer > h3 { color: #2e7d4f; }
.bk { font: 400 var(--fs-md)/1.85 var(--font-ui); }
.bk > * + * { margin-top: var(--s3); }
.bk-h { font: 800 1.08em/1.4 var(--font-head); margin-top: var(--s5) !important; padding-inline-start: 10px; border-inline-start: 4px solid var(--eosin); }
.bk-list { list-style: none; padding: 0; display: grid; gap: var(--s2); }
.bk-list li { position: relative; padding-inline-start: 18px; }
.bk-list li::before { content: ""; position: absolute; inset-inline-start: 2px; top: .8em; width: 7px; height: 7px; border-radius: 50%; background: var(--eosin); }
.bk-rule { padding: var(--s3) var(--s4); border-radius: 12px; background: #fde4ea; color: #5c1a2b; font-weight: 800; text-align: center; }
.bk-note { padding: var(--s3) var(--s4); border-radius: 12px; background: #fff4ec; border-inline-start: 4px solid #e08a59; }
:root[data-theme="dark"] .bk-rule { background: #3e1f2a; color: #ffd6e0; }
:root[data-theme="dark"] .bk-note { background: #33261d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bk-rule { background: #3e1f2a; color: #ffd6e0; } :root:not([data-theme="light"]) .bk-note { background: #33261d; } }
.bk-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.bk-table table { width: 100%; border-collapse: collapse; font-size: .92em; line-height: 1.6; }
.bk-table th { background: #2c406b; color: #fff; font-weight: 800; text-align: start; padding: 8px 10px; }
.bk-table td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.bk-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--frost) 45%, transparent); }
.bk-table td:first-child { font-weight: 700; }
.bk-fig { margin: var(--s4) 0; }
.bk-fig img { width: 100%; border-radius: 14px; display: block; }
.bk-fig figcaption { margin-top: var(--s2); font-size: .85em; color: var(--ink-2); text-align: center; }
/* a question in the text («تو آزمون اومده · ارتقا ۱۳۹۶»): the answer opens on a tap */
.bk-quiz { padding: var(--s3) var(--s4); border-radius: 12px; border: 1.5px dashed #e08a59; }
.bk-quiz__h { font: 800 .95em/1.5 var(--font-head); color: #b4501d; }
.bk-quiz__q { margin-top: var(--s2); }
.bk-quiz__opts { list-style: none; padding: 0; margin-top: var(--s2); display: grid; gap: 6px; }
.bk-quiz__opts li { padding: 6px 12px; border-radius: 8px; background: color-mix(in srgb, #e08a59 14%, var(--paper)); }
.bk-quiz__opts li.is-right { background: color-mix(in srgb, #2e7d4f 14%, var(--paper)); box-shadow: inset 0 0 0 1.5px #2e7d4f; }
.bk-quiz__btn { margin-top: var(--s3); min-height: 44px; }
.bk-quiz__ans { margin-top: var(--s3); padding: var(--s2) var(--s3); border-radius: 10px; background: color-mix(in srgb, var(--frost) 55%, transparent); }
/* «رمز»: a mnemonic or the key numbers */
.bk-code { padding: var(--s3) var(--s4); border-radius: 12px; background: #fff6df; border: 1.5px solid #f0c75e; color: #3b2a05; }
.bk-code__h { font: 800 .95em/1.5 var(--font-head); color: #8a5a00; }
.bk-code__key { font-weight: 800; margin-top: var(--s1); }
:root[data-theme="dark"] .bk-quiz__h { color: #f0a06f; }
:root[data-theme="dark"] .bk-code { background: #33290f; border-color: #8a6a1e; color: #f5e6bd; }
:root[data-theme="dark"] .bk-code__h { color: #f3cf7e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bk-quiz__h { color: #f0a06f; }
  :root:not([data-theme="light"]) .bk-code { background: #33290f; border-color: #8a6a1e; color: #f5e6bd; }
  :root:not([data-theme="light"]) .bk-code__h { color: #f3cf7e; }
}

/* Section headers (the stage): the section's picture fills the top of the page edge to edge and
   fades into the paper; the title sits on the picture's calm side, and anything passed as `low`
   (search, chips, the first heading) on its lower part. Home's map band does the same. */
.main:has(> .stage, > .band) { --pad: var(--gutter); max-width: none; padding: 0 0 calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s6)); }
.main:has(> .stage, > .band) > :not(.stage, .band) { margin-inline: max(var(--pad), (100% - 1120px) / 2 + var(--pad)); }
.stage, .band { --halo: rgba(244, 234, 210, .85); }
:root[data-theme="dark"] :is(.stage, .band) { --halo: rgba(12, 14, 32, .82); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.stage, .band) { --halo: rgba(12, 14, 32, .82); } }
.stage { position: relative; isolation: isolate; overflow: hidden; display: flex; min-height: clamp(280px, 44vh, 480px); margin-bottom: var(--s4); }
.stage--tall { min-height: clamp(420px, 62vh, 680px); margin-bottom: 0; }
:not(.main) > .stage { border-radius: 26px; } /* inside a padded box (the admin's reader preview) */
.stage__art { position: absolute; inset: 0; z-index: -1; -webkit-mask-image: linear-gradient(#000 60%, transparent 100%); mask-image: linear-gradient(#000 60%, transparent 100%); }
.stage__art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; display: block; }
.stage::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.stage--center::after { background: radial-gradient(42% 36% at 50% 14%, color-mix(in srgb, var(--halo) 75%, transparent), transparent 80%); }
.stage--right::after { background: linear-gradient(270deg, color-mix(in srgb, var(--halo) 85%, transparent) 0%, color-mix(in srgb, var(--halo) 55%, transparent) 26%, transparent 46%); }
.stage--left::after { background: linear-gradient(90deg, color-mix(in srgb, var(--halo) 85%, transparent) 0%, color-mix(in srgb, var(--halo) 55%, transparent) 26%, transparent 46%); }
.stage__in { width: 100%; display: flex; flex-direction: column; padding: var(--s6) max(var(--pad, var(--s4)), (100% - 1120px) / 2 + var(--pad, var(--s4))) 0; }
.stage__text { text-shadow: 0 0 12px var(--halo), 0 0 3px var(--halo); }
/* a soft cloud of paper behind the title, so it reads over any part of the picture */
.stage__text { position: relative; }
.stage__text::before { content: ""; position: absolute; inset: -18% -12%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--halo) 92%, transparent) 55%, transparent); }
.stage__text h1 { font: 900 clamp(2.2rem, 4.4vw, 3.4rem)/1.1 var(--font-head); }
.stage__text p { margin-top: var(--s2); font-weight: 650; font-size: var(--fs-lg); color: var(--ink-2); }
.stage--center .stage__text { text-align: center; }
/* the picture doesn't flip, so its calm side stays on the same side in both directions */
.stage--right .stage__text { margin-left: auto; max-width: min(36%, 24rem); }
.stage--left .stage__text { margin-right: auto; max-width: min(40%, 26rem); }
.stage--left .stage__art img { object-position: 50% 30%; }
.stage--right .stage__art img { object-position: 50% 40%; }
.stage__low { margin-top: auto; padding-top: var(--s7); }
.stage__low .clues-link, .stage__low .search { box-shadow: 0 14px 30px -16px var(--shadow); }
.stage__low .section-head { margin-bottom: var(--s3); }
.stage__low .section-head h2 { text-shadow: 0 0 10px var(--halo), 0 0 3px var(--halo); }
.stage__low .chips { margin-bottom: var(--s4); }
/* Home: the map band, edge to edge too */
.main > .band { border-radius: 0; box-shadow: none; background: none; margin-bottom: 0; min-height: clamp(360px, 54vh, 600px);
  padding: var(--s6) max(var(--pad), (100% - 1120px) / 2 + var(--pad)) var(--s7); }
.main > .band .band__art { -webkit-mask-image: linear-gradient(#000 70%, transparent 100%); mask-image: linear-gradient(#000 70%, transparent 100%); }
@media (min-width: 900px) {
  .main:has(> .stage, > .band) { --pad: var(--s6); padding-bottom: var(--s7); }
  .stage__in { padding-top: var(--s7); }
}
@media (max-width: 600px) {
  .stage { min-height: 300px; }
  .stage--tall { min-height: 440px; }
  .stage--right .stage__text, .stage--left .stage__text { max-width: none; margin: 0; text-align: center; }
  .stage--right::after, .stage--left::after { background: radial-gradient(70% 40% at 50% 14%, color-mix(in srgb, var(--halo) 80%, transparent), transparent 85%); }
  .stage--right .stage__art img { object-position: 100% 40%; }
  .stage--left .stage__art img { object-position: 0 30%; }
}
