/* Line of Best Fit with Error Bars: only what ft-tool-20261106.css doesn't cover —
   the three-panel layout with a result line that stays in view on phones, a spreadsheet-like data grid,
   column settings, chart frames sized like ft-plot's mountPlot, and the method comparison table.
   Colours and sizes come from the shell tokens. */

/* Layout. In the page the order is data, results, column settings, so a phone shows the result right after
   the table. From 56rem the results sit beside both other panels and stay in view while they scroll. */
.lf-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ft-space-4); align-items: start; }
.lf-top > * { min-width: 0; }
@media (min-width: 56rem) {
  .lf-top { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); grid-template-areas: "data results" "cols results"; }
  .lf-data { grid-area: data; }
  .lf-cols { grid-area: cols; }
  /* Sticky by its top when it fits the window, by its bottom when it is taller (the script sets --lf-results-h). */
  .lf-results { grid-area: results; position: sticky; top: min(var(--ft-space-4), calc(100vh - var(--lf-results-h, 0px) - var(--ft-space-4))); }
}

/* One line with the slope, in view on phones wherever the visitor is in the tool. */
.lf-summary { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: var(--ft-space-3); box-sizing: border-box; min-height: var(--ft-target); margin: 0 0 var(--ft-space-3); padding: 0.35rem var(--ft-space-3); border: 1px solid var(--ft-line-strong); border-radius: var(--ft-radius); background: var(--ft-surface-2); color: var(--ft-ink); font-size: var(--ft-text-sm); text-decoration: none; box-shadow: var(--ft-shadow, none); }
.lf-summary:focus-visible { outline: 3px solid var(--ft-focus); outline-offset: 2px; }
.lf-summary__value { flex: 0 1 auto; min-width: 0; overflow: hidden; font-weight: 700; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.lf-summary__method { flex: 1 1 0%; min-width: 0; overflow: hidden; color: var(--ft-ink-2); text-overflow: ellipsis; white-space: nowrap; }
.lf-summary__go { flex: none; margin-left: auto; color: var(--ft-link); font-weight: 600; text-decoration: underline; text-underline-offset: 0.2em; white-space: nowrap; }
@media (min-width: 56rem) { .lf-summary { display: none; } }
@media (max-width: 26rem) { .lf-summary__method { display: none; } }   /* on a phone the slope gets the room */
@media (max-width: 55.99rem) { :root { scroll-padding-top: 3.75rem; } }
#lf-results-title { scroll-margin-top: 4rem; }

/* Three quiet buttons in the data panel's head stay on one row on a phone */
.lf-data .ft-panel__head .ft-btnrow { gap: 0 var(--ft-space-1); }
.lf-data .ft-panel__head .ft-btn--quiet { padding-inline: 0.5rem; }

/* Notes in the data panel */
.lf-banner:empty, .lf-notes:empty, #lf-link-note:empty { display: none; }
.lf-banner .ft-note, .lf-notes .ft-note, .lf-decimal { margin: 0; }
.lf-note__actions { margin-top: var(--ft-space-2); }
.lf-decimal__field { max-width: 20rem; margin-top: var(--ft-space-2); }
.lf-roles { display: grid; gap: var(--ft-space-3); padding: var(--ft-space-3) var(--ft-space-4); border: 1px solid var(--ft-line-strong); border-radius: var(--ft-radius); background: var(--ft-accent-soft); }
.lf-roles__title { margin: 0; color: var(--ft-ink); font-size: var(--ft-text-sm); font-weight: 700; }
.lf-roles__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); gap: var(--ft-space-3); }
.lf-roles .ft-label__opt { display: block; overflow: hidden; color: var(--ft-ink-2); font-size: var(--ft-text-xs); font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.ft-btn.lf-inline-btn { min-height: 0; padding: 0.15rem 0.35rem; font-size: inherit; }

/* Data grid */
.lf-gridwrap { max-height: 24.5rem; overflow: auto; border: 1px solid var(--ft-line-strong); border-radius: var(--ft-radius); background: var(--ft-surface); }
@media (max-width: 40rem) { .lf-gridwrap { max-height: 21rem; } }
.lf-grid { width: 100%; min-width: calc(var(--lf-cols, 2) * 4.6rem + 2.4rem); border-collapse: separate; border-spacing: 0; color: var(--ft-ink); font-size: var(--ft-text-sm); table-layout: fixed; }
.lf-grid thead th { position: sticky; top: 0; z-index: 1; padding: 0.4rem 0.5rem; overflow: hidden; border-bottom: 1px solid var(--ft-line-strong); background: var(--ft-surface-2); color: var(--ft-ink); font-weight: 650; text-align: left; vertical-align: bottom; }
.lf-grid__name, .lf-grid__as { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-grid__as { color: var(--ft-ink-2); font-size: var(--ft-text-xs); font-weight: 400; }
.lf-grid thead th + th, .lf-grid td { border-left: 1px solid var(--ft-line-strong); }
.lf-grid .lf-grid__n { width: 2.4rem; padding: 0 0.45rem; border-bottom: 1px solid var(--ft-line); color: var(--ft-ink-3); font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.lf-grid thead .lf-grid__n { padding-bottom: 0.4rem; border-bottom-color: var(--ft-line-strong); color: var(--ft-ink-2); }
.lf-grid td { padding: 0; border-bottom: 1px solid var(--ft-line); }
.lf-grid tbody tr:last-child > * { border-bottom: 0; }
.lf-cell { box-sizing: border-box; display: block; width: 100%; min-width: 0; min-height: var(--ft-target); margin: 0; padding: 0.3rem 0.5rem; border: 0; border-radius: 0; background: transparent; color: var(--ft-ink); font: inherit; font-size: var(--ft-text-md); font-variant-numeric: tabular-nums; }
.lf-cell:hover { background: var(--ft-surface-2); }
.lf-cell:focus-visible { outline: 3px solid var(--ft-focus); outline-offset: -3px; background: var(--ft-accent-soft); }
.lf-cell[aria-invalid="true"] { background: var(--ft-bad-soft); box-shadow: inset 0 0 0 2px var(--ft-bad); }
/* a value whose decimal mark was guessed (see the note under the table): underlined, and the note says why */
.lf-cell[data-mark="check"], .lf-cols .ft-input[data-mark="check"] { box-shadow: inset 0 -3px 0 var(--ft-warn); }
@media (pointer: fine) { .lf-cell { min-height: 2.25rem; } }
.lf-gridbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ft-space-2) var(--ft-space-3); }
.lf-count { margin: 0 0 0 auto; color: var(--ft-ink-2); font-size: var(--ft-text-sm); font-variant-numeric: tabular-nums; }
.ft-btn.lf-sign { display: none; }
@media (pointer: coarse) { .lf-keys { display: none; } }
@media (pointer: coarse) { .ft-btn.lf-sign { display: inline-flex; } }

/* Column settings: two fieldsets side by side when the panel is wide enough */
.lf-axes { container-type: inline-size; }
.lf-axes__grid { display: grid; gap: var(--ft-space-4); }
@container (min-width: 25rem) { .lf-axes__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lf-axis { display: grid; align-content: start; gap: var(--ft-space-3); min-width: 0; margin: 0; padding: var(--ft-space-2) var(--ft-space-4) var(--ft-space-4); border: 1px solid var(--ft-line); border-radius: var(--ft-radius); }
.lf-axis__legend { padding: 0 var(--ft-space-1); color: var(--ft-ink); font-size: var(--ft-text-sm); font-weight: 700; }
.lf-axis__pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--ft-space-2); }
.lf-options { display: flex; flex-wrap: wrap; gap: 0 var(--ft-space-5); }

