/* Table Math Lab — implementation of the master's approved home mock-up (DESIGN_HANDOFF 2026-11-28), carried to
   every page. All values come from design-vars.css; media-query widths are literal (CSS variables are not allowed
   there). Class vocabulary is this site's own (tm-*), written for this theme only. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--layout-header-offset); }
body { margin: 0; background: var(--color-bg); color: var(--color-text); font-family: var(--font-sans); font-size: var(--fs-base); line-height: var(--lh-body); font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--font-heading); font-weight: var(--fw-heavy); color: var(--color-text); }
img, svg { max-width: 100%; height: auto; }
a { color: var(--color-text); }
a:hover { color: var(--color-accent); }
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.tm-wrap { max-width: var(--layout-max); margin: 0 auto; padding-left: var(--space-gutter); padding-right: var(--space-gutter); }
.tm-skip { position: absolute; left: -999px; top: 0; background: var(--color-accent); color: var(--color-accent-ink); padding: var(--space-3) var(--space-4); z-index: 50; }
.tm-skip:focus { left: var(--space-3); top: var(--space-3); }
.tm-label { font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-label); color: var(--color-accent); text-transform: uppercase; }

/* ---------- tap targets: every stand-alone link at least 44 px tall (handoff rule 6) ---------- */
.tm-brand, .tm-more, .tm-crumbs a, .tm-ad a, .tm-band-acts a.tm-plain { display: inline-flex; align-items: center; min-height: var(--layout-tap); }

/* ---------- buttons (pill) ---------- */
.tm-cta { display: inline-block; background: var(--color-accent); color: var(--color-accent-ink); font-weight: var(--fw-bold); font-size: var(--fs-base); line-height: 20px; padding: 15px 26px; border-radius: var(--radius-pill); text-decoration: none; min-height: var(--layout-tap); }
.tm-cta:hover { filter: brightness(1.1); color: var(--color-accent-ink); }
.tm-cta-sm { font-size: var(--fs-sm); padding: 12px 18px; }
.tm-ghost { display: inline-block; border: 1px solid var(--color-text-muted); color: var(--color-text); font-weight: var(--fw-semibold); font-size: var(--fs-sm); line-height: 18px; padding: 13px 16px; border-radius: var(--radius-pill); text-decoration: none; min-height: var(--layout-tap); }
.tm-ghost:hover { border-color: var(--color-accent); }

/* ---------- header ---------- */
.tm-top { background: var(--color-chrome); border-bottom: 1px solid var(--color-hairline); position: relative; z-index: 30; }
.tm-top-a { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-7); padding-top: 16px; }
.tm-top-b { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1) var(--space-7); padding-top: var(--space-2); padding-bottom: var(--space-2); }
.tm-brand { display: flex; align-items: center; gap: var(--space-3); font-weight: var(--fw-heavy); font-size: var(--fs-3xl); line-height: 26px; color: var(--color-text); text-decoration: none; }
.tm-brand-dot { width: 10px; height: 10px; background: var(--color-accent); display: inline-block; border-radius: var(--radius-pill); }
.tm-unoff { font-size: var(--fs-xs); line-height: 18px; color: var(--color-text-muted); }
.tm-nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-1) 30px; font-size: var(--fs-md); }
.tm-nav-item { position: relative; }
.tm-nav-open, .tm-nav-plain > a { display: inline-block; padding: 12px 0; color: var(--color-text-muted); background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none; min-height: var(--layout-tap); }
.tm-nav-open:hover, .tm-nav-plain > a:hover, .tm-nav-item.is-open .tm-nav-open { color: var(--color-accent); }
.tm-nav-open::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: var(--space-3); border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-3px) rotate(45deg); }
.tm-nav-sub { display: none; list-style: none; margin: 0; padding: var(--space-3); position: absolute; left: 0; top: 100%; min-width: 250px; background: var(--color-panel); border: 1px solid var(--color-hairline); box-shadow: var(--shadow-menu); z-index: 40; }
.tm-nav-item.is-open .tm-nav-sub, .tm-nav-item:focus-within .tm-nav-sub { display: block; }
@media (hover: hover) and (min-width: 721px) { .tm-nav-item:hover .tm-nav-sub { display: block; } }
.tm-nav-sub a { display: block; padding: var(--space-3) var(--space-4); color: var(--color-text); text-decoration: none; font-size: var(--fs-md); }
.tm-nav-sub a:hover, .tm-nav-sub a[aria-current] { background: var(--color-panel-2); color: var(--color-accent); }
.tm-menu-btn { display: none; }
@media (max-width: 720px) {
  .tm-menu-btn { display: inline-flex; align-items: center; gap: var(--space-3); background: none; border: 1px solid var(--color-hairline); color: var(--color-text); font: inherit; font-size: var(--fs-sm); padding: var(--space-3) var(--space-4); border-radius: var(--radius-pill); min-height: var(--layout-tap); cursor: pointer; }
  .tm-menu-bars, .tm-menu-bars::before, .tm-menu-bars::after { display: block; width: 16px; height: 2px; background: currentColor; position: relative; }
  .tm-menu-bars::before, .tm-menu-bars::after { content: ""; position: absolute; left: 0; }
  .tm-menu-bars::before { top: -5px; } .tm-menu-bars::after { top: 5px; }
  .tm-nav { display: none; width: 100%; order: 3; }
  .tm-nav.is-open { display: block; }
  .tm-nav-list { flex-direction: column; gap: 0; }
  .tm-nav-sub { position: static; display: block; box-shadow: none; border: 0; background: none; padding: 0 0 var(--space-3) var(--space-4); }
  .tm-nav-open::after { display: none; }
}

