/* Ablauf: Übersicht, Phasen Erfassen ⇄ Auswerten, Kopfzeile, geordnetes Bedienfeld, Menü in Spalten, «Mehr». */

/* ---------- Was in welcher Phase erscheint ---------- */
body[data-phase="uebersicht"] [data-nur-phase]:not([data-nur-phase~="uebersicht"]),
body[data-phase="erfassen"] [data-nur-phase]:not([data-nur-phase~="erfassen"]),
body[data-phase="auswerten"] [data-nur-phase]:not([data-nur-phase~="auswerten"]) { display: none !important; }

/* Erfassen: grosse Live-Werte über dem Live-Graph, keine Tabelle, nur «Alles zeigen» */
body[data-phase="erfassen"] .ansichten { grid-template: "a" auto "g" minmax(0, 1fr) / minmax(0, 1fr) !important; }
body[data-phase="erfassen"] .b-anzeige { display: flex !important; }
body[data-phase="erfassen"] .b-graph { display: flex !important; }
body[data-phase="erfassen"] .b-tabelle, body[data-phase="erfassen"] .b-graph2 { display: none !important; }
body[data-phase="erfassen"] .graph-werkzeuge > :not([data-alles]),
body[data-phase="erfassen"] .ausw-stapel, body[data-phase="erfassen"] .ausw-box { display: none !important; }
body[data-phase="erfassen"] .graph-werkzeuge { justify-content: flex-end; padding-top: 6px; }
/* Auswerten: Aufteilung ohne Live-Anzeige */
body[data-phase="auswerten"] #layoutWahl [data-layout="alle"], body[data-phase="auswerten"] #layoutWahl [data-layout="anzeige"] { display: none; }

/* ---------- Kopfzeile ---------- */
.leiste { flex-wrap: nowrap; gap: 12px; min-height: 60px; }
.zur-uebersicht {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 6px 14px 6px 11px; white-space: nowrap; flex: none;
}
.zur-uebersicht svg, .panel-knopf svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.versuch { display: flex; flex-direction: column; min-width: 0; flex: 0 1 300px; line-height: 1.2; }
.versuch-titel { font-family: var(--schrift-titel); font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.versuch .sitzungstitel { flex: none; max-width: none; width: 100%; min-height: 24px; padding: 1px 6px; margin-left: -6px; font-size: var(--gr-klein); color: var(--muted); }
.phasen { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--btn); margin-inline: auto; flex: none; }
.phasen button { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; border-radius: 9px; padding: 7px 16px 7px 10px; min-height: 36px; font-size: var(--gr-text); color: var(--muted); white-space: nowrap; }
.phasen button:hover { color: var(--text); }
.phasen .nr { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid currentColor; display: inline-grid; place-items: center; font-family: var(--schrift-mono); font-size: var(--gr-label); }
.phasen button[aria-selected="true"] { background: var(--accent); color: var(--bg); font-weight: 600; }
.phasen button[aria-selected="true"] .nr { border-color: currentColor; }
.weitere { flex: none; white-space: nowrap; min-height: 40px; padding: 8px 16px; }
.aufnahme { flex: none; }
body[data-phase="uebersicht"] .kopf-knoepfe { margin-left: auto; }
body:not([data-phase="uebersicht"]) .kopf-knoepfe { margin-left: 0; }

@media (max-width: 1180px) {
  .leiste { flex-wrap: wrap; row-gap: 8px; }
  .versuch { flex: 1 1 160px; }
  body:not([data-phase="uebersicht"]) .kopf-knoepfe { margin-left: auto; }
  .phasen { order: 10; margin-inline: 0; }
  .aufnahme, .weitere { order: 11; margin-left: auto; }
}
@media (max-width: 640px) {
  .zur-uebersicht span { display: none; }
  .zur-uebersicht { padding: 0; width: 40px; justify-content: center; }
  .phasen button { padding: 6px 12px 6px 8px; }
  .kam-knopf, .hg-knopf { display: none !important; }
  .zur-uebersicht { order: 0; }
  .versuch { order: 1; flex: 1 1 0; }
  .leiste .kopf-knoepfe, body:not([data-phase="uebersicht"]) .kopf-knoepfe { order: 2; margin-left: 0; }
  .phasen { flex: 1 1 auto; }
  .phasen button { flex: 1; justify-content: center; }
  .phasen .nr { display: none; }
}

