/* =====================================================================================
   HNMRviewer.css: the proton (¹H) NMR viewer's own rules (#nmr-tool-wrapper).
   Load after rs-spec-viewer.css, which holds the card, head row, controls, panels, spectrum
   box, explanation box, feedback, tables, windows and the phone and full-screen rules (the
   viewer's markup carries the shared .sv-* classes).
   This file: set-up forms, workspace layout (with the Deduce drawing panel), structure drawing,
   spectrum marks (signals, integration, multiplicity, peak letters), the peak window in
   Predict, the drawing panel, the data sheet window (the viewer moves it to <body> outside full
   screen, so its rules use its own id) and keyboard focus on signals and groups.
   Replaces the old HNMRviewer.css and the page's nmr <style> blocks. 29 Nov 2026. No important flags.
   ===================================================================================== */

/* ---- head: the Cheat sheet button takes the shared head look (rs-spec-viewer.css, .sv-head-btn);
   these are the button basics that the IR viewer's button gets from its .ir-btn class ---- */

#nmr-tool-wrapper #nmr-btn-help {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}

#nmr-tool-wrapper #nmr-study-context-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---- set-up: Explore ---- */

#nmr-tool-wrapper #view-config-explore .nmr-config-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

#nmr-tool-wrapper #view-config-explore select {
  margin-bottom: 8px;
}

/* ---- set-up: Deduce and Predict ---- */

#nmr-tool-wrapper .nmr-filter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

#nmr-tool-wrapper .nmr-filter-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

#nmr-tool-wrapper .nmr-filter-section h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.2;
}

#nmr-tool-wrapper .nmr-filter-option-grid label[hidden] {
  display: none;
}

#nmr-tool-wrapper .nmr-filter-count {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: fit-content;
  margin: 6px 0 0;
  padding: 6px 12px;
  border-left: 4px solid var(--info-line);
  border-radius: 0 10px 10px 0;
  background: var(--info-bg);
  color: var(--ink);
  font-size: 0.92rem;
}

#nmr-tool-wrapper .nmr-filter-count strong {
  font-size: 1.15rem;
  line-height: 1;
}

#nmr-tool-wrapper .nmr-filter-count.is-empty {
  border-left-color: var(--accent);
  background: var(--err-bg);
  color: var(--err-text);
}

/* phone: one column of functional groups, so no label breaks inside its formula */

@container svview (max-width: 460px) {
  #nmr-tool-wrapper #filter-fg-group {
    grid-template-columns: minmax(0, 1fr);
  }
}

@container svview (min-width: 620px) {
  #nmr-tool-wrapper #view-config-explore .nmr-config-panel {
    grid-template: auto auto / repeat(2, minmax(0, 300px));
    grid-auto-flow: column;
    column-gap: 16px;
  }
}

@container svview (min-width: 620px) {
  #nmr-tool-wrapper #view-config-explore select {
    margin-bottom: 0;
  }
}

@container svview (min-width: 620px) {
  #nmr-tool-wrapper .nmr-filter-layout {
    grid-template-columns: minmax(150px, 0.8fr) minmax(150px, 0.8fr) minmax(0, 2.2fr);
    gap: 20px;
  }
}

@container svview (min-width: 620px) {
  #nmr-tool-wrapper #filter-fg-group {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  }
}

/* ---- workspace ---- */

#nmr-tool-wrapper #btn-ws-exit-explore {
  margin-left: auto;
}

#nmr-tool-wrapper #ws-toolbar-question {
  justify-content: space-between;
}

/* one grid for the structure parts, the spectrum and the drawing panel (the molecule panel is
   display: contents, from the shared .sv-structure-panel). Phone: structure, spectrum, note,
   hints, drawing. Wide: spectrum left, structure and note right, then hints and drawing below. */

#nmr-tool-wrapper .nmr-workspace-main {
  grid-template-areas: "mt" "mol" "reset" "spec" "act" "xn" "fb" "expl" "note" "clues" "builder" "rep";
}

/* round 5: the Predict action row (act) replaces the answer group (ans) */

#nmr-tool-wrapper #nmr-predict-actions {
  grid-area: act;
}

