/* The platform's page styles, on top of ds.css (the design system: tokens and tp- components, generated by
   docs/design/build.py; never edit ds.css by hand). The classes below are the ones the templates and scripts
   already use (.card, .btn, .pill, tables, .banner, .tabs, the chapter matrix, the review screen), drawn with
   the design system's tokens so every page shares one look. New pages use the tp- components directly. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { font-size: 14px; line-height: 24px; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
.tp-app a, .card a.btn, a.btn, .tp-nav a, .tabs a, table a { text-decoration: none; }
table a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 40px; font-weight: 600; margin: 0 0 2px; text-wrap: balance; }
h2 { font-size: 17px; line-height: 28px; font-weight: 600; margin: 28px 0 12px; }
h3 { font-size: 15px; line-height: 24px; font-weight: 600; margin: 18px 0 6px; }
p { margin: 0 0 10px; }
small, .muted { color: var(--ink-muted); }
small { font-size: 12px; line-height: 18px; }
code { font: 12.5px/1.5 var(--font-mono); background: var(--surface-sunken); border: 1px solid var(--line); padding: 1px 5px; border-radius: var(--radius-sm); }

/* Shell: tp-app (sidebar + main) from ds.css; the old .wrap is the content column. */
.wrap { padding: var(--space-6); max-width: var(--content-max); width: 100%; margin: 0; }
.narrow { max-width: 780px; }
.tp-side { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.tp-side .tp-nav a .tp-icon, .tp-side .tp-navitem .tp-icon { color: inherit; }
.tp-side form { margin: 0; }
.tp-signout { margin-inline-start: auto; }
.tp-topbar .tp-search { max-width: 380px; }
.tp-topbar .tp-search input { height: 100%; }
.jobs-dot { position: relative; }
.jobs-dot[data-n]::after { content: attr(data-n); position: absolute; top: -6px; inset-inline-end: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 11px; line-height: 18px; font-weight: 600; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.offline { background: var(--warn-soft); color: var(--warn-ink); font-size: 13px; padding: 6px var(--space-6); border-bottom: 1px solid var(--line); }
@media (max-width: 860px) {
  .tp-side { position: static; height: auto; }
  .wrap { padding: var(--space-4) max(16px, env(safe-area-inset-right, 0px)) var(--space-8) max(16px, env(safe-area-inset-left, 0px)); }
  .offline { padding-inline: 16px; }
}

/* Page head */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.sub { color: var(--ink-muted); margin: 0; }

/* Status pills: the old names map onto the design system's six states. */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--neutral-soft); color: var(--neutral-ink); font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap; vertical-align: middle; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; flex: none; }
.pill.good { background: var(--good-soft); color: var(--good-ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.bad { background: var(--bad-soft); color: var(--bad-ink); }
.pill.info { background: var(--info-soft); color: var(--info-ink); }
.pill.hold { background: var(--hold-soft); color: var(--hold-ink); }

/* Banners */
.banner { display: block; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); margin: 0 0 var(--space-4); background: var(--info-soft); color: var(--info-ink); border: 0; font-size: 13px; }
.banner.ok { background: var(--good-soft); color: var(--good-ink); }
.banner.err { background: var(--bad-soft); color: var(--bad-ink); }
.banner.warn { background: var(--warn-soft); color: var(--warn-ink); }
.banner a { color: inherit; }

/* Cards, grids, stats */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-card); margin-bottom: var(--space-4); min-width: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: var(--space-4); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-card); min-width: 0; }
.stat b { display: block; font-size: 26px; line-height: 34px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-muted); font-size: 13px; }

