*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #070b1f;
  --card: rgba(16, 24, 58, 0.86);
  --card-strong: rgba(21, 31, 78, 0.96);
  --line: rgba(151, 178, 255, 0.25);
  --line-strong: rgba(117, 216, 255, 0.48);
  --text: #eef4ff;
  --muted: #9dacd2;
  --accent: #75d8ff;
  --accent-2: #b36cff;
  --good: #7cffcb;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --radius: 28px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, rgba(117, 216, 255, 0.24), transparent 30%),
    radial-gradient(circle at 82% 18%, rgba(179, 108, 255, 0.26), transparent 28%),
    linear-gradient(145deg, #050817 0%, #0b1026 48%, #130922 100%);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin-top: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(30px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.65rem, 8vw, 2.5rem);
  line-height: 1.02;
  font-weight: 900;
  color: var(--text);
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.25;
  text-transform: uppercase;
}

.mode-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #061022;
  background: linear-gradient(135deg, var(--good), var(--accent));
  box-shadow: 0 12px 30px rgba(117, 216, 255, 0.2);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.card {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.mode-section,
.countdown-card {
  background:
    linear-gradient(145deg, rgba(117, 216, 255, 0.13), transparent 42%),
    linear-gradient(315deg, rgba(179, 108, 255, 0.16), transparent 38%),
    var(--card-strong);
}

.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.mode-option {
  position: relative;
  display: flex;
  min-height: 116px;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 16px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s, transform 0.18s;
}

.mode-option:has(input:checked) {
  border-color: var(--line-strong);
  color: #061022;
  background: linear-gradient(135deg, var(--good), var(--accent) 56%, var(--accent-2));
  box-shadow: 0 12px 30px rgba(117, 216, 255, 0.24);
}

.mode-option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-label {
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
}

.mode-detail {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.28;
}

.mode-option:has(input:checked) .mode-detail {
  color: rgba(6, 16, 34, 0.76);
}

.countdown-card {
  text-align: center;
}

.timer-display {
  margin: 4px 0 10px;
  color: var(--text);
  font-size: clamp(4.35rem, 20vw, 6.3rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 0.95;
  text-shadow: 0 0 36px rgba(117, 216, 255, 0.18);
}

.timer-secondary {
  display: grid;
  gap: 6px;
  justify-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.timer-secondary p {
  margin: 0;
}

#session-remaining {
  color: #dfe8ff;
  font-variant-numeric: tabular-nums;
}

.rhythm-sequence {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 14px;
}

.rhythm-sequence--strong {
  gap: 11px;
}

.rhythm-row {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, auto));
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
}

.rhythm-separator {
  display: grid;
  place-items: center;
  min-width: 4px;
  color: rgba(157, 172, 210, 0.78);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
  user-select: none;
}

.rhythm-block {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(36px, 10.7vw, 48px);
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.2s;
}

.rhythm-block-num {
  position: relative;
  z-index: 1;
  color: inherit;
  font-size: clamp(0.76rem, 3.2vw, 0.92rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.rhythm-block.is-current {
  color: #061022;
  border-color: rgba(124, 255, 203, 0.86);
  background: linear-gradient(135deg, var(--good), var(--accent));
  box-shadow: 0 12px 30px rgba(117, 216, 255, 0.24);
  transform: translateY(-1px);
}

.rhythm-block.is-done {
  color: #dffdf6;
  border-color: rgba(124, 255, 203, 0.42);
  background: linear-gradient(135deg, rgba(124, 255, 203, 0.28), rgba(117, 216, 255, 0.16));
}

.rhythm-block.is-done::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 11px;
  background: rgba(124, 255, 203, 0.1);
}

.rhythm-support {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.controls-section {
  display: grid;
  gap: 11px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 0;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.2;
  transition: opacity 0.15s, transform 0.1s, border-color 0.15s, background 0.15s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.btn-primary,
.btn-sound {
  color: #061022;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.btn-sound.is-enabled {
  color: #061022;
  background: linear-gradient(135deg, var(--good), var(--accent));
}

.btn-secondary,
.btn-ghost {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
}

.btn-ghost {
  min-height: 44px;
  font-size: 0.84rem;
}

.audio-check {
  padding: 0;
  overflow: hidden;
}

.audio-check-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 54px;
  padding: 16px 18px;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-align: left;
  text-transform: uppercase;
}

.audio-check-toggle .chevron {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.25rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.audio-check-toggle[aria-expanded="true"] .chevron {
  margin-top: 0.25rem;
  transform: rotate(-135deg);
}

.audio-check-panel {
  display: grid;
  gap: 10px;
  padding: 0 18px 18px;
}

.audio-check-panel[hidden] {
  display: none;
}

.audio-check-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.45;
}

.audio-check-actions {
  display: grid;
  gap: 9px;
}

.status-message {
  min-height: 1.25rem;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  text-align: center;
}

.status-message.is-complete {
  color: var(--good);
}

.app.is-running .mode-selector {
  opacity: 0.55;
  pointer-events: none;
}

@media (min-width: 560px) {
  .controls-section {
    grid-template-columns: 1fr 1fr;
  }

  .btn-sound {
    grid-column: 1 / -1;
  }
}

@media (max-width: 380px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

  .card {
    padding: 15px;
    border-radius: 24px;
  }

  .mode-option {
    min-height: 108px;
    padding: 14px 10px;
  }

  .rhythm-row {
    gap: 3px;
  }

  .rhythm-block {
    border-radius: 14px;
  }

  .rhythm-separator {
    font-size: 0.65rem;
  }
}

/* ── Tab navigation (added for Current Window tab) ── */

.tab-nav {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  padding-top: 4px;
}

.tab-btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.tab-btn[aria-selected="true"] {
  border-color: var(--accent);
  background: rgba(117, 216, 255, 0.12);
  color: var(--accent);
}

/* ── Sprint page mode-pill row ── */

.sprint-mode-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

/* ── Current window page elements ── */

.tz-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.tz-select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.live-time {
  flex-shrink: 0;
  font-size: 1rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  white-space: nowrap;
}

.window-name {
  margin: 0 0 4px;
  font-size: clamp(1.5rem, 7vw, 2.1rem);
  font-weight: 900;
  letter-spacing: -0.02em;
}

.window-range {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.window-guidance {
  margin: 0 0 16px;
  color: rgba(238, 244, 255, 0.65);
  font-size: 0.88rem;
  line-height: 1.62;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 6px;
}

.progress-track {
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 1s linear;
}

.recharge-num {
  font-size: 3.4rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
  letter-spacing: -0.02em;
  margin: 4px 0 14px;
}

.cw-blocks {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.cw-block {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--muted);
  transition: background 0.3s, border-color 0.3s, color 0.3s;
}

.cw-block.is-current {
  background: linear-gradient(135deg, var(--good), var(--accent));
  border-color: rgba(124, 255, 203, 0.86);
  color: #061022;
}

.cw-audio-section {
  display: grid;
  gap: 10px;
}

.audio-status-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.btn-logout {
  display: block;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  opacity: 0.55;
  cursor: pointer;
}

.btn-logout:hover {
  opacity: 0.9;
}

.audio-status-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: baseline;
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  font-weight: 700;
}

.audio-status-list dt {
  color: var(--muted);
}

.audio-status-list dd {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