/* ---------- Übersicht ---------- */
.uebersicht { overflow-y: auto; min-height: 0; padding: clamp(20px, 4vh, 40px) clamp(16px, 4vw, 56px) 56px; overscroll-behavior: contain; }
.ue-innen { max-width: 1240px; margin: 0 auto; }
.ue-titel { font-family: var(--schrift-titel); font-weight: 600; font-size: clamp(24px, 3vw, 32px); margin: 0 0 6px; }
.ue-lead { color: var(--muted); font-size: var(--gr-text); margin: 0 0 8px; max-width: 70ch; }
.ue-gruppe { margin: 26px 0 10px; }
.karten { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.karte {
  display: grid; grid-template-rows: auto auto 1fr auto; align-content: start; gap: 4px; text-align: left; padding: 16px 18px 14px;
  min-height: 128px; border-radius: 16px; border: 1px solid var(--line); background: var(--btn); color: var(--text);
  transition: border-color .15s, transform .15s, background .15s;
}
.karte:hover:not(:disabled) { border-color: var(--btn-on-edge); background: var(--btn-hover); transform: translateY(-1px); }
.karten { grid-auto-rows: 1fr; }
.karte-huelle { position: relative; display: grid; }
.karte-huelle > .karte { padding-right: 44px; }
.karte-weg { position: absolute; top: 10px; right: 10px; border-color: transparent; background: transparent; color: var(--muted); }
.karte-weg:hover { color: var(--err, #d33); border-color: var(--line); }
.karte-weg svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.k-icon { color: var(--accent); margin-bottom: 6px; }
.k-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.k-titel { font-weight: 600; font-size: 16px; }
.k-text { color: var(--muted); font-size: var(--gr-panel); line-height: 1.4; }
/* Startseite: Messgeräte als kompakte Kacheln, darunter die Versuche des gewählten Geräts */
.geraete-karten { grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); }
.geraet-karte { min-height: 112px; }
.geraet-karte[aria-pressed="true"] { border-color: var(--accent); background: var(--btn-on, var(--btn-hover)); box-shadow: 0 0 0 1px var(--accent) inset; }
.karten.klein { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.karten.klein .karte { min-height: 0; padding: 12px 14px; grid-template-rows: auto auto auto 1fr; }
.karten.klein .k-icon { margin-bottom: 2px; }
.karten.klein .k-icon svg { width: 22px; height: 22px; }
.versuch-wahl:not(:empty) { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.vw-kopf { margin: 0 2px 10px; }
.ue-weitere { margin-top: 28px; }
.ue-weitere > summary { cursor: pointer; color: var(--muted); font-size: var(--gr-panel); padding: 6px 0; }
.ue-weitere > summary:hover { color: var(--text); }
.ue-weitere > .karten { margin-top: 10px; }
.k-fuss { color: var(--faint, var(--muted)); font-family: var(--schrift-mono); font-size: var(--gr-label); margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Bedienfeld ---------- */
.panel { position: relative; }
.panel-inhalt { padding: 12px 12px 24px; display: grid; gap: 10px; align-content: start; }
.panel-inhalt > .slot { display: contents; }
.panel .abschnitt { border: 1px solid var(--line); border-radius: 14px; padding: 4px 12px 12px; margin: 0; background: var(--btn); min-width: 0; }
.panel .abschnitt:last-of-type { border-bottom: 1px solid var(--line); }
.ab-kopf { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; margin: 0 -4px !important; padding: 0 4px; cursor: pointer; user-select: none; border-radius: 8px; }
.ab-kopf::after { content: ''; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s; flex: none; }
.abschnitt.zu { padding-bottom: 4px; }
.abschnitt.zu > .ab-kopf::after { transform: rotate(-45deg); }
.abschnitt.zu > :not(.ab-kopf) { display: none !important; }
.ab-kopf:hover { color: var(--text); }
.ab-kopf { display: block; position: relative; line-height: 40px; padding-right: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-kopf::after { position: absolute; right: 8px; top: 50%; margin-top: -5px; }
/* «Daten bearbeiten» steht unter «Werkzeuge» (Kachel) und im Menü */
#secDaten { display: none !important; }
.speicherhinweis { margin: 4px 4px 0; }

/* Ohne Umbrüche: Segmente als gleich breite Spalten, Beschriftungen einzeilig */
.panel .segment { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; }
.panel .segment > :is(button, [role="radio"]) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-inline: 6px; }
.panel .feld { grid-template-columns: 64px minmax(0, 1fr); }
.panel .feld > label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel .feld .eingabe { align-items: center; }
.panel .mm-einheit { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; color: var(--muted); font-size: var(--gr-klein); }
.panel select { min-width: 0; text-overflow: ellipsis; }
.erweitert, .sim-box { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 4px; }
.erweitert > summary, .sim-box > summary { border: 0; background: transparent; padding: 8px 0; min-height: 36px; color: var(--muted); font-size: var(--gr-panel); list-style: none; display: flex; align-items: center; gap: 8px; }
.erweitert > summary::-webkit-details-marker, .sim-box > summary::-webkit-details-marker { display: none; }
.erweitert > summary::before, .sim-box > summary::before { content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.erweitert[open] > summary::before, .sim-box[open] > summary::before { transform: rotate(45deg); }
.erweitert > summary:hover, .sim-box > summary:hover { color: var(--text); background: transparent; }
.verbinden { margin: 10px 0 0; }
.verbinden #usbBtn { flex: 0 0 auto; }
.weitere-geraete { margin-top: 8px; }
.weitere-geraete > summary { cursor: pointer; color: var(--muted); font-size: var(--gr-panel); padding: 4px 2px; }
.weitere-geraete > summary:hover { color: var(--text); }
.geraete-wahl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.geraete-wahl button { min-height: 36px; font-size: var(--gr-klein); white-space: normal; line-height: 1.25; }
.geraete-wahl button[hidden] { display: none; }
#unterstuetzung { margin: 8px 0 0; }
.geraeteliste:empty { display: none; }
.geraeteliste { margin: 0 0 4px; }

/* Bedienfeld in der Breite ziehen; auf breiten Bildschirmen ganz ausblenden */
.panel-rand { position: absolute; top: 0; right: -5px; width: 10px; height: 100%; cursor: col-resize; z-index: 6; touch-action: none; }
.panel-rand::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; background: transparent; transition: background .15s; }
.panel-rand:hover::after, .panel-rand.zieht::after, .panel-rand:focus-visible::after { background: var(--accent); }
@media (max-width: 900px), (orientation: portrait) and (max-width: 1100px) {
  .panel-rand, .panel-knopf { display: none !important; }
  .panel-inhalt { gap: 10px 14px; }
}
@media (min-width: 1101px), (min-width: 901px) and (orientation: landscape) {
  .panel-zu .arbeit { grid-template-columns: 0 minmax(0, 1fr); }
  .panel-zu .panel { visibility: hidden; border: 0; }
}

/* Werkzeuge (Auswerten) */
.wz-liste { display: grid; gap: 6px; }
.wz { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; align-items: center; text-align: left; padding: 9px 10px; min-height: 52px; border-radius: 10px; }
.wz svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.wz-t { display: grid; gap: 1px; min-width: 0; }
.wz-t b { font-weight: 600; font-size: var(--gr-panel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wz-t small { color: var(--muted); font-size: var(--gr-klein); line-height: 1.35; }

/* Module: Auswahl und Vorschläge anderer Module entfallen, der Versuch bestimmt das Modul */
.modul-auswahl, .modul-vorschlag, .modul-kopf, .mm-vorschlag { display: none !important; }

/* ---------- Werkzeugleiste der Graphen ---------- */
.graph-werkzeuge { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; padding: 8px 10px 2px; }
.graph-werkzeuge > * { flex: none; }
.graph-werkzeuge button, .tabelle-werkzeuge button { white-space: nowrap; }
.werkzeug-slot { display: inline-flex; gap: 6px; }
.werkzeug-slot > [hidden], .werkzeug-slot > .dt-chip { display: none !important; }
.mehr-knopf::after { content: ''; display: inline-block; width: 5px; height: 5px; margin-left: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.mehr-menu {
  position: fixed; z-index: 40; display: grid; gap: 8px; padding: 12px; min-width: 260px; max-width: calc(100vw - 16px);
  border: 1px solid var(--glass-edge); border-radius: 14px; background: var(--glass-strong); box-shadow: var(--shadow);
}
.mehr-zeile { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.mehr-zeile > .segment { width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: auto; }
.mehr-zeile > .chip { width: 100%; text-align: left; border-radius: 10px; }
.mehr-label { color: var(--text); font-size: var(--gr-panel); }

/* ---------- Menü in Spalten ---------- */
.menu { width: min(900px, calc(100vw - 24px)); padding: 16px 18px 14px; }
.menu:popover-open { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 6px 22px; align-items: start; }
.menu-spalte { display: grid; gap: 1px; align-content: start; }
.menu-spalte .label { margin: 2px 0 6px 12px; }
.menu button { white-space: nowrap; border-radius: 8px; }
@media (max-width: 520px) { .menu:popover-open { grid-template-columns: 1fr 1fr; } .menu button { white-space: normal; } }

/* Grosse Live-Werte beim Erfassen etwas luftiger */
body[data-phase="erfassen"] .b-anzeige { padding: 12px 14px 4px; gap: 12px; }

/* Tabelle: Breite ziehen, ein- und ausblenden */
.ansichten[data-layout="graph-tabelle"] { grid-template-columns: minmax(0, 1fr) var(--tabelle-b, minmax(260px, 34%)); }
.b-tabelle { position: relative; }
.tabelle-rand { position: absolute; top: 0; left: -5px; width: 10px; height: 100%; cursor: col-resize; z-index: 6; touch-action: none; }
.tabelle-rand::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; transition: background .15s; }
.tabelle-rand:hover::after, .tabelle-rand.zieht::after, .tabelle-rand:focus-visible::after { background: var(--accent); }
.tabelle-zu svg, .tabelle-auf svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabelle-auf {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 4; display: none; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px; min-height: 0; border-radius: 10px 0 0 10px; border-right: 0; font-size: var(--gr-label); color: var(--muted);
}
.tabelle-auf span { writing-mode: vertical-rl; }
body[data-phase="auswerten"] .ansichten[data-layout="graph"] .tabelle-auf { display: flex; }
@container (max-width: 900px) {
  .ansichten[data-layout="graph-tabelle"] { grid-template-columns: 1fr; grid-template-rows: minmax(0, 2fr) minmax(140px, 1fr); }
  .tabelle-rand { display: none; }
}

/* Simulationen nur über die Startseite */
#simBox { display: none !important; }
.sim-dialog { width: min(680px, calc(100vw - 24px)); }
.sim-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); grid-auto-rows: 1fr; gap: 8px; margin: 12px 0; }
.sim-karte { display: grid; grid-template-rows: auto 1fr auto; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 12px; }
.sim-karte b { font-weight: 600; font-size: var(--gr-panel); }
.sim-karte span { color: var(--muted); font-size: var(--gr-klein); line-height: 1.35; }
.sim-karte small { color: var(--accent); font-family: var(--schrift-mono); font-size: var(--gr-label); margin-top: 6px; }

/* ---------- Versuch «Live-Anzeige»: nur die Werte, gross, ohne Graph und ohne Aufzeichnen (auch im Beamer-Modus).
   Der Knopf «Messung über die Zeit» wechselt in die Messung mit Graph; dort führt «Live-Anzeige» zurück. ---------- */
.wechsel-zeit, .wechsel-live { display: none; }
body[data-versuch="anzeige"] .wechsel-zeit { display: inline-flex; }
body[data-versuch="anzeige"] #start, body[data-versuch="anzeige"] #markeBtn, body[data-versuch="anzeige"] #laufzeit { display: none !important; }
body.live-moeglich:not(.nimmt-auf) .wechsel-live { display: inline-flex; }
.beamer .wechsel-zeit, .beamer .wechsel-live { font-size: clamp(14px, 1.3vw, 22px); min-height: 44px; padding: 8px 18px; }
body[data-versuch="anzeige"][data-phase="erfassen"] .ansichten,
body.beamer[data-versuch="anzeige"] .ansichten { grid-template: "a" minmax(0, 1fr) / minmax(0, 1fr) !important; }
body[data-versuch="anzeige"][data-phase="erfassen"] .ansichten .b-graph,
body.beamer[data-versuch="anzeige"] .ansichten .b-graph,
body.beamer[data-versuch="anzeige"] .beamer-werte { display: none !important; }
body.beamer[data-versuch="anzeige"] .ansichten .b-anzeige { display: grid !important; }
body.beamer[data-versuch="anzeige"] .huelle { grid-template-rows: minmax(0, 1fr); }
/* Werte füllen die Fläche: Spaltenzahl setzt main.js (anzeigeSpalten), Schrift nach Breite und Höhe der Kachel */
body[data-versuch="anzeige"] .b-anzeige { display: grid !important; grid-template-columns: repeat(var(--spalten, 1), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr); padding: 3vh 3vw; gap: 2.5vh 2.5vw; overflow: hidden; }
body[data-versuch="anzeige"] .b-anzeige .leer { grid-column: 1 / -1; align-self: center; text-align: center; }
body[data-versuch="anzeige"] .meter { min-height: 0; min-width: 0; display: flex; flex-direction: column; justify-content: center;
  padding: 2vh 2vw 2vh calc(2vw + 12px); row-gap: 1vh; container-type: size; }
body[data-versuch="anzeige"] .meter::before { left: 1vw; top: 12%; bottom: 12%; width: 5px; }
body[data-versuch="anzeige"] .m-name { font-size: clamp(16px, min(7cqi, 9cqh), 48px); }
body[data-versuch="anzeige"] .m-wert { font-size: clamp(32px, min(24cqi, 42cqh), 320px); line-height: 1; text-overflow: clip; overflow: hidden; }
body[data-versuch="anzeige"] .m-wert small { font-size: 0.3em; }
body[data-versuch="anzeige"] .m-geraet { font-size: clamp(11px, min(3.5cqi, 5cqh), 20px); }
@media (max-width: 700px) and (orientation: portrait) { body[data-versuch="anzeige"] .b-anzeige { --spalten: 1 !important; grid-auto-rows: minmax(150px, 1fr); } }
/* Startseite: Live-Anzeige als erste Wahl hervorheben */
.karte.hervor { border-color: var(--btn-on-edge, var(--accent)); }
