/* ============================================================
   LoopTimer — Designsystem „Signal"
   Neutrale Grauskala (OKLCH, C=0), ein monochromer Akzent (Weiß),
   Farbe kommt ausschließlich von den Intervallfarben.
   Scharfe Kanten, Hairlines, keine Farbflächen.
   ============================================================ */

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-var.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Neutrale Skala — OKLCH C=0, WCAG-geprüft */
  --bg0: #0E0E0E;
  --bg1: #171717;
  --bg2: #222222;
  --line: #2F2F2F;
  --line-2: #444444;

  --ink: #F3F3F3;
  --ink-dim: #A9A9A9;
  --ink-faint: #7D7D7D;

  /* Monochromer Akzent: Weiß */
  --cta: #F7F7F7;
  --cta-press: #D4D4D4;
  --on-cta: #0E0E0E;

  /* Status (entsättigt) */
  --danger: #D8625C;
  --danger-ink: #F4928A;
  --on-danger: #1C0605;
  --warn-ink: #DCAF61;
  --ok-ink: #68B986;

  --shadow-fab: 0 8px 24px -8px rgba(0, 0, 0, 0.7);
  --press-ease: cubic-bezier(0.2, 0.7, 0.4, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg0);
  color: var(--ink);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Feines Korn gegen Banding */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

button {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
  border-radius: 0;
  transition: transform 180ms var(--press-ease), background 180ms var(--press-ease);
}
button:active { transition-duration: 90ms; }

input { border-radius: 0; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  display: block;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

.view {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}
.view-enter { animation: view-enter 180ms cubic-bezier(0.22, 0.9, 0.3, 1); }
@keyframes view-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.muted { color: var(--ink-faint); font-weight: 400; font-size: 0.82em; letter-spacing: 0; text-transform: none; }

/* ===== Buttons ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  min-height: 52px;
  padding: 0 18px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: var(--bg2);
  color: var(--ink);
}
.btn:active { transform: scale(0.98); }
.btn-big { min-height: 56px; font-size: 17px; }
.btn-primary { background: var(--cta); color: var(--on-cta); }
.btn-primary:active { background: var(--cta-press); }
.btn-add {
  background: transparent;
  border: 1px dashed var(--line-2);
  color: var(--ink-dim);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink);
}
.btn-outline:active { background: rgba(243, 243, 243, 0.08); }
.btn-glassline { border-color: var(--line-2); }
.btn-danger {
  background: transparent;
  border: 1px solid rgba(216, 98, 92, 0.45);
  color: var(--danger-ink);
}
.btn-danger.confirm { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }

.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: none;
  padding: 0 6px;
  color: var(--ink);
}
.btn-ghost:active { background: rgba(243, 243, 243, 0.08); transform: scale(0.96); }
.btn-back { font-size: 16px; font-weight: 600; padding-right: 10px; }
.btn-back .icon { width: 22px; height: 22px; }
.btn-glass { border: 1px solid var(--line); background: transparent; }
.btn-glass .icon { width: 22px; height: 22px; }
.btn-glass.off { color: var(--ink-faint); }

/* Fester Primärbutton unten rechts */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 22px 0 18px;
  border: none;
  background: var(--cta);
  color: var(--on-cta);
  font-size: 16px;
  font-weight: 700;
  box-shadow: var(--shadow-fab);
}
.fab:active { background: var(--cta-press); transform: scale(0.98); }

/* ===== Startseite ===== */
.home-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}
.wordmark {
  margin: 0;
  font-size: 27px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-stretch: 110%;
}
.wordmark span { font-weight: 460; }
.wordmark strong { font-weight: 830; }
.wordmark em { font-style: normal; font-weight: 830; color: var(--ink-faint); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 13px;
  font-weight: 650;
}
.chip-toggle .icon { width: 18px; height: 18px; }
.chip-toggle:active { transform: scale(0.97); }
.chip-toggle.on {
  background: var(--bg2);
  border-color: var(--ink-dim);
  color: var(--ink);
}

.timer-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 88px; /* Platz für den Festbutton */
}

.timer-card {
  display: grid;
  grid-template-columns: 1fr auto;
  background: var(--bg1);
  border: 1px solid var(--line);
  overflow: hidden;
}
.timer-card-main {
  min-width: 0;
  padding: 16px 0 0 18px;
  background: none;
  border: none;
  text-align: left;
  display: block;
}
.timer-card-name {
  font-size: 17px;
  font-weight: 750;
  font-stretch: 102%;
  letter-spacing: -0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timer-card-meta {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-dim);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.timer-card-play {
  width: 56px;
  height: 56px;
  align-self: center;
  margin: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink);
}
.timer-card-play .icon { width: 22px; height: 22px; }
.timer-card-play:active { background: var(--cta); color: var(--on-cta); transform: scale(0.96); }
.timer-card-strip {
  grid-column: 1 / -1;
  display: flex;
  gap: 2px;
  height: 5px;
  margin-top: 14px;
}
.timer-card-strip i { display: block; height: 100%; }

