:root {
  color-scheme: dark;
  --bg: #0f1216;
  --panel: rgba(20, 25, 31, .86);
  --panel-solid: #14191f;
  --panel-strong: #1b232b;
  --text: #f7f8f4;
  --muted: #9aa6b2;
  --line: rgba(202, 214, 226, .14);
  --cyan: #7dd3fc;
  --green: #86efac;
  --amber: #f8c76f;
  --red: #fb8277;
  --ink: #071015;
  --shadow: 0 26px 70px rgba(0, 0, 0, .34);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(140deg, rgba(125, 211, 252, .12), transparent 34%),
    linear-gradient(210deg, rgba(134, 239, 172, .10), transparent 38%),
    linear-gradient(330deg, rgba(248, 199, 111, .09), transparent 30%),
    var(--bg);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

.ambient {
  position: fixed;
  inset: auto -15% -25% -15%;
  height: 42vh;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(125, 211, 252, .18), rgba(134, 239, 172, .14), rgba(248, 199, 111, .12));
  filter: blur(70px);
  animation: breathe 8s ease-in-out infinite alternate;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 14px 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 2px 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 8vw, 4.8rem);
  line-height: .9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
  letter-spacing: 0;
}

.today-pill {
  min-width: 128px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 25, 31, .72);
  backdrop-filter: blur(18px);
  text-align: right;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .22);
}

.today-pill span {
  display: block;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 750;
}

.today-pill strong {
  display: block;
  margin-top: 4px;
  font-size: .95rem;
}

.app-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin: 0 -4px 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 18, 22, .82);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.nav-btn {
  min-height: 42px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: clamp(.68rem, 2.8vw, .86rem);
  font-weight: 900;
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--cyan), var(--green));
  color: var(--ink);
}

.view {
  display: none;
  animation: rise .34s ease both;
}

.active-view {
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero-panel {
  overflow: hidden;
}

.hero-copy {
  min-height: 250px;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(125, 211, 252, .18), transparent 48%),
    linear-gradient(145deg, rgba(134, 239, 172, .18), transparent 52%),
    linear-gradient(45deg, rgba(248, 199, 111, .14), transparent 55%),
    var(--panel-strong);
}

.hero-copy h2 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2rem, 10vw, 5rem);
  line-height: .92;
}

.hero-copy p:last-of-type {
  max-width: 680px;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.hero-copy .primary-btn {
  margin-top: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.stat-card {
  min-height: 94px;
  padding: 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat-card:nth-child(2n) {
  border-right: 0;
}

.stat-card:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.stat-card span {
  display: block;
  min-height: 18px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.35rem, 8vw, 2.1rem);
  line-height: 1;
}

.exercise-grid,
.week-strip,
.program-grid,
.category-grid,
.history-list {
  display: grid;
  gap: 12px;
}

.exercise-grid {
  grid-template-columns: 1fr;
}

.week-panel {
  overflow: hidden;
  padding-bottom: 14px;
}

.compact-head {
  padding-top: 16px;
}

.week-strip {
  grid-auto-flow: column;
  grid-auto-columns: minmax(122px, 1fr);
  overflow-x: auto;
  padding: 16px 18px 4px;
  scrollbar-width: none;
}

.week-strip::-webkit-scrollbar {
  display: none;
}

.week-day {
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1117;
  color: var(--text);
  text-align: left;
}

.week-day.today {
  border-color: rgba(134, 239, 172, .62);
  background: linear-gradient(145deg, rgba(125, 211, 252, .16), rgba(134, 239, 172, .10)), #0d1117;
}

.week-day span {
  color: var(--green);
  font-size: .75rem;
  font-weight: 950;
  text-transform: uppercase;
}

.week-day strong {
  min-height: 34px;
  font-size: .92rem;
  line-height: 1.15;
}

.week-day small {
  color: var(--muted);
  font-weight: 850;
}

.exercise-card,
.day-card,
.category-card,
.history-item,
.rest-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 25, 31, .9);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .24);
  animation: cardIn .42s ease both;
}

.exercise-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}