/* 30 Nov 2026: + the signal box (note, S7b); + Reveal / Check answer (ans), the proton exchange note (xn) and the report link (rep), round 4 */

#nmr-tool-wrapper #nmr-explanation-container {
  grid-area: expl;
  margin: 12px 0 0;
}

#nmr-tool-wrapper #nmr-predict-feedback {
  grid-area: fb;
  min-width: 0;
}

/* 30 Nov 2026 (round 3): Predict feedback in its own row, the full width of the card when wide */

#nmr-tool-wrapper .nmr-clues-container {
  margin: 16px 0 0;
}

#nmr-tool-wrapper .nmr-clues-list {
  margin: 0;
  padding-left: 20px;
}

#nmr-tool-wrapper .nmr-clues-list li + li {
  margin-top: 4px;
}

/* round 4: the picker widths are shared now (a row of their own, rs-spec-viewer.css). Deduce's "Hints used"
     moves beside the spectrum, under the title (as in the ¹³C viewer), where the hidden structure leaves room */

@container svview (min-width: 700px) {
  #nmr-tool-wrapper .nmr-workspace-main {
    grid-template: "spec mt" auto "spec clues" auto "spec mol" auto "spec reset" auto "spec expl" auto "spec note" 1fr "act act" auto "xn xn" auto "fb fb" auto "builder builder" auto "rep rep" auto / minmax(0, 1.85fr) minmax(220px, 1fr);
  }
}

/* ---- structure: name and formula, drawing, hidden-structure note ---- */

#nmr-tool-wrapper .nmr-molecule-title-name {
  overflow-wrap: anywhere;
}

#nmr-tool-wrapper .nmr-molecule-title-formula {
  white-space: nowrap;
}

#nmr-tool-wrapper .nmr-molecule-title-formula::before {
  content: " (";
}

#nmr-tool-wrapper .nmr-molecule-title-formula::after {
  content: ")";
}

#nmr-tool-wrapper .nmr-molecule-title:focus {
  outline: none;
}

#nmr-tool-wrapper .nmr-molecule-title:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

#nmr-tool-wrapper #nmr-mol-drag-wrapper {
  user-select: none;
  -webkit-user-select: none;
}

#nmr-tool-wrapper #nmr-molecule-svg {
  display: block;
  width: 100%;
  height: 100%;
}

#nmr-tool-wrapper .nmr-mol-group {
  cursor: pointer;
}

#nmr-tool-wrapper .nmr-mol-group text {
  fill: var(--ink);
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
}

/* 30 Nov 2026 (round 2): the drawings colour some atoms (Cl green, O red, N blue) with fill attributes in
   the data; the same hues darkened to 4.5:1 on the white structure box, by the ¹³C viewer's rule */

#nmr-tool-wrapper #nmr-molecule-zoom-group text[fill="#2ecc71"] {
  fill: #25242f;
}

#nmr-tool-wrapper #nmr-molecule-zoom-group text[fill="#e74c3c"] {
  fill: #25242f;
}

#nmr-tool-wrapper #nmr-molecule-zoom-group text[fill="#2980b9"] {
  fill: #25242f;
}

#nmr-tool-wrapper #nmr-molecule-zoom-group text[fill="#8e44ad"] {
  fill: #25242f;
}

#nmr-tool-wrapper .nmr-mol-group line {
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
}

#nmr-tool-wrapper .nmr-mol-group .nmr-env-label {
  fill: var(--muted);
  font-size: 14px;
}

#nmr-tool-wrapper .nmr-hover-rect {
  fill: transparent;
  stroke: none;
}

#nmr-tool-wrapper .nmr-molecule-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--soft);
  color: var(--muted);
  text-align: center;
}

#nmr-tool-wrapper .nmr-molecule-overlay p {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

/* the molecule's note (Show note / Hide note): the shared explanation box */

#nmr-tool-wrapper #nmr-explanation-text > .nmr-explanation-toggle {
  margin: 0;
}

#nmr-tool-wrapper .nmr-explanation-body {
  margin: 10px 0 0;
  line-height: 1.45;
}

#nmr-tool-wrapper .nmr-explanation-body > :first-child {
  margin-top: 0;
}

#nmr-tool-wrapper .nmr-explanation-body > :last-child {
  margin-bottom: 0;
}

