:root {
  --tm-bg: #ffffff;
  --tm-fg: #1f2933;
  --tm-muted: #5f6b7a;
  --tm-line: #d9e0e8;
  --tm-soft: #eef2f7;
  --tm-accent: #2f6fd1;
  --tm-accent-fg: #ffffff;
  --tm-stage: #f7f9fc;
  --tm-radius: 10px;
}

* { box-sizing: border-box; }

html { scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--tm-bg);
  color: var(--tm-fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.tm-app {
  padding: 12px 16px 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.tm-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-bottom: 10px;
}
.tm-header h1 {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 650;
}

.tm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--tm-line); flex: 1; min-width: 240px; }
.tm-tab {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  color: var(--tm-muted);
  padding: 8px 14px;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tm-tab:hover { color: var(--tm-fg); }
.tm-tab.is-active { color: var(--tm-accent); border-bottom-color: var(--tm-accent); font-weight: 600; }

.tm-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 22px;
  margin-bottom: 10px;
}
.tm-group { display: flex; flex-direction: column; gap: 4px; }
.tm-label { font-size: 0.8rem; color: var(--tm-muted); font-weight: 600; letter-spacing: 0.01em; }

.tm-seg {
  display: inline-flex;
  background: var(--tm-soft);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.tm-seg button {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--tm-fg);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.tm-seg button:hover { background: rgba(0, 0, 0, 0.05); }
.tm-seg button.is-active { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); font-weight: 600; color: var(--tm-accent); }

.tm-temp-row { display: flex; align-items: center; gap: 10px; }
.tm-temp input[type="range"] {
  width: 220px;
  height: 8px;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 4px;
  background: linear-gradient(90deg, #4f9be8, #f5c04a 55%, #e5533d);
  outline-offset: 4px;
}
.tm-temp input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid var(--tm-fg);
  cursor: pointer;
}
.tm-temp input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid var(--tm-fg);
  cursor: pointer;
}
.tm-temp output { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 4.2em; }

.tm-actions { flex-direction: row; gap: 6px; }
.tm-btn {
  appearance: none;
  font: inherit;
  border: 1px solid var(--tm-line);
  background: #fff;
  color: var(--tm-fg);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.tm-btn:hover { background: var(--tm-soft); }
.tm-btn:disabled { opacity: 0.5; cursor: default; }
.tm-primary { background: var(--tm-accent); border-color: var(--tm-accent); color: var(--tm-accent-fg); font-weight: 600; }
.tm-primary:hover { background: #255cb0; }
.tm-primary.is-on { background: #d6453a; border-color: #d6453a; }

.tm-stage {
  position: relative;
  border-radius: var(--tm-radius);
  overflow: hidden;
  background: var(--tm-stage);
  border: 1px solid var(--tm-line);
}
.tm-stage canvas { display: block; width: 100%; }

.tm-hint {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(31, 41, 51, 0.82);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  pointer-events: none;
  transition: opacity 0.4s;
}
.tm-hint:empty, .tm-hint.is-hidden { opacity: 0; }

.tm-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 20px;
  margin: 8px 2px 6px;
  font-variant-numeric: tabular-nums;
}
.tm-note { color: var(--tm-muted); font-style: italic; }

.tm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 8px 10px;
  background: var(--tm-soft);
  border-radius: var(--tm-radius);
  font-size: 0.88rem;
}
.tm-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.tm-legend-item canvas { flex: none; }
.tm-legend-title { font-weight: 600; color: var(--tm-muted); }
.tm-legend-break { flex-basis: 100%; height: 0; }
.tm-swatch {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.35);
  display: inline-block;
}

.tm-placeholder {
  border: 1px dashed var(--tm-line);
  border-radius: var(--tm-radius);
  padding: 48px 16px;
  text-align: center;
  color: var(--tm-muted);
}
.tm-placeholder h2 { color: var(--tm-fg); margin-top: 0; }

@media (max-width: 640px) {
  .tm-temp input[type="range"] { width: 160px; }
  .tm-seg button { padding: 6px 9px; }
}

/* Aggregatzustände */
.tm-check { display: inline-flex; align-items: center; gap: 6px; padding-bottom: 7px; cursor: pointer; }
.tm-check[hidden] { display: none; }
.tm-phasebar {
  display: flex;
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 600;
}
.tm-phasebar span {
  flex: none;
  display: flex; align-items: center; justify-content: center;
  white-space: nowrap; overflow: hidden;
  transition: width 0.6s;
}
.tm-phasebar .is-solid { background: #cfe3f5; color: #23476b; }
.tm-phasebar .is-liquid { background: #4f95e3; color: #fff; }
.tm-phasebar .is-gas { background: #eef2f7; color: #5f6b7a; }
.tm-hb-swatch {
  display: inline-block; width: 22px; height: 0;
  border-top: 2px dashed rgba(40, 60, 90, 0.55);
}