/* Charts: the frame keeps mountPlot's size (aspect, min and max height) before the SVG arrives */
.lf-figure { margin: 0; }
.lf-plot-frame { position: relative; overflow: hidden; border: 1px solid var(--ft-line); border-radius: var(--ft-radius); background: var(--ft-plot-surface); }
.lf-plot { width: 100%; aspect-ratio: 100 / 62; min-height: 17.5rem; max-height: 30rem; }
.lf-plot--res { aspect-ratio: 2 / 1; min-height: 15rem; max-height: 23.75rem; }
.lf-plot > svg { display: block; width: 100%; height: auto; }
.lf-plot__empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: var(--ft-space-5); color: var(--ft-ink-2); font-size: var(--ft-text-sm); text-align: center; pointer-events: none; }
.lf-plot__empty > span { padding: var(--ft-space-2) var(--ft-space-3); border-radius: var(--ft-radius); background: var(--ft-plot-surface); }
.lf-swatch--marker { width: 0.75rem; height: 0.75rem; border-radius: 50%; }
.lf-swatch--line { width: 1.25rem; height: 0.1875rem; border-radius: 2px; }
.lf-swatch--dashed { width: 1.25rem; height: 0; border-top: 2px dashed var(--ft-swatch); border-radius: 0; background: none; }
.lf-readout { min-height: 2.9em; color: var(--ft-ink); font-variant-numeric: tabular-nums; }
.lf-exportbar { display: grid; gap: var(--ft-space-3); }
.lf-exports .ft-select { width: auto; }
.lf-graph-options { display: grid; gap: var(--ft-space-1) var(--ft-space-4); align-items: end; }
@media (min-width: 30rem) { .lf-graph-options { grid-template-columns: minmax(0, 1fr) auto; } }
.lf-table-hint { margin-top: var(--ft-space-2); }
/* W-06d: the table's title sits above its scrolling box, so it wraps on a phone instead of scrolling with the table */
.lf-table-cap { margin: 0 0 var(--ft-space-2); color: var(--ft-ink-2); font-size: var(--ft-text-sm); }
.lf-table td, .lf-table th { white-space: nowrap; }