/* ---- spectrum: signals, integration traces and numbers, multiplicity names, peak letters ---- */

/* the viewBox is 0 -60 800 410: 60 units of room above the peaks for their labels */

#nmr-tool-wrapper .nmr-spectrum-svg {
  aspect-ratio: 800 / 410;
  cursor: crosshair;
  touch-action: pan-y;
}

#nmr-tool-wrapper .nmr-axis-label, #nmr-tool-wrapper .nmr-axis-title {
  text-anchor: middle;
}

#nmr-tool-wrapper .nmr-peak-group {
  cursor: pointer;
}

#nmr-tool-wrapper .nmr-peak-hitbox {
  fill: transparent;
}

#nmr-tool-wrapper .nmr-peak-line {
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
}

#nmr-tool-wrapper .nmr-leader {
  stroke: var(--edge);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

#nmr-tool-wrapper .nmr-peak-letter {
  font-size: 14px;
  font-weight: 900;
}

#nmr-tool-wrapper .nmr-mult-label {
  display: none;
  fill: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

#nmr-tool-wrapper .nmr-show-multiplicity .nmr-mult-label {
  display: inline;
}

#nmr-tool-wrapper .nmr-integration-curve {
  display: none;
  fill: none;
  stroke: var(--lb-text);
  stroke-width: 2;
}

#nmr-tool-wrapper .nmr-integration-text {
  display: none;
  fill: var(--lb-text);
  font-size: 14px;
  font-weight: 900;
}

#nmr-tool-wrapper .nmr-show-integration :is(.nmr-integration-curve, .nmr-integration-text) {
  display: inline;
}

#nmr-tool-wrapper .nmr-zoom-box {
  display: none;
  fill: rgba(91, 164, 207, 0.2);
  stroke: var(--blue);
  stroke-width: 1;
  pointer-events: none;
}

/* the other signals and groups fade while one is highlighted (as in the IR viewer); the text of
   the chosen one stays at full strength */

#nmr-tool-wrapper .nmr-faded {
  opacity: 0.22;
}

/* labels grow on a narrow spectrum, like the shared axis text */

#nmr-tool-wrapper :is(.nmr-peak-letter, .nmr-mult-label, .nmr-integration-text) {
  transform-box: fill-box;
  transform-origin: center bottom;
}

@container svspec (max-width: 620px) {
  #nmr-tool-wrapper :is(.nmr-peak-letter, .nmr-mult-label, .nmr-integration-text) {
    transform: scale(1.35);
  }
}

@container svspec (max-width: 440px) {
  #nmr-tool-wrapper :is(.nmr-peak-letter, .nmr-mult-label, .nmr-integration-text) {
    transform: scale(2.3);
  }
}

@container svspec (max-width: 440px) {
  #nmr-tool-wrapper .nmr-peak-line {
    stroke-width: 3;
  }
}

@container svspec (max-width: 440px) {
  #nmr-tool-wrapper .nmr-axis-title {
    translate: 0 30px;
  }
}

/* clear of the larger tick numbers */

/* keyboard focus on a signal or a structure group: a ring drawn round its hit area (an SVG
   group has no usable CSS outline) */

#nmr-tool-wrapper :is(.nmr-peak-group, .nmr-mol-group):focus {
  outline: none;
}

#nmr-tool-wrapper .nmr-peak-group:focus-visible .nmr-peak-hitbox, #nmr-tool-wrapper .nmr-mol-group:focus-visible .nmr-hover-rect {
  stroke: var(--focus);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  rx: 6px;
}

/* ---- actions under the spectrum, and the feedback ---- */

#nmr-tool-wrapper .nmr-feedback:focus {
  outline: none;
}

#nmr-tool-wrapper .nmr-feedback.info {
  border-color: var(--info-line);
  background: var(--info-bg);
  color: var(--ink);
}

/* "Answer:" after Reveal structure */

#nmr-tool-wrapper .nmr-feedback .title {
  font-weight: 900;
}

#nmr-tool-wrapper .nmr-feedback-list {
  margin: 8px 0 0;
  padding-left: 20px;
}

#nmr-tool-wrapper .nmr-feedback-list li + li {
  margin-top: 4px;
}

