/* theFIT Spectra Inference. Same tokens, type scale, header, buttons and footer as thefit.science
   (public-site/site/styles.css). Grounds: --bg page, --surface panels, --bg blocks inside panels,
   white only for form fields and the plot. One accent: cobalt. Red and amber only for errors/warnings. */

@font-face {
  font-family: "Libre Franklin";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url("/fonts/libre-franklin-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/source-serif-4-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bg: #eef0f3;
  --surface: #e2e5ea;
  --surface-strong: #d3d7de;
  --white: #ffffff;
  --ink: #0b0c0e;
  --muted: #5d6470;
  --accent: #b8361a;
  --danger: #a3121f;
  --danger-soft: #fbe9ea;
  --warning: #7a4b00;
  --warning-soft: #fdf3dc;
  --display: "Libre Franklin", "Franklin Gothic Medium", "Helvetica Neue", Arial, sans-serif;
  --text: "Source Serif 4", "Iowan Old Style", Charter, Georgia, serif;
  --step-small: 0.875rem;
  --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --step-head: clamp(1.6rem, 1.2rem + 1.2vw, 2.25rem);
  --step-display: clamp(2.5rem, 1rem + 5vw, 4.75rem);
  --margin: clamp(1rem, 4vw, 3.5rem);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: var(--step-body);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--white); }
img, svg { display: block; max-width: 100%; }
p { overflow-wrap: break-word; }

a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.2em; transition: color 160ms var(--ease); }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.7rem 1rem;
  background: var(--ink);
  color: var(--white);
  font-family: var(--display);
  font-weight: 700;
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); color: var(--white); }

/* Page frame: same width and margins as the website shell. */
.topbar, main, .site-footer { width: min(77.5rem, 100% - 2 * var(--margin)); margin-inline: auto; }

/* Header, identical to the website header. */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem 2rem; min-height: 5.25rem; padding-block: 0.75rem; }
.brand { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand svg { flex: 0 0 auto; width: 2.25rem; height: 2.25rem; }
.wordmark { display: inline-flex; align-items: baseline; font-family: var(--display); font-size: 1.5rem; font-weight: 500; letter-spacing: -0.04em; line-height: 1; }
.wordmark strong { font-weight: 800; }
.tool-name { margin-left: 0.15rem; padding-left: 0.85rem; border-left: 2px solid var(--surface-strong); color: var(--muted); font-family: var(--display); font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.5rem; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.4rem; }
nav a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  padding: 0.4rem 0.75rem;
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 160ms var(--ease);
}
nav a:hover { background: var(--surface); color: var(--ink); }

/* Type, on the website scale. */
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: -0.035em; line-height: 1; overflow-wrap: break-word; text-wrap: balance; }
h1 { max-width: 15ch; font-size: var(--step-display); line-height: 0.95; }
h2 { font-size: var(--step-head); line-height: 1.04; }
h3 { margin: 2rem 0 0.75rem; font-size: 1.3rem; letter-spacing: -0.02em; line-height: 1.15; }
.eyebrow { margin: 0 0 0.9rem; color: var(--muted); font-family: var(--display); font-size: var(--step-small); font-weight: 600; line-height: 1.3; }

.intro { padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(2.5rem, 5vw, 4rem); }
.lede { max-width: 40rem; margin: 1.6rem 0 0; font-size: var(--step-lead); line-height: 1.4; }
.flow { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; margin: 2.25rem 0 0; padding: 0; list-style: none; font-family: var(--display); }
.flow li { display: flex; align-items: center; gap: 0.65rem; min-width: 0; font-size: 0.95rem; font-weight: 600; }
.flow span, .step { flex: 0 0 auto; display: grid; place-items: center; width: 2rem; height: 2rem; background: var(--accent); color: var(--white); font-family: var(--display); font-size: 0.95rem; font-weight: 700; }

/* Panels: grey surfaces with 4px seams, as the website's service list. */
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(18rem, 0.75fr); gap: 4px; align-items: stretch; }
.panel { min-width: 0; padding: clamp(1.25rem, 3vw, 2.5rem); background: var(--surface); }
.section-heading { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1.5rem; }
.section-heading.compact { margin-bottom: 0.75rem; }
.section-heading.compact h3 { margin: 0; }

