/* CLA V8 Sound – Web-Version. Dunkles Design wie die native App. */

:root {
  --bg-top: #040404;
  --bg-bottom: #131313;
  --card: #1b1b1b;
  --card-stroke: rgba(255, 255, 255, 0.07);
  --text: #ffffff;
  --text-2: rgba(255, 255, 255, 0.58);
  --text-3: rgba(255, 255, 255, 0.38);
  --red: #e6121f;
  --red-deep: #8c050f;
  --red-light: #ff5a4d;
  --green: #30d158;
  --yellow: #ffd60a;
  --orange: #ff9f0a;
  --blue: #0a84ff;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom)) fixed;
  background-color: var(--bg-top);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select { font: inherit; color: inherit; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 10px) 16px calc(var(--safe-bottom) + 28px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Kopfzeile */
.header { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; }
.brand {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2.5px;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, sans-serif;
}
.profile-line {
  display: flex; align-items: center; gap: 6px; margin-top: 4px;
  font-size: 12px; font-weight: 600; letter-spacing: 1px; color: var(--text-2); text-transform: uppercase;
}
.dash { width: 18px; height: 3px; border-radius: 2px; background: var(--red); }

.icon-button {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card);
  display: grid; place-items: center; cursor: pointer;
}
.icon-button:disabled { color: var(--text-3); cursor: not-allowed; }
.icon-button svg { width: 22px; height: 22px; }

/* Icons */
.ico { display: inline-grid; place-items: center; width: 1.15em; height: 1.15em; margin-right: 6px; vertical-align: -0.2em; }
.ico svg { width: 100%; height: 100%; }

/* Banner */
.banners { display: flex; flex-direction: column; gap: 8px; }
.banners:empty { display: none; }
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 12px; border-radius: 12px; font-size: 14px; line-height: 1.35;
  background: rgba(10, 132, 255, 0.12); border: 1px solid rgba(10, 132, 255, 0.28);
}
.banner .ico { flex: none; width: 18px; height: 18px; margin: 1px 0 0; color: var(--blue); }
.banner.warning { background: rgba(255, 159, 10, 0.12); border-color: rgba(255, 159, 10, 0.3); }
.banner.warning .ico { color: var(--orange); }
.banner.critical { background: rgba(230, 18, 31, 0.14); border-color: rgba(230, 18, 31, 0.4); }
.banner.critical .ico { color: var(--red); }
.banner-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.banner button {
  display: block; margin-top: 8px; padding: 7px 12px; border-radius: 9px; border: 0;
  background: rgba(255, 255, 255, 0.12); font-weight: 600; cursor: pointer;
}

