/* Three processes on a DFA (.tp[data-tp]): tabs, the state diagram coloured at each step, the step panel, the pair tables and the editor.
   Site tokens only (the class tints are mixes of --accent, --accent-2, --warm, --muted and --ink with the background), so both themes follow.
   No sideways scroll of the page at 360 px: the pair tables are laid out to fit the presets, and a larger edited machine scrolls inside its own box. */
.tp { container-type:inline-size; margin-block:1.5rem; padding:1.2rem; border:1px solid var(--line); border-block-start:4px solid var(--accent-2); border-radius:var(--radius); background:var(--surface); color:var(--ink);
  --tp-c1:color-mix(in srgb, var(--accent) 30%, var(--surface-strong));
  --tp-c2:color-mix(in srgb, var(--accent-2) 34%, var(--surface-strong));
  --tp-c3:color-mix(in srgb, var(--warm) 36%, var(--surface-strong));
  --tp-c4:color-mix(in srgb, var(--muted) 26%, var(--surface-strong));
  --tp-c5:color-mix(in srgb, color-mix(in srgb, var(--accent) 50%, var(--warm)) 34%, var(--surface-strong));
  --tp-c6:color-mix(in srgb, color-mix(in srgb, var(--accent-2) 50%, var(--warm)) 38%, var(--surface-strong));
  --tp-c7:color-mix(in srgb, color-mix(in srgb, var(--accent) 50%, var(--accent-2)) 32%, var(--surface-strong));
  --tp-c8:color-mix(in srgb, var(--ink) 10%, var(--surface-strong));
  --tp-new:color-mix(in srgb, var(--accent) 42%, var(--surface-strong));
  --tp-old:color-mix(in srgb, var(--accent) 14%, var(--surface-strong)); }
