:root {
  color-scheme: dark;
  --bg-top: #0b0f19;
  --bg-bottom: #04050a;
  --blue-top: #f2fbff;
  --blue-mid: #a4ddf7;
  --blue-bottom: #6fc0e8;
  --text-dim: rgba(230, 244, 255, 0.55);
  --text-dimmer: rgba(230, 244, 255, 0.32);
  --pill-bg: rgba(255, 255, 255, 0.06);
  --pill-active: rgba(143, 215, 247, 0.18);
  --pill-border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(120% 90% at 50% 20%, var(--bg-top), var(--bg-bottom));
  color: #eaf6ff;
  overflow: hidden;
  touch-action: manipulation;
}

.app {
  /* Flux flexbox normal en 3 lignes (header / stage / bottom-ui). En
     mode standalone iOS, dvh/innerHeight sous-évaluent la hauteur
     réelle disponible (bug WebKit confirmé : innerHeight=793 alors que
     screen.height=852 sur le même appareil) — app.js corrige la valeur
     via --app-height dans ce cas précis ; ces deux lignes restent le
     repli pour tous les autres contextes (Safari normal, desktop...). */
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  width: 100%;
  display: flex;
  flex-direction: column;
  user-select: none;
  overflow: hidden;
}

.header {
  flex: 0 0 auto;
  padding-top: calc(env(safe-area-inset-top) + clamp(14px, 4vh, 28px));
  padding-bottom: 4px;
  text-align: center;
}

.title-toggle {
  appearance: none;
  background: none;
  border: none;
  padding: 6px 10px;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.app-name {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  font-weight: 500;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  margin-left: 6px;
  border: 1px solid var(--text-dimmer);
  border-radius: 50%;
  color: var(--text-dimmer);
  font-size: 9px;
  font-weight: 700;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0; /* laisse le flex item se réduire correctement */
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

/* Le disque est plafonné à 500px, et sa taille dépend du plus petit
   côté du "stage" (via les unités cqmin) plutôt que du viewport entier,
   pour ne jamais chevaucher le header ou l'UI du bas. Les valeurs en
   vmin servent de repli pour les navigateurs sans container query units. */

.glow {
  position: absolute;
  width: min(95vmin, 475px);
  height: min(95vmin, 475px);
  width: min(95cqmin, 475px);
  height: min(95cqmin, 475px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(143, 215, 247, 0.16), rgba(143, 215, 247, 0) 68%);
  filter: blur(8px);
  pointer-events: none;
}

.max-ring {
  position: absolute;
  width: min(90vmin, 450px);
  height: min(90vmin, 450px);
  width: min(90cqmin, 450px);
  height: min(90cqmin, 450px);
  border-radius: 50%;
  border: 1.5px solid rgba(111, 192, 232, 0.6);
  background: transparent;
  pointer-events: none;
}

.circle {
  --scale: 0.1;
  position: relative;
  width: min(100vmin, 500px);
  height: min(100vmin, 500px);
  width: min(100cqmin, 500px);
  height: min(100cqmin, 500px);
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: linear-gradient(180deg, var(--blue-top) 0%, var(--blue-mid) 55%, var(--blue-bottom) 100%);
  box-shadow:
    0 0 40px rgba(143, 215, 247, 0.3),
    inset 0 0 30px rgba(255, 255, 255, 0.2);
  transform: scale(var(--scale));
  will-change: transform, opacity;
  opacity: 0.5;
  transition: opacity 0.35s ease;
}

.circle.active {
  opacity: 1;
}

.circle:active {
  filter: brightness(1.03);
}

.circle-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: normal;
  color: rgba(8, 26, 38, 0.55);
  /* contrebalance le transform:scale() du parent pour rester lisible
     quelle que soit la taille courante du cercle ; clamp() évite un
     facteur qui explose quand --scale approche 0 (ex: apparition au
     chargement) */
  transform: scale(clamp(1, calc(1 / var(--scale, 0.1)), 12));
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.circle.active .circle-label {
  opacity: 0;
}

.info-panel {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 13%;
  text-align: center;
  font-size: 14px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.stage.info-open .info-panel {
  opacity: 1;
}

.stage.info-open .glow,
.stage.info-open .max-ring,
.stage.info-open .circle {
  opacity: 0;
  pointer-events: none;
}

.bottom-ui {
  flex: 0 0 auto;
  padding-top: 4px;
  padding-bottom: calc(env(safe-area-inset-bottom) + clamp(14px, 3vh, 26px));
  text-align: center;
}

.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(84vw, 340px);
  margin: 0 auto;
}

.time-elapsed,
.time-remaining,
.phase-label {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(234, 246, 255, 0.85);
}

.time-elapsed {
  flex: 0 0 auto;
  text-align: left;
}

.time-remaining {
  flex: 0 0 auto;
  text-align: right;
  color: rgba(234, 246, 255, 0.95);
}

.phase-label {
  flex: 1;
  text-align: center;
  cursor: pointer;
}

.progress-track {
  width: min(84vw, 340px);
  height: 3px;
  margin: 7px auto 0;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue-bottom), var(--blue-mid));
  border-radius: 2px;
}

.mode-name {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.mode-switch {
  display: inline-flex;
  gap: clamp(1px, 1vw, 4px);
  padding: 5px;
  margin: 10px auto 0;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  max-width: 96vw;
}

.mode-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  /* clamp() plutôt qu'un seul saut de breakpoint : 4 pastilles (dont
     "Standard 365", la plus longue) doivent tenir sans déborder même
     sur les téléphones étroits (~375px). */
  font-size: clamp(10.5px, 3vw, 13px);
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: clamp(7px, 2.2vw, 9px) clamp(7px, 3vw, 16px);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.25s ease, color 0.25s ease;
}

.mode-btn[aria-selected="true"] {
  background: var(--pill-active);
  color: #eaf9ff;
}
