/* styles.css — Stover PWA
   Adapted from the Canopeo stylesheet.
   Light theme by default; dark theme via [data-theme="dark"] on <html>.
   Every color is a CSS variable so the theme switch costs zero extra rules. */

/* ── Variables ─────────────────────────────────────────────────────── */
:root {
  --bg:             #ffffff;
  --surface:        #f4f4f4;
  --canvas-bg:      #e2e2e2;
  --menubar-bg:     #fafafa;
  --menubar-border: #dadada;
  --text:           #1c1c1c;
  --text-muted:     #5a5a5a;
  --border:         #c6c6c6;
  --btn-from:       #ffffff;
  --btn-to:         #ebebeb;
  --btn-hover-from: #ffffff;
  --btn-hover-to:   #e0e0e0;
  --btn-active:     #d4d4d4;
  --input-bg:       #ffffff;
  --row-alt:        #fafafa;
  --row-hover:      #eef2ff;
  --modal-bg:       #ffffff;
  --modal-shadow:   rgba(0,0,0,0.22);
  --pre-bg:         #f4f4f4;
  --cover-color:    #b07a00;
  --accent:         #c8892a;
  --accent-dark:    #a4691a;
  --ok-green:       #2a7a2a;
  --warn-amber:     #b07a00;
  --danger:         #a04040;
  --btn-border-hover: #aaaaaa;
  --slider-accent:    #a4691a;
  --right-width:    320px;
}

[data-theme="dark"] {
  --bg:             #0f110e;
  --surface:        #161815;
  --canvas-bg:      #0c0d0b;
  --menubar-bg:     #161815;
  --menubar-border: #252722;
  --text:           #d4d9d3;
  --text-muted:     #7a8079;
  --border:         #2c302b;
  --btn-from:       #252722;
  --btn-to:         #1e2019;
  --btn-hover-from: #343830;
  --btn-hover-to:   #2c302a;
  --btn-active:     #141610;
  --btn-border-hover: #444843;
  --slider-accent:    #e22d2d;
  --input-bg:       #1e211c;
  --row-alt:        #141610;
  --row-hover:      #1a2218;
  --modal-bg:       #1a1d18;
  --modal-shadow:   rgba(0,0,0,0.55);
  --pre-bg:         #141610;
  --cover-color:    #e0a83a;
  --accent:         #d99a3c;
  --accent-dark:    #c8892a;
  --ok-green:       #4ade80;
  --warn-amber:     #fbbf24;
  --danger:         #f87171;
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  /* allow scrolling so the results section is reachable */
  min-height: 100%;
}

/* ── Menubar ─────────────────────────────────────────────────────────── */
.menubar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 10px;
  height: 34px;
  background: var(--menubar-bg);
  border-bottom: 1px solid var(--menubar-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-item {
  position: relative;
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text);
  flex-shrink: 0;
}
.menu-item:hover, .menu-item.open { background: var(--surface); }

.caret { font-size: 10px; color: var(--text-muted); }

.menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 16px var(--modal-shadow);
  min-width: 150px;
  z-index: 60;
  overflow: hidden;
}
.menu-item.open .menu-dropdown { display: block; }

.menu-dropdown button,
.menu-dropdown a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  background: none;
  border: none;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}
.menu-dropdown button:hover,
.menu-dropdown a:hover { background: var(--surface); }

.menubar-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 15px;
  margin-right: 6px;
}
.menubar-logo { width: 25px; height: 25px; }

.menubar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 7px;
  line-height: 1.5;
  transition: background 0.15s;
}
.theme-toggle:hover { background: var(--surface); color: var(--text); }

.install-btn {
  padding: 3px 10px;
  font-size: 12px;
  font-family: inherit;
  border-radius: 3px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
}
.install-btn:hover { background: var(--surface); }

/* ── App two-pane layout ─────────────────────────────────────────────── */
.app {
  display: flex;
  align-items: stretch;
  width: 100%;
  /* fixed height so the sidebar scrolls independently and the image never moves */
  height: calc(100vh - 34px);
  overflow: hidden;
}

