/* Shared Setup and saved-fit workspace. Preserve the desktop arrangement;
   narrower browser viewports scroll the page horizontally. */
:root {
  --cf-ink: #17212c; --cf-muted: #465361; --cf-surface: #fff;
  --cf-base: #d9dee4; --cf-tint: #eef1f4; --cf-line: #a4afbb;
  --cf-blue: #155eb0; --cf-wash: #edf4fc; --cf-lock: #f2f5f8;
}
html, body { min-width: 1440px; font-weight: 500; background: var(--cf-base); color: var(--cf-ink); }
#wrap { width: calc(100% - 32px); max-width: 1600px; margin: 0 auto; background: transparent; }
#wrap *, #wrap *::before, #wrap *::after { box-sizing: border-box; }
#header { background: transparent; width: calc(100% - 32px); max-width: 1600px; margin: 0 auto; padding: 8px 0 9px; }
#header .cf-brand { display: flex; align-items: center; gap: 16px; color: inherit; text-decoration: none; }
#header .cf-wordmark { font-size: 26px; font-weight: 800; letter-spacing: -1px; color: var(--cf-blue); }
#header h1 { margin: 0; padding-left: 16px; border-left: 2px solid var(--cf-line); font-size: 23px; font-weight: 700; }
#cf-toolbar { display: flex; align-items: end; gap: 12px; min-width: 0; }
#cf-page-actions { display: flex; align-items: center; gap: 6px; padding-bottom: 5px; flex-shrink: 0; }
#cf-page-actions .buttonlink { float: none; margin: 0; display: flex; }
#cf-page-actions .feedback-cta { order: -1; }
#wrap #cf-page-actions .resetbutton { display: inline-flex; align-items: center; justify-content: center; height: 34px; min-height: 34px; margin: 0; padding: 4px 13px; border-color: #7d8997; color: var(--cf-ink); font-size: 13px; line-height: 20px; font-weight: 750; }
#cf-page-actions #walkthrough-open { width: auto; min-width: 118px; }
#wrap #cf-page-actions #feedback-open { color: white; background: var(--cf-blue); border-color: #10519a; }
#wrap .resetbutton, #wrap .sesbutton, #wrap .csvbutton, #wrap .addrembutton,
#wrap button, #wrap input[type=submit] { font-family: var(--cf-ui-font); font-size: 13px; font-weight: 600; border: 1.5px solid var(--cf-line); border-radius: 5px; background: var(--cf-surface); color: var(--cf-ink); padding: 6px 11px; box-shadow: none; text-shadow: none; cursor: pointer; }
#wrap button:hover:not(:disabled), #wrap .resetbutton:hover, #wrap .sesbutton:hover, #wrap .csvbutton:hover { background: var(--cf-wash); border-color: var(--cf-blue); }
#wrap button:disabled, #wrap input:disabled { cursor: default; }
#wrap [hidden] { display: none !important; }
#start { display: block; padding: 0; margin: 0; }
#cf-app-frame { display: grid; grid-template-columns: minmax(0,30fr) minmax(0,70fr); gap: 10px; padding: 8px; border: 2px solid #7d8997; background: #edf0f3; }
#cf-tabbar { flex: 1; min-width: 0; margin: 0; height: 42px; padding: 3px 0 0; gap: 4px; background: transparent; overflow-x: auto; }
#wrap .cf-tab { position: relative; display: inline-flex; align-items: baseline; gap: 4px; height: 39px; border-radius: 6px 6px 0 0; border-bottom: none; padding: 8px 14px; font-size: 14px; color: var(--cf-muted); background: var(--cf-base); font-weight: 700; }
#wrap .cf-tab-on { color: var(--cf-blue); background: var(--cf-surface); }
#wrap .cf-tab-setup.cf-tab-on, #wrap .cf-tab-setup.cf-tab-on:hover:not(:disabled) { color: #fff; background: var(--cf-blue); border-color: #10519a; }
#wrap .cf-tab-warn { color: #865316; }
#dataholder, #optionsholder { float: none; width: auto; height: auto; min-width: 0; padding: 0; border: 0; background: transparent; }
#dataholder { border: 1px solid var(--cf-line); border-radius: 7px; background: var(--cf-surface); overflow: hidden; min-height: 745px; text-align: left; }
#datatable, #cf-fit-data, .datatable { width: 100%; height: 742px; border: 0; font-size: 14px; }
#dataholder.cf-table-locked { background: var(--cf-tint); }
#dataholder.cf-table-locked #datatable { opacity: 1; filter: none; }
#dataholder .htCore td, #dataholder .htCore th { border-color: #ccc; color: var(--cf-ink); }
#dataholder .htCore td { height: 30px; padding: 3px 6px; text-align: center; }
#dataholder .htCore th { background: #ededed; height: 32px; font-weight: 650; }
#dataholder .htDimmed { background: #ededed; color: #666 !important; }
#dataholder .htCore td.cf-uncertainty-inactive { background: #ededed; color: #666; }
#dataholder .htCore th.cf-uncertainty-inactive { background: #e2e2e2; color: #666; }
#dataholder .htCore td.area { background: #d6e7ff; color: var(--cf-ink) !important; }
#dataholder .htCore th.cf-uncertainty-inactive.active { background: #c7dcf7; color: var(--cf-ink); }
#wrap .cf-plot-frame { position: relative; }
#cf-plotbar { position: absolute; z-index: 5; right: 9px; top: 8px; width: auto; height: auto; border: 0; background: transparent; }
#cf-plotbox .modebar { left: 45px; right: auto; top: 8px; }
#quickplot, #container, #cf-plotbox { width: 100%; height: 320px; float: none; background: var(--cf-surface); }
#quickplot, #cf-plotbox { border: 1px solid var(--cf-line); border-radius: 5px; }
#cf-fitview, #cf-prevview { width: 100%; min-height: 745px; float: none; }
#cf-prevview { border-color: var(--cf-line); border-radius: 7px; }
#wrap .cf-plot-mode { border: 1px solid var(--cf-line); border-radius: 5px; }
#wrap .cf-plot-mode button { border: 0; border-radius: 0; min-height: 27px; padding: 4px 10px; }
#wrap .cf-plot-mode button + button { border-left: 1px solid var(--cf-line); }
#wrap .cf-plot-mode-on { background: var(--cf-wash); color: var(--cf-blue); }
#wrap .cf-plot-caption { text-transform: none; letter-spacing: normal; font-weight: 400; }
#bottomholder, #cf-result.cf-controls { width: 100%; min-height: 415px; height: auto; margin: 10px 0 0; padding: 0; float: none; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.08fr) 174px; background: var(--cf-surface); border: 1px solid var(--cf-line); border-radius: 7px; }
#fittingleft, #fittingright { float: none; width: auto; height: auto; margin: 0; border: 0; }
#wrap .cf-settings { display: grid; grid-template-rows: minmax(153px,auto) 116px 144px; min-width: 0; }
#wrap .cf-control-section { padding: 8px 10px; border-bottom: 1px solid var(--cf-line); min-width: 0; }
#wrap .cf-control-section:last-child { border-bottom: 0; }
#wrap .cf-section-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
#wrap .cf-panel-head { padding: 7px 10px; height: 34px; min-height: 34px; border-bottom: 1px solid var(--cf-line); display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--cf-surface); }
#wrap .cf-panel-head h2, #wrap .cf-panel-head h3, #wrap .cf-control-section h3, #wrap .cf-evaluator h3 { font-size: 13px; line-height: 18px; letter-spacing: .7px; text-transform: uppercase; font-weight: 700; color: #263442; margin: 0; }
#wrap .cf-controls input[type=text], #wrap .cf-controls select, #wrap .cf-controls textarea { min-width: 0; width: 100%; margin: 0; min-height: 29px; height: auto; padding: 4px 7px; border: 1px solid var(--cf-line); border-radius: 4px; background: var(--cf-surface); color: var(--cf-ink); font-size: 13px; font-weight: 550; box-shadow: none; }
#wrap .cf-controls input:disabled, #wrap .cf-controls input[readonly], #wrap .cf-controls select:disabled { opacity: 1; background: var(--cf-lock); color: var(--cf-muted); }
#wrap .cf-controls select { font-family: var(--cf-ui-font); }
#wrap .funceqn { width: 100%; height: auto; min-height: 44px; padding-top: 8px; font-size: 21px; overflow-wrap: anywhere; }
#wrap .cf-settings > .cf-control-section:first-child { display: flex; flex-direction: column; }
#wrap .funceqn:not(.custom), #wrap .cf-settings .cf-res-eq { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px 0; min-height: 58px; }
#wrap .cf-static-math { display: inline-flex; align-items: center; max-width: 100%; }
#wrap .cf-static-math svg { display: block; max-width: 100%; height: auto; overflow: visible; }
#wrap #related_custom_contenteqn { padding-top: 8px; }
#wrap .cf-custom-tools { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; margin-bottom: 6px; }
#wrap .cf-custom-tools button { width: 32px; height: 32px; min-height: 32px; flex: 0 0 32px; padding: 0; font-size: 20px; line-height: 1; font-weight: 700; }
#wrap .cf-uncertainty-row { display: grid; grid-template-columns: 20px 174px minmax(0,1fr); align-items: center; gap: 6px; margin-top: 7px; }
#wrap .cf-math { font: italic 15px Georgia, serif; }
#wrap .toggle-btn-grp { margin: 0; display: flex; min-width: 0; border: 1px solid var(--cf-line); border-radius: 5px; overflow: hidden; }
#wrap .toggle-btn { position: relative; flex: 1; display: flex; justify-content: center; align-items: center; margin: 0; padding: 4px 2px; min-height: 27px; font-size: 12px; font-weight: 600; border: 0; border-radius: 0; background: var(--cf-surface); box-shadow: none; color: var(--cf-muted); white-space: nowrap; }
#wrap .toggle-btn + .toggle-btn { border-left: 1px solid var(--cf-line); }
#wrap .toggle-btn:has(input:checked), #wrap .toggle-btn.success { background: var(--cf-wash); color: var(--cf-blue); font-weight: 600; }
#wrap .toggle-btn input[type=radio] { display: block; position: absolute; opacity: 0; width: 100%; height: 100%; inset: 0; margin: 0; cursor: pointer; }
#wrap .toggle-btn:has(input:focus-visible) { outline: 2px solid var(--cf-blue); outline-offset: -2px; }
#wrap .cf-uncertainty-row .toggle-btn:last-child { flex: 1.65; }
#wrap .errorval { float: none; margin: 0; min-width: 0; }
#wrap .cf-label-row { display: grid; grid-template-columns: 24px minmax(0,1fr); align-items: center; gap: 7px; margin-top: 5px; font-size: 13px; font-weight: 600; }
#wrap .cf-axis-field { display: grid; grid-template-columns: minmax(0,1fr) 70px; align-items: center; gap: 6px; }
#wrap .cf-axis-field .toggle-btn { font-size: 12px; }
#wrap .cf-parameters { border-left: 1px solid var(--cf-line); min-width: 0; display: flex; flex-direction: column; }
#wrap .cf-parameter-models { min-height: 220px; }
#wrap .relatedcontent { height: auto; }
#wrap .cf-param-table { border-collapse: collapse; width: 100%; table-layout: fixed; }
#wrap .cf-param-table th { height: 34px; padding: 7px 5px; background: var(--cf-tint); color: var(--cf-muted); font-size: 12px; font-weight: 650; text-align: right; white-space: nowrap; }
#wrap .cf-param-table td { height: 36px; padding: 3px 4px; border-bottom: 1px solid #edf0f4; font: 500 12px var(--cf-mono-font); text-align: right; white-space: nowrap; }
#wrap .cf-param-table th:first-child, #wrap .cf-param-table td:first-child { text-align: left; padding-left: 10px; }
#wrap .cf-param-table td:first-child { font: italic 17px Georgia, serif; }
#wrap .cf-param-table th:nth-child(2) { text-align: left; }
#wrap .cf-param-table th:nth-child(3), #wrap .cf-param-table td:nth-child(3) { text-align: center; }
#wrap .cf-param-table th:nth-child(4), #wrap .cf-param-table td:nth-child(4) { border-left: 1px solid var(--cf-line); }
#wrap .cf-param-table th:nth-child(n+4), #wrap .cf-param-table td:nth-child(n+4) { padding-left: 8px; padding-right: 10px; }
#wrap .cf-param-table td:last-child { color: var(--cf-muted); }
#wrap .cf-param-table input[type=text] { font-size: 12px; min-height: 27px; padding: 3px 5px; }
#wrap .cf-param-table input[type=checkbox] { width: 13px; height: 13px; margin: 0; accent-color: var(--cf-blue); }
#wrap .cf-empty-result { color: var(--cf-muted); }
#wrap .cf-evaluator { margin-top: auto; min-height: 112px; border-top: 1px solid var(--cf-line); padding: 8px 8px; background: var(--cf-tint); }
#wrap .cf-evaluator-placeholder, #wrap .cf-evaluator .cf-calc { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-top: 8px; align-items: end; }
#wrap .cf-evaluator-placeholder label, #wrap .cf-evaluator .cf-calc-field { min-width: 0; display: grid; grid-template-columns: 18px minmax(0,1fr); align-items: center; gap: 5px; }
#wrap .cf-evaluator-placeholder label { font: italic 14px Georgia, serif; }
#wrap .cf-evaluator-placeholder label:nth-child(3) { grid-column: 1; }
#wrap .cf-evaluator-placeholder button { padding: 4px 6px; }
#wrap .cf-result-actions { border-left: 1px solid var(--cf-line); display: grid; grid-template-rows: 34px minmax(84px,auto) minmax(102px,auto) 156px; background: var(--cf-tint); min-width: 0; }
#wrap #fittingright .cf-panel-head { background: var(--cf-tint); }
#wrap .cf-result-body { padding: 7px 11px; }
#wrap .cf-result-notes { padding: 5px 9px; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; min-width: 0; }
#wrap .cf-result-notes .cf-warnings { font-size: 12px; padding: 5px; }
#wrap .cf-action-area { border-top: 1px solid var(--cf-line); padding: 10px; display: flex; flex-direction: column; background: var(--cf-surface); }
#submitbutton { margin: auto 0 0; width: 100%; }
#wrap #submitbuttona { width: 100%; min-height: 39px; font-size: 20px; font-weight: 800; background: var(--cf-blue); color: #fff; }
#wrap .cf-exports { width: 100%; gap: 5px; }
#wrap .cf-export { min-height: 31px; font-size: 13px; padding: 5px 8px; background: var(--cf-blue); color: white; border-color: #10519a; }
#wrap .cf-export:hover:not(:disabled), #wrap #submitbuttona:hover { background: #104e94; color: white; }
#footer { position: relative; padding: 7px 0; height: 46px; background: transparent; clear: both; }
#footer .csvbutton, #footer .sesbutton { margin: 0; }
#footer .sesbutton { margin-left: 6px; }
#displaysesid { position: absolute; left: 50%; top: 13px; transform: translateX(-50%); white-space: nowrap; cursor: text; user-select: text; }
#version-footer { padding: 3px 0 8px; background: transparent; font-size: 12px; }
.cf-data-skeleton { height: 745px; }
.cf-plot-skeleton { width: 100%; height: 320px; }
.cf-controls-skeleton { width: 100%; height: 415px; }
/* Saved fit controls. */
#wrap .cf-model-chip { min-height: 31px; padding: 5px 9px; border: 1px solid var(--cf-line); border-radius: 4px; background: var(--cf-lock); font-size: 13px; font-weight: 550; }
#wrap .cf-settings .cf-res-eq { margin: 0; font-size: 21px; }
#wrap .cf-params.cf-param-table th { text-transform: none; letter-spacing: normal; }
#wrap .cf-param-table th:nth-child(1) { width: 14%; }
#wrap .cf-param-table th:nth-child(2) { width: 26%; }
#wrap .cf-param-table th:nth-child(3) { width: 10%; }
#wrap .cf-param-table th:nth-child(4), #wrap .cf-param-table th:nth-child(5) { width: 25%; }
#wrap .cf-res-banner.cf-evaluator { flex: 0 0 auto; min-height: 112px; }
#wrap .cf-evaluator .cf-calc-title { max-width: none; }
#wrap .cf-evaluator .cf-calc-field:nth-of-type(3) { grid-column: 1; }
#wrap .cf-evaluator .cf-calc-field label, #wrap .cf-evaluator .cf-calc-field > span { font: italic 14px Georgia, serif; }
#wrap .cf-evaluator input[type=text], #wrap .cf-evaluator .cf-calc-out { height: 29px; line-height: 19px; }
#wrap .cf-evaluator .cf-calc-out { padding: 4px 7px; border: 1px solid var(--cf-line); border-radius: 4px; background: var(--cf-lock); color: var(--cf-muted); font-size: 13px; font-weight: 550; }
#wrap .cf-evaluator .cf-calc-run { margin: 0; padding: 4px 6px; align-self: end; }
#wrap .cf-evaluator .cf-calc-note { grid-column: 1 / -1; font-size: 11px; }
#wrap .cf-result-actions .cf-res-exports { width: 100%; border-left: 0; }
#wrap .cf-result-actions .cf-export-note { order: -1; margin-bottom: 6px; font-size: 12px; }
#wrap .cf-status { color: #276844; font-size: 11px; font-weight: 600; }
#wrap .cf-status.warning { color: #865316; }
#wrap .cf-metric { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px; margin-top: 5px; }
#wrap .cf-metric strong { flex-shrink: 0; max-width: 100%; font: 600 27px var(--cf-mono-font); }
#wrap .cf-metric span, #wrap .cf-counts { color: var(--cf-muted); font-size: 12px; }
#wrap .cf-counts { margin-top: 3px; }
#wrap .cf-uncertainty-row:not(:has(input[value=manual]:checked)) .errorval { visibility: hidden; }
#wrap .cf-uncertainty-row .toggle-btn:has(input:disabled) { cursor: default; background: var(--cf-lock); }
#wrap .cf-uncertainty-row .toggle-btn:has(input:disabled:checked) { background: var(--cf-wash); }
#wrap .cf-panel-head > span { font-size: 12px; color: var(--cf-muted); }
#wrap .cf-control-section > h3 { margin-bottom: 9px; }
#wrap .cf-result-body .cf-pill { display: inline-flex; align-items: center; gap: 5px; padding: 0; margin: 0; font-size: 11px; font-weight: 600; background: transparent; color: #276844; }
#wrap .cf-result-body .cf-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
#wrap .cf-result-body .cf-pill-warn { color: #865316; }
#wrap .cf-result-notes p { margin: 0 0 6px; }
#wrap .cf-warning, #wrap .cf-result-notes .cf-plot-note { font-size: 12px; color: #865316; }
#wrap .cf-unused td { border-bottom-color: transparent; }
#wrap #submitbuttona { text-transform: uppercase; }
/* Loading placeholders occupy their host's box, including after being hidden. */
#wrap .cf-panel-skeleton { inset: 0; width: 100%; height: 100%; }