.empty-note {
  text-align: center;
  color: var(--ink-dim);
  padding: 48px 10px;
  font-size: 15px;
  line-height: 1.5;
}

.hint {
  margin-top: 18px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--warn-ink);
  background: var(--bg1);
  border: 1px solid var(--line-2);
  padding: 10px 12px;
}

/* ===== Kopfzeile ===== */
.bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -6px -8px 14px;
}
.bar h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-spacer { width: 96px; flex: none; }

/* ===== Editor ===== */
.field {
  display: block;
  background: var(--bg1);
  border: 1px solid var(--line);
  padding: 12px 16px;
  margin-bottom: 12px;
  transition: border-color 180ms;
}
.field:focus-within { border-color: var(--ink-dim); }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.field input[type="text"] {
  width: 100%;
  border: none;
  background: none;
  outline: none;
  font-size: 17px;
  font-weight: 600;
  padding: 2px 0;
  caret-color: var(--ink);
}
.field input::placeholder { color: var(--ink-faint); }

.stepper-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.stepper-field .field-label { margin-bottom: 0; }

.stepper {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--line);
}
.st-btn {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ink-dim);
}
.st-btn:active { background: rgba(243, 243, 243, 0.08); color: var(--ink); }
.st-btn:disabled { opacity: 0.38; pointer-events: none; }
.st-val {
  min-width: 68px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  font-stretch: 95%;
  font-variant-numeric: tabular-nums;
}

.section-title {
  margin: 22px 4px 10px;
  font-size: 16px;
  font-weight: 750;
}
.section-title::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 3px;
  background: var(--ink);
  transform: translateY(-3px);
  margin-right: 8px;
}

.interval-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }

.int-row {
  position: relative;
  background: var(--bg1);
  border: 1px solid var(--line);
  padding: 14px 14px 12px 20px;
  overflow: hidden;
}
/* Farbkante links — einzige Farbe an der Karte */
.int-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--c, var(--ink-faint));
}
.int-row-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-dot {
  width: 28px;
  height: 28px;
  flex: none;
  border: 1px solid rgba(243, 243, 243, 0.25);
  background: var(--c, #4D9960);
  padding: 0;
}
.color-dot:active { transform: scale(0.9); }
.color-dot.pop { animation: dot-pop 150ms ease-out; }
@keyframes dot-pop {
  50% { transform: scale(1.15); }
}
.int-name {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  outline: none;
  font-size: 17px;
  font-weight: 600;
  padding: 8px 0;
  caret-color: var(--ink);
}
.int-name::placeholder { color: var(--ink-faint); }
.int-del {
  flex: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--ink-dim);
}
.int-del:active { color: var(--danger-ink); background: rgba(243, 243, 243, 0.06); }
.int-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}
.int-move { display: flex; gap: 6px; }
.int-move .st-btn {
  background: var(--bg2);
  border: 1px solid var(--line);
}
.int-move .st-btn:active { background: rgba(243, 243, 243, 0.08); }