.drop-zone { padding: 1.5rem; border: 2px dashed var(--surface-strong); background: var(--bg); text-align: center; transition: border-color 160ms var(--ease), background-color 160ms var(--ease); }
.drop-zone.is-dragging { border-color: var(--accent); background: var(--white); }
.drop-zone p { margin: 0.2rem 0; }
.drop-zone strong { font-family: var(--display); }
.drop-zone .or { color: var(--muted); font-size: var(--step-small); }
.file-input { display: block; width: min(100%, 32rem); margin: 0.9rem auto; padding: 0.4rem; border: 1px solid var(--muted); background: var(--white); color: var(--ink); font: inherit; font-size: 0.95rem; }
.file-input::file-selector-button { margin-right: 0.8rem; padding: 0.6rem 1rem; border: 0; background: var(--surface); color: var(--ink); font-family: var(--display); font-size: 0.95rem; font-weight: 700; cursor: pointer; transition: background-color 160ms var(--ease); }
.file-input::file-selector-button:hover { background: var(--surface-strong); }
.selected-file { font-family: var(--display); font-size: 0.95rem; font-weight: 700; overflow-wrap: anywhere; }
.requirements { margin: 1rem 0; color: var(--muted); font-size: var(--step-small); }
.requirements strong { color: var(--ink); }
code { padding: 0.05rem 0.3rem; background: var(--bg); color: var(--ink); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.85em; }
label { display: block; margin: 1.2rem 0 0.45rem; font-family: var(--display); font-size: 1rem; font-weight: 700; }
select { width: 100%; min-height: 3.25rem; padding: 0.7rem 0.8rem; border: 1px solid var(--muted); border-radius: 0; background: var(--white); color: var(--ink); font: inherit; }
select:focus-visible { border-color: var(--accent); outline-offset: 0; }
input[type="range"] { width: 100%; min-height: 2.4rem; accent-color: var(--accent); }
output { float: right; color: var(--muted); font-family: var(--display); font-weight: 600; font-variant-numeric: tabular-nums; }
.candidate { margin-top: 1.25rem; padding: 1rem 1.25rem; background: var(--warning-soft); box-shadow: inset 4px 0 0 var(--warning); }
.advanced { margin-top: 1.25rem; padding: 1rem 1.25rem; background: var(--bg); }
.advanced summary { cursor: pointer; font-family: var(--display); font-size: 1rem; font-weight: 700; }
.advanced summary span { margin-left: 0.5rem; color: var(--muted); font-size: var(--step-small); font-weight: 600; }
.advanced > p { color: var(--muted); font-size: var(--step-small); }

/* Buttons: the website's one square shape. Cobalt for the main action, a quiet grey for the rest. */
button, .download-button {
  display: inline-flex;
  min-height: 3.25rem;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.5rem;
  border: 0;
  border-radius: 0;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms var(--ease), transform 160ms var(--ease);
}
button:active, .download-button:active { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: 0.6; }
.primary-button, .download-button { background: var(--accent); color: var(--white); }
.primary-button { width: 100%; margin-top: 1.5rem; }
.primary-button:hover, .download-button:hover { background: var(--ink); color: var(--white); }
.secondary-button, .secondary-download { background: var(--bg); color: var(--ink); }
.secondary-button:hover, .secondary-download:hover { background: var(--surface-strong); color: var(--ink); }
.download-block .secondary-download { background: var(--surface); }
.download-block .secondary-download:hover { background: var(--surface-strong); }
.text-button { min-height: auto; margin-top: 1rem; padding: 0.35rem 0; border-bottom: 2px solid var(--accent); background: transparent; color: var(--ink); font-size: 0.95rem; }
.text-button:hover { color: var(--accent); }

