/* Chemie-Module im Bedienfeld (ui/module-ui.js, module/*.js). Nur Variablen der App, hell und dunkel.
   Ein Raster für alle Module (Bausteine aus ui/module-ui.js und module/module2-ui.js):
   Beschriftung (feste Breite, eine Zeile) | Feld (Eingabe + Spalte für die Einheit), Segmente und Knopfzeilen als
   gleich breite Spalten, Ergebnisse als Wertetabelle (Name gedämpft links, Wert in Mono rechts). */

/* ---------- Auswahl ---------- */
.modul-vorschlag { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; margin: 0 0 10px;
  border: 1px dashed var(--btn-on-edge); border-radius: 10px; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.modul-vorschlag-text { flex: 1 1 auto; min-width: 0; font-size: var(--gr-klein); color: var(--muted); line-height: 1.4; }
.modul-vorschlag-text b { color: var(--text); font-weight: 600; }
.modul-vorschlag .chip { flex: none; }
.modul-auswahl { display: grid; gap: 12px; }
.modul-gruppe { display: grid; gap: 4px; }
.modul-gruppe-titel { font-family: var(--schrift-mono); font-size: var(--gr-label); color: var(--faint, var(--muted)); letter-spacing: .08em; text-transform: uppercase; margin: 0 0 2px; }
.modul-wahl { display: grid; gap: 2px; text-align: left; padding: 8px 11px; width: 100%; }
.modul-wahl-titel { font-weight: 600; font-size: var(--gr-panel); }
.modul-wahl-text { color: var(--muted); font-size: var(--gr-klein); line-height: 1.35; }

/* Kopf des offenen Moduls: Titel und Schliessen-Knopf in einer Zeile */
.modul-kopf { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; margin: -4px 0 12px; }
.modul-titel { min-width: 0; font-family: var(--schrift-titel); font-weight: 600; font-size: var(--gr-titel); line-height: 1.25;
  text-wrap: balance; overflow-wrap: anywhere; hyphens: auto; }
.modul-zu { color: var(--muted); align-self: start; }
.modul-kopf .chip { white-space: nowrap; }

/* ---------- Raster ---------- */
.modul-box {
  container: modul / inline-size;
  --m-lab: 112px;              /* Breite der Beschriftung */
  --m-einh: 58px;              /* Spalte für die Einheit */
  --m-zeile: 34px;             /* Mindesthöhe einer Zeile */
  min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr);
}
@container modul (min-width: 400px) {
  .modul-box > * { --m-lab: 148px; }
}