/* Drehzahlanzeige */
.gauge-wrap { padding: 4px 20px; }
.gauge { display: block; width: 100%; max-width: 360px; margin: 0 auto; overflow: visible; }
.gauge-track { fill: none; stroke: rgba(255, 255, 255, 0.07); stroke-width: 9; stroke-linecap: round; }
.gauge-red { fill: none; stroke: rgba(230, 18, 31, 0.28); stroke-width: 9; }
.gauge-value {
  fill: none; stroke: url(#gaugeGradient); stroke-width: 9; stroke-linecap: round;
  transition: stroke-dasharray 80ms linear;
}
.gauge.live .gauge-value { filter: drop-shadow(0 0 4px rgba(230, 18, 31, 0.55)); }
.tick { stroke: rgba(255, 255, 255, 0.45); stroke-width: 1.2; }
.tick.red { stroke: var(--red); }
.tick-label { fill: rgba(255, 255, 255, 0.5); font-size: 8.4px; font-weight: 600; font-family: ui-rounded, -apple-system, sans-serif; }
.tick-label.red { fill: var(--red); }
.g-speed { fill: #fff; font-size: 50px; font-weight: 700; font-family: ui-rounded, "SF Pro Rounded", -apple-system, sans-serif; font-variant-numeric: tabular-nums; }
.g-unit { fill: var(--text-2); font-size: 10px; font-weight: 500; }
.g-rpm { fill: var(--red); font-size: 15px; font-weight: 600; font-family: ui-rounded, -apple-system, sans-serif; font-variant-numeric: tabular-nums; }
.g-caption { fill: var(--text-3); font-size: 7.6px; }
.g-gear rect { fill: rgba(255, 255, 255, 0.06); }
.g-gear text { fill: var(--text-2); font-size: 9px; font-weight: 600; font-family: ui-rounded, -apple-system, sans-serif; }

/* Karten */
.card {
  background: var(--card);
  border: 1px solid var(--card-stroke);
  border-radius: var(--radius);
  padding: 14px;
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card.status { padding: 12px; min-height: 96px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.card-title { font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-value { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-detail { font-size: 12px; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin: 6px 0 4px; }
.bar-fill { height: 100%; width: 0; border-radius: 4px; background: var(--red); transition: width 200ms ease; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-label { font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; }
.mono { font-variant-numeric: tabular-nums; }
.dim { color: var(--text-2); }
.hint { margin: 6px 2px 0; font-size: 12px; color: var(--text-3); }
.hint.center { text-align: center; }
.hint code { font-size: 11px; color: var(--text-2); }

/* Schieberegler */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px; margin: 4px 0 0; background: transparent; cursor: pointer;
  --fill: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--red) var(--fill), rgba(255, 255, 255, 0.16) var(--fill));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 26px; height: 26px; margin-top: -11px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.16); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--red); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: #fff; }
input[type="range"]:disabled { opacity: 0.4; cursor: not-allowed; }

/* Start/Stopp */
.start-button {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 18px; border-radius: 16px; border: 0; cursor: pointer;
  font-size: 17px; font-weight: 900; letter-spacing: 1.2px;
  background: linear-gradient(180deg, var(--red), var(--red-deep));
  box-shadow: 0 4px 12px rgba(230, 18, 31, 0.35);
  touch-action: manipulation;
}
.start-button svg { width: 20px; height: 20px; }
.start-button.active { background: #242424; box-shadow: inset 0 0 0 1.5px var(--red); }
.start-button:disabled { opacity: 0.7; cursor: progress; }
.start-button:active { transform: scale(0.99); }

/* Listen und Schalter */
.card.list { padding: 0 14px; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 10px 0; font-size: 15px;
  border-bottom: 1px solid var(--card-stroke);
}
.list-row:last-child { border-bottom: 0; }
.list-row.column { flex-direction: column; align-items: stretch; gap: 0; }
.list-row.small { font-size: 14px; min-height: 44px; }
.list-row select {
  max-width: 58%; background: transparent; border: 0; color: var(--text-2); text-align: right;
  text-align-last: right; padding: 4px 0;
}
.list-row select option { background: #1b1b1b; color: #fff; }

.switch { position: relative; flex: none; width: 51px; height: 31px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: 16px; background: rgba(120, 120, 128, 0.32);
  transition: background 180ms ease;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); transition: transform 180ms ease;
}
.switch input:checked + span { background: var(--red); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: 0.4; }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

.list-button {
  display: block; width: 100%; min-height: 48px; padding: 12px 0; border: 0; border-bottom: 1px solid var(--card-stroke);
  background: transparent; color: var(--blue); text-align: left; font-size: 15px; cursor: pointer;
}
.list-button:last-child { border-bottom: 0; }
.list-button.danger { color: var(--red-light); }
.list-button:disabled { color: var(--text-3); cursor: not-allowed; }

/* Segmentierte Auswahl */
.segmented { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(118, 118, 128, 0.24); }
.segmented button {
  flex: 1; min-width: 0; padding: 7px 4px; border: 0; border-radius: 7px; background: transparent;
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.segmented button[aria-checked="true"] { background: #636366; font-weight: 600; }
.segmented button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Testmodus */
.test-panel { border-color: rgba(230, 18, 31, 0.4); display: flex; flex-direction: column; gap: 10px; }
.test-panel[hidden] { display: none; }
.test-title { color: var(--red); font-weight: 700; display: inline-flex; align-items: center; }
#manualControls label { font-size: 14px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.metrics[hidden] { display: none; }
.metrics small { display: block; font-size: 11px; color: var(--text-3); }
.metrics b { font-size: 13px; font-variant-numeric: tabular-nums; }

.footer { margin: 4px 8px 0; text-align: center; font-size: 11px; color: var(--text-3); }

/* Einstellungen */
.sheet {
  width: 100%; max-width: 560px; height: 100%; max-height: 100%; margin: 0 auto; padding: 0;
  border: 0; background: #0b0b0b; color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet[open] { display: flex; flex-direction: column; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px; border-bottom: 1px solid var(--card-stroke);
  background: #0b0b0b; position: sticky; top: 0; z-index: 1;
}
.sheet-head h2 { margin: 0; font-size: 17px; }
.text-button { border: 0; background: transparent; color: var(--red-light); font-weight: 600; font-size: 16px; cursor: pointer; padding: 6px 2px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px calc(var(--safe-bottom) + 32px); }
.sheet-body h3 { margin: 22px 4px 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-2); }
.sample-list:empty { display: none; }
.sample-list { padding: 4px 0 10px; border-bottom: 1px solid var(--card-stroke); font-size: 13px; color: var(--text-2); }
.sample-list div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.sample-list .ok { color: var(--green); }
.sample-list .miss { color: var(--text-3); }
.sample-list .err { color: var(--red-light); }
.notes p { margin: 0 0 10px; font-size: 13px; color: var(--text-2); }
.notes p:last-child { margin-bottom: 0; }

.noscript { padding: 24px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
