/* =====================================================================================
   CNMRviewer.css: the ¹³C NMR viewer's own rules (#cnmr-tool-wrapper).
   Load after rs-spec-viewer.css, which holds the card, head row, controls, panels, explanation
   box and spectrum box (the markup carries the shared .sv-* classes). This file: set-up forms,
   the workspace grid (with the Deduce drawing panel), structure drawing, spectrum marks (peaks,
   letters), the Predict peak window, the drawing panel, feedback, the exam answer table, the data
   sheet window and full screen. 29 Nov 2026. Replaces the old CNMRviewer.css and the page's inline
   <style> blocks for this viewer. No important flags.
   ===================================================================================== */

/* ---- head and set-up ---- */

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

#cnmr-tool-wrapper .cnmr-landing-note {
  margin: 0 0 14px;
}

#cnmr-tool-wrapper .cnmr-landing-note p {
  margin: 0;
  color: var(--ink);
}

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

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

#cnmr-tool-wrapper .cnmr-filter-page-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 12px;
}

#cnmr-tool-wrapper .cnmr-filter-page-heading h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

#cnmr-tool-wrapper .cnmr-filter-page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

#cnmr-tool-wrapper .cnmr-filter-count {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--info-line);
  border-radius: 12px;
  background: var(--info-bg);
  color: var(--ink);
}

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

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

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

#cnmr-tool-wrapper .cnmr-filter-section {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #fff;
}

#cnmr-tool-wrapper .cnmr-filter-section h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

#cnmr-tool-wrapper .cnmr-filter-section h3 label {
  font: inherit;
  color: inherit;
}

#cnmr-tool-wrapper .cnmr-filter-section select {
  width: 100%;
}

#cnmr-tool-wrapper .cnmr-filter-option-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 14px;
}

#cnmr-tool-wrapper .cnmr-filter-option-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.25;
  cursor: pointer;
}

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

@container svview (min-width: 520px) {
  #cnmr-tool-wrapper .cnmr-filter-option-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

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

@container svview (min-width: 620px) {
  #cnmr-tool-wrapper .cnmr-filter-page-heading {
    flex-direction: row;
    justify-content: space-between;
  }
}

@container svview (min-width: 620px) {
  #cnmr-tool-wrapper .cnmr-filter-layout {
    grid-template-columns: minmax(200px, 0.75fr) minmax(0, 1.75fr);
  }
}

@container svview (min-width: 620px) {
  #cnmr-tool-wrapper .cnmr-filter-section-functional {
    grid-column: 1 / -1;
  }
}

@container svview (min-width: 620px) {
  #cnmr-tool-wrapper .cnmr-filter-option-grid label {
    min-height: 32px;
  }
}

@container svview (min-width: 900px) {
  #cnmr-tool-wrapper .cnmr-filter-functional-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

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

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

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

/* 30 Nov 2026 (round 4): the picker widths are shared now (a row of their own, rs-spec-viewer.css) */

/* the grid: the shared order plus the hidden-molecule note (expl) and the Deduce drawing panel
   (builder). Phone: title, hints, structure, spectrum, explanation, drawing. Wide: spectrum left;
   title, hints, structure and explanation right; the drawing panel across the bottom. */

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

/* 30 Nov 2026: + Predict feedback (fb, round 3); + the report link (rep), round 4; round 5: the Predict action row (act: Add peak, Clear all peaks, Reveal answer, Check answer) replaces the answer group (ans) */

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

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

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

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

#cnmr-tool-wrapper #cnmr-explanation-container {
  grid-area: expl;
}

#cnmr-tool-wrapper .cnmr-explanation-body {
  margin-top: 8px;
}

#cnmr-tool-wrapper .cnmr-clues-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
}

#cnmr-tool-wrapper .cnmr-clues-list li {
  margin-bottom: 4px;
}

/* the title: name, then the formula in a soft pill (in Deduce: "Unknown" and the formula) */

#cnmr-tool-wrapper .cnmr-molecule-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}

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

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

#cnmr-tool-wrapper .cnmr-molecule-title-formula {
  padding: 1px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

/* ---- structure drawing ---- */

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

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

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

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

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

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

/* 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 (the data is unchanged) */

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

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

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

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

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

#cnmr-tool-wrapper .cnmr-mol-group:hover .cnmr-hover-rect {
  fill: rgba(211, 62, 22, 0.05);
  stroke: rgba(211, 62, 22, 0.16);
}

#cnmr-tool-wrapper .cnmr-molecule-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  text-align: center;
}

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

/* fading: the other peaks and groups while one is highlighted (the owner's decision for IR: they
   may stay faded; the highlighted one is named in the explanation box) */

#cnmr-tool-wrapper :is(.cnmr-mol-group, .cnmr-peak-group).cnmr-faded {
  opacity: 0.22;
}

/* ---- spectrum marks: peaks (blue band when highlighted), letters ---- */

#cnmr-tool-wrapper #cnmr-spectrum-svg {
  cursor: crosshair;
  touch-action: pan-y;
}

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

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

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

#cnmr-tool-wrapper .cnmr-peak-group:is(.cnmr-highlighted-spec, .cnmr-highlight-locked) .cnmr-peak-hitbox {
  fill: rgba(91, 164, 207, 0.18);
  stroke: var(--zone);
  stroke-width: 1.5;
}