/* ── Left pane: image canvas ─────────────────────────────────────────── */
.left-pane {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas-bg);
  min-width: 0;
  overflow: hidden;
  min-height: 400px;
}

.image-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

#display-canvas {
  max-width: 100%;
  max-height: calc(100vh - 34px);
  display: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
  cursor: zoom-in;
}
#display-canvas.visible { display: block; }

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 0 40px;
  pointer-events: none;
}

.drag-overlay {
  display: none;
  position: absolute;
  inset: 10px;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgba(47,111,237,0.07);
  color: var(--accent-dark);
  font-size: 16px;
  font-weight: 600;
  pointer-events: none;
}
.image-container.drag-over .drag-overlay { display: flex; }

/* ── Right pane: sidebar ─────────────────────────────────────────────── */
.right-pane {
  width: var(--right-width);
  flex: 0 0 var(--right-width);
  background: var(--bg);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
}

/* ── Flow sections ───────────────────────────────────────────────────── */
.step {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 20px 20px;
  border-bottom: 1px solid var(--border);
}
.step:last-child { border-bottom: none; }

.step-head { display: flex; align-items: center; gap: 9px; }
.step-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.step-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text);
}
.step-sub {
  margin: -6px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

.hint { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--text-muted); }
.hint.center { text-align: center; }
.loaded-count { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--text); }

/* ── Fields ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text); }

.scale-ends {
  display: flex;
  justify-content: space-between;
  margin-top: -3px;
  font-size: 10.5px;
  color: var(--text-muted);
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: linear-gradient(to bottom, var(--btn-from), var(--btn-to));
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: linear-gradient(to bottom, var(--btn-hover-from), var(--btn-hover-to)); border-color: var(--btn-border-hover); }
.btn:active:not(:disabled) { background: var(--btn-active); }
.btn:disabled { color: var(--text-muted); cursor: not-allowed; opacity: 0.6; }

.btn.primary {
  background: linear-gradient(to bottom, var(--accent), var(--accent-dark));
  border-color: var(--accent-dark);
  color: #ffffff;
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) {
  background: linear-gradient(to bottom, var(--accent), var(--accent-dark));
  border-color: var(--accent-dark);
  filter: brightness(1.1);
}
.btn.primary:disabled { opacity: 0.5; }

/* Load: inviting dashed call-to-action that doubles as a drop hint */
.btn.load-btn {
  padding: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-dark);
  background: transparent;
  border: 1.5px dashed var(--accent);
}
.btn.load-btn:hover:not(:disabled) { background: var(--row-hover); }

.btn.run-btn { padding: 12px; font-size: 14px; border-radius: 8px; }

.btn.danger-outline {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
  width: auto;
  padding: 6px 11px;
  border-radius: 6px;
}
.btn.danger-outline:hover:not(:disabled) { background: rgba(160,64,64,0.08); }

/* ── Segmented control (processing size) ─────────────────────────────── */
.seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.seg-opt { position: relative; flex: 1; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span {
  display: block;
  text-align: center;
  padding: 8px 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.seg-opt input:checked + span { background: var(--accent); color: #ffffff; font-weight: 600; }
.seg-opt input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--accent-dark); }

/* ── Cover readout ───────────────────────────────────────────────────── */
.readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.readout-cover { display: flex; flex-direction: column; line-height: 1; }
.readout-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--cover-color);
  font-variant-numeric: tabular-nums;
}
.readout-caption {
  margin-top: 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}
.readout-nav { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--btn-from);
  border-radius: 7px;
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--btn-hover-from); border-color: var(--btn-border-hover); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.readout-counter {
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Checkboxes ──────────────────────────────────────────────────────── */
.check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.outputs { display: flex; flex-direction: column; gap: 9px; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--slider-accent); cursor: pointer; }

