/* CGE integrity tool. The site header, footer, fonts and colours come from /styles.css. */

.cge-page [hidden] { display: none !important; }

.cge-main {
  width: min(1480px, 100% - 2.5rem);
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.cge-main section { margin-bottom: 1.25rem; }
.cge-page .site-header .container, .cge-page .site-footer .container { width: min(1480px, 100% - 2.5rem); }

/* ── Intro ───────────────────────────────────────────────────── */
.cge-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.cge-intro h1 {
  margin: 0.5rem 0 0.6rem;
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
}

.cge-lede {
  margin: 0;
  max-width: 62ch;
  color: var(--muted);
  line-height: 1.55;
}

.cge-beta {
  margin-left: 0.35rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

.cge-privacy {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  max-width: 34ch;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 0.85rem;
  line-height: 1.45;
}

.cge-privacy svg { flex: none; margin-top: 0.1rem; color: var(--brand-deep); }

/* ── Drop zone ───────────────────────────────────────────────── */
.cge-drop {
  padding: 2.6rem 1.5rem;
  border: 2px dashed #9fbfba;
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.cge-drop:hover, .cge-drop:focus-visible, .cge-drop.over {
  border-color: var(--brand-deep);
  background: #f3faf8;
  outline: none;
}

.cge-drop p { margin: 0; }
.cge-drop-title { font-size: 1.2rem; font-weight: 700; color: var(--ink); }
.cge-drop-sub { margin-top: 0.3rem !important; color: var(--muted); }
.cge-drop-hint { margin-top: 0.9rem !important; color: var(--muted); font-size: 0.85rem; }

.cge-drop.compact { padding: 0.8rem 1.2rem; display: flex; align-items: baseline; justify-content: center; gap: 0.6rem; flex-wrap: wrap; }
.cge-drop.compact .cge-drop-title { font-size: 0.95rem; }
.cge-drop.compact .cge-drop-sub { margin-top: 0 !important; font-size: 0.9rem; }
.cge-drop.compact .cge-drop-hint { display: none; }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-deep);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-button:hover { color: var(--ink); }

/* ── Status and messages ─────────────────────────────────────── */
.cge-status { margin: 0.6rem 0; color: var(--muted); font-size: 0.9rem; min-height: 1.4em; }
.cge-status.error { color: #a12627; font-weight: 600; }

.cge-message {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid #efc0c0;
  background: #fdf1f1;
  color: #7c1d1e;
  font-size: 0.9rem;
  line-height: 1.45;
}

.cge-message.warning { border-color: #ecd9a4; background: #fdf7e6; color: #6b4e00; }
.cge-message .link-button { flex: none; color: inherit; }

/* ── Toolbar and settings ────────────────────────────────────── */
.cge-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.cge-toolbar-right { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; font-weight: 600; color: var(--muted-strong); }

.cge-page select, .cge-page input[type="number"] {
  height: 2.3rem;
  padding: 0 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
}

.cge-page select:focus-visible, .cge-page input:focus-visible, .cge-button:focus-visible, .link-button:focus-visible,
.segmented button:focus-visible, .sample-row:focus-visible {
  outline: 2px solid var(--brand-deep);
  outline-offset: 2px;
}

.cge-button {
  height: 2.3rem;
  padding: 0 0.95rem;
  border: 1px solid var(--brand-deep);
  border-radius: var(--radius-sm);
  background: var(--brand-deep);
  color: #ffffff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.cge-button:hover { background: #3d736c; }
.cge-button.quiet { border-color: var(--line); background: var(--surface); color: var(--muted-strong); }
.cge-button.quiet:hover { border-color: var(--brand-deep); background: var(--surface); color: var(--ink); }

.cge-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem 1.5rem;
  margin-bottom: 0.9rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.cge-settings fieldset { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.cge-settings legend { padding: 0; margin-bottom: 0.5rem; font-size: 0.85rem; font-weight: 800; color: var(--ink); }
.cge-settings-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.check { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.85rem; font-weight: 600; color: var(--muted-strong); line-height: 1.4; }
.check input { margin-top: 0.2rem; accent-color: var(--brand-deep); }
.hint { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.45; }

/* ── Panes ───────────────────────────────────────────────────── */
.cge-panes {
  display: grid;
  grid-template-columns: minmax(520px, 6fr) minmax(0, 7fr);
  gap: 1rem;
  align-items: start;
}

.cge-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.cge-list-scroll { max-height: 78vh; overflow: auto; border-radius: var(--radius); }

.cge-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; line-height: 1.35; }
.cge-table th, .cge-table td { padding: 0.4rem 0.5rem; text-align: left; vertical-align: middle; }
.cge-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f6f8;
  color: var(--muted-strong);
  font-size: 0.75rem;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.cge-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cge-table .strong { font-weight: 700; color: var(--ink); }
.cge-table .muted, .muted { color: var(--muted); }

.file-row th { background: #f8fbfc; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-weight: 600; font-size: 0.8rem; }
.file-name { font-weight: 800; color: var(--ink); }
.file-remove { float: right; font-size: 0.78rem; font-weight: 600; }

.sample-row { cursor: pointer; border-bottom: 1px solid #edf2f4; }
.sample-row:hover { background: #f5faf9; }
.sample-row.selected { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand-deep); }
.sample-name { min-width: 7rem; overflow-wrap: break-word; }

.cge-table td:has(.type-select) { white-space: nowrap; }
.type-select { height: 1.9rem !important; padding: 0 0.3rem !important; font-size: 0.82rem !important; }
.guess { margin-left: 0.35rem; color: var(--muted); font-size: 0.72rem; cursor: help; white-space: nowrap; }
.guess-unsure { padding: 0.05rem 0.35rem; border-radius: 999px; background: #fdf3d3; color: #6b4e00; font-weight: 700; }
.edited { margin-left: 0.4rem; padding: 0.05rem 0.4rem; border-radius: 999px; background: #e8eef7; color: #1b4f93; font-size: 0.7rem; font-weight: 700; white-space: nowrap; }

.chip { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-weight: 700; color: var(--muted-strong); white-space: nowrap; }
.chip-symbol {
  display: inline-grid;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #c9d3da;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  flex: none;
}
.st-ok .chip-symbol { background: #0a8f1f; }
.st-check .chip-symbol { background: #fbb315; color: #3d2c00; }

/* ── Detail ──────────────────────────────────────────────────── */
.cge-detail { padding: 1.1rem 1.2rem 1.2rem; min-width: 0; }
.cge-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }
.cge-detail h2 { margin: 0; font-size: 1.2rem; line-height: 1.25; overflow-wrap: anywhere; }
.cge-detail h3 { margin: 1.1rem 0 0.4rem; font-size: 0.95rem; }
.cge-detail-sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.86rem; line-height: 1.45; }

.cge-figure { text-align: right; flex: none; }
.cge-figure-value { display: block; font-size: 2.1rem; font-weight: 800; line-height: 1; color: var(--ink); letter-spacing: -0.02em; }
.cge-figure-label { display: block; margin-top: 0.25rem; color: var(--muted); font-size: 0.78rem; font-weight: 600; }

.cge-flags { margin-top: 0.6rem; }
.flag {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.3rem 0 0;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  background: #fdf7e6;
  color: #5c4300;
  font-size: 0.84rem;
  line-height: 1.4;
}
.flag .chip-symbol { background: #fbb315; color: #3d2c00; margin-top: 0.05rem; }
.flag-info { background: #eef3f7; color: var(--muted-strong); }
.flag-info .chip-symbol { background: #7c8b98; color: #ffffff; }

.cge-plot-tools { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.9rem 0 0.5rem; }
.cge-plot-tools .spacer { flex: 1; }
.cge-plot-tools .cge-button { height: 2rem; font-size: 0.8rem; padding: 0 0.7rem; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented button {
  height: 2rem;
  padding: 0 0.7rem;
  border: 0;
  border-right: 1px solid var(--line);
  background: none;
  color: var(--muted-strong);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button.on { background: var(--brand-soft); color: var(--ink); font-weight: 800; }
.segmented button:disabled { color: #a9b5bd; cursor: default; }

.cge-plot-wrap { position: relative; }
.cge-plot { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.cge-plot .handle-edge rect:last-of-type { cursor: ew-resize; }
.cge-plot .handle-anchor circle:last-of-type { cursor: grab; }

.cge-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 9rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  pointer-events: none;
  white-space: nowrap;
}
.cge-tooltip strong { display: block; color: var(--ink); font-size: 0.85rem; }
.cge-tooltip b { color: var(--ink); }

.cge-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; margin: 0.5rem 0 0.4rem; padding: 0; list-style: none; color: var(--muted-strong); font-size: 0.8rem; }
.cge-legend li { display: inline-flex; align-items: center; }

.key { display: inline-block; flex: none; margin-right: 0.4rem; vertical-align: middle; }
.key-line { width: 16px; height: 0; border-top: 2px solid; }
.key-fill { width: 12px; height: 12px; border-radius: 2px; }
.key-band { width: 12px; height: 12px; border-radius: 2px; background: #e9f4f2; border: 1px solid #4a8880; }
.key-trace { border-color: #29333f; }
.key-fit { border-color: #00b894; }
.key-base { border-color: #7c8b98; }
.key-main { background: rgba(37, 125, 224, 0.45); }
.key-other { background: rgba(244, 114, 48, 0.45); }

.cge-peaks { margin-top: 0.2rem; }
.cge-peaks td, .cge-peaks th { border-bottom: 1px solid #edf2f4; }
.cge-peaks thead th { position: static; background: none; }
.peak-main td { font-weight: 700; color: var(--ink); }
.peak-rest td { color: var(--muted); }

/* ── About ───────────────────────────────────────────────────── */
.cge-about { margin-top: 2rem; max-width: 80ch; }
.cge-about details { border-top: 1px solid var(--line); padding: 0.7rem 0; }
.cge-about summary { font-weight: 700; color: var(--ink); cursor: pointer; }
.cge-about p, .cge-about li { color: var(--muted-strong); font-size: 0.92rem; line-height: 1.6; }
.cge-about ol { padding-left: 1.2rem; }
.cge-about a { color: var(--brand-deep); font-weight: 600; }

body.busy .cge-panes { opacity: 0.6; }
.print-only { display: none; }

@media (max-width: 1000px) {
  .cge-panes { grid-template-columns: 1fr; }
  .cge-list-scroll { max-height: 46vh; }
  .cge-settings { grid-template-columns: 1fr; }
}

/* ── Printed report ──────────────────────────────────────────── */
@media print {
  .site-header, .site-footer, .cge-main { display: none !important; }
  body.cge-page { background: #ffffff; }
  body.cge-page::before { display: none; }
  .print-only { display: block; padding: 0; font-size: 9pt; }
  .print-only h1 { margin: 0 0 4pt; font-size: 15pt; }
  .print-only .cge-table { font-size: 8pt; margin: 8pt 0 12pt; }
  .print-only .cge-table th, .print-only .cge-table td { padding: 2pt 4pt; border-bottom: 0.5pt solid #c8d8da; }
  .print-only .cge-table thead th { position: static; }
  .report-plots { display: grid; grid-template-columns: 1fr 1fr; gap: 8pt; }
  .report-plots figure { margin: 0; break-inside: avoid; }
  .report-plots svg { width: 100%; height: auto; }
}