#cnmr-tool-wrapper .cnmr-peak-letter {
  font-size: 14px;
  font-weight: 900;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  stroke-linejoin: round;
}

#cnmr-tool-wrapper .cnmr-label-guide {
  stroke: var(--muted);
  stroke-width: 1;
  pointer-events: none;
}

#cnmr-tool-wrapper .cnmr-axis-tick-minor {
  stroke-width: 1;
}

#cnmr-tool-wrapper .cnmr-zoom-box {
  stroke: var(--blue);
  stroke-width: 1;
  pointer-events: none;
}

@container svspec (max-width: 620px) {
  #cnmr-tool-wrapper .cnmr-peak-letter {
    font-size: 20px;
  }
}

@container svspec (max-width: 440px) {
  #cnmr-tool-wrapper .cnmr-peak-letter {
    font-size: 33px;
    stroke-width: 5px;
  }
}

/* ---- Predict: the peak window ---- */

#cnmr-tool-wrapper .cnmr-peak-modal {
  position: absolute;
  z-index: 20;
  display: none;
  width: 250px;
  max-width: calc(100% - 8px);
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

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

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

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

#cnmr-tool-wrapper .cnmr-peak-modal input {
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
}

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

/* ---- feedback (the script sets these class names) ---- */

#cnmr-tool-wrapper #cnmr-predict-feedback {
  display: none;
}

#cnmr-tool-wrapper :is(.cnmr-feedback, .cnmr-structure-feedback) {
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--info-line);
  border-radius: 12px;
  background: var(--info-bg);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.45;
}

#cnmr-tool-wrapper :is(.cnmr-feedback, .cnmr-structure-feedback).error {
  border-color: var(--err-line);
  background: var(--err-bg);
  color: var(--err-text);
}

#cnmr-tool-wrapper :is(.cnmr-feedback, .cnmr-structure-feedback).success {
  border-color: var(--ok-line);
  background: var(--ok-bg);
  color: var(--ok-text);
}

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

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

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

#cnmr-tool-wrapper .cnmr-feedback-list li {
  margin-bottom: 4px;
}

/* ---- Deduce: the drawing panel (the JSME editor itself is third-party) ---- */

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

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

#cnmr-tool-wrapper .cnmr-structure-builder-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 12px;
}

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

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

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

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

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

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

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

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

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

@container svview (min-width: 700px) {
  #cnmr-tool-wrapper .cnmr-structure-builder-heading {
    flex-direction: row;
    justify-content: space-between;
    gap: 12px;
  }
}

@container svview (min-width: 700px) {
  #cnmr-tool-wrapper #cnmr-jsme-container {
    min-height: 300px;
  }
}

/* ---- exam answer layout ---- */

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

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

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

#cnmr-tool-wrapper .cnmr-table-empty {
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

/* ---- windows: the data sheet (moved and resized by the script), and the cheat sheet list ---- */

#cnmr-tool-wrapper .cnmr-datasheet-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 2147483000;
  width: min(1000px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  padding: 16px;
  overflow: hidden;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
}

#cnmr-tool-wrapper .cnmr-datasheet-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  margin: 0 0 10px;
  padding-right: 44px;
  cursor: move;
  user-select: none;
}

#cnmr-tool-wrapper .cnmr-datasheet-titlebar h3 {
  margin: 0;
  font-size: 1.05rem;
}

#cnmr-tool-wrapper .cnmr-datasheet-wrapper {
  width: 100%;
  max-height: calc(100vh - 130px);
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--soft);
  cursor: grab;
}

#cnmr-tool-wrapper #cnmr-datasheet-img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: top left;
  pointer-events: none;
}

#cnmr-tool-wrapper .cnmr-datasheet-resize-handle {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 18px;
  height: 18px;
  border-right: 3px solid var(--edge);
  border-bottom: 3px solid var(--edge);
  cursor: nwse-resize;
}

#cnmr-tool-wrapper .cnmr-help-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
}

#cnmr-tool-wrapper .cnmr-help-list li {
  margin-bottom: 10px;
}

/* ---- full screen: the drawing panel stays a sensible width ---- */

#cnmr-tool-wrapper:fullscreen {
  background: #fff;
}

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

/* ---- 29 Nov 2026 accessibility ---- */

/* (d) keyboard focus on a peak or a structure group: the 3px focus colour, drawn round the peak's
   band or the group's box (an SVG <g> has no usable CSS outline) */

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

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

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

/* full screen Deduce: the drawing panel sits beside the spectrum, in the column the hidden structure leaves
   empty, so the spectrum, the hints and the drawing are all on the screen at once */

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

@container svview (min-width: 700px) {
  #cnmr-tool-wrapper:fullscreen .cnmr-structure-builder-active .cnmr-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 */

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

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

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

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

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

/* Predict, wide: the action row comes straight under the spectrum and the structure. The peak note keeps its
   room beside the spectrum (so it never pushes the row down when it appears), and the molecule's note
   (expl), when there is one, goes under the row */

@container svview (min-width: 700px) {
  #cnmr-tool-wrapper .cnmr-workspace-main.sv-st-check-c:not(#cnmr-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 "fb fb" auto "builder builder" auto "rep rep" auto / minmax(0, 1.85fr) minmax(220px, 1fr);
  }
}

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

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

@container svview (min-width: 700px) {
  #cnmr-tool-wrapper .cnmr-workspace-main.sv-st-check-c:not(#cnmr-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 */

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