/* Tables: header band, hairlines, row hover (ds.css draws tp-table the same way). */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: start; padding: 10px var(--space-3); border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--ink-muted); font-weight: 500; background: var(--surface-sunken); white-space: nowrap; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:not(:first-child):hover td { background: var(--surface-sunken); }
.card > table, .card.scroll > table, .card > .scroll > table { margin: 0; }
.card.scroll { padding: 0; overflow-x: auto; }
.card.scroll > p, .card.scroll > .help { padding: 0 var(--space-5) var(--space-4); }
.scroll { overflow-x: auto; }
td.clip { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Book content takes its direction from its own text (dir="auto"); in the Arabic interface it still lines up
   on the right with the rest of the page. The review screen's text columns keep their own alignment. */
[dir="rtl"] :is(td, h3, .tp-card div)[dir="auto"] { text-align: right; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ar { direction: rtl; text-align: right; font-size: 16px; line-height: 30px; }

/* Buttons and fields */
button, .btn, input, select, textarea { font: inherit; color: inherit; }
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--control-h); padding: 0 var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover, button:hover { background: var(--surface-sunken); }
.btn.primary, button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover, button.primary:hover { background: var(--primary); opacity: .86; }
.btn.danger, button.danger { color: var(--bad-ink); }
.btn.small, button.small { height: var(--control-h-sm); padding: 0 var(--space-3); font-size: 12px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.link { height: auto; border: 0; background: none; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: var(--control-h); padding: 6px var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); }
.tp-search input, .tp-search input:not([type]) { border: 0; min-height: 0; padding: 0; background: transparent; }
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
textarea.mono { font: 12.5px/1.6 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
input.term-ar { font-size: 15px; line-height: 1.6; padding: 4px var(--space-3); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; }
:where(input, select, textarea):focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
label { display: block; font-weight: 500; font-size: 13px; margin: 14px 0 4px; }
label.check { display: flex; align-items: center; gap: var(--space-2); font-weight: 400; font-size: 14px; margin: 4px 0; }
label.check input { width: auto; }
.tp-search { margin: 0; font-weight: 400; }
.help { color: var(--ink-muted); font-size: 12px; line-height: 18px; margin: 4px 0 0; font-weight: 400; }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
form.inline { display: inline; }

/* Tabs (a book's pages) */
.tabs { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--line); margin: var(--space-2) 0 var(--space-5); overflow-x: auto; }
.tabs a { padding: 10px 2px; color: var(--ink-muted); font-weight: 500; white-space: nowrap; text-decoration: none; }
.tabs a.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--primary); }
.tabs a:hover { color: var(--ink); }

/* The top of a book's page: the next step with its button, and the passes as a line of steps. */
.tp-next { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); padding: var(--space-5) var(--space-6); margin-bottom: var(--space-5); }
.tp-next.is-go { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow-card); }
.tp-next-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4) var(--space-6); flex-wrap: wrap; }
.tp-next-what { min-width: min(100%, 280px); flex: 1; }
.tp-next-what h2 { margin: 2px 0 4px; font-size: 22px; line-height: 32px; font-weight: 600; text-wrap: balance; }
.tp-next-what p { margin: 0; color: var(--ink-muted); font-size: 14px; }
.tp-next-act { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.tp-next-go { height: 48px; padding: 0 var(--space-6); font-size: 16px; font-weight: 600; border-radius: var(--radius-lg); }
.tp-next-go .tp-icon { width: 20px; height: 20px; }
.tp-steps { list-style: none; margin: var(--space-5) 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-3); }
.tp-step { background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.tp-step.is-now { background: var(--accent-soft); border-color: var(--accent); }
.tp-step-head { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; line-height: 20px; }
.tp-step-n { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--radius-full); background: var(--surface); border: 1px solid var(--line-strong); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tp-step.is-done .tp-step-n { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tp-step.is-now .tp-step-n { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tp-step-bar { height: 6px; border-radius: var(--radius-full); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.tp-step-bar i { display: block; height: 100%; background: var(--primary); border-radius: var(--radius-full); }
.tp-step-info { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--space-2); font-size: 12px; line-height: 18px; color: var(--ink-muted); min-height: var(--control-h-sm); }
.tp-step-count { margin-inline-end: auto; font-variant-numeric: tabular-nums; }
.tp-next-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-5); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--line); font-size: 13px; }
.tp-auto-on { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); color: var(--ink-muted); }
.tp-auto td, .tp-auto th { padding: 6px var(--space-2); vertical-align: middle; }
.tp-auto td:first-child { white-space: nowrap; } .tp-auto label { margin: 0; }
.tp-auto input[type=number] { width: 7.5rem; }
.tp-auto-cost { margin: var(--space-3) 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-sunken); border: 1px solid var(--line); font-size: 13px; }
.tp-auto-cost table { margin-top: var(--space-2); } .tp-auto-cost td, .tp-auto-cost th { padding: 4px var(--space-2); background: none; }
.tp-auto-cost .tp-auto-total { font-size: 16px; }
@media (max-width: 640px) { .tp-next { padding: var(--space-4); } .tp-next-go { flex: 1; } .tp-next-act { width: 100%; } .tp-auto td, .tp-auto th { display: block; padding: 2px 0; } .tp-auto tr:first-child { display: none; } .tp-auto tr { display: block; padding: var(--space-2) 0; } }