.exercise-card:active,
.exercise-card:hover {
  transform: translateY(-2px);
  border-color: rgba(134, 239, 172, .42);
  background: rgba(24, 31, 38, .96);
}

.exercise-top {
  display: grid;
  gap: 6px;
}

.exercise-category,
.day-name,
.history-date,
.category-card-head span {
  color: var(--green);
  font-size: .74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.exercise-name {
  font-size: 1.15rem;
}

.exercise-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.exercise-stats span {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1117;
  color: var(--text);
  font-weight: 900;
}

.rest-card {
  padding: 22px;
}

.rest-card strong {
  display: block;
  font-size: 1.3rem;
}

.rest-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 0;
}

.section-head select {
  width: min(210px, 52vw);
}

.chart-panel,
.category-panel,
.form-panel,
.history-panel {
  padding-bottom: 18px;
}

select,
input,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1117;
  color: var(--text);
  outline: none;
  padding: 0 12px;
}

textarea {
  min-height: 92px;
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(134, 239, 172, .16);
}

.session-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 850;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.range-label > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--green);
}

.primary-btn,
.ghost-btn,
.danger-btn,
.delete-session {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 44px;
  padding: 0 14px;
  font-weight: 950;
}

.primary-btn {
  background: linear-gradient(135deg, var(--cyan), var(--green));
  color: var(--ink);
  box-shadow: 0 14px 30px rgba(125, 211, 252, .16);
}

.ghost-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.danger-btn,
.delete-session {
  background: rgba(251, 130, 119, .12);
  border-color: rgba(251, 130, 119, .30);
  color: #ffd2ce;
}

.program-grid {
  padding: 18px;
}

.day-card {
  padding: 15px;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.day-type {
  font-size: 1.06rem;
  text-align: right;
}

.day-exercises {
  display: grid;
  gap: 8px;
}

.program-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1117;
}

.program-row span {
  font-weight: 850;
}

.program-row strong {
  color: var(--muted);
  font-size: .84rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 16px 18px 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1117;
}

.segment {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 900;
}

.segment.active {
  background: linear-gradient(135deg, var(--cyan), var(--green));
  color: var(--ink);
}

.chart-wrap {
  position: relative;
  margin: 12px 18px 0;
  min-height: 252px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1117;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 280px;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 22px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.category-grid {
  padding: 18px;
}

.category-card {
  padding: 15px;
}

.category-card-head {
  display: grid;
  gap: 6px;
}

.category-card-head strong {
  font-size: 1rem;
}

.progress-line {
  height: 9px;
  margin: 14px 0 10px;
  border-radius: 999px;
  background: #0d1117;
  overflow: hidden;
}

.progress-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green), var(--amber));
  animation: fillLine .7s ease both;
}

.category-values {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-values span,
.category-card p,
.mini-empty {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
}

.category-values strong {
  color: var(--amber);
}

.category-card p {
  margin: 9px 0 0;
}

.history-actions {
  display: flex;
  gap: 8px;
}

.history-list {
  padding: 18px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 12px;
  padding: 14px;
}

.history-exercise {
  display: block;
  margin-top: 5px;
  font-size: 1rem;
}

.history-meta,
.history-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
}

.history-note:empty {
  display: none;
}

.delete-session {
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 1.25rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fillLine {
  from {
    transform: scaleX(.2);
    transform-origin: left center;
  }
  to {
    transform: scaleX(1);
    transform-origin: left center;
  }
}

@keyframes breathe {
  from {
    transform: translateX(-3%) scale(1);
  }
  to {
    transform: translateX(3%) scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

@media (min-width: 760px) {
  .app-shell {
    padding: 28px 22px 44px;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stat-card,
  .stat-card:nth-child(2n) {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .stat-card:last-child {
    border-right: 0;
  }

  .exercise-grid,
  .program-grid,
  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .active-view {
    gap: 18px;
  }
}

@media (min-width: 1040px) {
  .exercise-grid,
  .category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .program-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #view-progress.active-view {
    grid-template-columns: 1.1fr .9fr;
    align-items: start;
  }

  .chart-panel {
    min-height: 100%;
  }

  canvas {
    height: 360px;
  }
}