/* Status line: neutral block with a cobalt edge, as the website's notices. */
.status-box { display: flex; align-items: flex-start; gap: 0.7rem; min-height: 3.25rem; margin-top: 1rem; padding: 0.8rem 1rem; background: var(--bg); font-family: var(--display); font-size: 0.95rem; font-weight: 600; line-height: 1.4; }
.status-box p { margin: 0; }
.status-indicator { flex: 0 0 auto; width: 0.7rem; height: 0.7rem; margin-top: 0.3rem; background: var(--muted); }
.status-box.loading .status-indicator { border: 3px solid var(--surface-strong); border-top-color: var(--accent); border-radius: 50%; background: transparent; animation: spin 0.8s linear infinite; }
.status-box.success { box-shadow: inset 4px 0 0 var(--ink); }
.status-box.success .status-indicator { background: var(--ink); }
.status-box.error { background: var(--danger-soft); color: var(--danger); box-shadow: inset 4px 0 0 var(--danger); }
.status-box.error .status-indicator { background: var(--danger); }
.status-box.busy { background: var(--warning-soft); color: var(--warning); box-shadow: inset 4px 0 0 var(--warning); }
.status-box.busy .status-indicator { background: var(--warning); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .status-box.loading .status-indicator { animation: none; } }

.guidance h2 { margin: 0 0 1.25rem; }
.pilot-notice { margin: 0 0 1.25rem; padding: 1.1rem 1.25rem; background: var(--bg); box-shadow: inset 4px 0 0 var(--accent); font-family: var(--display); font-size: 1rem; font-weight: 700; line-height: 1.35; }
.guidance ul, .review-notes { margin: 0; padding-left: 1.2rem; }
.guidance li, .review-notes li { padding-left: 0.3rem; }
.guidance li + li, .review-notes li + li { margin-top: 0.6rem; }
.guidance li::marker, .review-notes li::marker { color: var(--accent); }
.quiet { margin: 1.5rem 0 0; color: var(--muted); font-size: var(--step-small); }

/* Result */
.result { margin-top: 4px; }
.result-meta { margin: 0 0 1rem; color: var(--muted); font-family: var(--display); font-size: var(--step-small); font-weight: 600; }
.plot-frame { overflow: auto; background: var(--white); }
#fit-image { display: block; width: min(100%, 56rem); height: auto; margin: auto; }
.table-wrap { overflow-x: auto; background: var(--bg); }
table { width: 100%; min-width: 40rem; border-collapse: collapse; text-align: left; }
th, td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--surface-strong); }
th { color: var(--muted); font-family: var(--display); font-size: var(--step-small); font-weight: 700; }
td { font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.restore-button { margin: 1rem 0 0; }
.download-block { margin-top: 2.5rem; padding: clamp(1.25rem, 3vw, 2rem); background: var(--bg); }
.download-block > p { max-width: 46rem; }
.downloads { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }

/* Data handling */
.data-handling { margin: 4px 0 clamp(3rem, 7vw, 6rem); }
.data-handling > h2 { margin: 0 0 1.75rem; }
.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem clamp(2rem, 5vw, 4rem); }
.data-grid h3 { margin: 0 0 0.5rem; }
.data-grid p { margin: 0; }

/* Footer, identical to the website footer. */
.site-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem; min-height: 7rem; padding-block: 1.5rem; }
.brand-small svg { width: 1.9rem; height: 1.9rem; }
.brand-small .wordmark { font-size: 1.25rem; }
.site-footer p { margin: 0; color: var(--muted); font-family: var(--display); font-size: var(--step-small); font-weight: 500; }
.site-footer p a { color: var(--ink); font-weight: 700; }
.site-footer p a:hover { color: var(--accent); }

[hidden] { display: none !important; }

@media (max-width: 980px) {
  .workspace-grid, .data-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 0.25rem; min-height: 0; }
  nav { gap: 0.1rem; margin-left: -0.5rem; }
  nav a { padding-inline: 0.5rem; font-size: 0.9rem; }
  .site-footer { align-items: flex-start; flex-direction: column; justify-content: center; }
  .download-button, .secondary-button { width: 100%; }
}
@media (max-width: 380px) {
  .tool-name { display: none; }
}
@media (forced-colors: active) {
  button, .download-button { border: 2px solid ButtonText; }
  .panel, .drop-zone, .pilot-notice, .status-box { border: 1px solid CanvasText; }
  .flow span, .step { border: 1px solid CanvasText; }
}