/* Abschnitte: Linie oben, Überschrift als Label */
.m2-teil, .m-teil { min-width: 0; padding: 12px 0 6px; border-top: 1px solid var(--line); }
.m2-teil:first-child, .m-teil:first-child { border-top: 0; padding-top: 0; }
.m2-teil > .label, .m-teil > .label, .modul-box .m-erg-kopf { margin: 0 0 10px; }
.m-teil { margin-top: 6px; }
.modul-box .m-erg-kopf { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
/* Zeile Beschriftung | Feld */
.m-feld, .m2-feld {
  display: grid; grid-template-columns: var(--m-lab) minmax(0, 1fr); gap: 10px; align-items: center;
  min-height: var(--m-zeile); margin: 0 0 6px;
}
.m-feld > label, .m2-feld > label {
  min-width: 0; color: var(--muted); font-size: var(--gr-panel); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-feld > select, .m-feld > input, .m-feld .m-text { width: 100%; min-width: 0; }
.m-feld .m-text, .modul-box input.m-text { font-family: var(--schrift-text); }
/* Feld: Eingabe links, Einheit in fester Spalte, damit alle Eingaben gleich breit sind */
.m-eingabe, .m2-eingabe { display: grid; grid-template-columns: minmax(0, 1fr) var(--m-einh); gap: 6px; align-items: center; min-width: 0; }
.m-eingabe > input, .m2-eingabe > input, .m2-eingabe > select { width: 100%; min-width: 0; }
.m2-eingabe > select:only-child { grid-column: 1 / -1; }
.m-einheit, .m2-einheit {
  min-width: 0; color: var(--muted); font-family: var(--schrift-mono); font-size: var(--gr-klein);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Verhältnis n(Probe) : n(Titer) */
.m-eingabe.m-stoech { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); margin-right: calc(var(--m-einh) + 6px); }
.m-stoech input { text-align: center; }
.m-stoech .m-einheit { overflow: visible; }

/* Segmente: gleich breite Spalten in einer Reihe */
.modul-box .segment {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; margin: 0 0 10px;
}
.modul-box .segment button { min-width: 0; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Schalter */
.modul-box .schalter { min-height: 30px; padding: 3px 0; margin: 0 0 2px; line-height: 1.3; }
.modul-box .schalter input { flex: none; }

/* Knopfzeilen: gleich breite Knöpfe in einer Reihe */
.modul-box .zeile { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; margin: 4px 0 10px; }
.modul-box .zeile > button { min-width: 0; padding-left: 8px; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* einzelner Knopf (z. B. «Im Graphen: …») */
.modul-box .m2-teil > .chip, .modul-box .m2-teil > div > .chip, .m-optionen > .chip { max-width: 100%; margin: 0 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Hinweise: klein und gedämpft */
.modul-box .hinweis { font-size: var(--gr-klein); line-height: 1.45; color: var(--muted); margin: 0 0 10px; }
.modul-box .hinweis.warn { color: var(--warn); }
.modul-box .hinweis[hidden] { display: none; }

.m-optionen { margin: 2px 0 6px; }
.m-optionen .m-feld { margin-top: 4px; }

/* ---------- Ergebnisse: Wertetabelle ----------
   Zeile: Name gedämpft links, Wert in Mono rechts; passt beides nicht nebeneinander, rückt der Wert rechtsbündig
   in die nächste Zeile. Gilt für .m-ergebnis (ui/module-ui.js) und dl.m2-ergebnis (module2-ui.js). */
.m-ergebnis { display: grid; margin: 0 0 8px; font-size: var(--gr-panel); }
.m-ergebnis:empty { display: none; }
.m-ergebnis .hinweis { margin: 6px 0 4px; }
.m-erg-titel { font-weight: 600; font-size: var(--gr-panel); margin: 10px 0 2px; }
.m-erg-titel:first-child { margin-top: 0; }
.m-erg-zeile {
  display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; row-gap: 0;
  padding: 4px 0; border-top: 1px solid var(--line);
}
.m-erg-zeile:first-child, .m-erg-titel + .m-erg-zeile, .m-erg-zeile.weiter { border-top: 0; }
.m-erg-zeile.weiter { padding-top: 0; }
.m-erg-zeile > span, .m-erg-zeile > dt {
  flex: 1 1 auto; min-width: 0; max-width: 100%; margin: 0; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-erg-zeile > b, .m-erg-zeile > dd {
  flex: 0 1 auto; max-width: 100%; margin: 0 0 0 auto; text-align: right; white-space: nowrap;
  font-family: var(--schrift-mono); font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text);
}
.m-erg-zeile:is(.haupt, .gross) > :first-child { color: var(--text); }
.m-erg-zeile:is(.haupt, .gross) > :last-child { font-weight: 600; font-size: var(--gr-text); }
.m-erg-zeile.ok > :last-child { color: var(--ok); }
.m-erg-zeile.klein { font-size: var(--gr-klein); }
/* Wert als Text (z. B. «Masse eingeben», «kein Plateau gefunden») */
.m-erg-zeile.text > :last-child { font-family: var(--schrift-text); font-weight: 400; white-space: normal; text-align: left; }
/* Warnung: über die ganze Breite, ohne Namen */
.m-erg-zeile.warn { border-top: 0; padding: 6px 0; }
.m-erg-zeile.warn > :first-child { display: none; }
.m-erg-zeile.warn > :last-child { margin: 0; flex: 1 1 100%; white-space: normal; text-align: left; color: var(--warn); font-family: var(--schrift-text); font-size: var(--gr-klein); line-height: 1.45; }

/* ---------- Schmelzpunkt ---------- */
.sp-anzeige { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 12px; background: var(--btn); margin-bottom: 12px; }
.sp-temp { font-family: var(--schrift-mono); font-size: clamp(38px, 4.5vw, 54px); font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }
.sp-temp small { font-size: var(--gr-titel); color: var(--muted); margin-left: 8px; }
.sp-rate { display: flex; align-items: center; gap: 8px; font-size: var(--gr-klein); color: var(--muted); margin-top: 4px; line-height: 1.35; }
.sp-ampel { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 20%, transparent); }
.sp-ampel[data-stufe="ideal"] { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.sp-ampel[data-stufe="schnell"] { background: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 25%, transparent); }
.sp-ampel[data-stufe="langsam"] { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); }
.sp-hinweis { font-weight: 600; border-left: 3px solid var(--warn); padding-left: 8px; }
.sp-kapillaren { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-bottom: 10px; }
.sp-kap { min-width: 0; border: 1px solid var(--line); border-left: 4px solid var(--kap-farbe, var(--accent)); border-radius: 10px; padding: 8px 10px; background: var(--btn); }
.sp-kap-kopf { display: grid; grid-template-columns: auto minmax(0, 1fr) 64px auto; gap: 6px; align-items: center; }
.sp-nr { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; font-family: var(--schrift-mono); font-size: var(--gr-klein);
  border: 1px solid var(--line); border-bottom-width: 2px; color: var(--text); }
.sp-kap-kopf .m-text { width: 100%; min-width: 0; font-family: var(--schrift-text) !important; }
.sp-lit { width: 100%; min-width: 0; }
.sp-knoepfe { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.sp-mess { display: grid; gap: 1px; text-align: left; padding: 6px 10px; min-width: 0; }
.sp-mess span { font-size: var(--gr-klein); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-mess b { font-family: var(--schrift-mono); font-weight: 500; font-size: var(--gr-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-mess:disabled { opacity: 1; cursor: default; }
.sp-mess:disabled span { opacity: .7; }
.sp-erg { margin-top: 6px; }
.sp-rein { margin: 6px 0 0; font-size: var(--gr-klein); line-height: 1.4; color: var(--muted); }
.sp-rein[data-stufe="rein"] { color: var(--ok); }
.sp-rein[data-stufe="unrein"] { color: var(--warn); }
.sp-misch { width: 100%; }

@media (pointer: coarse) {
  .modul-box { --m-zeile: 44px; }
  .sp-nr { width: 32px; height: 32px; }
  .modul-box .schalter { min-height: 44px; }
  .modul-box .segment button, .modul-box .zeile > button { min-height: 44px; }
}