/* ---------- AD DISCLOSURE bar ---------- */
.tm-ad-wrap { padding-top: var(--space-4); }
.tm-ad { border: 1px solid var(--color-hairline); background: var(--color-panel); padding: var(--space-3) var(--space-4); display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2) var(--space-4); font-size: var(--fs-xs); line-height: 19px; color: var(--color-text-muted); }
.tm-ad-label { font-weight: var(--fw-bold); letter-spacing: var(--ls-label); color: var(--color-accent); }
.tm-ad-text { flex: 1 1 420px; }
.tm-ad a { color: var(--color-text); text-decoration: underline; padding: var(--space-2) 0; }

/* ---------- home hero (owner picture, gradient from the right) ---------- */
.tm-hero-photo { margin-top: 20px; background-color: var(--color-bg); background-image: linear-gradient(270deg, var(--color-bg) 0%, var(--color-hero-fade) 36%, var(--color-hero-fade-mid) 66%, var(--color-hero-clear) 100%), var(--tm-hero-img); background-size: cover; background-position: left center; }
.tm-hero-photo-in { padding-top: var(--space-11); padding-bottom: 92px; display: flex; flex-wrap: wrap; gap: var(--space-7) var(--space-8); align-items: center; justify-content: flex-end; }
.tm-hero-copy { flex: 1 1 420px; max-width: 560px; display: flex; flex-direction: column; gap: 20px; }
.tm-hero-copy h1 { margin: 0; font-size: var(--fs-display); line-height: var(--lh-display); }
.tm-hero-sub { margin: 0; font-size: var(--fs-xl); line-height: 29px; color: var(--color-text-body); }
.tm-hero-acts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4) 20px; }
.tm-risk { margin: 0; font-size: var(--fs-xs); line-height: 19px; color: var(--color-text-muted); }
@media (max-width: 720px) {
  /* Mobile (master review 2026-11-28 06:15, handoff rule 9): the owner's hero picture as a visible top band
     (~200 px), cropped by position only, fading into the page colour; the copy sits below it on plain background. */
  .tm-hero-photo { background-image: none; }
  .tm-hero-photo::before { content: ""; display: block; height: 200px; background-color: var(--color-bg); background-image: linear-gradient(180deg, var(--color-hero-clear) 60%, var(--color-hero-fade) 92%, var(--color-bg) 100%), var(--tm-hero-img); background-size: cover, auto 360px; background-position: center, 2% 76%; background-repeat: no-repeat; }
  .tm-hero-photo-in { padding-top: var(--space-4); padding-bottom: var(--space-9); }
}