/* ── Info block ──────────────────────────────────────────────────────── */
.info-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}
.info-line { margin: 0; font-size: 12px; line-height: 1.45; color: var(--text-muted); }

.mpx-low  { color: var(--ok-green);    font-weight: 600; }
.mpx-mid  { color: var(--warn-amber);  font-weight: 600; }
.mpx-high { color: var(--danger);      font-weight: 600; }

/* ── Color chips ─────────────────────────────────────────────────────── */
.color-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 2px 0;
}

.color-chip {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  outline: none;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 0 0 1px var(--border);
}
.color-chip:hover { transform: scale(1.15); }
.color-chip.active {
  transform: scale(1.1);
  box-shadow: 
    0 0 0 2px #ffffff,  /* Inner white ring */
    0 0 0 4px #000000,  /* Outer black ring */
    0 4px 10px rgba(0, 0, 0, 0.3); /* Soft drop shadow for depth */
}

/* "Original" chip: subtle neutral diagonal hatch to read as "as-is", not a control color */
.color-chip.is-original {
  background-color: var(--surface);
  background-image: repeating-linear-gradient(
    45deg,
    var(--text-muted) 0, var(--text-muted) 1.5px,
    transparent 1.5px, transparent 5px
  );
}

/* ── Progress bar ────────────────────────────────────────────────────── */
.progress-track {
  width: 100%;
  height: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, var(--accent), var(--accent-dark));
  transition: width 0.15s ease;
}
.progress-label {
  margin: 0;
  min-height: 1em;
  font-size: 12px;
  text-align: center;
  color: var(--text-muted);
}