/* Emails: the outbox, and one email as its reader sees it. */
.tp-mail-frame { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #f4f4f5; }
.tp-mail-meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px var(--space-4); font-size: 13px; margin: 0 0 var(--space-3); }
.tp-mail-meta dt { color: var(--ink-muted); } .tp-mail-meta dd { margin: 0; overflow-wrap: anywhere; }

/* The chapter × pass grid */
.matrix td { min-width: 160px; }
.matrix td:first-child, .matrix th:first-child { min-width: 0; width: 34px; }
.matrix td.title { min-width: 220px; max-width: 320px; font-weight: 500; }
.cell { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.cell .who { font-size: 12px; color: var(--ink-muted); }
.bar { height: 6px; border-radius: var(--radius-full); background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; display: flex; min-width: 120px; }
.bar i { display: block; height: 100%; }
.bar .done { background: var(--primary); } .bar .check { background: var(--warn-ink); } .bar .ai { background: var(--info-ink); }

/* The shared dialog (filled by app.js) */
dialog { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--ink); max-width: 640px; width: calc(100% - 32px); box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgba(10, 10, 12, .5); }
dialog .dh { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; }
dialog .db { padding: var(--space-4) var(--space-5); max-height: 60vh; overflow: auto; }
dialog .df { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: var(--space-2); }