/* Ansagen-Zeile (immer sichtbar) */
.int-ann {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  padding: 6px 2px 0 0;
  border: none;
  border-top: 1px solid var(--line);
  background: none;
  text-align: left;
  color: var(--ink-dim);
}
.int-ann .icon { width: 18px; height: 18px; }
.int-ann-text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.int-ann-text b { color: var(--ink); font-weight: 650; }
.int-ann .chev { transition: transform 200ms var(--press-ease); }
.int-ann[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* Aufklappbares Ansagen-Panel */
.int-rounds-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.int-rounds-wrap.open { grid-template-rows: 1fr; }
.int-rounds {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.int-rounds > :first-child { margin-top: 10px; }
.int-rounds-head {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}
.round-row { display: flex; align-items: center; gap: 8px; }
.round-row .num {
  width: 24px;
  flex: none;
  text-align: right;
  color: var(--ink-faint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.round-row input,
.list-name-input {
  flex: 1;
  min-width: 0;
  background: var(--bg2);
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 16px;
  font-weight: 500;
  outline: none;
  caret-color: var(--ink);
  transition: border-color 180ms;
}
.round-row input:focus,
.list-name-input:focus { border-color: var(--ink-dim); }
.round-row input::placeholder,
.list-name-input::placeholder { color: var(--ink-faint); }
.list-name-input { min-width: 130px; font-size: 14px; }

.int-rounds-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
  padding-bottom: 2px;
}
.btn-small {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}
.btn-small .icon { width: 16px; height: 16px; }
.btn-small:active { background: rgba(243, 243, 243, 0.08); transform: scale(0.97); }

.list-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.list-row {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--line);
  min-height: 48px;
  padding-left: 12px;
}
.list-row .list-load {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
}
.list-row .list-load em {
  font-style: normal;
  color: var(--ink-faint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.list-row .list-load span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row .list-del {
  flex: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--ink-dim);
}
.list-row .list-del:active { color: var(--danger-ink); }
.list-row .list-del .icon { width: 18px; height: 18px; }

.total-line {
  text-align: center;
  color: var(--ink-dim);
  font-size: 15px;
  margin: 18px 0;
}
.total-line b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 750; }

.edit-actions { display: flex; flex-direction: column; gap: 10px; }

/* ===== Laufender Timer =====
   Konstanter neutraler Hintergrund — Farbe nur im Ring,
   im Intervallnamen und im Danach-Punkt. */
.view-run {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 560px;
}
.run-bar { margin-bottom: 6px; }
.run-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wake-chip {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  background: var(--bg1);
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.wake-chip .icon { width: 14px; height: 14px; }
.wake-chip.warn { border-color: var(--warn-ink); color: var(--warn-ink); }

#run-live { display: flex; flex-direction: column; flex: 1; }

.run-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 0;
}

.run-interval-name {
  font-size: clamp(26px, 8vw, 36px);
  font-weight: 800;
  font-stretch: 104%;
  letter-spacing: -0.01em;
  line-height: 1.1;
  text-align: center;
  text-wrap: balance;
  min-height: 1.1em;
  color: var(--seg, var(--ink));
  animation: label-in 200ms cubic-bezier(0.22, 0.9, 0.3, 1);
}
@keyframes label-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.ring-wrap {
  position: relative;
  width: min(70vw, 296px);
  aspect-ratio: 1 / 1;
}
.ring { width: 100%; height: 100%; display: block; }
/* Lünette: 60 Ticks (C = 276.46) */
.ring-bg {
  fill: none;
  stroke: rgba(243, 243, 243, 0.13);
  stroke-width: 5;
  stroke-dasharray: 1.15 3.4577;
  stroke-dashoffset: 0.575;
}
.ring-fg {
  fill: none;
  stroke: var(--seg, var(--ink));
  stroke-width: 6;
  stroke-linecap: butt;
  transition: stroke 300ms;
}
.ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.run-time {
  font-size: clamp(64px, 24vw, 104px);
  font-weight: 640;
  font-stretch: 80%;
  letter-spacing: -0.015em;
  line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1;
}
.run-time.pulse { animation: digit-pulse 240ms ease-out; }
@keyframes digit-pulse {
  50% { transform: scale(1.06); }
}
.run-time.paused { animation: breathe 2.6s ease-in-out infinite alternate; }
@keyframes breathe {
  from { opacity: 0.45; }
  to { opacity: 0.68; }
}
.run-round {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

/* „Danach"-Anzeige: groß genug, um sie aus der Distanz zu lesen */
.run-next {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  min-height: 68px;
  max-width: 100%;
}
.run-next:empty { visibility: hidden; }
.run-next-eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.run-next-label {
  font-size: clamp(28px, 9vw, 40px);
  font-weight: 800;
  font-stretch: 104%;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--ink);
  text-wrap: balance;
}

.run-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 12px 0 18px;
}
.btn-round {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink);
}
.btn-round:active { background: rgba(243, 243, 243, 0.1); transform: scale(0.96); }
.btn-round-big {
  width: 96px;
  height: 96px;
  background: var(--cta);
  border: none;
  color: var(--on-cta);
}
.btn-round-big .icon { width: 34px; height: 34px; }
.btn-round-big:active { background: var(--cta-press); transform: scale(0.97); }

.run-total { padding-bottom: 6px; }
.run-total-bar {
  position: relative;
  height: 5px;
  background: var(--bg2);
  overflow: hidden;
  margin-bottom: 7px;
}
.run-total-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ink);
}
/* Lap-Linien pro Runde */
.run-total-bar.has-laps::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to right,
    transparent 0 calc(100% / var(--laps) - 1.5px),
    var(--bg0) 0 calc(100% / var(--laps))
  );
}
.run-total-text {
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ===== Geschafft ===== */
.run-finished {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}
.finish-badge {
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  background: var(--bg1);
  color: var(--ok-ink);
  margin-bottom: 6px;
}
.finish-badge .icon {
  width: 44px;
  height: 44px;
  stroke-dasharray: 24;
  stroke-dashoffset: 0;
  animation: check-in 400ms cubic-bezier(0.22, 0.9, 0.3, 1);
}
@keyframes check-in {
  from { stroke-dashoffset: 24; }
  to { stroke-dashoffset: 0; }
}
.finish-title {
  font-size: 34px;
  font-weight: 800;
  font-stretch: 108%;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.finish-meta { font-size: 15px; color: var(--ink-dim); margin-bottom: 18px; }
.run-finished .btn { max-width: 320px; }

/* ===== NoSleep-Fallback-Video ===== */
.nosleep {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 2px;
  height: 2px;
  opacity: 0.01;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
