:root {
  --bg-top: #0f2027;
  --bg-mid: #1f4959;
  --bg-bottom: #2c7a7b;
  --circle-color: #7fe7dc;
  --circle-glow: rgba(127, 231, 220, 0.45);
  --circle-highlight: #d7fff9;
  --circle-shade: #3fb6a8;
  --text-main: #eafbf9;
  --text-muted: #9fc9c4;
  --panel-bg: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.12);
  --panel-solid: #16323d;
  --accent: #7fe7dc;
  --accent-light: #97efe5;
  --accent-contrast: #073b3a;
}

:root.night {
  --bg-top: #150b08;
  --bg-mid: #341c11;
  --bg-bottom: #4a2716;
  --circle-color: #ffb27a;
  --circle-glow: rgba(255, 178, 122, 0.4);
  --circle-highlight: #ffe9d6;
  --circle-shade: #c9642f;
  --text-main: #fbe9da;
  --text-muted: #cf9d80;
  --panel-bg: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(255, 255, 255, 0.1);
  --panel-solid: #2a150d;
  --accent: #ffb27a;
  --accent-light: #ffc999;
  --accent-contrast: #3a1608;
}


* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(ellipse at top, var(--bg-mid), var(--bg-top) 70%);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

.app-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.app {
  width: 100%;
  min-width: 0;
  max-width: 460px;
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 25px 16px;
  gap: 25px;
}

.app-middle {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.exercise-select {
  position: relative;
  min-width: 0;
}

.exercise-field {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  transition: border-color 0.15s ease;
}

.exercise-field:hover,
.exercise-select.open .exercise-field {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.exercise-field-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.exercise-field-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.exercise-field-value-text {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.exercise-field-icon {
  display: flex;
  align-items: center;
  color: var(--circle-color);
  flex-shrink: 0;
}

#exerciseValue {
  font-size: 1rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exercise-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.exercise-select.open .exercise-chevron {
  transform: rotate(180deg);
}

.exercise-panel {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 15;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  max-height: min(360px, 60vh);
  overflow-y: auto;
}

.exercise-select.open .exercise-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.exercise-option {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}

.exercise-option:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

.exercise-option[aria-selected="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.exercise-option-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.exercise-option-icon {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.exercise-option[aria-selected="true"] .exercise-option-icon {
  color: var(--circle-color);
}

.exercise-option-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.exercise-option[aria-selected="true"] .exercise-option-name {
  color: var(--circle-color);
}

.exercise-option-tag {
  font-size: 0.74rem;
  color: var(--text-muted);
  opacity: 0.8;
}

@media (max-width: 380px) {
  .exercise-select.open .exercise-panel {
    grid-template-columns: 1fr;
  }
}

.app-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  position: relative;
}

.app-sidebar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-bottom: 6px;
}

.circle-track {
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 0;
  min-height: 160px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: 30px;
  padding-bottom: 30px;
}

.circle-track::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 30px;
  bottom: 30px;
  width: 2px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.08), transparent);
  transform: translateX(-50%);
}

.ripple-track {
  position: absolute;
  left: 50%;
  bottom: 30px;
  width: 90px;
  height: 90px;
  margin-left: -45px;
  transform-origin: center bottom;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  will-change: transform;
}

.ripple {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  opacity: 0;
  transform: scale(1);
}

.ripple-track.animate .ripple {
  animation: ripple-pulse 1s ease-out infinite;
}

@keyframes ripple-pulse {
  0% { opacity: 0.55; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.8); }
}

.circle {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--circle-highlight), var(--circle-color) 55%, var(--circle-shade) 100%);
  box-shadow: 0 0 40px 6px var(--circle-glow);
  transform: translateY(0) scale(0.55);
  transform-origin: center bottom;
  will-change: transform;
}

.circle-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ring-track,
.ring-progress {
  fill: none;
  stroke-width: 5;
}

.ring-track {
  stroke: color-mix(in srgb, var(--accent-contrast) 15%, transparent);
}

.ring-progress {
  stroke: var(--accent-contrast);
  stroke-linecap: round;
}

.circle-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-contrast);
}

.bottom-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 auto;
}

.phase-info {
  text-align: center;
  min-height: 1.9rem;
}