/* ---- Predict: the peak window (opens over the spectrum where the peak is) ---- */

#nmr-tool-wrapper .nmr-peak-modal {
  display: none;
  position: absolute;
  z-index: 100;
  width: 250px;
  max-width: calc(100% - 8px);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  user-select: text;
}

#nmr-tool-wrapper .nmr-peak-modal h4 {
  margin: 0 0 10px;
  padding-right: 40px;
  font-size: 1rem;
}

#nmr-tool-wrapper .nmr-peak-modal label {
  display: block;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

#nmr-tool-wrapper .nmr-peak-modal :is(input, select) {
  width: 100%;
  margin: 0 0 12px;
}

#nmr-tool-wrapper input[type="number"] {
  min-height: 40px;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
}

#nmr-tool-wrapper .nmr-peak-modal .nmr-modal-buttons {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* ---- Deduce: the drawing panel (the editor itself is JSME, from an external host) ---- */

#nmr-tool-wrapper .nmr-structure-builder-panel {
  grid-area: builder;
  min-width: 0;
  margin: 16px 0 0;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--soft);
}

#nmr-tool-wrapper .nmr-structure-builder-inner {
  width: 100%;
  max-width: 1050px;
  margin: 0 auto;
}

#nmr-tool-wrapper .nmr-structure-builder-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 12px;
}

#nmr-tool-wrapper .nmr-structure-builder-heading h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

#nmr-tool-wrapper .nmr-structure-builder-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

#nmr-tool-wrapper .nmr-jsme-status {
  flex: none;
  padding: 6px 10px;
  border: 1px solid var(--info-line);
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

#nmr-tool-wrapper .nmr-jsme-status.ready {
  border-color: var(--ok-edge);
  background: var(--ok-bg);
  color: var(--ok-text);
}

#nmr-tool-wrapper .nmr-jsme-status.error {
  border-color: var(--accent);
  background: var(--err-bg);
  color: var(--err-text);
}

#nmr-tool-wrapper .nmr-jsme-shell {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

#nmr-tool-wrapper #nmr-jsme-container {
  width: 100%;
  min-height: 300px;
  line-height: normal;
}

#nmr-tool-wrapper #nmr-jsme-container > div {
  border: 0;
}

#nmr-tool-wrapper .nmr-structure-builder-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
}

#nmr-tool-wrapper .nmr-structure-feedback.info {
  border-color: var(--info-line);
  background: var(--info-bg);
  color: var(--ink);
}

@container svview (max-width: 699px) {
  #nmr-tool-wrapper .nmr-structure-builder-heading {
    flex-direction: column;
  }
}

@container svview (max-width: 699px) {
  #nmr-tool-wrapper .nmr-jsme-status {
    white-space: normal;
  }
}

@container svview (max-width: 699px) {
  #nmr-tool-wrapper #nmr-jsme-container {
    min-height: 280px;
  }
}

@media (max-width: 520px) {
  #nmr-tool-wrapper .nmr-structure-builder-panel {
    padding: 12px;
  }
}

/* ---- exam answer layout: rows link to the spectrum and structure ---- */

#nmr-tool-wrapper .nmr-data-table tbody tr {
  cursor: pointer;
}

#nmr-tool-wrapper .nmr-data-table tbody tr:hover td {
  background: var(--soft);
}

#nmr-tool-wrapper .nmr-data-table tbody tr.nmr-table-row-highlight td {
  background: var(--tab);
  font-weight: 800;
}

#nmr-tool-wrapper .nmr-data-table td[colspan] {
  padding: 20px;
  color: var(--muted);
  text-align: center;
  cursor: default;
}

/* ---- cheat sheet ---- */

#nmr-tool-wrapper #nmr-help-content {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
}

#nmr-tool-wrapper #nmr-help-content ul {
  margin: 0;
  padding-left: 20px;
}

#nmr-tool-wrapper #nmr-help-content li + li {
  margin-top: 10px;
}

/* ---- data sheet window: the viewer sets its position, size and frame; these are the rest ---- */

#nmr-datasheet-modal #nmr-datasheet-heading {
  margin: 0;
  color: var(--ink);
  font-size: 1.2rem;
}

#nmr-datasheet-modal .nmr-datasheet-titlebar {
  touch-action: none;
}