/* Headline result and method choice */
.ft-tool .ft-stack { grid-template-columns: minmax(0, 1fr); }
.lf-method .ft-segmented__options { display: flex; }
@media (max-width: 40rem) {
  .lf-method .ft-segmented__options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lf-method .ft-segmented__option span { width: 100%; }
}
.lf-headline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ft-space-1) var(--ft-space-4); padding: var(--ft-space-3) var(--ft-space-4); border: 1px solid var(--ft-line); border-radius: var(--ft-radius); background: var(--ft-surface-2); }
.lf-headline__label { margin: 0; color: var(--ft-ink-2); font-size: var(--ft-text-xs); font-weight: 650; }
.lf-headline__value { margin: 0; color: var(--ft-ink); font-size: var(--ft-text-2xl); font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.lf-headline__value > span { white-space: nowrap; }
/* L-02: values of 13 or more figures wrap inside the card instead of widening the page */
.lf-headline__value > .lf-long { white-space: normal; overflow-wrap: anywhere; }
.lf-headline__value:has(> .lf-long) { font-size: var(--ft-text-lg); }
.lf-headline__unit { color: var(--ft-ink-2); font-size: var(--ft-text-sm); font-weight: 600; }
.lf-headline__pct { min-height: 1.45em; margin: 0; color: var(--ft-ink-2); font-size: var(--ft-text-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.lf-headline__note { grid-column: 1 / -1; margin: var(--ft-space-1) 0 0; color: var(--ft-ink-2); font-size: var(--ft-text-xs); line-height: 1.45; }
@media (max-width: 40rem) { .lf-headline__value { font-size: var(--ft-text-xl); } }
@media (max-width: 26rem) { .lf-headline { gap: var(--ft-space-1) var(--ft-space-3); padding: var(--ft-space-3); } .lf-headline__value { font-size: var(--ft-text-lg); } }
.lf-rule__fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: var(--ft-space-3); margin-bottom: var(--ft-space-2); }
.lf-rule .ft-hint + .ft-hint { margin-top: var(--ft-space-1); }

/* Comparison of the four methods */
.lf-compare th[scope="row"] { font-weight: 400; }
.lf-compare__name { font-weight: 650; }
.lf-compare .lf-compare__main > * { border-bottom: 0; padding-bottom: 0.15rem; }
.lf-compare td.lf-compare__note { padding-top: 0; color: var(--ft-ink-2); font-size: var(--ft-text-xs); line-height: 1.45; text-align: left; white-space: normal; }
.lf-compare tr.is-current > * { background: var(--ft-accent-soft); }
/* the shared table keeps numbers on one line; here value, ± and percentage may wrap as whole pieces so the table fits a phone */
.lf-compare td.lf-val.ft-num { white-space: normal; }
.lf-val > span { display: inline-block; white-space: nowrap; }
.lf-pct { color: var(--ft-ink-2); font-size: var(--ft-text-xs); }
@media (max-width: 40rem) {
  .lf-compare th, .lf-compare td { padding-left: 0.4rem; padding-right: 0.4rem; }
  .lf-compare thead th { white-space: normal; }
}
.lf-why { margin: var(--ft-space-3) 0 0; max-width: var(--ft-measure); color: var(--ft-ink); font-size: var(--ft-text-sm); }
.lf-why:empty { display: none; }
.lf-row2 .lf-exports { margin-top: var(--ft-space-3); }

/* Use the slope */
.lf-derived__value { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem); }
.lf-derived__value > span { white-space: nowrap; }
.lf-derived-all { display: grid; gap: var(--ft-space-1); margin: var(--ft-space-3) 0 0; padding: 0; list-style: none; color: var(--ft-ink-2); font-size: var(--ft-text-sm); }
.lf-derived-all:empty { display: none; }
.lf-derived-all__name { color: var(--ft-ink); font-weight: 600; }

/* Show the working */
.lf-work { display: grid; gap: var(--ft-space-2); }
.lf-work__intro { margin: 0 0 var(--ft-space-2); max-width: var(--ft-measure); color: var(--ft-ink-2); font-size: var(--ft-text-sm); }
.lf-work .ft-formula { margin: 0 0 var(--ft-space-3); font-size: 0.875rem; }
.lf-work .ft-disclosure__body > p:not(.ft-formula) { margin: 0; color: var(--ft-ink-2); font-size: var(--ft-text-sm); }
.lf-row2 { margin-top: var(--ft-space-4); }
.lf-working { margin-top: var(--ft-space-4); }

/* Help sections: tables as wide as the text beside them, not the whole page */
.lf-kept { max-width: var(--ft-measure); margin: var(--ft-space-4) 0 0; color: var(--ft-ink-2); }
.ft-prose .lf-helptable { width: fit-content; max-width: min(100%, var(--ft-measure)); }
.ft-prose .lf-helptable .ft-table { width: auto; min-width: min(100%, 22rem); }

@media print {
  .lf-summary, .lf-banner, .lf-roles, .lf-gridbar, .lf-sign, #lf-undo, .lf-exportbar, .lf-readout, .lf-cols, .lf-rule, #lf-grid-hint, .lf-table-hint, .lf-decimal__field { display: none !important; }
  .lf-top { display: block; }
  .lf-top > * + * { margin-top: 1rem; }
  .lf-results { position: static; }
  .lf-gridwrap { max-height: none; overflow: visible; }
  .lf-grid { min-width: 0; }
  /* the drawing was made for the screen's width: on paper its frame takes the drawing's own shape, whatever that was */
  .lf-plot, .lf-plot--res { aspect-ratio: auto; min-height: 0; max-height: none; }
  .lf-row2 .ft-switch { display: none; }
  .lf-cell { min-height: 0; padding: 0.15rem 0.4rem; font-size: 0.8rem; }
  .lf-swatch { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .lf-table, .lf-compare { font-size: 0.72rem; }
  .lf-table td, .lf-table th { padding: 0.15rem 0.3rem; }
}

/* Mobile form controls (16px to prevent iOS Safari zoom) and 44px primary buttons */
@media screen and (max-width: 640px), screen and (hover: none) and (pointer: coarse) {
  .ft-tool input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  .ft-tool select,
  .ft-tool textarea,
  .ft-tool .ft-input,
  .ft-tool .ft-select,
  .ft-tool .ft-textarea,
  .ft-tool .ft-inputgroup > .ft-select.ft-inputgroup__unit {
    font-size: max(16px, 1rem);
  }
  .ft-tool .ft-btn--primary {
    min-height: 44px;
  }
}