/* ---------- lesson module (steps + dice chart) ---------- */
.tm-lesson { padding-top: var(--space-10); }
.tm-lesson-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: var(--space-7) 56px; align-items: start; }
.tm-lesson-copy { display: flex; flex-direction: column; gap: 16px; }
.tm-lesson-copy h2 { margin: 0; font-size: var(--fs-h2); line-height: var(--lh-heading); }
.tm-steps { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--color-hairline); }
.tm-steps li { display: flex; gap: 16px; padding: var(--space-4) 0; border-bottom: 1px solid var(--color-hairline); }
.tm-step-n { font-weight: var(--fw-heavy); font-size: var(--fs-3xl); color: var(--color-accent); width: 28px; flex: none; }
.tm-step-t { display: flex; flex-direction: column; gap: 2px; }
.tm-step-t b { font-weight: var(--fw-semibold); color: var(--color-text); }
.tm-step-t span { font-size: var(--fs-md); color: var(--color-text-muted); }
.tm-panel { background: var(--color-panel); border: 1px solid var(--color-hairline); padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); }
.tm-panel h3 { margin: 0; font-size: var(--fs-lg); line-height: var(--lh-card); }
.tm-panel p { margin: 0; font-size: var(--fs-md); line-height: var(--lh-copy); color: var(--color-text-body); }
.tm-dice-chart { display: flex; align-items: flex-end; gap: var(--space-2); height: 150px; list-style: none; margin: 0; padding: 0; }
.tm-dice-chart li { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); flex: 1 1 0; min-width: 0; }
.tm-dice-bar { display: block; width: 100%; background: var(--color-bar); }
.tm-dice-bar.is-top { background: var(--color-accent); }
.tm-dice-total { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--color-text); }
.tm-dice-ways { font-size: var(--fs-3xs); color: var(--color-text-muted); }

/* ---------- Stake offer bar ---------- */
.tm-offer-wrap { padding-top: 20px; }
.tm-offer { background: var(--color-panel); border: 1px solid var(--color-accent); border-radius: var(--radius-offer); padding: var(--space-5) 22px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px var(--space-7); }
.tm-offer-copy { display: flex; flex-direction: column; gap: var(--space-1); max-width: 640px; }
.tm-offer-title { font-weight: var(--fw-heavy); font-size: var(--fs-2xl); line-height: 26px; color: var(--color-text); }
.tm-offer-note { font-size: var(--fs-sm); line-height: 21px; color: var(--color-text-muted); }
.tm-code { font-family: var(--font-mono); color: var(--color-text); border: 1px dashed var(--color-text-muted); padding: 1px var(--space-2); }

/* ---------- lessons: picture tiles + full list ---------- */
.tm-lessons { padding-top: var(--space-10); }
.tm-lessons > h2 { margin: 0 0 var(--space-6); font-size: var(--fs-h2-sm); line-height: var(--lh-heading); }
.tm-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 28px var(--space-7); }
@media (min-width: 721px) { .tm-tile-wide { grid-column: span 2; } }
.tm-tile { display: flex; flex-direction: column; gap: 12px; color: var(--color-text); text-decoration: none; min-width: 0; }
.tm-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; border: 1px solid var(--color-hairline); border-radius: var(--radius-photo); }
.tm-tile-wide img { aspect-ratio: 16 / 8; }
.tm-tile h3 { margin: 0; font-size: var(--fs-h3); line-height: var(--lh-card); }
.tm-tile:hover h3 { color: var(--color-accent); }
.tm-tile p { margin: 0; font-size: var(--fs-md); line-height: var(--lh-copy); color: var(--color-text-muted); }
.tm-more { color: var(--color-accent); font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.tm-shelf { margin-top: var(--space-8); }
.tm-shelf-h { margin: 0 0 var(--space-2); }
.tm-rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--color-hairline); }
.tm-row-link { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.6fr) auto; gap: 16px; align-items: baseline; padding: var(--space-4) var(--space-2); border-bottom: 1px solid var(--color-hairline); text-decoration: none; color: var(--color-text); min-height: var(--layout-tap); }
.tm-row-link:hover { background: var(--color-panel); }
.tm-row-name { font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.tm-row-link:hover .tm-row-name { color: var(--color-accent); }
.tm-row-what { color: var(--color-text-muted); font-size: var(--fs-md); }
.tm-row-fig { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--color-accent); white-space: nowrap; }
@media (max-width: 720px) { .tm-row-link { grid-template-columns: minmax(0, 1fr); gap: 2px; } }