#nmr-datasheet-modal #nmr-datasheet-close:hover {
  background: var(--soft);
}

#nmr-datasheet-modal .nmr-datasheet-resize-handle {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 2;
  width: 18px;
  height: 18px;
  border-right: 3px solid var(--edge);
  border-bottom: 3px solid var(--edge);
  cursor: nwse-resize;
}

/* ---- full screen: a taller structure and drawing area come from the shared rules ---- */

#nmr-tool-wrapper:fullscreen .nmr-structure-builder-inner {
  max-width: 1100px;
}

/* 30 Nov 2026 (round 3): what Add D₂O did ("proton exchange", OCR A only); takes no room while empty.
   Round 4: its own row (xn), the full width of the card when wide, like the Predict feedback */

#nmr-tool-wrapper .nmr-d2o-note {
  grid-area: xn;
  min-width: 0;
  margin: 12px 0 0;
  font-size: 0.95rem;
}

#nmr-tool-wrapper .nmr-d2o-note:empty {
  display: none;
}

/* ---- 30 Nov 2026 (round 5) ---- */

/* full screen Deduce: the drawing panel sits beside the spectrum, under the title and the hints used */

@container svview (min-width: 700px) {
  #nmr-tool-wrapper:fullscreen .nmr-workspace-main.nmr-structure-builder-active {
    grid-template: "spec mt" auto "spec clues" auto "spec mol" auto "spec reset" auto "spec expl" auto "spec builder" auto "spec note" 1fr "act act" auto "xn xn" auto "fb fb" auto "rep rep" auto / minmax(0, 1.1fr) minmax(420px, 1fr);
  }
}

@container svview (min-width: 700px) {
  #nmr-tool-wrapper:fullscreen .nmr-structure-builder-active .nmr-structure-builder-panel {
    margin: 4px 0 0;
    padding: 12px 14px;
  }
}

/* full screen: the drawing panel's line repeats the instructions line above it, so it is left out there */

#nmr-tool-wrapper:fullscreen .nmr-structure-builder-heading p {
  display: none;
}

#nmr-tool-wrapper:fullscreen .nmr-structure-builder-heading {
  margin-bottom: 8px;
}

#nmr-tool-wrapper:fullscreen .nmr-structure-builder-actions {
  column-gap: 12px;
  margin-top: 8px;
}

/* full screen Explore and Predict: the signal box keeps its room (see rs-spec-viewer.css) */

#nmr-tool-wrapper:fullscreen .nmr-workspace-main:not(.nmr-structure-builder-active) .sv-note-slot {
  display: block;
  min-height: var(--sv-fs-note, 140px);
}

/* Predict, wide: the action row comes straight under the spectrum and the structure. The signal box keeps its
   room beside the spectrum (so it never pushes the row down when it appears); the molecule's Show note goes
   under the row */

@container svview (min-width: 700px) {
  #nmr-tool-wrapper .nmr-workspace-main.sv-st-check-h:not(#nmr-btn-check) {
    grid-template: "spec mt" auto "spec clues" auto "spec mol" auto "spec reset" auto "spec note" 1fr "act act" auto "expl expl" auto "xn xn" auto "fb fb" auto "builder builder" auto "rep rep" auto / minmax(0, 1.85fr) minmax(220px, 1fr);
  }
}

@container svview (min-width: 700px) {
  #nmr-tool-wrapper .nmr-workspace-main.sv-st-check-h:not(#nmr-btn-check) .sv-note-slot {
    display: block;
    min-height: 128px;
  }
}

@container svview (min-width: 700px) {
  #nmr-tool-wrapper .nmr-workspace-main.sv-st-check-h:not(#nmr-btn-check) .sv-spectrum-panel {
    align-self: stretch;
  }
}

@container svview (min-width: 700px) {
  #nmr-tool-wrapper .nmr-workspace-main.sv-st-check-h:not(#nmr-btn-check) .sv-spectrum {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
  }
}

/* full screen Predict: the right column is wider there, so the note needs less room */

#nmr-tool-wrapper:fullscreen .nmr-workspace-main.sv-st-check-h:not(#nmr-btn-check) .sv-note-slot {
  min-height: 100px;
}

