:root {
  color-scheme: dark;
  --bg: #07131c;
  --bg-deep: #030a0f;
  --surface: #0d1d28;
  --surface-2: #112633;
  --surface-3: #16313f;
  --line: rgba(193, 220, 228, 0.13);
  --line-strong: rgba(193, 220, 228, 0.24);
  --text: #f3f8fa;
  --muted: #8fa3ae;
  --teal: #45dfd0;
  --teal-dark: #0c8f88;
  --orange: #ff835b;
  --lime: #c8f66d;
  --danger: #ff677d;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg-deep); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(69, 223, 208, 0.13), transparent 32rem),
    radial-gradient(circle at 105% 20%, rgba(255, 131, 91, 0.08), transparent 25rem),
    var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

body.picker-open { overflow: hidden; }

main:focus {
  outline: none;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(69, 223, 208, 0.48);
  outline-offset: 3px;
}

.app-shell { width: min(100%, 1180px); margin: 0 auto; min-height: 100vh; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 22px 14px;
  background: linear-gradient(180deg, rgba(7, 19, 28, 0.98), rgba(7, 19, 28, 0.84));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand, .profile-pill {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.brand { display: flex; align-items: center; gap: 8px; padding: 0; text-align: left; }
.brand-mark {
  width: 45px;
  height: 45px;
  flex: 0 0 auto;
}
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand-wordmark, .gate-wordmark { display: flex; align-items: baseline; gap: 0; }
.brand strong { display: block; font-size: 0.96rem; letter-spacing: 0.14em; line-height: 1; }
.brand-lab { color: var(--teal); }

.profile-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px 7px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 38, 51, 0.72);
  font-weight: 750;
}
.profile-pill svg { width: 17px; fill: none; stroke: var(--muted); stroke-width: 2; }
.profile-dot, .avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--orange), #ffb05b);
  color: #1a0a04;
  font-weight: 950;
}
.profile-dot { width: 30px; height: 30px; font-size: 0.78rem; }

main { padding: 20px 18px 112px; }

.profile-gate {
  display: grid;
  min-height: 100vh;
  align-content: center;
  gap: 34px;
  padding: 38px 4px max(50px, env(safe-area-inset-bottom));
}

.gate-brand { display: flex; align-items: center; gap: 14px; }
.gate-brand .brand-mark { width: 52px; height: 52px; }
.gate-brand strong { display: block; font-size: 1.25rem; letter-spacing: 0.18em; }

.gate-copy { max-width: 640px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 22px; height: 2px; background: currentColor; }
h1, h2, h3, p { margin-top: 0; }
.gate-copy h1, .page-title h1 {
  margin: 10px 0 12px;
  font-size: clamp(2.3rem, 8vw, 5.6rem);
  line-height: 0.96;
  letter-spacing: -0.055em;
}
.gate-copy p, .page-title p { margin-bottom: 0; color: var(--muted); font-size: 1.02rem; }