/* The review screen */
.rv-bar { position: sticky; top: var(--topbar-h); z-index: 4; background: var(--canvas); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); margin-bottom: var(--space-3); display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.rv-bar .filters { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-md); background: var(--surface-sunken); flex-wrap: wrap; }
.rv-bar .filters button { height: 28px; border: 0; background: transparent; color: var(--ink-muted); }
.rv-bar .filters button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card), 0 0 0 1px var(--line); }
.seg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: var(--space-3); scroll-margin-top: 140px; overflow: hidden; }
.seg.cur { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.seg .meta { display: flex; gap: var(--space-2); align-items: center; padding: 6px var(--space-4); border-bottom: 1px solid var(--line); background: var(--surface-sunken); font-size: 12px; color: var(--ink-muted); flex-wrap: wrap; }
.seg .meta .path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 80px; }
.seg .cols { display: grid; grid-template-columns: 1fr 1fr; }
.seg .cols.one { grid-template-columns: 1fr; }
.seg .col { padding: var(--space-3) var(--space-4); min-width: 0; overflow-wrap: anywhere; font-size: 15px; line-height: 28px; }
.seg .col + .col { border-inline-start: 1px solid var(--line); }
.seg .col h4 { margin: 0 0 4px; font-size: 12px; line-height: 18px; color: var(--ink-muted); font-weight: 500; }
.seg.heading .col .text { font-weight: 600; }
.seg .foot { display: flex; gap: var(--space-2); align-items: center; padding: var(--space-2) var(--space-4); border-top: 1px solid var(--line); flex-wrap: wrap; }
.seg .why { padding: 0 var(--space-4) var(--space-2); font-size: 13px; color: var(--ink-muted); }
.seg .why ul { margin: 4px 0 0; padding-inline-start: 18px; }
.seg .why .flag { color: var(--warn-ink); }
.seg img.fig { max-width: 260px; max-height: 160px; border: 1px solid var(--line); border-radius: var(--radius-md); display: block; margin-top: 8px; }
/* An approved term where it stands in the text, and the segment's terms with their approved Arabic. */
mark.tp-term { background: var(--accent-soft); color: var(--ink); font-weight: 700; border-radius: 3px; padding: 0 2px; box-shadow: inset 0 -2px 0 var(--accent); cursor: help; }
ins mark.tp-term, del mark.tp-term { background: none; color: inherit; }
.tp-terms { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--space-2); padding: var(--space-2) var(--space-4); border-top: 1px solid var(--line); font-size: 12px; line-height: 18px; }
.tp-terms-h { color: var(--ink-muted); font-weight: 500; margin-inline-end: 2px; }
.tp-termchip { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; padding: 3px 8px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); max-width: 100%; }
.tp-termchip > span { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; }
.tp-termchip b { font-weight: 700; }
.tp-termchip-ar { font-size: 14px; line-height: 20px; font-weight: 600; }
.tp-termchip-sep { color: var(--ink-muted); }
.tp-termchip.is-miss { background: var(--warn-soft); color: var(--warn-ink); box-shadow: inset 0 -2px 0 currentColor; }
.tp-termchip em { font-style: normal; font-weight: 500; }
ins { background: var(--good-soft); color: var(--good-ink); text-decoration: none; border-radius: 3px; padding: 0 1px; }
del { background: var(--bad-soft); color: var(--bad-ink); border-radius: 3px; padding: 0 1px; }
.ref { border-bottom: 1px dotted var(--ink-muted); }
.seg textarea { min-height: 80px; }
.seg .comments { padding: 6px var(--space-4) 10px; font-size: 13px; border-top: 1px solid var(--line); }
.seg .comments div { margin-bottom: 4px; }
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-sunken); font: 11px var(--font-mono); color: var(--ink-muted); }

/* The original file beside the text: the picture of a page with a box round each piece of text.
   The page is paper in both themes, so the boxes use fixed colours that read on white. */
.wrap.wide { max-width: none; }
.tp-src-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); margin-bottom: var(--space-4); }
.tp-src-pager, .tp-src-goto, .tp-src-tools { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.tp-src-tools { margin-inline-start: auto; }
.tp-src-goto { margin: 0; }
.tp-src-goto label { margin: 0; color: var(--ink-muted); font-weight: 400; }
.tp-src-goto input[type=number] { width: 5rem; min-height: var(--control-h-sm); padding: 2px var(--space-2); }
.tp-src-goto select { min-height: var(--control-h-sm); padding: 2px var(--space-2); max-width: 22rem; width: auto; }
.tp-src-goto span { color: var(--ink-muted); white-space: nowrap; }
.tp-src-prev { transform: rotate(90deg); } .tp-src-next { transform: rotate(-90deg); }
[dir=rtl] .tp-src-prev { transform: rotate(-90deg); } [dir=rtl] .tp-src-next { transform: rotate(90deg); }
.tp-src { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.tp-src-left { position: sticky; top: calc(var(--topbar-h) + var(--space-3)); max-height: calc(100vh - var(--topbar-h) - var(--space-5)); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-sunken); box-shadow: var(--shadow-card); }
.tp-src-page { position: relative; width: 100%; background: #fff; direction: ltr; }
.tp-src-page img { display: block; width: 100%; height: auto; }
.tp-src-layer { position: absolute; inset: 0; }
.tp-src-box { position: absolute; border-radius: 2px; background: rgba(29, 78, 216, .09); cursor: pointer; mix-blend-mode: multiply; }
.tp-src-layer.quiet .tp-src-box { background: none; }
.tp-src-box.hot, .tp-src-layer.quiet .tp-src-box.hot { background: rgba(29, 78, 216, .22); }
.tp-src-box.on, .tp-src-layer.quiet .tp-src-box.on { background: rgba(255, 214, 10, .55); }
.tp-src-text { min-width: 0; }
.tp-src-sum { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-3); color: var(--ink-muted); font-size: 13px; }
.tp-src-sum b { color: var(--ink); font-size: 15px; }
.tp-src-sum label.check { margin: 0; margin-inline-start: auto; font-size: 13px; color: var(--ink); }
.tp-src-seg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3) var(--space-3); margin-bottom: var(--space-2); cursor: pointer; scroll-margin-top: 140px; }
.tp-src-seg.hot { border-color: var(--line-strong); }
.tp-src-seg.cur { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--accent-soft); }
.tp-src-seg:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tp-src-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: 4px; }
.tp-src-body { font-size: 14px; line-height: 24px; overflow-wrap: anywhere; }
.tp-src-seg.is-heading .tp-src-body { font-weight: 600; }
@media (max-width: 1000px) {
  .tp-src { grid-template-columns: minmax(0, 1fr); }
  .tp-src-left { top: 0; max-height: 46vh; z-index: 3; }
  .tp-src-tools { margin-inline-start: 0; }
}

