/* Curve tracer styling, carried over with the tracer itself.

   Layout is Jon's. The colours follow the selector it sits in (Jon, 30 Sep
   2026): a grey #eef1f4 header like the selector's card headers, the banner
   blue #0d5aa7 for the title, toggles, buttons and switches, and the
   selector's own navy, steel and muted greys for text. The palette names his
   rules use are mapped here onto selector.css's tokens, on the overlay and the
   trigger rather than :root, so nothing leaks into the rest of the site.
   The canvas keeps its cyan grid and crimson points - those are the
   selector chart's own series colours.

   Every selector below is scoped under .tr- or #tr, so none of it can reach the
   selector's own markup. */

.tr-overlay,
#customCurveTrace {
  --white: #fff;
  --brand: #0d5aa7;
  --brand-dk: #0a4886;
  --border: var(--bs-border-color, #dee2e6);
  --navy: var(--qp-navy, #1a2b3c);
  --charcoal: var(--bs-body-color, #212529);
  --steel: var(--qp-steel, #4a6580);
  --silver: var(--qp-muted, #556b7d);
  --smoke: #eef1f4;
  --red: var(--qp-red, #b3352a);
  --green: var(--qp-green, #198040);
}

    .tr-overlay { position: fixed; inset: 0; background: rgba(26,43,60,0.55); z-index: 9000; display: none; }
    .tr-overlay.open { display: flex; align-items: center; justify-content: center; padding: 22px; }
    .tr-modal { background: var(--white); border: 1px solid var(--border); border-radius: 8px; width: 100%; max-width: 1340px; height: 100%; max-height: 880px; display: flex; flex-direction: column; overflow: hidden; }
    .tr-head { background: var(--smoke); border-bottom: 1px solid var(--border); padding: 11px 18px; display: flex; align-items: baseline; gap: 12px; flex: 0 0 auto; }
    .tr-head h3 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.05rem; font-weight: 700; color: var(--bs-emphasis-color, #212529); letter-spacing: 0.06em; text-transform: uppercase; margin: 0; }
    .tr-head h3 span { color: var(--brand); }
    .tr-head p { font-size: 0.78rem; color: var(--silver); letter-spacing: 0.04em; margin: 0; }
    .tr-close { align-self: center; background: none; border: none; color: var(--steel); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 2px; font-family: inherit; }
    .tr-close:hover { color: var(--navy); }
    .tr-body { flex: 1 1 auto; display: flex; min-height: 0; }
    .tr-rail { width: 240px; flex: 0 0 auto; padding: 14px; overflow-y: auto; background: #fff; border-right: 1px solid var(--border); }
    .tr-rail.tr-right { width: 268px; border-right: none; border-left: 1px solid var(--border); }
    .tr-rail .field { margin-bottom: 10px; }
    .tr-rail .field input, .tr-rail .field select { font-size: 0.85rem; }
    .tr-rail .field .form-label { margin-bottom: 3px; font-size: 0.8rem; color: var(--steel); display: block; }
    .tr-rail .field-row { display: flex; gap: 8px; }
    .tr-rail .field-row .field { flex: 1 1 0; min-width: 0; }
    .tr-rail .section-label { margin: 14px 0 9px; }
    .tr-rail .section-label:first-child { margin-top: 0; }
    .tr-rail .form-check { font-size: 0.82rem; color: var(--charcoal); }
    .tr-toggle { margin-bottom: 10px; }
    .tr-toggle .btn { font-size: 0.8rem; }
    .tr-val { float: right; color: var(--navy); font-variant-numeric: tabular-nums; }
    .tr-stage { flex: 1 1 auto; min-width: 0; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
    .tr-toolbar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
    .tr-zoom { display: flex; border: 1.5px solid var(--border); border-radius: 5px; overflow: hidden; }
    .tr-zoom button { padding: 4px 11px; font-family: inherit; font-size: 0.9rem; font-weight: 600; line-height: 1.2; color: var(--steel); background: var(--white); border: none; border-right: 1px solid var(--border); cursor: pointer; }
    .tr-zoom button:last-child { border-right: none; }
    .tr-zoom button:hover { background: var(--smoke); color: var(--navy); }
    .tr-zoom span { padding: 4px 8px; font-size: 0.78rem; font-weight: 600; color: var(--navy); background: var(--white); border-right: 1px solid var(--border); min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; align-self: center; }
    .tr-tool-readout { margin-left: auto; display: flex; gap: 14px; font-size: 0.82rem; font-variant-numeric: tabular-nums; color: var(--charcoal); }
    .tr-tool-readout b { color: var(--silver); font-weight: 700; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; }
    .tr-wide-btn { padding: 4px 11px; font-family: inherit; font-size: 0.78rem; font-weight: 600; color: var(--steel); background: var(--white); border: 1.5px solid var(--border); border-radius: 5px; cursor: pointer; }
    .tr-wide-btn:hover { border-color: var(--brand); color: var(--brand); }
    .tr-modal.tr-wide .tr-rail { display: none; }
    .tr-overlay.tr-full { padding: 0; }
    .tr-overlay.tr-full .tr-modal { max-width: none; max-height: none; border: none; border-radius: 0; }
    .tr-head-btn { align-self: center; padding: 3px 10px; font-family: inherit; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--brand); background: var(--white); border: 1px solid var(--brand); border-radius: 4px; cursor: pointer; }
    .tr-head-btn:hover { color: var(--white); background: var(--brand); }
    .tr-head-btn.on { background: var(--brand); border-color: var(--brand); color: var(--white); }
    .tr-tool-hint { font-size: 0.75rem; color: var(--silver); white-space: nowrap; }
    .tr-modal.tr-wide .tr-wide-btn { background: var(--brand); border-color: var(--brand); color: var(--white); }
    #trWrap { position: relative; flex: 1 1 auto; min-width: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--white); }
    #trCanvas { position: absolute; inset: 0; display: block; touch-action: none; }
    #trDrop { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--silver); font-size: 0.9rem; background: var(--white); pointer-events: none; }
    #trDrop.hide { display: none; }
    #trDrop.over { color: var(--brand); background: #eef4fb; box-shadow: inset 0 0 0 2px var(--brand); }
    .tr-readout { display: flex; justify-content: space-between; gap: 8px; background: var(--bs-tertiary-bg, #f8f9fa); color: var(--navy); border: 1px solid var(--border); border-radius: 5px; padding: 6px 10px; font-size: 0.82rem; font-variant-numeric: tabular-nums; margin-bottom: 10px; }
    .tr-readout b { color: var(--brand); font-weight: 700; }
    .tr-mini { display: flex; gap: 6px; margin-bottom: 8px; }
    .tr-mini button { flex: 1; padding: 5px 8px; font-family: inherit; font-size: 0.78rem; font-weight: 600; color: var(--steel); background: var(--white); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
    .tr-mini button:hover { border-color: var(--brand); color: var(--brand); }
    .tr-mini button.tr-primary { background: var(--brand); border-color: var(--brand); color: var(--white); }
    .tr-mini button.tr-on { background: var(--red); border-color: var(--red); color: var(--white); }
    .tr-mini button.tr-on:hover { background: #8f2a21; border-color: #8f2a21; color: var(--white); }
    .tr-mini button.tr-primary:hover { background: var(--brand-dk); border-color: var(--brand-dk); color: var(--white); }
    .tr-mini button:disabled { opacity: 0.45; cursor: default; border-color: var(--border); color: var(--silver); }
    .tr-swatches { display: flex; gap: 4px; margin-bottom: 8px; }
    .tr-swatches button { flex: 1; height: 19px; border: 1px solid rgba(0,0,0,0.18); border-radius: 3px; cursor: pointer; padding: 0; }
    .tr-pts { width: 100%; border-collapse: collapse; font-size: 0.78rem; font-variant-numeric: tabular-nums; }
    .tr-pts th { background: var(--smoke); color: var(--navy); border-bottom: 1px solid var(--border); font-family: 'Barlow Condensed', sans-serif; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px 6px; text-align: right; }
    .tr-pts th:first-child { text-align: left; }
    .tr-pts td { padding: 3px 6px; text-align: right; border-bottom: 1px solid var(--smoke); }
    .tr-pts td:first-child { text-align: left; color: var(--silver); }
    .tr-pts tbody tr:nth-child(even) { background: #f8fafc; }
    .tr-pts td button { background: none; border: none; color: var(--red); cursor: pointer; font-family: inherit; font-size: 0.8rem; padding: 0 4px; }
    .tr-ptwrap { max-height: 190px; overflow-y: auto; border: 1px solid var(--smoke); border-radius: 4px; }
    .tr-empty { padding: 14px 10px; text-align: center; color: var(--silver); font-size: 0.78rem; }

    /* Several curves (18 Nov 2026): one chip each, the active one outlined. */
    .tr-curves { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
    .tr-curve-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 8px; font-family: inherit; font-size: 0.78rem; color: var(--charcoal); background: var(--white); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
    .tr-curve-chip:hover { border-color: var(--brand); }
    .tr-curve-chip.tr-cur { border: 2px solid var(--brand); padding: 2px 7px; font-weight: 600; color: var(--navy); }
    .tr-curve-chip .tr-sw { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
    .tr-curve-chip .tr-cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
    .tr-curve-chip .tr-cc { color: var(--silver); font-variant-numeric: tabular-nums; }
    .tr-curve-chip .tr-cx { color: var(--silver); font-size: 0.9rem; line-height: 1; padding: 0 1px; }
    .tr-curve-chip .tr-cx:hover { color: var(--red); }
    .tr-mini button.tr-armed { background: var(--brand); border-color: var(--brand); color: var(--white); }
    .tr-pts tbody tr { cursor: pointer; }
    .tr-pts tbody tr.tr-sel, .tr-pts tbody tr.tr-sel:nth-child(even) { background: #e4eefa; }

    /* The tracer's own right-click menu (18 Nov 2026) - a browser offers Paste
       only over a text box, never over a canvas. */
    .tr-menu { position: absolute; z-index: 5; min-width: 150px; padding: 4px 0; background: var(--white); border: 1px solid var(--border); border-radius: 5px; box-shadow: 0 4px 14px rgba(26,43,60,0.18); }
    .tr-menu button { display: block; width: 100%; padding: 6px 14px; font-family: inherit; font-size: 0.82rem; text-align: left; color: var(--charcoal); background: none; border: none; cursor: pointer; }
    .tr-menu button:hover, .tr-menu button:focus { background: var(--smoke); color: var(--navy); outline: none; }
    .tr-menu button:disabled { color: var(--silver); cursor: default; background: none; }

    /* The banner over the chart, where the eye is (18 Nov 2026): the guide
       lines done so far, or the colour pick (3 Dec 2026). At the foot, clear
       of the guide lines' labels. Only its buttons take the pointer, so clicks
       reach the canvas under it. */
    .tr-prompt { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 4; max-width: calc(100% - 24px); display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 12px; font-size: 0.86rem; color: var(--white); background: var(--brand); border-radius: 6px; box-shadow: 0 3px 10px rgba(26,43,60,0.25); pointer-events: none; }
    .tr-prompt b { font-weight: 700; }
    .tr-prompt .tr-step { flex: 0 0 auto; padding: 1px 7px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; color: var(--brand); background: var(--white); border-radius: 999px; }
    .tr-prompt button { pointer-events: auto; padding: 1px 9px; font-family: inherit; font-size: 0.78rem; font-weight: 600; color: var(--white); background: transparent; border: 1px solid rgba(255,255,255,0.7); border-radius: 4px; cursor: pointer; }
    .tr-prompt button:hover { background: rgba(255,255,255,0.18); }
    .tr-prompt #trCancelPick { border: none; font-size: 1.05rem; line-height: 1; padding: 0 3px; }
    .tr-prompt .tr-say { flex: 0 1 auto; min-width: 0; }
    .tr-prompt { width: max-content; }

    .tr-guides { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
    .tr-guides input { width: 4.2rem; }

    /* Tracing by colour (18 Nov 2026). */
    .tr-colour { align-items: center; }
    .tr-colour-sw { flex: 0 0 22px; height: 22px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.2); }
    .tr-prompt .tr-step-warn { color: #8a4b00; background: #fde68a; }