.profile-grid { display: grid; gap: 14px; }
.profile-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 126px;
  padding: 22px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(17, 38, 51, 0.98), rgba(10, 27, 37, 0.96));
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
}
.profile-card::after {
  content: "";
  position: absolute;
  right: -36px;
  top: -55px;
  width: 140px;
  height: 140px;
  border: 30px solid rgba(69, 223, 208, 0.06);
  border-radius: 50%;
}
.profile-card.fede::after { border-color: rgba(255, 131, 91, 0.07); }
.profile-card:hover { transform: translateY(-2px); border-color: rgba(69, 223, 208, 0.42); }
.avatar { width: 58px; height: 58px; font-size: 1.25rem; }
.profile-card.fede .avatar { background: linear-gradient(145deg, var(--teal), #7df2b8); }
.profile-card h2 { margin: 0 0 4px; font-size: 1.45rem; }
.profile-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.profile-card .arrow { position: relative; z-index: 1; font-size: 1.7rem; color: var(--teal); }

.page-title { padding: 8px 0 20px; }
.page-title h1 { font-size: clamp(2.2rem, 10vw, 4.8rem); }
.page-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }

.today-layout { display: grid; gap: 18px; }
.hero-session {
  position: relative;
  overflow: hidden;
  min-height: 330px;
  padding: 26px;
  border: 1px solid rgba(69, 223, 208, 0.22);
  border-radius: 28px;
  background:
    linear-gradient(150deg, rgba(14, 45, 55, 0.97), rgba(10, 25, 35, 0.98) 70%),
    var(--surface);
  box-shadow: var(--shadow);
}
.hero-session::before {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  right: -70px;
  top: -75px;
  border: 50px solid rgba(69, 223, 208, 0.055);
  border-radius: 50%;
}
.session-index { color: var(--teal); font-weight: 850; letter-spacing: 0.1em; font-size: 0.78rem; }
.hero-session h2 { position: relative; max-width: 650px; margin: 24px 0 10px; font-size: clamp(2rem, 8vw, 4.2rem); line-height: 0.98; letter-spacing: -0.045em; }
.hero-session > p { position: relative; max-width: 540px; color: var(--muted); }
.session-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 26px 0; }
.metric-chip { padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; background: rgba(7, 19, 28, 0.52); font-size: 0.82rem; color: #cfe0e5; }

.primary, .secondary, .ghost, .set-done {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 850;
}
.primary { padding: 14px 18px; background: var(--teal); color: #041513; box-shadow: 0 10px 24px rgba(69, 223, 208, 0.13); }
.secondary { padding: 13px 17px; background: var(--surface-3); color: var(--text); border: 1px solid var(--line); }
.ghost { padding: 9px 0; background: transparent; color: var(--teal); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card { padding: 17px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(13, 29, 40, 0.78); }
.stat-card strong { display: block; font-size: 1.55rem; line-height: 1; }
.stat-card span { display: block; margin-top: 7px; color: var(--muted); font-size: 0.75rem; }

.week-rail { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.day-node {
  min-width: 0;
  padding: 14px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}
.day-node strong { display: block; color: var(--text); font-size: 0.86rem; }
.day-node span { display: block; margin-top: 3px; font-size: 0.69rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-node.active { border-color: var(--teal); background: rgba(69, 223, 208, 0.1); }
.day-node.active strong { color: var(--teal); }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 28px 0 12px; }
.section-head h2 { margin: 0; font-size: 1.28rem; }
.section-head span { color: var(--muted); font-size: 0.82rem; }

.exercise-list, .plan-list, .history-list { display: grid; gap: 10px; }
.exercise-card {
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(13, 29, 40, 0.92);
}
.exercise-card[open] { border-color: rgba(69, 223, 208, 0.3); }
.exercise-card summary {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 15px;
  cursor: pointer;
  list-style: none;
}
.exercise-card summary::-webkit-details-marker { display: none; }
.exercise-number { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: var(--surface-3); color: var(--teal); font-weight: 900; }
.exercise-card h3 { margin: 0; font-size: 1rem; }
.exercise-card summary p { margin: 3px 0 0; color: var(--muted); font-size: 0.78rem; }
.exercise-card .chevron { color: var(--muted); transition: transform 180ms ease; }
.exercise-card[open] .chevron { transform: rotate(90deg); }
.exercise-body { padding: 0 15px 16px; border-top: 1px solid var(--line); }
.exercise-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 14px; }
.exercise-metric { min-height: 52px; display: grid; align-content: center; justify-items: center; padding: 6px 4px; border-radius: 11px; background: var(--surface-3); text-align: center; }
.exercise-metric small, .tempo-row small { color: var(--muted); font-size: 0.62rem; font-weight: 850; letter-spacing: 0.08em; text-transform: uppercase; }
.exercise-metric strong, .tempo-row strong { font-size: 0.86rem; line-height: 1.15; }
.exercise-metric strong { margin-top: 3px; }
.tempo-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; padding: 9px 10px; border: 1px solid rgba(69, 223, 208, 0.35); border-radius: 10px; }
.tempo-row strong { color: var(--teal); letter-spacing: 0.015em; text-align: right; }
.cue { margin: 14px 0; color: #c0cfd4; font-size: 0.88rem; }
.recommendation { margin: 0 0 14px; padding: 12px; border-left: 3px solid var(--orange); border-radius: 0 10px 10px 0; background: rgba(255, 131, 91, 0.075); font-size: 0.84rem; }
.recommendation strong { color: var(--orange); }
.set-grid { display: grid; gap: 5px; }
.set-row { display: grid; grid-template-columns: 48px 1fr 1fr 40px; gap: 6px; align-items: end; }
.set-row > span { align-self: center; color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.field-label { display: block; margin: 0 0 3px; color: var(--muted); font-size: 0.7rem; }
.field input,
.number-picker {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #081620;
  color: var(--text);
  padding: 7px 9px;
}
.number-picker { display: flex; align-items: baseline; justify-content: center; gap: 5px; cursor: pointer; }
.number-picker strong { font-size: 1.05rem; line-height: 1; }
.number-picker small { color: var(--muted); font-size: 0.66rem; }
.number-picker:hover { border-color: rgba(69, 223, 208, 0.46); background: #0b1c27; }
.set-done { display: grid; width: 40px; height: 38px; place-items: center; background: var(--surface-3); color: var(--muted); border: 1px solid var(--line); }
.set-done.done { background: var(--teal); color: #041513; }

.workout-head { display: grid; gap: 14px; padding-bottom: 18px; }
.workout-head h1 { margin: 0; font-size: clamp(2rem, 9vw, 4rem); line-height: 0.98; letter-spacing: -0.04em; }
.workout-head p { margin: 0; color: var(--muted); }
.progress-track { height: 5px; overflow: hidden; border-radius: 99px; background: var(--surface-3); }
.progress-track span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--lime)); transition: width 220ms ease; }
.finish-bar { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--surface-2); }
.finish-bar .primary { flex: 1; }

.plan-card, .history-card, .empty-card, .profile-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(13, 29, 40, 0.86);
}
.plan-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.plan-card h2, .history-card h2 { margin: 0 0 5px; font-size: 1.06rem; }
.plan-card p, .history-card p, .empty-card p, .profile-panel p { margin: 0; color: var(--muted); font-size: 0.86rem; }
.plan-card .count { color: var(--teal); font-size: 0.8rem; }
.plan-card button { grid-column: 1 / -1; justify-self: start; }

.history-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.history-date { display: grid; min-width: 52px; height: 52px; place-items: center; border-radius: 14px; background: var(--surface-3); font-weight: 900; }
.history-date small { display: block; color: var(--muted); font-size: 0.64rem; text-align: center; }
.history-card .score { color: var(--lime); font-weight: 850; font-size: 0.83rem; }
.history-actions { display: flex; gap: 12px; margin-top: 10px; }
.history-actions button { padding: 0; border: 0; background: transparent; color: var(--teal); font-size: 0.78rem; font-weight: 850; cursor: pointer; }
.history-actions .danger-link { color: var(--danger); }
.danger-button { padding: 13px 17px; border: 0; border-radius: 14px; background: var(--danger); color: #21040a; font-weight: 900; cursor: pointer; }
.confirm-overlay { position: fixed; z-index: 130; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(1, 7, 10, 0.78); backdrop-filter: blur(12px); }
.confirm-card { width: min(100%, 430px); padding: 28px; border: 1px solid var(--line-strong); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.confirm-card .empty-symbol { color: var(--danger); border-color: rgba(255, 103, 125, 0.48); }
.confirm-card h2 { margin-bottom: 8px; }
.confirm-card p { color: var(--muted); }
.confirm-card .button-row { justify-content: center; margin-top: 22px; }

.empty-card { min-height: 260px; display: grid; place-items: center; text-align: center; }
.empty-symbol { display: grid; width: 74px; height: 74px; margin: 0 auto 20px; place-items: center; border: 1px dashed rgba(69, 223, 208, 0.45); border-radius: 22px; color: var(--teal); font-size: 1.8rem; }
.empty-card h2 { margin-bottom: 8px; }

.profile-panel { display: grid; gap: 18px; }
.profile-hero { display: flex; align-items: center; gap: 16px; }
.profile-hero .avatar { width: 64px; height: 64px; }
.profile-hero h2 { margin: 0; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.bottom-nav {
  position: fixed;
  z-index: 50;
  display: grid;
  left: 50%;
  bottom: 0;
  width: min(100%, 640px);
  transform: translateX(-50%);
  grid-template-columns: repeat(4, 1fr);
  padding: 9px 10px max(9px, env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: rgba(7, 19, 28, 0.96);
  backdrop-filter: blur(20px);
  box-shadow: 0 -18px 45px rgba(0, 0, 0, 0.3);
}
.bottom-nav button { display: grid; justify-items: center; gap: 3px; padding: 6px 4px; border: 0; background: transparent; color: var(--muted); font-size: 0.7rem; cursor: pointer; }
.bottom-nav button.active { color: var(--teal); }
.nav-icon svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.rest-timer {
  position: fixed;
  z-index: 80;
  left: 50%;
  top: max(82px, calc(env(safe-area-inset-top) + 64px));
  width: min(calc(100% - 28px), 520px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(69, 223, 208, 0.42);
  border-radius: 18px;
  background: rgba(4, 17, 24, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.wheel-overlay {
  position: fixed;
  z-index: 120;
  inset: 0;
  background: rgba(1, 7, 10, 0.72);
  backdrop-filter: blur(10px);
}
.wheel-sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(100%, 620px);
  transform: translateX(-50%);
  padding: 12px 18px max(16px, env(safe-area-inset-bottom));
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, #102633, #08151e);
  box-shadow: 0 -30px 90px rgba(0, 0, 0, 0.5);
}
.wheel-head { display: grid; grid-template-columns: 78px 1fr 78px; align-items: center; gap: 8px; text-align: center; }
.wheel-head button { border: 0; background: transparent; color: var(--teal); padding: 7px 0; cursor: pointer; font-size: 0.83rem; font-weight: 800; }
.wheel-head small { display: block; max-width: 320px; margin: 0 auto 3px; overflow: hidden; color: var(--muted); font-size: 0.62rem; letter-spacing: 0.08em; text-overflow: ellipsis; white-space: nowrap; }
.wheel-head h2 { margin: 0; font-size: 1rem; }
.wheel-grid { display: grid; grid-template-columns: 1.15fr 0.8fr 1.15fr; gap: 8px; margin-top: 8px; }
.wheel-group { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: rgba(3, 11, 16, 0.5); }
.wheel-group > span { position: absolute; z-index: 3; top: 9px; left: 0; right: 0; color: var(--muted); font-size: 0.62rem; font-weight: 850; letter-spacing: 0.12em; text-align: center; }
.wheel-group::before,
.wheel-group::after { content: ""; position: absolute; z-index: 2; left: 8px; right: 8px; height: 1px; background: rgba(69, 223, 208, 0.32); pointer-events: none; }
.wheel-group::before { top: 74px; }
.wheel-group::after { top: 114px; }
.wheel-column {
  height: 188px;
  overflow-y: auto;
  padding: 74px 0;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  overscroll-behavior: contain;
  mask-image: linear-gradient(to bottom, transparent, black 34%, black 66%, transparent);
}
.wheel-column::-webkit-scrollbar { display: none; }
.wheel-option {
  display: grid;
  height: 40px;
  place-items: center;
  scroll-snap-align: center;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.38;
  transform: scale(0.88);
  transition: opacity 120ms ease, transform 120ms ease, color 120ms ease;
}
.wheel-option.selected { color: var(--text); font-size: 1.55rem; opacity: 1; transform: scale(1); }
.wheel-hint { margin: 8px 0 0; color: var(--muted); font-size: 0.72rem; text-align: center; }
.rest-timer small { display: block; color: var(--teal); font-weight: 850; font-size: 0.65rem; letter-spacing: 0.12em; }
.rest-timer strong { margin-right: 10px; font-size: 1.45rem; }
.rest-timer span { color: var(--muted); font-size: 0.74rem; }
.timer-actions { display: flex; gap: 6px; }
.timer-actions button { padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: 0.74rem; cursor: pointer; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 104px; transform: translateX(-50%); width: min(calc(100% - 28px), 480px); padding: 13px 16px; border-radius: 14px; background: var(--text); color: #07131c; font-weight: 800; text-align: center; box-shadow: var(--shadow); }

[hidden] { display: none !important; }

@media (min-width: 760px) {
  main { padding: 36px 34px 120px; }
  .app-header { padding-inline: 34px; }
  .profile-gate { grid-template-columns: 0.95fr 1.05fr; align-items: center; gap: 70px; }
  .gate-brand { grid-column: 1 / -1; }
  .profile-grid { grid-template-columns: 1fr; }
  .today-layout { grid-template-columns: minmax(0, 1.65fr) minmax(270px, 0.75fr); align-items: start; }
  .hero-session { grid-row: span 2; min-height: 415px; }
  .stats-grid { grid-template-columns: 1fr; }
  .plan-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exercise-card summary { padding: 17px 18px; }
  .exercise-body { padding-inline: 18px; }
}

@media (min-width: 1100px) {
  .bottom-nav { left: max(24px, calc(50% - 570px)); top: 118px; bottom: auto; width: 150px; transform: none; grid-template-columns: 1fr; padding: 10px; border: 1px solid var(--line); border-radius: 18px; }
  .bottom-nav button { grid-template-columns: 28px 1fr; justify-items: start; align-items: center; gap: 8px; padding: 10px; font-size: 0.82rem; border-radius: 10px; }
  .bottom-nav button.active { background: rgba(69, 223, 208, 0.09); }
  main { padding-left: 200px; padding-bottom: 48px; }
}

@media (prefers-reduced-motion: no-preference) {
  .profile-card, .primary, .secondary, .day-node { transition: transform 180ms ease, border-color 180ms ease, background 180ms ease; }
  .primary:hover, .secondary:hover { transform: translateY(-1px); }
}
