  :root {
    --red: #e63c48;
    --red-dark: #c42b37;
    --bar: #3a3a3a;
    --bg: #ffffff;
    --soft: #f5f5f5;
    --line: #dfdfdf;
    --ink: #111111;
    --muted: #707070;
    --r: 14px;
    --font: "Myriad Pro", "Source Sans Pro", "Source Sans 3", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  }
  body.dark {
    --bg: #1b1b1b; --soft: #262626; --line: #3a3a3a; --ink: #f2f2f2; --muted: #a5a5a5; --bar: #0f0f0f;
  }
  * { box-sizing: border-box; margin: 0; }
  html, body { background: var(--bg); }
  body {
    font-family: var(--font); font-weight: 300; color: var(--ink);
    max-width: 480px; margin: 0 auto; min-height: 100svh;
    display: flex; flex-direction: column;
    padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
    user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  }
  button { font: inherit; color: inherit; cursor: pointer; }
  button:focus-visible, input:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }

  /* Kopf */
  .bar {
    background: var(--bar); color: #fff;
    padding: calc(env(safe-area-inset-top) + 6px) 16px 6px;
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    font-size: .78rem; font-weight: 400;
  }
  .bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .theme-btn {
    background: rgba(255,255,255,.12); border: none; color: #fff; border-radius: 99px;
    font-size: .72rem; letter-spacing: .06em; padding: 4px 10px; flex: none;
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 10px 16px 8px; }
  .brand svg { width: 34px; height: 31px; flex: none; }
  .brand .t1 { font-size: .8rem; color: var(--muted); line-height: 1.1; }
  .brand .t2 { font-size: 1.2rem; font-weight: 700; line-height: 1.05; }
  .logos {
    margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none;
    background: #fff; border-radius: 10px; padding: 3px 6px;
  }
  .logo { height: 34px; width: auto; display: block; }
  .logo[src$=".svg"] { height: 40px; margin: -3px -4px; }
  @media (max-width: 370px) { .logo { height: 28px; } .logo[src$=".svg"] { height: 34px; } }
  body.dark .logos { box-shadow: 0 0 0 1px var(--line); }

  /* Timer – Priorität */
  .timer-box {
    margin: 0 16px; padding: 8px 14px 10px; border-radius: var(--r);
    background: var(--soft); box-shadow: inset 5px 0 0 var(--red);
  }
  .timer-label { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); }
  .timer {
    font-weight: 700; font-size: clamp(3.8rem, 19vw, 5rem); line-height: 1;
    font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin: 2px 0 6px;
  }
  .track { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
  #timerBar { height: 100%; background: var(--red); border-radius: 99px; transform-origin: left; transition: transform .2s linear; }
  .timer-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: .9rem; }
  .timer-foot label { display: flex; gap: 8px; align-items: center; }
  .ghost {
    background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
    padding: 5px 12px; font-size: .85rem;
  }
  .ghost:active { border-color: var(--red); color: var(--red); }
  .timer-box.soon .timer { color: var(--red); }
  .timer-box.final { background: rgba(230, 60, 72, .14); }
  .timer-box.final .timer { color: var(--red); }
  .timer.tick { animation: tick .35s ease-out; transform-origin: left center; }
  @keyframes tick { 0% { transform: scale(1.12); } 100% { transform: scale(1); } }
  .timer-box.alarm { animation: alarm .4s steps(2) infinite; }
  @keyframes alarm { 0% { background: var(--red); color: #fff; } 100% { background: var(--soft); color: var(--ink); } }

  /* Metronom */
  .main { flex: 1; display: flex; flex-direction: column; justify-content: center; }
  .metro { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 10px 16px 2px; }
  .step {
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--soft); border: 1px solid var(--line);
    font-size: 1.8rem; font-weight: 300; line-height: 1;
  }
  .step:active { background: var(--red); color: #fff; border-color: var(--red); }
  .pulse {
    width: min(60vw, 230px); aspect-ratio: 1; border-radius: 50%;
    border: 9px solid var(--red); background: var(--bg);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: transform .07s ease-out, background .07s, color .07s;
  }
  .pulse.beat { background: var(--red); color: #fff; transform: scale(1.06); }
  .bpm-display { font-weight: 700; font-size: clamp(4.4rem, 22vw, 6rem); line-height: 1; font-variant-numeric: tabular-nums; }
  .bpm-unit { font-size: .85rem; opacity: .75; margin-top: 2px; }

  .presets { display: flex; justify-content: center; gap: 8px; margin: 8px 16px 0; }
  .presets button {
    flex: 1; max-width: 100px; padding: 7px 0; border-radius: 12px; background: var(--bg);
    border: 1.5px solid var(--red); color: var(--red); font-weight: 700; font-size: 1.05rem;
  }
  .presets button.active { background: var(--red); color: #fff; }
  .slider { padding: 6px 24px 0; }
  input[type=range] { width: 100%; accent-color: var(--red); }

  .start {
    display: block; width: calc(100% - 32px); margin: 8px 16px 0; padding: 14px 0;
    border-radius: var(--r); background: var(--red); color: #fff; border: none;
    font-weight: 700; font-size: 1.25rem; letter-spacing: .12em; text-transform: uppercase;
    box-shadow: 0 4px 14px rgba(230, 60, 72, .35);
  }
  .start:active { background: var(--red-dark); transform: translateY(1px); }
  .start.stop { background: var(--bar); box-shadow: none; }

  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 16px 0; }
  .stat {
    background: var(--soft); border-radius: var(--r); padding: 6px 12px 8px;
    display: grid; grid-template-columns: 1fr auto; align-items: end;
  }
  .stat small { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }
  .stat .count, .stat .cyc { font-weight: 700; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
  .stat .ghost { padding: 3px 10px; font-size: .78rem; }
  #cycle { display: none; }

  .toggles { display: flex; gap: 20px; margin: 8px 16px 0; font-size: .95rem; }
  .toggles { justify-content: space-between; gap: 6px; font-size: .85rem; white-space: nowrap; }
  .brand .t1 { white-space: nowrap; }
  @media (max-width: 370px) { .brand .t1 { font-size: .7rem; } .toggles { font-size: .78rem; } }
  .toggles label { display: flex; gap: 6px; align-items: center; }
  .toggles select {
    font: inherit; font-weight: 700; color: var(--ink); background: var(--soft);
    border: 1px solid var(--line); border-radius: 10px; padding: 4px 2px;
  }
  input[type=checkbox] { accent-color: var(--red); width: 18px; height: 18px; }
  .note { margin: 8px 16px 0; font-size: .76rem; color: var(--muted); line-height: 1.35; }
  .note b { color: var(--red); font-weight: 700; }

  /* Installations-Hinweis */
  .install {
    display: none; margin: 8px 16px 0; padding: 8px 12px; border-radius: var(--r);
    background: var(--soft); font-size: .82rem; line-height: 1.35;
    align-items: center; gap: 10px;
  }
  .install.show { display: flex; }
  .install p { flex: 1; }
  .install .ghost { flex: none; }
  /* Teilen / QR */
  .share {
    position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.55);
    display: flex; align-items: center; justify-content: center; padding: 16px;
  }
  .share[hidden] { display: none; }
  .share-card {
    position: relative; width: 100%; max-width: 380px; background: var(--bg); color: var(--ink);
    border-radius: 18px; padding: 18px 18px 16px; text-align: center;
  }
  .share-logos { height: 48px; background: #fff; border-radius: 8px; padding: 2px 6px; }
  .share-card h2 { font-size: 1.3rem; font-weight: 700; margin-top: 6px; }
  .share-card p { font-size: .88rem; color: var(--muted); margin: 4px 0 10px; line-height: 1.35; }
  .qr { background: #fff; border-radius: 12px; padding: 10px; width: min(70vw, 240px); margin: 0 auto; }
  .qr img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
  .share-url { font-size: .8rem; margin-top: 8px; word-break: break-all; font-weight: 400; }
  .share-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
  .share-main {
    flex: 1 1 100%; background: var(--red); color: #fff; border: none; border-radius: 12px;
    padding: 11px 0; font-weight: 700; font-size: 1rem;
  }
  .share-actions .ghost { flex: 1; padding: 8px 6px; }
  .share-close {
    position: absolute; top: 6px; right: 8px; background: none; border: none;
    font-size: 1.6rem; line-height: 1; color: var(--muted); padding: 4px 8px;
  }
  @media print {
    body > *:not(.share) { display: none !important; }
    body { display: block; max-width: none; background: #fff; }
    .share { position: static; background: #fff; padding: 0; }
    .share-card { max-width: none; color: #000; background: #fff; padding-top: 10mm; }
    .share-logos { height: 30mm; }
    .share-card h2 { font-size: 28pt; margin-top: 6mm; }
    .share-card p { font-size: 15pt; color: #000; margin: 4mm 0 8mm; }
    .qr { width: 110mm; padding: 0; }
    .share-url { font-size: 13pt; margin-top: 6mm; }
    .share-actions, .share-close { display: none !important; }
  }
  .install .x { background: none; border: none; font-size: 1.2rem; color: var(--muted); padding: 0 4px; }