#wrap .cf-param-table td:first-child { white-space: normal; overflow-wrap: anywhere; }

#dataholder, #quickplot, #cf-plotbox, #bottomholder, #cf-result.cf-controls { border-width: 1.5px; }

#wrap .cf-prev-item { padding: 4px 10px; }

/* A saved fit owns a separate grid; Setup keeps its draft and undo history. */
#cf-fit-data { display: none; overflow-y: auto; font-family: var(--cf-mono-font); }
#dataholder.cf-table-locked #datatable { display: none; }
#dataholder.cf-table-locked #cf-fit-data { display: block; }

/* Keep mouse focus quiet; retain a complete, visible ring for keyboard use. */
#wrap .toggle-btn:focus-within { outline: none; }
#wrap .toggle-btn:has(input:focus-visible) { outline: 2px solid var(--cf-blue); outline-offset: -2px; }
#wrap .toggle-btn input[type=radio] { appearance: none; outline: none; }
/* Plotly fills its box; draw the rounded frame above the white canvas. */
#wrap #quickplot, #wrap #cf-plotbox { border: 0; }
#quickplot, .cf-plot-frame { position: relative; border-radius: 5px; }
#quickplot::after, .cf-plot-frame::after { content: ''; position: absolute; inset: 0; border: 1.5px solid var(--cf-line); border-radius: inherit; pointer-events: none; z-index: 6; }
#bottomholder, #cf-result.cf-controls { overflow: hidden; }


#wrap .cf-uncertainty-row > span:first-child { font: italic 15px Georgia, serif; }