/* The review screen with the original page beside the list. */
.rv-split.has-src { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 44%); gap: var(--space-4); align-items: start; }
.rv-src { position: sticky; top: calc(var(--topbar-h) + 66px); height: calc(100vh - var(--topbar-h) - 82px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; min-width: 0; }
.rv-src-head { display: flex; align-items: center; gap: var(--space-2) var(--space-3); flex-wrap: wrap; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); font-size: 13px; }
.rv-src-tools { display: inline-flex; gap: 4px; margin-inline-start: auto; }
.rv-src-tools .small { padding: 0 8px; }
.rv-src-body { flex: 1; overflow: auto; background: var(--surface-sunken); }
.rv-src-note { margin: 0; padding: var(--space-3) var(--space-4); font-size: 13px; color: var(--ink-muted); }
.rv-src .tp-src-box { cursor: default; }
#src-toggle[aria-pressed=true] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.seg .meta button.link { font-size: 12px; color: var(--ink-muted); }
.seg .meta button.link:hover { color: var(--ink); }
@media (max-width: 1700px) { .rv-split.has-src .seg .cols { grid-template-columns: 1fr; } .rv-split.has-src .seg .col + .col { border-inline-start: 0; border-top: 1px solid var(--line); } }
@media (max-width: 1100px) {
  .rv-split.has-src { display: block; }
  .rv-src { position: fixed; inset: 0; top: 0; height: auto; z-index: 40; border-radius: 0; border: 0; }
  body.rv-src-open { overflow: hidden; }
}

/* Figures, the guide, login */
.figgrid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.figgrid img { max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; }
.guide { max-width: 860px; } .guide h1 { margin-bottom: 12px; } .guide h2 { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--line); }
.guide table { margin: 10px 0 16px; } .guide td, .guide th { border: 1px solid var(--line); }
.guide ol, .guide ul { padding-inline-start: 22px; } .guide li { margin-bottom: 4px; }
pre { background: var(--surface-sunken); border: 1px solid var(--line); padding: var(--space-3); border-radius: var(--radius-md); overflow-x: auto; font: 12.5px/1.6 var(--font-mono); white-space: pre-wrap; }
.login { max-width: 400px; margin: 10vh auto 0; }
.login .tp-brand { justify-content: center; margin-bottom: var(--space-5); }
@media (max-width: 760px) {
  .seg .cols { grid-template-columns: 1fr; } .seg .col + .col { border-inline-start: 0; border-top: 1px solid var(--line); }
  .figgrid { grid-template-columns: 1fr; } .rv-bar { top: 0; position: static; }
}

/* Arabic interface: one family for both scripts (Readex Pro); a few things stay left to right. */
html[dir=rtl] code, html[dir=rtl] textarea.code, html[dir=rtl] .guide { direction: ltr; unicode-bidi: plaintext; }
html[dir=rtl] input[type=email], html[dir=rtl] input[type=password], html[dir=rtl] input[type=number], html[dir=rtl] input[list] { direction: ltr; text-align: right; }
html[dir=rtl] [translate=no] { unicode-bidi: plaintext; }