.tp [hidden] { display:none !important; }
.tp .tp-bar { display:flex; flex-wrap:wrap; gap:.4rem .5rem; align-items:center; margin-block:.5rem; }
.tp label { display:inline-flex; flex-wrap:wrap; align-items:center; gap:.4rem; max-width:100%; font-weight:600; }
.tp select, .tp input[type="text"] { max-width:100%; min-width:0; min-height:44px; padding:.4rem; background:var(--bg); color:var(--ink); border:1px solid var(--line); border-radius:.4rem; font:inherit; }
.tp .tp-preset { text-overflow:ellipsis; }
.tp input[type="text"] { width:min(100%, 26rem); font-family:ui-monospace, monospace; }
.tp input[type="radio"], .tp input[type="checkbox"] { width:1.15rem; height:1.15rem; accent-color:var(--accent-2); }
.tp button { padding:.45rem .8rem; min-height:44px; background:var(--surface-strong); color:var(--ink); border:1px solid var(--line); border-radius:.4rem; cursor:pointer; font:inherit; }
.tp button:hover:not(:disabled) { border-color:var(--accent); }
.tp button[aria-pressed="true"], .tp [role="tab"][aria-selected="true"] { background:var(--accent); color:var(--on-accent, #fff); border-color:var(--accent); font-weight:700; }
.tp button:disabled { opacity:.45; cursor:default; }
.tp :is(input,select,button,.tp-side):focus-visible { outline:3px solid var(--accent-2); outline-offset:2px; }
.tp .tp-tabs { margin-block-start:0; }
.tp h4 { margin:1rem 0 .35rem; }
.tp .tp-side > h4:first-child { margin-block-start:0; }
.tp .tp-main { display:grid; grid-template-columns:minmax(0,1fr); gap:1rem; margin-block-start:.6rem; }
@container (min-width: 60rem) {
  .tp .tp-main { grid-template-columns:minmax(0,1.1fr) minmax(0,1fr); }
  .tp .tp-figbox { position:sticky; top:4.5rem; align-self:start; }
}
.tp .tp-figbox, .tp .tp-side { min-width:0; padding:.8rem; border:1px solid var(--line); border-radius:var(--radius-sm); background:var(--bg); }
.tp .tp-fig { position:relative; height:clamp(330px, 62cqi, 420px); }
.tp .tp-fig > svg { position:absolute; inset:0; width:100%; height:100%; overflow:visible; }

/* the diagram */
.tp svg text { font-family:KaTeX_Main, Georgia, "Times New Roman", serif; font-size:15px; fill:var(--ink); }
.tp svg .tp-sv-l, .tp svg .tp-elab { font-family:KaTeX_Math, Georgia, "Times New Roman", serif; font-style:italic; }
.tp svg .tp-sv-sub { font-size:11px; }
.tp svg .tp-elab { fill:var(--muted); paint-order:stroke; stroke:var(--bg); stroke-width:4px; stroke-linejoin:round; }
.tp svg .tp-elab.is-hit { fill:var(--warm); font-weight:700; }
.tp svg .tp-elab.is-dim { opacity:.45; }
.tp svg .tp-edge { fill:none; stroke:var(--muted); stroke-width:1.4; }
.tp svg .tp-edge.is-hit { stroke:var(--warm); stroke-width:3; }
.tp svg .tp-edge.is-dim { opacity:.35; }
.tp svg .tp-head { fill:var(--muted); }
.tp svg .tp-head.is-hit { fill:var(--warm); }
.tp svg .tp-head.is-dim { opacity:.35; }
.tp svg .tp-head.is-ink { fill:var(--ink); }
.tp svg .tp-start { stroke:var(--ink); stroke-width:1.6; }
.tp svg .tp-node rect { fill:var(--surface-strong); stroke:var(--ink); stroke-width:1.5; }
.tp svg .tp-node .tp-ring { fill:none; stroke-width:1.2; }
.tp svg .tp-node.is-new > rect:first-child { fill:var(--tp-new); stroke-width:2.6; }
.tp svg .tp-node.is-old > rect:first-child { fill:var(--tp-old); }
.tp svg .tp-node.is-sel > rect:first-child { fill:var(--tp-old); stroke:var(--accent); stroke-width:3; }
.tp svg .tp-node.is-end > rect:first-child { stroke:var(--warm); stroke-width:3.5; }
.tp svg .tp-node.is-out rect { stroke:var(--muted); stroke-dasharray:5 4; opacity:.75; }
.tp svg .tp-node.is-out text { fill:var(--muted); }
.tp svg .tp-node.tp-c1 > rect:first-child { fill:var(--tp-c1); } .tp svg .tp-node.tp-c2 > rect:first-child { fill:var(--tp-c2); }
.tp svg .tp-node.tp-c3 > rect:first-child { fill:var(--tp-c3); } .tp svg .tp-node.tp-c4 > rect:first-child { fill:var(--tp-c4); }
.tp svg .tp-node.tp-c5 > rect:first-child { fill:var(--tp-c5); } .tp svg .tp-node.tp-c6 > rect:first-child { fill:var(--tp-c6); }
.tp svg .tp-node.tp-c7 > rect:first-child { fill:var(--tp-c7); } .tp svg .tp-node.tp-c8 > rect:first-child { fill:var(--tp-c8); }

/* legend, colour tags and class chips */
.tp .tp-legend { display:flex; flex-wrap:wrap; gap:.3rem .9rem; margin-block-start:.4rem; font-size:.9rem; color:var(--muted); }
.tp .tp-sw { display:inline-block; width:.9rem; height:.9rem; margin-inline-end:.3rem; vertical-align:-.12rem; border:1px solid var(--ink); border-radius:.25rem; background:var(--surface-strong); }
.tp .tp-sw.is-new { background:var(--tp-new); } .tp .tp-sw.is-old { background:var(--tp-old); }
.tp .tp-sw.is-hit { height:.2rem; border:none; border-radius:0; background:var(--warm); vertical-align:.2rem; }
.tp .tp-sw.is-out { border-style:dashed; border-color:var(--muted); }
.tp .tp-c1 { background:var(--tp-c1); } .tp .tp-c2 { background:var(--tp-c2); } .tp .tp-c3 { background:var(--tp-c3); } .tp .tp-c4 { background:var(--tp-c4); }
.tp .tp-c5 { background:var(--tp-c5); } .tp .tp-c6 { background:var(--tp-c6); } .tp .tp-c7 { background:var(--tp-c7); } .tp .tp-c8 { background:var(--tp-c8); }
.tp .tp-tag { display:inline-block; padding:0 .35rem; border-radius:.3rem; white-space:nowrap; color:var(--ink); unicode-bidi:isolate; direction:ltr; }
.tp .tp-cls { display:flex; flex-wrap:wrap; gap:.4rem; margin-block:.3rem .7rem; }
.tp .tp-cls > div { padding:.35rem .7rem; border-radius:.5rem; color:var(--ink); }

/* text: state names, words and sets stay left to right inside Hebrew sentences */
.tp .tp-s, .tp .tp-w, .tp .tp-f, .tp .tp-set { unicode-bidi:isolate; direction:ltr; white-space:nowrap; }
.tp .tp-s, .tp .tp-f { font-family:KaTeX_Main, Georgia, "Times New Roman", serif; }
.tp .tp-s i, .tp .tp-w, .tp .tp-formula i { font-family:KaTeX_Math, Georgia, "Times New Roman", serif; font-style:italic; }
.tp .tp-w { font-size:1.08em; }
.tp .tp-set { white-space:normal; }
.tp sub { font-size:.72em; }
.tp .tp-formula { margin:0 0 .6rem; padding:.45rem .7rem; border:1px solid var(--line); border-radius:.4rem; background:var(--surface-strong); font-family:KaTeX_Main, Georgia, "Times New Roman", serif; text-align:left; }
.tp .tp-formula > span { display:inline-block; white-space:nowrap; }
.tp .tp-msg, .tp .tp-note { margin:.45rem 0; }
.tp .tp-note { color:var(--muted); font-size:.92rem; }
.tp .tp-ok { color:var(--accent-2); font-weight:700; }
.tp .tp-err { font-weight:700; }
.tp .tp-new { font-weight:700; color:var(--accent); }
.tp .tp-sets { display:flex; flex-direction:column; gap:.3rem; margin:.6rem 0; padding:0; list-style:none; }
.tp .tp-sets li { padding:.3rem .6rem; border:1px solid var(--line); border-radius:.4rem; background:var(--surface-strong); text-align:left; }
.tp .tp-sets li.is-cur { border-color:var(--accent); background:var(--tp-old); }
.tp .tp-list { margin:.3rem 0 .6rem; padding-inline-start:1.3rem; }
.tp .tp-list li { margin-block:.25rem; }
.tp .tp-steps button { padding-inline:.6rem; }

/* the triangular tables of pairs: no card layout, compact cells; a machine larger than the presets scrolls inside the box */
.tp .tp-matwrap, .tp .tp-tablewrap { max-width:100%; overflow-x:auto; margin-block:.6rem; }
.tp .tp-mat { border-collapse:separate; border-spacing:2px; margin:0; }
.tp .tp-mat th { padding:.1rem .25rem; font-weight:400; font-size:.85rem; white-space:nowrap; text-align:center; }
.tp .tp-mat th[scope="row"] { text-align:end; }
.tp .tp-mat.is-long tr:first-child th { writing-mode:vertical-rl; transform:rotate(180deg); vertical-align:bottom; text-align:start; padding:.25rem .1rem; }
.tp .tp-mat td { padding:0; }
.tp .tp-mat .tp-cell { display:flex; align-items:center; justify-content:center; width:100%; min-width:2.1rem; min-height:2.3rem; padding:.1rem .2rem; border:1px solid var(--line); border-radius:.3rem; background:var(--surface-strong); font-size:.95rem; }
.tp .tp-mat button.tp-cell { background:var(--tp-old); }
.tp .tp-mat button.tp-cell.is-fresh { border:2px solid var(--accent); }
.tp .tp-mat button.tp-cell[aria-pressed="true"] { background:var(--accent); }
.tp .tp-mat button.tp-cell[aria-pressed="true"] .tp-w { color:var(--on-accent, #fff); }
.tp .tp-mat .tp-cell.is-open { color:var(--muted); background:var(--bg); }
.tp .tp-sig, .tp .tp-log, .tp .tp-edt { border-collapse:collapse; margin:0; }
.tp .tp-sig :is(th,td), .tp .tp-log :is(th,td), .tp .tp-edt :is(th,td) { padding:.25rem .45rem; border-bottom:1px solid var(--line); text-align:center; }
.tp .tp-sig th, .tp .tp-log th, .tp .tp-edt thead th { font-size:.88rem; font-weight:600; color:var(--muted); }
.tp .tp-sig tr.is-hot td { background:color-mix(in srgb, var(--accent) 10%, transparent); }
.tp .tp-log td:nth-child(2) { text-align:left; }
.tp .tp-edt select { min-height:38px; padding:.2rem; font-size:.9rem; }
.tp .tp-editor { margin-block-start:.6rem; }
.tp .tp-edtoggle { font-weight:600; }
.tp .tp-edtoggle::before { content:"▸"; display:inline-block; margin-inline-end:.4rem; }
.tp .tp-edtoggle[aria-expanded="true"]::before { transform:rotate(90deg); }
[dir="rtl"] .tp .tp-edtoggle:not([aria-expanded="true"])::before { transform:scaleX(-1); }
.tp .tp-ed { max-width:100%; overflow-x:auto; }
.tp .tp-wlabel { display:block; margin-block-end:.3rem; }

@media (max-width:30rem) {
  .tp { padding:.7rem; }
  .tp .tp-figbox, .tp .tp-side { padding:.55rem; }
  .tp .tp-mat .tp-cell { min-width:1.85rem; min-height:2.1rem; font-size:.88rem; }
  .tp .tp-mat th { font-size:.78rem; }
  .tp .tp-sig :is(th,td), .tp .tp-log :is(th,td), .tp .tp-edt :is(th,td) { padding:.2rem .25rem; }
  .tp button { padding:.4rem .6rem; }
}
@media print { .tp[data-tp] { display:none !important; } [data-tp-fallback] { display:block !important; } }
