:root {
  --bg: #111512;
  --surface: #1a211d;
  --surface-strong: #222b26;
  --ink: #eef4ef;
  --muted: #a8b3aa;
  --line: #334139;
  --green: #54b47a;
  --blue: #6ea8d8;
  --yellow: #d8b85a;
  --red: #e06d62;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

main {
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(16px, calc((100vw - 1160px) / 2));
  background: #0a0d0b;
  color: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 800;
  text-decoration: none;
  font-size: 1.2rem;
}

nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

nav a,
.link-button {
  color: #e9f3ee;
  background: transparent;
  border: 0;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-head h1,
.auth-panel h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.02;
}

.page-head p {
  max-width: 700px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--yellow);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.program-grid,
.metric-grid,
.achievement-grid,
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.program-card,
.form-card,
.metric,
.achievement,
.info-panel,
.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px var(--shadow);
}

.program-card {
  min-height: 260px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.program-card h2,
.exercise-row h2,
.info-panel h2 {
  margin: 0 0 8px;
}

.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: #07100b;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button.secondary {
  background: var(--blue);
  color: #071019;
}

.stat-pill {
  flex: 0 0 auto;
  padding: 12px 16px;
  background: var(--surface-strong);
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
}

.stat-pill span {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  margin-top: 28px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.info-panel {
  padding: 20px;
}

.exercise-list {
  display: grid;
  gap: 12px;
}

.exercise-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.exercise-row span,
legend small {
  color: var(--muted);
}

.note-band {
  margin-top: 18px;
  padding: 16px;
  border-left: 5px solid var(--yellow);
  background: #2b2819;
}

.auth-panel {
  width: min(440px, 100%);
  margin: 10vh auto;
}

.form-card,
.log-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.form-card {
  padding: 22px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #48554d;
  border-radius: 6px;
  background: #0f1411;
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
}

.form-grid,
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.extra-field-row {
  grid-template-columns: minmax(220px, 1.4fr) repeat(auto-fit, minmax(120px, 1fr));
}

.extra-exercise-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px 18px;
}

.extra-exercise-panel > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--green);
  font-weight: 900;
  cursor: pointer;
}

.section-title {
  margin: 26px 0 12px;
}

.section-title h2,
.section-title p {
  margin: 0;
}

.section-title p {
  color: var(--muted);
}

.form-actions,
.table-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.table-actions form {
  margin: 0;
}

.exercise-help {
  margin-top: 10px;
  color: var(--muted);
}

.exercise-help summary {
  width: max-content;
  min-height: 36px;
  display: flex;
  align-items: center;
  color: var(--green);
  font-weight: 800;
  cursor: pointer;
}

.exercise-help p {
  margin: 8px 0 0;
  max-width: 760px;
}

.effort-picker {
  display: inline-flex;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #101612;
}

.effort-option {
  display: block;
  cursor: pointer;
}

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

.effort-option span {
  width: 42px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 1.2rem;
  border: 1px solid transparent;
}

.effort-option input:checked + span {
  background: var(--surface-strong);
  border-color: var(--green);
}

.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.small-button.danger {
  color: var(--red);
}

fieldset.exercise-row {
  display: block;
  margin: 0;
}

legend {
  width: 100%;
  margin-bottom: 12px;
  font-weight: 800;
}

legend small {
  display: block;
  margin-top: 4px;
  font-weight: 500;
}

.metric {
  padding: 18px;
  font-weight: 800;
  color: var(--muted);
}

.metric span {
  display: block;
  color: var(--ink);
  font-size: 2rem;
}

.stats-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.stats-nav {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 108px);
  overflow: auto;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
}

.stats-nav a:hover,
.stats-nav a:focus,
.stats-nav a.active {
  background: var(--surface-strong);
  color: var(--ink);
}

.stats-content {
  display: grid;
  gap: 22px;
}

.stats-section {
  scroll-margin-top: 92px;
}

.stats-section[hidden] {
  display: none;
}

.stats-section > h2 {
  margin-top: 0;
}

.bars {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 2fr 32px;
  align-items: center;
  gap: 12px;
}

.bar-row div {
  height: 12px;
  overflow: hidden;
  background: #2c3831;
  border-radius: 999px;
}

.bar-row i {
  display: block;
  height: 100%;
  background: var(--blue);
}

.achievement {
  padding: 16px;
  color: var(--muted);
}

.achievement strong,
.achievement span {
  display: block;
}

.achievement.done {
  border-color: #5fbf82;
  background: #183223;
  color: var(--ink);
}

.chart-card {
  padding: 18px;
}

.chart-card h3 {
  margin: 0;
}

.chart-card header span,
.chart-label span {
  color: var(--muted);
}

.chart-metrics {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.mini-chart {
  display: grid;
  gap: 8px;
}

.chart-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}

.mini-chart svg {
  width: 100%;
  height: 150px;
  overflow: visible;
  background: #101612;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-chart line {
  stroke: #526359;
  stroke-width: 1.5;
}

.mini-chart polyline {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.flash {
  padding: 12px 14px;
  border-radius: 6px;
  background: #1c2830;
}

.flash.error {
  background: #321c1a;
  color: var(--red);
}

.flash.success {
  background: #173122;
  color: var(--green);
}

@media (max-width: 820px) {
  .topbar,
  .page-head,
  .exercise-row {
    align-items: flex-start;
  }

  .topbar,
  .page-head {
    flex-direction: column;
    height: auto;
    padding-top: 16px;
    padding-bottom: 16px;
  }

  nav {
    flex-wrap: wrap;
  }

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

  .stats-layout {
    grid-template-columns: 1fr;
  }

  .stats-nav {
    position: static;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    max-height: none;
  }

  .exercise-row {
    flex-direction: column;
  }

  main {
    width: min(100% - 20px, 1160px);
    padding-top: 20px;
  }

  .program-card,
  .form-card,
  .metric,
  .achievement,
  .info-panel,
  .exercise-row {
    padding: 14px;
  }

  .log-form {
    gap: 12px;
  }

  .form-grid,
  .field-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

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

  input,
  select,
  textarea,
  .button,
  button[type="submit"] {
    min-height: 48px;
    font-size: 1rem;
  }

  fieldset.exercise-row {
    padding: 14px;
  }

  legend {
    margin-bottom: 10px;
  }

  table {
    min-width: 760px;
  }
}