/* ---------- closing Stake band (owner texture) ---------- */
.tm-band { margin-top: var(--space-10); border-top: 1px solid var(--color-hairline); border-bottom: 1px solid var(--color-hairline); background-color: var(--color-bg); background-image: linear-gradient(var(--color-band-veil), var(--color-band-veil)), var(--tm-band-img); background-size: cover; background-position: center; }
.tm-band-in { padding-top: var(--space-9); padding-bottom: var(--space-9); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-6) var(--space-8); }
.tm-band-copy { max-width: 640px; display: flex; flex-direction: column; gap: 12px; }
.tm-band-copy h2 { margin: 0; font-size: var(--fs-h2); line-height: var(--lh-heading); }
.tm-band-copy p { margin: 0; line-height: var(--lh-copy); color: var(--color-text-body); }
.tm-band-acts { display: flex; flex-direction: column; gap: var(--space-3); align-items: flex-start; }
.tm-band-acts a.tm-plain { color: var(--color-text); text-decoration: underline; font-size: var(--fs-sm); padding: var(--space-3) 0; }

/* ---------- footer ---------- */
.tm-base { background: var(--color-chrome); }
.tm-base-in { padding-top: 36px; padding-bottom: var(--space-8); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px var(--space-8); font-size: var(--fs-sm); line-height: 22px; color: var(--color-text-muted); }
.tm-base-in p { margin: 0; max-width: 600px; }
.tm-base-nav { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-6); }
.tm-base-nav a { padding: 12px 0; color: var(--color-text-muted); text-decoration: none; display: inline-block; min-height: var(--layout-tap); }
.tm-base-nav a:hover { color: var(--color-accent); }

/* ---------- inner pages ---------- */
.tm-head { padding-top: var(--space-8); }
.tm-head-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
.tm-head-grid.has-photo { grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); align-items: end; }
.tm-head h1 { margin: var(--space-3) 0 0; font-size: var(--fs-h1); line-height: var(--lh-heading); max-width: 22ch; }
.tm-head-photo { margin: 0; }
.tm-head-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; border: 1px solid var(--color-hairline); border-radius: var(--radius-photo); }
.tm-crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); font-size: var(--fs-sm); color: var(--color-text-muted); }
.tm-crumbs li + li::before { content: "/"; margin-right: var(--space-2); color: var(--color-hairline); }
.tm-crumbs a { color: var(--color-text-muted); }
.tm-stamp { margin: var(--space-3) 0 0; font-size: var(--fs-xs); color: var(--color-text-muted); }
@media (max-width: 720px) { .tm-head-grid.has-photo { grid-template-columns: minmax(0, 1fr); } }
.tm-layout { display: grid; grid-template-columns: minmax(0, 1fr) var(--layout-side); gap: var(--space-8); align-items: start; padding-top: var(--space-8); }
.tm-layout-one { grid-template-columns: minmax(0, var(--layout-measure)); }
.tm-article { grid-column: 1; grid-row: 1; min-width: 0; }
.tm-article > p, .tm-article > ul, .tm-article > ol, .tm-article > h2, .tm-article > h3 { max-width: var(--layout-measure); }
.tm-side { grid-column: 2; grid-row: 1; position: sticky; top: var(--space-6); font-size: var(--fs-md); }
.tm-toc, .tm-sibs { border-top: 1px solid var(--color-hairline); padding-top: var(--space-4); margin-bottom: var(--space-7); }
.tm-toc-h { margin: 0 0 var(--space-3); }
.tm-toc ol, .tm-sibs ul { margin: 0; padding: 0; list-style: none; }
.tm-toc li, .tm-sibs li { margin: 0; border-bottom: 1px solid var(--color-hairline); }
.tm-toc a, .tm-sibs a { display: block; padding: var(--space-3) 0; color: var(--color-text-muted); text-decoration: none; }
.tm-toc a:hover, .tm-sibs a:hover { color: var(--color-accent); }
@media (max-width: 960px) {
  .tm-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
  .tm-side { position: static; grid-column: 1; grid-row: 1; }
  .tm-article { grid-row: 2; }
  .tm-sibs { display: none; }
  .tm-toc ol { columns: 2; column-gap: var(--space-6); }
}
@media (max-width: 480px) { .tm-toc ol { columns: 1; } }