.phase-label {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.info-select {
  position: relative;
}

.sound-select {
  position: relative;
}

.sound-panel {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: 200px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.sound-panel.open {
  display: block;
}

.sound-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  color: var(--text-muted);
  font: inherit;
  text-align: left;
}

.sound-option-icon {
  width: 22px;
  height: 22px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-shrink: 0;
}

.sound-option-label {
  flex: 1;
  font-size: 0.86rem;
}

.sound-option.disabled {
  color: var(--text-dim);
  cursor: default;
}

/* --- Expandable rows: souffle / voix / musique (toggle + variant + volume) --- */

.sound-option-row {
  border-radius: 10px;
  padding: 0 8px;
}

.sound-option-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sound-option-expand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-radius: 10px;
  border: none;
  background: none;
  color: var(--text-muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sound-option-expand:hover {
  background: var(--panel-bg);
  color: var(--text-main);
}

.sound-option-row.is-on .sound-option-expand {
  color: var(--text-main);
}

.sound-option-row.is-on .sound-option-icon {
  color: var(--circle-color);
}

.sound-option-chevron {
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.sound-option-row.open .sound-option-chevron {
  transform: rotate(180deg);
}

.sound-option-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.sound-option-row.loading .sound-option-ring {
  opacity: 1;
}

.sound-option-row.loading .sound-option-glyph {
  opacity: 0.45;
}

.sound-ring-track {
  fill: none;
  stroke: var(--panel-border);
  stroke-width: 1.2;
}

.sound-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.sound-switch {
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--panel-border);
  border: none;
  position: relative;
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s ease;
}

.sound-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-main);
  transition: transform 0.2s ease;
}

.sound-option-row.is-on .sound-switch {
  background: var(--accent);
}

.sound-option-row.is-on .sound-switch::after {
  transform: translateX(14px);
  background: var(--accent-contrast);
}

.sound-option-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.sound-option-row.open .sound-option-body {
  max-height: 90px;
  padding: 2px 0 12px;
}

.sound-variant-picks {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
}

.variant-pick {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.variant-pick.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--circle-color);
}

.variant-pick:disabled {
  opacity: 0.4;
  cursor: default;
}

.sound-vol-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sound-vol-icon {
  color: var(--text-dim);
  flex-shrink: 0;
}

.sound-vol-slider {
  flex: 1;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  padding: 0;
  height: 3px;
  border-radius: 999px;
  background: var(--panel-border);
}

.sound-vol-slider::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  height: 3px;
  border-radius: 999px;
  background: transparent;
}

.sound-vol-slider::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: transparent;
}

.sound-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  margin-top: -5px;
}

.sound-vol-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.infobox {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: 210px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.infobox.open {
  display: block;
}

.infobox-tag {
  display: inline-block;
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--circle-color);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.infobox h4 {
  margin: 0 0 6px;
  font-size: 0.94rem;
  color: var(--text-main);
}

.infobox p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.time-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cycle-count {
  font-size: 0.75rem;
  opacity: 0.8;
}

.progress-bar {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--circle-shade), var(--accent));
  border-radius: 999px;
  transition: width 0.15s linear;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  color: var(--text-main);
  transition: transform 0.12s ease, background 0.2s ease;
}

.ctrl-btn:active {
  transform: scale(0.92);
}

.ctrl-primary {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 4px 24px var(--circle-glow);
}

.ctrl-primary:hover {
  background: var(--accent-light);
}

.ctrl-secondary {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
}

.ctrl-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 380px) {
  .phase-label {
    font-size: 1.15rem;
  }
}

@media (max-height: 700px) {
  .circle {
    width: 76px;
    height: 76px;
  }
  .ripple-track {
    width: 76px;
    height: 76px;
    margin-left: -38px;
  }
  .circle-countdown {
    font-size: 2rem;
  }
  .phase-label {
    font-size: 1.15rem;
  }
  .ctrl-primary {
    width: 58px;
    height: 58px;
  }
  .ctrl-secondary {
    width: 44px;
    height: 44px;
  }
}

.app-sidebar {
  width: 56px;
}

#infoBtn,
#soundMenuBtn {
  width: 48px;
  height: 48px;
}

#infoBtn svg,
#soundMenuBtn svg {
  width: 22px;
  height: 22px;
}

.infobox {
  width: 280px;
  padding: 18px 20px;
}

.infobox h4 {
  font-size: 1rem;
}

.infobox p {
  font-size: 0.88rem;
}

.sound-panel {
  width: 280px;
  padding: 12px;
}

.sound-option-expand {
  padding: 13px 0;
  gap: 12px;
}

.sound-option-label {
  font-size: 1rem;
}

.sound-switch {
  width: 38px;
  height: 22px;
}

.sound-switch::after {
  width: 18px;
  height: 18px;
}

.sound-option-row.is-on .sound-switch::after {
  transform: translateX(16px);
}

.sound-option-row.open .sound-option-body {
  max-height: 110px;
}

.variant-pick {
  width: 32px;
  height: 32px;
}

.variant-pick svg {
  width: 17px;
  height: 17px;
}

.sound-vol-slider {
  height: 4px;
}

.sound-vol-slider::-webkit-slider-runnable-track {
  height: 4px;
}

.sound-vol-slider::-moz-range-track {
  height: 4px;
}

.sound-vol-slider::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
}

.sound-vol-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
}

@media (min-width: 900px) {
  .app-wrap {
    align-items: center;
    padding: 32px 0;
  }

  .app {
    width: min(380px, 100%);
    height: min(780px, 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.24);
    border-radius: 34px;
    padding: 38px 20px 24px;
    position: relative;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  }

  .app::before {
    content: "";
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 5px;
    background: rgba(255, 255, 255, 0.24);
    border-radius: 999px;
  }
}