/* Dashboard and My work */
.dash-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: var(--space-4); }
.mw-row { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(220px, .8fr) minmax(280px, 1fr); gap: var(--space-4); }
.big { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.big strong { font-size: 26px; line-height: 34px; font-weight: 600; font-variant-numeric: tabular-nums; }
.vsep { border-inline-start: 2px solid var(--line); padding-inline-start: var(--space-3); }
.book-sub { display: flex; align-items: center; gap: 8px; color: var(--ink-muted); font-size: 13px; }
.book-title { margin: 6px 0; font-size: 21px; line-height: 32px; font-weight: 600; }
.book-title a { text-decoration: none; }
.hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-5) 0; }
.stats-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.marker { display: inline-block; width: 10px; height: 10px; flex: none; border-radius: 3px; }
.schedwrap { overflow-x: auto; padding-bottom: 4px; }
.schedwrap .tp-sched { min-width: 680px; }
.tp-chart .hit { fill: transparent; cursor: pointer; }
.tp-chart .hit:focus-visible { outline: none; stroke: var(--focus); stroke-width: 2; }
.tp-tip .tp-delta { margin-inline-start: 6px; vertical-align: 3px; }
.tp-kpis .tp-kpi .tp-display { font-size: 32px; }
.empty-note { color: var(--ink-muted); font-size: 13px; padding: var(--space-6) 0; text-align: center; }
.search-group h2 { margin-top: var(--space-5); }
@media (max-width: 1180px) { .dash-row, .mw-row { grid-template-columns: minmax(0, 1fr); } .stats-stack { flex-direction: row; flex-wrap: wrap; } .stats-stack .tp-stat { flex: 1 1 200px; } }
.tp-darkrow { display: flex; align-items: center; gap: 10px; height: var(--control-h); padding: 0 10px; color: var(--ink-muted); font-weight: 500; flex-wrap: nowrap; }
.tp-usercard b a { color: var(--ink); }
.tp-usercard .tp-signout .tp-btn span { display: none; }
@media (max-width: 860px) {
  .tp-side .tp-usercard { display: flex; margin: 0; padding: 0; border: 0; flex: none; }
  .tp-side .tp-usercard > div { display: none; }
}

/* A book's Profile and prompts page: one block per master prompt with the chapter's own section */
.cp { padding: var(--space-4) 0; border-top: 1px solid var(--line); }
.cp:first-of-type { border-top: 0; }
.cp-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-2); }
.cp-head h3 { margin: 0; }
.cp-meta { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: 13px; }
.cp textarea { width: 100%; font-family: inherit; }
.cp-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.cp-actions input { flex: 1 1 14rem; min-width: 0; }
.cp details { margin-top: var(--space-3); }
.cp summary { cursor: pointer; color: var(--ink-muted); font-size: 13px; }
.cp pre, .cp-full { white-space: pre-wrap; word-break: break-word; max-height: 28rem; overflow: auto; background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); font-size: 12.5px; line-height: 1.6; }
.cp-full mark { background: var(--accent-soft); color: var(--ink); border-radius: 3px; }
.cp-hist { list-style: none; padding: 0; margin: var(--space-2) 0 0; display: flex; flex-direction: column; gap: var(--space-3); font-size: 13px; }

/* Terms: the slider that ticks the most used terms */
.tp-pick { padding-block: var(--space-3); }
.tp-pick label { font-weight: 600; }
.tp-pick-row { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-2); }
.tp-pick-row input[type=range] { --pct: 0%; flex: 1; min-width: 0; height: var(--control-h-sm); margin: 0; background: transparent;
  -webkit-appearance: none; appearance: none; cursor: pointer; }
.tp-pick-row input[type=range]:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: var(--radius-sm); }
.tp-pick-row input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: var(--radius-full);
  background: linear-gradient(to right, var(--accent) var(--pct), var(--line-strong) var(--pct)); }
html[dir=rtl] .tp-pick-row input[type=range]::-webkit-slider-runnable-track {
  background: linear-gradient(to left, var(--accent) var(--pct), var(--line-strong) var(--pct)); }