/* ---------- article typography ---------- */
.tm-article { color: var(--color-text-body); }
.tm-article h2 { font-size: var(--fs-h2-sm); line-height: var(--lh-heading); margin: var(--space-10) 0 var(--space-4); }
.tm-article > h2:first-child { margin-top: 0; }
.tm-article h3 { font-size: var(--fs-2xl); line-height: var(--lh-card); margin: var(--space-7) 0 var(--space-3); }
.tm-article p, .tm-article ul, .tm-article ol { margin: 0 0 var(--space-5); }
.tm-article li { margin: var(--space-1) 0; }
.tm-article a { color: var(--color-accent); }
.tm-article strong { color: var(--color-text); }
.tm-lede { font-size: var(--fs-xl); line-height: 29px; color: var(--color-text); border-left: 3px solid var(--color-accent); padding-left: var(--space-5); }
.tm-key { background: var(--color-accent-soft); border-left: 3px solid var(--color-accent); padding: var(--space-4) var(--space-5); color: var(--color-text); font-weight: var(--fw-semibold); }
.tm-note { font-size: var(--fs-md); color: var(--color-text-muted); background: var(--color-panel); border: 1px solid var(--color-hairline); padding: var(--space-3) var(--space-4); }
.tm-formula { font-family: var(--font-mono); font-size: var(--fs-md); line-height: var(--lh-copy); color: var(--color-text); background: var(--color-panel); border: 1px solid var(--color-hairline); border-left: 3px solid var(--color-accent); padding: var(--space-4); margin: 0 0 var(--space-5); white-space: pre-wrap; overflow-x: auto; }
.tm-worked { border: 1px solid var(--color-hairline); border-top: 3px solid var(--color-accent); background: var(--color-panel); padding: var(--space-1) var(--space-6) var(--space-3); margin: var(--space-7) 0; }
.tm-worked h3 { margin-top: var(--space-5); }
.tm-fig { margin: var(--space-7) 0; }
.tm-fig svg { display: block; width: 100%; height: auto; background: var(--color-panel); border: 1px solid var(--color-hairline); }
.tm-fig figcaption { font-size: var(--fs-sm); color: var(--color-text-muted); margin-top: var(--space-3); }
.tm-card { display: inline-block; font-weight: var(--fw-bold); padding: 0 var(--space-2); border-radius: var(--radius-photo); background: var(--color-card-face); color: var(--color-card-ink); line-height: 1.45; white-space: nowrap; }
.tm-card.tm-red { color: var(--color-card-red); }

/* ---------- tables (scroll inside their own box) ---------- */
.tm-scroll { overflow-x: auto; margin: var(--space-5) 0 var(--space-6); border: 1px solid var(--color-hairline); background: var(--color-panel); }
.tm-table { border-collapse: collapse; width: 100%; font-size: var(--fs-md); color: var(--color-text-body); }
.tm-table caption { text-align: left; font-weight: var(--fw-bold); color: var(--color-text); padding: var(--space-3) var(--space-4); caption-side: top; border-bottom: 1px solid var(--color-hairline); }
.tm-table th, .tm-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-hairline); vertical-align: top; }
.tm-table thead th { text-align: left; font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-label); color: var(--color-text-muted); white-space: nowrap; }
.tm-table td { text-align: right; white-space: nowrap; }
.tm-table td:first-child, .tm-table th[scope="row"] { text-align: left; white-space: normal; }
.tm-table th[scope="row"] { font-weight: var(--fw-semibold); color: var(--color-text); }
.tm-table tbody tr:last-child td, .tm-table tbody tr:last-child th { border-bottom: 0; }
@media (max-width: 560px) {
  .tm-table { font-size: var(--fs-sm); }
  .tm-table th, .tm-table td { padding: var(--space-3); }
  .tm-table th[scope="row"] { min-width: 7.5em; }
  .tm-table caption { max-width: calc(100vw - 58px); position: sticky; left: 0; }
  .tm-table td { white-space: normal; min-width: 4.5em; }
  .tm-fig { overflow-x: auto; }
  .tm-fig svg { min-width: 480px; }
}

