/* Chapter 3 — Repair roots: piles of permutations, the d = 7 obstruction, the sharp repair and the tails (v13). Apache-2.0. */
.rep-lab h4{font-size:17px;margin:4px 0 2px}
.rep-lab .ex-controls .seg-options{display:inline-flex;max-width:100%}
.rep-lab .ex-controls .rep-seg-grid .seg-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
.rep-sub{font-size:11px}
.rep-basis-top{grid-template-columns:minmax(0,1.3fr) minmax(0,1fr)}

/* Piles of permutation cards (eq. (16)) */
.rep-piles{display:grid;gap:10px;grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}
.rep-piles.rep-d4{grid-template-columns:repeat(auto-fit,minmax(215px,1fr))}
.rep-pile{border:1px solid var(--line);border-radius:8px;background:#fff;padding:8px 8px 6px;min-width:0}
.rep-pile.is-on{border-color:var(--wine);box-shadow:0 0 0 1px var(--wine) inset;background:var(--wine-tint)}
.rep-pile h4{font-size:15.5px;margin:0 0 4px;color:var(--wine)}
.rep-pile-table{border-collapse:collapse;width:100%;font-size:15px}
.rep-pile-table th,.rep-pile-table td{padding:3px 4px;border-bottom:1px solid var(--soft-line);vertical-align:middle;text-align:left}
.rep-pile-table thead th{font-size:13.5px;color:var(--muted);font-weight:400}
.rep-pile-table td.num,.rep-pile-table th.num{text-align:right;font-variant-numeric:tabular-nums;width:2.6em}
.rep-pile-table tbody th{width:2.4em;font-weight:400}
.rep-cards{list-style:none;margin:0;padding:0;display:flex;flex-wrap:wrap;gap:4px}
.rep-card{display:inline-flex;border:1px solid var(--line);border-radius:5px;background:#fff;padding:1px 5px;font-family:var(--mono);font-size:15px;line-height:1.35}
.rep-perm{display:inline-flex;align-items:center}
.rep-gap{display:inline-block;width:.75em;text-align:center;font-size:12px;color:var(--wine);font-weight:700}
.rep-gap.is-desc{width:1em}
.rep-letter{display:inline-block;min-width:.62em;text-align:center}
.rep-last{outline:1.5px solid var(--ochre);outline-offset:0;border-radius:3px;padding:0 1px;margin-left:1px}
.rep-none{color:var(--muted);font-size:14px}
.rep-pile-poly{margin:6px 0 0;font-size:15.5px}

/* Weights for d = 3 */
.rep-presets .btn{font-size:15px;min-height:44px}
.rep-plot{display:block;width:100%;max-width:340px;height:auto}
.rep-curve{fill:none;stroke:var(--wine);stroke-width:2.2}

/* Worpitzky bridge */
.rep-step{color:var(--wine);margin-top:10px!important}
.rep-terms td,.rep-terms th{white-space:nowrap}
.rep-terms tbody th{font-weight:700;text-align:center}
.rep-chips{list-style:none;margin:4px 0 8px;padding:0;display:flex;flex-wrap:wrap;gap:6px}
.rep-chip{display:inline-flex;flex-direction:column;align-items:center;gap:1px;border:1px solid var(--line);border-radius:7px;background:#fff;padding:4px 9px;font-size:16px;font-variant-numeric:tabular-nums;min-width:44px}
.rep-chip small{font-size:12.5px;color:var(--muted)}
.rep-chip.is-neg{border-color:var(--red);background:var(--red-tint);box-shadow:0 0 0 1px var(--red) inset}
.rep-chip.is-neg small{color:var(--red);font-weight:700}
.rep-chip.is-zero{border-style:dashed}
.rep-list-title{margin:4px 0 2px!important;font-size:15px;color:var(--muted)}
.rep-poly-list{margin:6px 0;padding-left:18px;display:flex;flex-direction:column;gap:4px;overflow-x:auto}

/* Obstruction */
.rep-eta .btn,.rep-signs .btn{min-height:44px;padding:4px 10px;font-size:15px;white-space:nowrap}
.rep-eta th,.rep-eta td{white-space:nowrap;padding:6px 6px}
.rep-eta tbody th{font-weight:700;text-align:center;min-width:2em}
.rep-eta-wrap{min-width:0;display:flex;flex-direction:column;gap:6px}
.rep-eta-wrap .ex-note{margin:0}
.rep-signs{width:auto}
.rep-signs th.rep-sign,.rep-signs td.rep-sign{text-align:center;padding:4px 2px;min-width:24px;font-family:var(--mono);font-size:16px}
.rep-sign.is-pos{color:var(--teal)}
.rep-sign.is-zero{color:var(--ochre);font-weight:700;background:var(--ochre-tint)}
.rep-sign.is-neg{color:#fff;background:var(--red);font-weight:700}
.rep-sign.is-none{background:var(--panel)}

/* Sharp repair: order diagram in the style of Figure 3 */
.rep-order{display:block;width:100%;max-width:440px;height:auto;margin:0 auto}
.rep-axis{stroke:#5f6a73;stroke-width:1.5}
.rep-mk-a1{fill:var(--wine);stroke:var(--wine);stroke-width:1.5}
.rep-mk-e{fill:none;stroke:var(--teal);stroke-width:2.5}
.rep-mk-other{fill:#fff;stroke:#7a838a;stroke-width:1.5}
.rep-lbl{font-size:15px;fill:var(--ink)}
.rep-brace{fill:none;stroke:var(--teal);stroke-width:1.5}
.rep-brace.is-bad{stroke:var(--red);stroke-dasharray:4 3}
.rep-brace-lbl{font-size:14px;fill:var(--muted)}
.rep-glyph,.ex-object svg.rep-glyph{display:inline-block;width:1.05em;height:1.05em;max-width:none;margin:0 2px 0 0;vertical-align:-.18em;overflow:visible}
.rep-legend>span{white-space:nowrap;margin-right:10px}
.rep-witness-line{border-top:1px dashed var(--line);padding-top:8px;margin-top:8px!important}

/* Tails */
.rep-tails td,.rep-tails th{white-space:nowrap}
.rep-tails tbody th{font-weight:400}
.rep-tail-name{display:inline-block;padding:1px 6px;border-radius:5px}
.rep-tail-name.is-sel{background:var(--wine);color:#fff}
.rep-end{display:inline-block;font-size:14px;color:var(--muted);padding:0 4px}
.rep-sign-inline{font-size:14px;margin-left:4px}
.rep-muted{color:var(--muted);font-size:14.5px}
.rep-tails tr.rep-negrow .rep-weight{color:var(--red);font-weight:700}
.rep-run-wrap{min-width:0}
.rep-run{display:block;width:100%;max-width:452px;height:auto}
.rep-neg-lbl{fill:var(--red);font-weight:700}
.rep-lbl.rep-col-head{fill:var(--muted)}
/* a formula with its punctuation, or a sign verdict such as "> 0", never splits across lines */
.rep-nw,.rep-lab .ex-verdict-ok,.rep-lab .ex-verdict-bad{white-space:nowrap}
/* column names inside the cells: only phones show them (the card layout below) */
.rep-cell-label{display:none}
/* wide screens: the running total stays on one line (tag and value), the table scrolls sideways instead */
@media(min-width:641px){.rep-tails .approx-value{flex-wrap:nowrap}}
.rep-zero{stroke:#9aa3aa;stroke-width:1.2;stroke-dasharray:3 3}
.rep-step-pos{stroke:var(--teal);stroke-width:3}
.rep-step-neg{stroke:var(--red);stroke-width:3}
.rep-dot-pos{fill:var(--teal)}
.rep-dot-neg{fill:var(--red)}

.rep-eq-pair{display:flex;flex-wrap:wrap;gap:6px 36px;align-items:center;font-size:17px;padding:4px 0}
.rep-lab .ex-scroll{overflow-y:hidden}
.rep-lab .ex-controls .seg .btn{min-width:44px;padding:8px 11px}
.rep-weights-out{display:flex;flex-direction:column;gap:10px;min-width:0}
.rep-positions{font-size:14.5px;color:var(--muted);margin:4px 0 0}

@media(max-width:760px){
 /* Phones and narrow tablets: the controls first, then the chosen pile, then the result, then the other piles,
    so that a tap on "i = 3" shows pile 3 and its polynomial right below the control. */
 .rep-basis-top{display:flex;flex-direction:column;gap:12px}
 .rep-basis-top>.ex-object,.rep-basis-top>.ex-object>.rep-piles,.rep-basis-top>.ex-controls{display:contents}
 .rep-basis-top .seg{order:1}
 .rep-basis-top .rep-pile.is-on{order:2}
 .rep-basis-top #basis-result{order:3}
 .rep-basis-top .rep-pile{order:4}
}
/* Phones: wide tables become one card per row; each cell keeps its column name. A long formula (td.rep-full) takes the
   whole card width and wraps after its top-level − or +; short cells pair up two per line (dense fills the gaps). */
@media(max-width:640px){
 .rep-cardtable thead{display:none}
 .rep-cardtable,.rep-cardtable tbody{display:block;width:100%}
 .rep-cardtable tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-flow:row dense;gap:4px 10px;padding:8px 6px;border-bottom:1px solid var(--soft-line)}
 .rep-cardtable th,.rep-cardtable td{display:block;border:none;padding:0;white-space:normal;text-align:left!important;min-width:0;overflow-x:auto;overflow-y:hidden;padding-bottom:3px}
 .rep-cardtable tbody th{grid-column:1/-1}
 .rep-cardtable td.rep-wide,.rep-cardtable td.rep-full{grid-column:1/-1}
 .rep-cardtable .rep-cell-label{display:block;font-size:12.5px;line-height:1.5;color:var(--muted);font-weight:400}
}
@media(max-width:640px){
 .rep-piles,.rep-piles.rep-d4{grid-template-columns:minmax(0,1fr)}
 .rep-roomy{display:none}
 .rep-terms th,.rep-terms td{padding:5px 4px}
 .rep-terms thead th{white-space:normal;vertical-align:bottom}
 .rep-eta th,.rep-eta td{padding:5px 4px}
 .rep-chips-tight{gap:4px}
 .rep-chips-tight .rep-chip{padding:2px 6px;font-size:14.5px;min-width:40px}
 .rep-chips-tight .rep-chip small{font-size:12px}
 .rep-card{font-size:14.5px}
 .rep-chip{font-size:15px;padding:3px 7px}
 .rep-signs th.rep-sign,.rep-signs td.rep-sign{min-width:20px;font-size:15px;padding:4px 1px}
 .rep-lbl{font-size:16px}
}

/* Obstruction: the two lists right below the verdict panel */
.rep-lists{display:flex;flex-direction:column;gap:2px;margin-top:-6px;padding:0 2px}
.rep-lists .ex-note{margin:2px 0 0}