.tp-pick-row input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-top: -7px;
  border-radius: var(--radius-full); background: var(--accent); border: 2px solid var(--on-accent); }
.tp-pick-row input[type=range]::-moz-range-track { height: 6px; border-radius: var(--radius-full); background: var(--line-strong); }
.tp-pick-row input[type=range]::-moz-range-progress { height: 6px; border-radius: var(--radius-full); background: var(--accent); }
.tp-pick-row input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: var(--radius-full); background: var(--accent);
  border: 2px solid var(--on-accent); }
.tp-pick-row input[type=number] { width: 84px; flex: none; }
.tp-pick .help { margin: var(--space-2) 0 0; }

/* Sidebar: the shared term list and the master prompts, under Books */
.tp-nav a.tp-nav-sub { height: 32px; padding-inline-start: 22px; font-size: 0.875rem; }
.tp-nav a.tp-nav-sub .tp-icon { width: 16px; height: 16px; }
@media (max-width: 860px) { .tp-nav a.tp-nav-sub { height: auto; padding-inline-start: 10px; font-size: inherit; } }

/* A book's page: what must be ready before the first AI pass */
.tp-ready ol { margin: var(--space-2) 0 0; padding-inline-start: 20px; display: grid; gap: var(--space-2); }
.tp-ready li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.tp-ready-what { font-weight: 600; min-width: 170px; }
.tp-ready .help { margin: var(--space-3) 0 0; }
.tp-book-cell { min-width: 240px; }

/* Terms: assigning the term check, and the checker's own card */
.tp-assign { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-2) 0 0; }
.tp-assign select { width: auto; max-width: 240px; }
.tp-assign input[type=date] { width: auto; }
.tp-termcheck { border-inline-start: 4px solid var(--accent); }
.tp-termcheck p { margin: var(--space-2) 0 0; }

/* Word comparison: a Word upload beside the platform's text */
.tp-cmp td { font-size: 13px; line-height: 19px; }
.tp-cmp .tp-cmp-w, .tp-cmp .tp-cmp-p { width: 40%; white-space: pre-wrap; overflow-wrap: anywhere; }
.tp-cmp .tp-cmp-pg { width: 3.5rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.tp-cmp td.tp-cmp-note { color: var(--ink-muted); font-size: 12px; line-height: 17px; width: 16%; }
.tp-cmp tr.k-extra .tp-cmp-p { background: var(--good-soft); color: var(--good-ink); }
.tp-cmp tr.k-fig .tp-cmp-p { background: var(--info-soft); color: var(--info-ink); }
.tp-cmp tr.k-toc .tp-cmp-w { background: var(--neutral-soft); color: var(--ink-muted); }
.tp-cmp tr.k-bad .tp-cmp-w, .tp-cmp tr.k-miss .tp-cmp-w { background: var(--bad-soft); }
.tp-cmp details summary { cursor: pointer; }
mark.tp-cmp-miss { background: var(--bad-soft); color: var(--bad-ink); font-weight: 600; border-radius: 3px; }
mark.tp-cmp-extra { background: var(--good-soft); color: var(--good-ink); border-radius: 3px; }
mark.tp-cmp-num { background: none; color: var(--ink-muted); font-style: italic; }
.tp-cmp-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: 12px; color: var(--ink-muted); margin: var(--space-3) 0; }
.tp-cmp-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; border: 1px solid var(--line); }
.tp-cmp-key.k-bad { background: var(--bad-soft); } .tp-cmp-key.k-extra { background: var(--good-soft); }
.tp-cmp-key.k-fig { background: var(--info-soft); } .tp-cmp-key.k-toc { background: var(--neutral-soft); }
.tp-cmp-filters { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; font-size: 13px; margin-bottom: var(--space-3); }
@media (max-width: 720px) { .tp-cmp .tp-cmp-note { display: none; } .tp-cmp .tp-cmp-w, .tp-cmp .tp-cmp-p { width: 45%; } }