/* ---------- calculator panel (markup printed by the TML Tables plugin) ---------- */
.tm-lab { margin: var(--space-8) 0; background: var(--color-panel); border: 1px solid var(--color-hairline); border-top: 3px solid var(--color-accent); }
.tm-lab-bar { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--color-hairline); }
.tm-lab-bar h2.tm-lab-title { margin: 0; font-size: var(--fs-2xl); line-height: var(--lh-card); color: var(--color-text); }
.tm-lab-tag { margin-left: auto; font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--color-accent); }
.tm-lab-body { padding: var(--space-6); color: var(--color-text-body); }
.tm-lab-body noscript p { margin: 0; }
.tm-rig { display: grid; grid-template-columns: minmax(0, var(--layout-lab-controls)) minmax(0, 1fr); gap: var(--space-6); }
.tm-in { display: flex; flex-direction: column; gap: var(--space-4); }
.tm-out { min-width: 0; }
@media (max-width: 720px) { .tm-rig { grid-template-columns: minmax(0, 1fr); } .tm-lab-body, .tm-lab-bar { padding-left: var(--space-4); padding-right: var(--space-4); } }
.tm-field { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--color-text-muted); text-align: left; }
.tm-field input, .tm-field select, .tm-field textarea { font-family: var(--font-sans); font-size: 16px; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-hairline); border-radius: var(--radius-panel); background: var(--color-input); color: var(--color-text); width: 100%; min-width: 0; min-height: var(--layout-tap); }
.tm-field input[type="radio"], .tm-field input[type="checkbox"], .tm-set input[type="radio"], .tm-set input[type="checkbox"] { width: auto; flex: none; margin: 0; min-height: 0; accent-color: var(--color-accent); }
.tm-field:has(> input[type="radio"]), .tm-field:has(> input[type="checkbox"]) { flex-direction: row; justify-content: flex-start; align-items: center; gap: var(--space-3); font-weight: var(--fw-regular); color: var(--color-text-body); min-height: var(--layout-tap); }
.tm-field:has(> input[type="radio"]) > input, .tm-field:has(> input[type="checkbox"]) > input { order: -1; }
.tm-field:has(> input[type="radio"]) > span, .tm-field:has(> input[type="checkbox"]) > span { flex: 1; }
.tm-field input:focus, .tm-field select:focus { border-color: var(--color-accent); outline: 1px solid var(--color-accent); }
.tm-set { border: 1px solid var(--color-hairline); padding: var(--space-3) var(--space-4) var(--space-4); margin: 0; font-size: var(--fs-md); }
.tm-set legend { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--color-text-muted); padding: 0 var(--space-1); }
.tm-set label { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-1) 0; min-height: var(--layout-tap); }
.tm-btn { display: inline-block; font-family: var(--font-sans); font-weight: var(--fw-bold); font-size: var(--fs-sm); line-height: var(--lh-control); color: var(--color-accent-ink); background: var(--color-accent); border: 1px solid var(--color-accent); border-radius: var(--radius-pill); padding: 12px 18px; cursor: pointer; text-decoration: none; min-height: var(--layout-tap); }
.tm-btn:hover { filter: brightness(1.1); }
.tm-btn-quiet { background: transparent; color: var(--color-text); border-color: var(--color-text-muted); }
.tm-btn-quiet:hover { border-color: var(--color-accent); filter: none; }
.tm-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); margin: 0 0 var(--space-5); }
.tm-stats > div { background: var(--color-panel-2); border: 1px solid var(--color-hairline); padding: var(--space-3) var(--space-4); }
.tm-stats dt { font-size: var(--fs-xs); color: var(--color-text-muted); font-weight: var(--fw-semibold); }
.tm-stats dd { margin: 2px 0 0; font-size: var(--fs-3xl); font-weight: var(--fw-heavy); color: var(--color-text); }
.tm-plot { margin: var(--space-4) 0; }
.tm-plot svg { display: block; width: 100%; height: auto; }
.tm-err { color: var(--color-negative); font-weight: var(--fw-semibold); background: var(--color-negative-soft); padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); }
.tm-err:empty, .tm-note:empty, .tm-key:empty { display: none; }
.tm-out .tm-scroll { margin: var(--space-4) 0; }
@media (max-width: 560px) {
  .tm-plot { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tm-plot svg { min-width: 540px; }
}