/* ── Results section ─────────────────────────────────────────────────── */
.results-section {
  border-top: 1px solid var(--border);
  padding: 16px 20px 28px;
  background: var(--bg);
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.results-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Download buttons (CSV / ZIP) that appear in the results header after a batch completes */
.btn.dl-btn {
  width: auto;
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 12px;
  gap: 4px;
  color: var(--accent);
  border-color: var(--accent);
  background: transparent;
}
.btn.dl-btn:hover:not(:disabled) {
  background: rgba(47,111,237,0.08);
  border-color: var(--accent);
}

.results-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.results-badge {
  display: inline-block;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
}

/* ── Results table ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.results-table thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

.results-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.results-table tbody tr:last-child { border-bottom: none; }
.results-table tbody tr:nth-child(even) { background: var(--row-alt); }
.results-table tbody tr:hover { background: var(--row-hover); }

.results-table tbody td {
  padding: 7px 10px;
  vertical-align: middle;
  white-space: nowrap;
  color: var(--text);
}

.thumb {
  display: block;
  width: 60px;
  height: 45px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.thumb:hover { opacity: 0.88; box-shadow: 0 0 0 2px var(--accent); }

.col-cover {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--cover-color);
  text-align: left;
}
.col-cover .pct { font-size: 11px; font-weight: 400; margin-left: 1px; }

.col-fn {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11.5px;
}

.null-val { color: var(--text-muted); }

/* ── Lightbox ─────────────────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 400;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }

.lightbox-img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  cursor: default;
  image-rendering: auto;
}

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.lightbox-close:hover { background: rgba(0,0,0,0.75); }

/* ── Modals ──────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px 26px;
  max-width: 560px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px var(--modal-shadow);
}
.modal-box.wide { max-width: 720px; }

.modal-box h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
}
.modal-box .close-btn {
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
}
.modal-box .close-btn:hover { color: var(--text); }

.modal-box p, .modal-box li {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.6;
  margin: 0 0 10px;
}
.version-line { color: var(--text-muted); }
.modal-box a { color: var(--accent); }
.modal-box h3 { font-size: 13.5px; font-weight: 700; margin: 16px 0 6px; color: var(--text); }
.modal-box h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 16px 0 6px;
}
.modal-box .logo-row { display: flex; align-items: center; gap: 16px; margin: 14px 0; }
.modal-box .logo-row img { max-height: 50px; max-width: 150px; object-fit: contain; }

.modal-box pre {
  white-space: pre-wrap;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11.5px;
  background: var(--pre-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  line-height: 1.5;
  color: var(--text);
}

/* Cross-reference note in the User Guide pointing to the collection modal */
.guide-xref {
  margin: 0 0 6px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.guide-xref strong { color: var(--text); }

/* ── Photo Guide modal (field photo collection) ───────────────────────── */
#photoguide-modal .pg-lede {
  margin: 0 0 2px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
.pg-steps { display: flex; flex-direction: column; }
.pg-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 13px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.pg-step:last-child { border-bottom: none; }
.pg-num {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent-dark);
  font-weight: 700; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.pg-body h3 { font-size: 14.5px; font-weight: 650; margin: 3px 0 5px; color: var(--text); }
.pg-body > p { font-size: 13px; line-height: 1.55; color: var(--text-muted); margin: 0 0 12px; max-width: 56ch; }
.pg-body > p:last-child { margin-bottom: 0; }
.pg-hero, .pg-card { margin: 0; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.pg-hero picture { display: block; }
.pg-hero img, .pg-card img { display: block; width: 100%; height: auto; }
.pg-card img { aspect-ratio: 4 / 3; object-fit: cover; }
.pg-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pg-hero figcaption, .pg-card figcaption {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 11px;
  font-size: 12px; font-weight: 650;
  border-top: 1px solid var(--border);
}
.pg-cap.good, .pg-card.good figcaption { color: var(--ok-green); }
.pg-card.bad figcaption { color: var(--danger); }
.pg-badge {
  width: 16px; height: 16px; flex: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; line-height: 1; color: #fff;
}
.pg-badge.good { background: var(--ok-green); }
.pg-badge.bad { background: var(--danger); }
.pg-foot {
  margin: 14px 0 0; padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px; line-height: 1.5; color: var(--text-muted);
}
.pg-foot strong { color: var(--text); }
@media (max-width: 460px) { .pg-pair { grid-template-columns: 1fr; } }

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a2a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  max-width: 90vw;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  z-index: 300;
}
.toast.error { background: #6b2424; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app { flex-direction: column; min-height: auto; }
  .left-pane { height: 52vh; min-height: 240px; overflow: hidden; }
  .right-pane { width: 100%; flex: 1 1 auto; border-left: none; border-top: 1px solid var(--border); overflow-y: visible; }
  #display-canvas { max-height: 52vh; }
}

@media (max-width: 600px) {
  .hide-sm { display: none; }
  .results-section { padding: 12px 10px 24px; }
}

/* ── Scrollbar (webkit) ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Dark-mode overrides for elements that are blue in light but better white in dark ── */
[data-theme="dark"] .install-btn {
  color: var(--text);
  border-color: var(--border);
}
[data-theme="dark"] .btn.load-btn {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ── Stover additions ─────────────────────────────────────────────────── */

/* Tri-class cover readout (Residue / Canopy / Soil) */
.tri-readout {
  justify-content: space-around;
  gap: 6px;
  padding: 14px 12px;
}
.tri-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.tri-value {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.tri-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.tri-caption {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--text);
}
.tri-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
  flex: none;
}

/* Standalone prev/next row (no longer inside the readout box) */
.standalone-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: -4px;
}

/* Class-color legend under the overlay control */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 2px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Per-class cover columns in the results table */
.col-res, .col-can, .col-soil {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

/* Report detail inputs (PDF) */
.text-input {
  width: 100%;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  resize: vertical;
}
.text-input:focus { outline: none; border-color: var(--accent); }
.text-input::placeholder { color: var(--text-muted); }

/* [uncertainty] gradient legend for the Uncertainty overlay (magma) */
.uncert-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.uncert-bar {
  flex: 1;
  height: 9px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--border);
  background: linear-gradient(to right,
    #000004, #1c1044, #4f127b, #812581, #b5367a, #e55064, #fb8761, #fec287, #fcfdbf);
}
